diff --git a/BUILD.gn b/BUILD.gn index 6fbe656..8942c1a 100644 --- a/BUILD.gn +++ b/BUILD.gn
@@ -284,6 +284,7 @@ if (is_android) { deps += [ "//base:base_junit_tests", + "//base/android/jni_generator:jni_generator_tests", "//base/android/linker:chromium_android_linker", "//build/android/gyp/test:hello_world", "//build/android/gyp/test:hello_world", @@ -883,7 +884,6 @@ "//mojo/public/interfaces/bindings/tests:test_data_deps", "//services/device/public/interfaces:interfaces_js_data_deps", "//services/device/public/interfaces:generic_sensor_js_data_deps", - "//services/service_manager/public/interfaces:interfaces_js_data_deps", "//services/shape_detection/public/interfaces:interfaces_js_data_deps", "//third_party/WebKit/public:blink_devtools_frontend_resources_files", "//third_party/WebKit/public:mojo_bindings_js_data_deps",
diff --git a/DEPS b/DEPS index a7300f2d4..0db6c8c 100644 --- a/DEPS +++ b/DEPS
@@ -40,11 +40,11 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Skia # and whatever else without interference from each other. - 'skia_revision': '50f7a1e4abea043b57a39ea1da53a0697bfa1f01', + 'skia_revision': '8289306771381298cf3b87183882cc1f1fef4dc3', # 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': '1dc40944fe81cbabc94f96e3a06595da2d093657', + 'v8_revision': 'bfb1b022eeae4d9d3d1ada9b0c3defcd315d5bad', # 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. @@ -64,7 +64,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': 'aea80dcc0abc0c310316fa502f91a359bc684758', + 'pdfium_revision': 'b4fee4d5d471475ada1d0d9110e1a534b49477ba', # 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.
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index b2d62f5e..aeff7f8 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py
@@ -2041,8 +2041,9 @@ def _CheckForRiskyJsFeatures(input_api, output_api): maybe_ios_js = (r"^(ios|components|ui\/webui\/resources)\/.+\.js$", ) - file_filter = lambda f: input_api.FilterSourceFile(f, white_list=maybe_ios_js) - + chromeos_filter = (r".*chromeos.*", ) + file_filter = lambda f: input_api.FilterSourceFile(f, white_list=maybe_ios_js, + black_list=chromeos_filter) results = [] for f in input_api.AffectedFiles(file_filter=file_filter): arrow_error_lines = []
diff --git a/android_webview/browser/hardware_renderer.cc b/android_webview/browser/hardware_renderer.cc index 22e5b6f..6c5addd9 100644 --- a/android_webview/browser/hardware_renderer.cc +++ b/android_webview/browser/hardware_renderer.cc
@@ -263,12 +263,11 @@ void HardwareRenderer::CreateNewCompositorFrameSinkSupport() { constexpr bool is_root = false; - constexpr bool handles_frame_sink_id_invalidation = false; constexpr bool needs_sync_points = true; support_.reset(); support_ = viz::CompositorFrameSinkSupport::Create( this, surfaces_->GetFrameSinkManager(), frame_sink_id_, is_root, - handles_frame_sink_id_invalidation, needs_sync_points); + needs_sync_points); } } // namespace android_webview
diff --git a/android_webview/browser/surfaces_instance.cc b/android_webview/browser/surfaces_instance.cc index b933066..b40c66d 100644 --- a/android_webview/browser/surfaces_instance.cc +++ b/android_webview/browser/surfaces_instance.cc
@@ -58,11 +58,10 @@ local_surface_id_allocator_.reset(new viz::LocalSurfaceIdAllocator()); constexpr bool is_root = true; - constexpr bool handles_frame_sink_id_invalidation = true; constexpr bool needs_sync_points = true; support_ = viz::CompositorFrameSinkSupport::Create( this, frame_sink_manager_.get(), frame_sink_id_, is_root, - handles_frame_sink_id_invalidation, needs_sync_points); + needs_sync_points); begin_frame_source_.reset(new viz::StubBeginFrameSource); std::unique_ptr<cc::TextureMailboxDeleter> texture_mailbox_deleter(
diff --git a/android_webview/renderer/aw_content_renderer_client.cc b/android_webview/renderer/aw_content_renderer_client.cc index e614bb3b..81d5d6e 100644 --- a/android_webview/renderer/aw_content_renderer_client.cc +++ b/android_webview/renderer/aw_content_renderer_client.cc
@@ -46,7 +46,6 @@ #include "content/public/renderer/render_view.h" #include "net/base/escape.h" #include "net/base/net_errors.h" -#include "services/service_manager/public/cpp/binder_registry.h" #include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/interface_provider.h" #include "third_party/WebKit/public/platform/WebString.h" @@ -178,11 +177,14 @@ parent_frame->GetRoutingID(), render_frame->GetRoutingID())); } + registry_ = base::MakeUnique<service_manager::BinderRegistry>(); + // TODO(sgurun) do not create a password autofill agent (change // autofill agent to store a weakptr). autofill::PasswordAutofillAgent* password_autofill_agent = - new autofill::PasswordAutofillAgent(render_frame); - new autofill::AutofillAgent(render_frame, password_autofill_agent, NULL); + new autofill::PasswordAutofillAgent(render_frame, registry_.get()); + new autofill::AutofillAgent(render_frame, password_autofill_agent, nullptr, + registry_.get()); #if BUILDFLAG(ENABLE_SPELLCHECK) new SpellCheckProvider(render_frame, spellcheck_.get());
diff --git a/android_webview/renderer/aw_content_renderer_client.h b/android_webview/renderer/aw_content_renderer_client.h index df7252c..6f4e390 100644 --- a/android_webview/renderer/aw_content_renderer_client.h +++ b/android_webview/renderer/aw_content_renderer_client.h
@@ -15,6 +15,7 @@ #include "components/spellcheck/spellcheck_build_features.h" #include "components/web_restrictions/interfaces/web_restrictions.mojom.h" #include "content/public/renderer/content_renderer_client.h" +#include "services/service_manager/public/cpp/binder_registry.h" #if BUILDFLAG(ENABLE_SPELLCHECK) class SpellCheck; @@ -74,6 +75,8 @@ std::unique_ptr<SpellCheck> spellcheck_; #endif + std::unique_ptr<service_manager::BinderRegistry> registry_; + DISALLOW_COPY_AND_ASSIGN(AwContentRendererClient); };
diff --git a/ash/DEPS b/ash/DEPS index a7476e7..1c030d7d 100644 --- a/ash/DEPS +++ b/ash/DEPS
@@ -68,10 +68,6 @@ # TODO: This is temporary, ash should not use these. http://crbug.com/747415. "+ui/events/devices/device_data_manager.h", "+ui/events/devices/input_device_manager.h", - - # X11 support isn't used in production and will go away soon. - # http://crbug.com/671355. - "+ui/events/devices/x11", ] specific_include_rules = {
diff --git a/ash/display/extended_mouse_warp_controller.cc b/ash/display/extended_mouse_warp_controller.cc index 7fea26a..5c646074 100644 --- a/ash/display/extended_mouse_warp_controller.cc +++ b/ash/display/extended_mouse_warp_controller.cc
@@ -142,14 +142,12 @@ gfx::Point point_in_native = ui::EventSystemLocationFromNative(event->native_event()); -#if defined(USE_OZONE) // TODO(dnicoara): crbug.com/415680 Move cursor warping into Ozone once Ozone // has access to the logical display layout. // Native events in Ozone are in the native window coordinate system. We need // to translate them to get the global position. point_in_native.Offset(target->GetHost()->GetBoundsInPixels().x(), target->GetHost()->GetBoundsInPixels().y()); -#endif return WarpMouseCursorInNativeCoords(point_in_native, point_in_screen, false); }
diff --git a/ash/display/unified_mouse_warp_controller.cc b/ash/display/unified_mouse_warp_controller.cc index ec347e2..2a11a3a 100644 --- a/ash/display/unified_mouse_warp_controller.cc +++ b/ash/display/unified_mouse_warp_controller.cc
@@ -35,7 +35,6 @@ ->GetAshWindowTreeHostForDisplayId(display_id); } -#if defined(USE_OZONE) // Find a WindowTreeHost used for mirroring displays that contains // the |point_in_screen|. Returns nullptr if such WTH does not exist. aura::WindowTreeHost* FindMirroringWindowTreeHostFromScreenPoint( @@ -49,7 +48,6 @@ return GetMirroringAshWindowTreeHostForDisplayId(iter->id()) ->AsWindowTreeHost(); } -#endif } // namespace @@ -95,7 +93,6 @@ gfx::Point point_in_native = ui::EventSystemLocationFromNative(event->native_event()); -#if defined(USE_OZONE) // TODO(dnicoara): crbug.com/415680 Move cursor warping into Ozone once Ozone // has access to the logical display layout. // Native events in Ozone are in the native window coordinate system. We need @@ -106,7 +103,6 @@ return false; point_in_native.Offset(host->GetBoundsInPixels().x(), host->GetBoundsInPixels().y()); -#endif return WarpMouseCursorInNativeCoords(point_in_native, point_in_unified_host, update_location_for_test_);
diff --git a/ash/display/unified_mouse_warp_controller_unittest.cc b/ash/display/unified_mouse_warp_controller_unittest.cc index 853345b..3bd2db2 100644 --- a/ash/display/unified_mouse_warp_controller_unittest.cc +++ b/ash/display/unified_mouse_warp_controller_unittest.cc
@@ -72,14 +72,9 @@ &point_in_mirroring_host, &point_in_unified_host)) { return false; } -#if defined(USE_OZONE) // The location of the ozone's native event is relative to the host. GetEventGenerator().MoveMouseToWithNative(point_in_unified_host, point_in_mirroring_host); -#else - GetEventGenerator().MoveMouseToWithNative(point_in_unified_host, - point_in_native); -#endif aura::Window* root = Shell::GetPrimaryRootWindow(); gfx::Point new_location_in_unified_host = aura::Env::GetInstance()->last_mouse_location();
diff --git a/ash/fast_ink/fast_ink_points.cc b/ash/fast_ink/fast_ink_points.cc index 6fe4b75..65a08c5 100644 --- a/ash/fast_ink/fast_ink_points.cc +++ b/ash/fast_ink/fast_ink_points.cc
@@ -46,8 +46,12 @@ } gfx::Rect FastInkPoints::GetBoundingBox() const { + return gfx::ToEnclosingRect(GetBoundingBoxF()); +} + +gfx::RectF FastInkPoints::GetBoundingBoxF() const { if (IsEmpty()) - return gfx::Rect(); + return gfx::RectF(); gfx::PointF min_point = GetOldest().location; gfx::PointF max_point = GetOldest().location; @@ -55,7 +59,7 @@ min_point.SetToMin(point.location); max_point.SetToMax(point.location); } - return gfx::ToEnclosingRect(gfx::BoundingRect(min_point, max_point)); + return gfx::BoundingRect(min_point, max_point); } FastInkPoints::FastInkPoint FastInkPoints::GetOldest() const {
diff --git a/ash/fast_ink/fast_ink_points.h b/ash/fast_ink/fast_ink_points.h index 8c16482..b264cee 100644 --- a/ash/fast_ink/fast_ink_points.h +++ b/ash/fast_ink/fast_ink_points.h
@@ -11,8 +11,8 @@ #include "ash/ash_export.h" #include "base/macros.h" #include "base/time/time.h" -#include "ui/gfx/geometry/point_f.h" #include "ui/gfx/geometry/rect.h" +#include "ui/gfx/geometry/rect_f.h" namespace ash { @@ -38,8 +38,10 @@ void MoveForwardToTime(const base::TimeTicks& latest_time); // Removes all points. void Clear(); - // Gets the bounding box of the points. + // Gets the bounding box of the points, int coordinates. gfx::Rect GetBoundingBox() const; + // Gets the bounding box of the points, float coordinates. + gfx::RectF GetBoundingBoxF() const; // Returns the oldest point in the collection. FastInkPoint GetOldest() const; // Returns the newest point in the collection.
diff --git a/ash/highlighter/highlighter_controller.cc b/ash/highlighter/highlighter_controller.cc index 1d074437..4aa65ea 100644 --- a/ash/highlighter/highlighter_controller.cc +++ b/ash/highlighter/highlighter_controller.cc
@@ -13,6 +13,7 @@ #include "ash/system/palette/palette_utils.h" #include "base/command_line.h" #include "base/strings/string_number_conversions.h" +#include "ui/aura/window_tree_host.h" #include "ui/display/screen.h" #include "ui/events/base_event_utils.h" #include "ui/views/widget/widget.h" @@ -24,12 +25,30 @@ // Adjust the height of the bounding box to match the pen tip height, // while keeping the same vertical center line. Adjust the width to // account for the pen tip width. -gfx::Rect AdjustHorizontalStroke(const gfx::Rect& box, - const gfx::SizeF& pen_tip_size) { - return gfx::ToEnclosingRect( - gfx::RectF(box.x() - pen_tip_size.width() / 2, - box.CenterPoint().y() - pen_tip_size.height() / 2, - box.width() + pen_tip_size.width(), pen_tip_size.height())); +gfx::RectF AdjustHorizontalStroke(const gfx::RectF& box, + const gfx::SizeF& pen_tip_size) { + return gfx::RectF(box.x() - pen_tip_size.width() / 2, + box.CenterPoint().y() - pen_tip_size.height() / 2, + box.width() + pen_tip_size.width(), pen_tip_size.height()); +} + +// This method computes the scale required to convert window-relative DIP +// coordinates to the coordinate space of the screenshot taken from that window. +// The transform returned by WindowTreeHost::GetRootTransform translates points +// from DIP to physical screen pixels (by taking into account not only the +// scale but also the rotation and the offset). +// However, the screenshot bitmap is always oriented the same way as the window +// from which it was taken, and has zero offset. +// The code below deduces the scale from the transform by applying it to a pair +// of points separated by the distance of 1, and measuring the distance between +// the transformed points. +float GetScreenshotScale(aura::Window* window) { + const gfx::Transform transform = window->GetHost()->GetRootTransform(); + gfx::Point3F p1(0, 0, 0); + gfx::Point3F p2(1, 0, 0); + transform.TransformPoint(&p1); + transform.TransformPoint(&p2); + return (p2 - p1).Length(); } // The default amount of time used to estimate time from VSYNC event to when @@ -102,23 +121,24 @@ if (event->type() == ui::ET_TOUCH_RELEASED && highlighter_view_) { const FastInkPoints& points = highlighter_view_->points(); - const gfx::Rect box = points.GetBoundingBox(); - const gfx::Point pivot(box.CenterPoint()); + const gfx::RectF box = points.GetBoundingBoxF(); + const gfx::PointF pivot(box.CenterPoint()); - const float scale_factor = current_window->layer()->device_scale_factor(); + const float scale_factor = GetScreenshotScale(current_window); if (DetectHorizontalStroke(box, HighlighterView::kPenTipSize)) { - const gfx::Rect box_adjusted = + const gfx::RectF box_adjusted = AdjustHorizontalStroke(box, HighlighterView::kPenTipSize); observer_->HandleSelection( - gfx::ScaleToEnclosingRect(box_adjusted, scale_factor)); + gfx::ToEnclosingRect(gfx::ScaleRect(box_adjusted, scale_factor))); highlighter_view_->Animate(pivot, HighlighterView::AnimationMode::kFadeout); result_view_ = base::MakeUnique<HighlighterResultView>(current_window); result_view_->AnimateInPlace(box_adjusted, HighlighterView::kPenColor); } else if (DetectClosedShape(box, points)) { - observer_->HandleSelection(gfx::ScaleToEnclosingRect(box, scale_factor)); + observer_->HandleSelection( + gfx::ToEnclosingRect(gfx::ScaleRect(box, scale_factor))); highlighter_view_->Animate(pivot, HighlighterView::AnimationMode::kInflate);
diff --git a/ash/highlighter/highlighter_controller_test_api.cc b/ash/highlighter/highlighter_controller_test_api.cc index 275ce70..76747eb 100644 --- a/ash/highlighter/highlighter_controller_test_api.cc +++ b/ash/highlighter/highlighter_controller_test_api.cc
@@ -6,34 +6,19 @@ #include "ash/fast_ink/fast_ink_points.h" #include "ash/highlighter/highlighter_controller.h" -#include "ash/highlighter/highlighter_selection_observer.h" #include "ash/highlighter/highlighter_view.h" namespace ash { -namespace { - -class DummyHighlighterObserver : public HighlighterSelectionObserver { - public: - DummyHighlighterObserver() {} - ~DummyHighlighterObserver() override {} - - private: - void HandleSelection(const gfx::Rect& rect) override {} -}; - -} // namespace - HighlighterControllerTestApi::HighlighterControllerTestApi( HighlighterController* instance) - : instance_(instance), - observer_(base::MakeUnique<DummyHighlighterObserver>()) {} + : instance_(instance) {} HighlighterControllerTestApi::~HighlighterControllerTestApi() {} void HighlighterControllerTestApi::SetEnabled(bool enabled) { if (enabled) - instance_->EnableHighlighter(observer_.get()); + instance_->EnableHighlighter(this); else instance_->DisableHighlighter(); } @@ -59,4 +44,9 @@ return instance_->highlighter_view_->predicted_points_; } +void HighlighterControllerTestApi::HandleSelection(const gfx::Rect& rect) { + handle_selection_called_ = true; + selection_ = rect; +} + } // namespace ash
diff --git a/ash/highlighter/highlighter_controller_test_api.h b/ash/highlighter/highlighter_controller_test_api.h index 76773b1..e8966e0e 100644 --- a/ash/highlighter/highlighter_controller_test_api.h +++ b/ash/highlighter/highlighter_controller_test_api.h
@@ -5,21 +5,22 @@ #ifndef ASH_HIGHLIGHTER_HIGHLIGHTER_CONTROLLER_TEST_API_H_ #define ASH_HIGHLIGHTER_HIGHLIGHTER_CONTROLLER_TEST_API_H_ -#include <memory> - +#include "ash/highlighter/highlighter_selection_observer.h" #include "base/macros.h" +#include "ui/gfx/geometry/rect.h" namespace ash { class FastInkPoints; class HighlighterController; -class HighlighterSelectionObserver; // An api for testing the HighlighterController class. -class HighlighterControllerTestApi { +// Inheriting from HighlighterSelectionObserver to provide the tests +// with access to gesture recognition results. +class HighlighterControllerTestApi : public HighlighterSelectionObserver { public: explicit HighlighterControllerTestApi(HighlighterController* instance); - ~HighlighterControllerTestApi(); + ~HighlighterControllerTestApi() override; void SetEnabled(bool enabled); bool IsShowingHighlighter() const; @@ -28,9 +29,18 @@ const FastInkPoints& points() const; const FastInkPoints& predicted_points() const; + void ResetSelection() { handle_selection_called_ = false; } + bool handle_selection_called() const { return handle_selection_called_; } + const gfx::Rect& selection() const { return selection_; } + private: + // HighlighterSelectionObserver: + void HandleSelection(const gfx::Rect& rect) override; + HighlighterController* instance_; - std::unique_ptr<HighlighterSelectionObserver> observer_; + + bool handle_selection_called_ = false; + gfx::Rect selection_; DISALLOW_COPY_AND_ASSIGN(HighlighterControllerTestApi); };
diff --git a/ash/highlighter/highlighter_controller_unittest.cc b/ash/highlighter/highlighter_controller_unittest.cc index fca9e59..93e405f7 100644 --- a/ash/highlighter/highlighter_controller_unittest.cc +++ b/ash/highlighter/highlighter_controller_unittest.cc
@@ -4,11 +4,12 @@ #include "ash/highlighter/highlighter_controller.h" +#include "ash/fast_ink/fast_ink_points.h" #include "ash/highlighter/highlighter_controller_test_api.h" -#include "ash/highlighter/highlighter_view.h" #include "ash/public/cpp/config.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" +#include "base/strings/stringprintf.h" #include "ui/events/test/event_generator.h" namespace ash { @@ -34,6 +35,16 @@ protected: std::unique_ptr<HighlighterController> controller_; + void TraceRect(const gfx::Rect& rect) { + GetEventGenerator().MoveTouch(gfx::Point(rect.x(), rect.y())); + GetEventGenerator().PressTouch(); + GetEventGenerator().MoveTouch(gfx::Point(rect.right(), rect.y())); + GetEventGenerator().MoveTouch(gfx::Point(rect.right(), rect.bottom())); + GetEventGenerator().MoveTouch(gfx::Point(rect.x(), rect.bottom())); + GetEventGenerator().MoveTouch(gfx::Point(rect.x(), rect.y())); + GetEventGenerator().ReleaseTouch(); + } + private: DISALLOW_COPY_AND_ASSIGN(HighlighterControllerTest); }; @@ -142,4 +153,144 @@ } } +// Test that stylus gestures are correctly recognized by HighlighterController. +TEST_F(HighlighterControllerTest, HighlighterGestures) { + HighlighterControllerTestApi controller_test_api_(controller_.get()); + + controller_test_api_.SetEnabled(true); + GetEventGenerator().EnterPenPointerMode(); + + // A non-horizontal stroke is not recognized + controller_test_api_.ResetSelection(); + GetEventGenerator().MoveTouch(gfx::Point(100, 100)); + GetEventGenerator().PressTouch(); + GetEventGenerator().MoveTouch(gfx::Point(200, 200)); + GetEventGenerator().ReleaseTouch(); + EXPECT_FALSE(controller_test_api_.handle_selection_called()); + + // An almost horizontal stroke is recognized + controller_test_api_.ResetSelection(); + GetEventGenerator().MoveTouch(gfx::Point(100, 100)); + GetEventGenerator().PressTouch(); + GetEventGenerator().MoveTouch(gfx::Point(300, 102)); + GetEventGenerator().ReleaseTouch(); + EXPECT_TRUE(controller_test_api_.handle_selection_called()); + + // Horizontal stroke selection rectangle should: + // have the same horizontal center line as the stroke bounding box, + // be 4dp wider than the stroke bounding box, + // be exactly 14dp high. + EXPECT_EQ("98,94 204x14", controller_test_api_.selection().ToString()); + + // An insufficiently closed C-like shape is not recognized + controller_test_api_.ResetSelection(); + GetEventGenerator().MoveTouch(gfx::Point(100, 0)); + GetEventGenerator().PressTouch(); + GetEventGenerator().MoveTouch(gfx::Point(0, 0)); + GetEventGenerator().MoveTouch(gfx::Point(0, 100)); + GetEventGenerator().MoveTouch(gfx::Point(100, 100)); + GetEventGenerator().ReleaseTouch(); + EXPECT_FALSE(controller_test_api_.handle_selection_called()); + + // An almost closed G-like shape is recognized + controller_test_api_.ResetSelection(); + GetEventGenerator().MoveTouch(gfx::Point(200, 0)); + GetEventGenerator().PressTouch(); + GetEventGenerator().MoveTouch(gfx::Point(0, 0)); + GetEventGenerator().MoveTouch(gfx::Point(0, 100)); + GetEventGenerator().MoveTouch(gfx::Point(200, 100)); + GetEventGenerator().MoveTouch(gfx::Point(200, 20)); + GetEventGenerator().ReleaseTouch(); + EXPECT_TRUE(controller_test_api_.handle_selection_called()); + EXPECT_EQ("0,0 200x100", controller_test_api_.selection().ToString()); + + // A closed diamond shape is recognized + controller_test_api_.ResetSelection(); + GetEventGenerator().MoveTouch(gfx::Point(100, 0)); + GetEventGenerator().PressTouch(); + GetEventGenerator().MoveTouch(gfx::Point(200, 150)); + GetEventGenerator().MoveTouch(gfx::Point(100, 300)); + GetEventGenerator().MoveTouch(gfx::Point(0, 150)); + GetEventGenerator().MoveTouch(gfx::Point(100, 0)); + GetEventGenerator().ReleaseTouch(); + EXPECT_TRUE(controller_test_api_.handle_selection_called()); + EXPECT_EQ("0,0 200x300", controller_test_api_.selection().ToString()); +} + +// Test that stylus gesture recognition correctly handles display scaling +TEST_F(HighlighterControllerTest, HighlighterGesturesScaled) { + HighlighterControllerTestApi controller_test_api_(controller_.get()); + + controller_test_api_.SetEnabled(true); + GetEventGenerator().EnterPenPointerMode(); + + const gfx::Rect original_rect(200, 100, 400, 300); + + // Allow for rounding errors. + gfx::Rect inflated(original_rect); + inflated.Inset(-1, -1); + + constexpr float display_scales[] = {1.f, 1.5f, 2.0f}; + constexpr float ui_scales[] = {0.5f, 0.67f, 1.0f, 1.25f, + 1.33f, 1.5f, 1.67f, 2.0f}; + + for (size_t i = 0; i < sizeof(display_scales) / sizeof(float); ++i) { + const float display_scale = display_scales[i]; + for (size_t j = 0; j < sizeof(ui_scales) / sizeof(float); ++j) { + const float ui_scale = ui_scales[j]; + + std::string display_spec = + base::StringPrintf("1500x1000*%.2f@%.2f", display_scale, ui_scale); + SCOPED_TRACE(display_spec); + UpdateDisplay(display_spec); + + controller_test_api_.ResetSelection(); + TraceRect(original_rect); + EXPECT_TRUE(controller_test_api_.handle_selection_called()); + + const gfx::Rect selection = controller_test_api_.selection(); + EXPECT_TRUE(inflated.Contains(selection)); + EXPECT_TRUE(selection.Contains(original_rect)); + } + } +} + +// Test that stylus gesture recognition correctly handles display rotation +TEST_F(HighlighterControllerTest, HighlighterGesturesRotated) { + HighlighterControllerTestApi controller_test_api_(controller_.get()); + + controller_test_api_.SetEnabled(true); + GetEventGenerator().EnterPenPointerMode(); + + const gfx::Rect trace(200, 100, 400, 300); + + // No rotation + UpdateDisplay("1500x1000"); + controller_test_api_.ResetSelection(); + TraceRect(trace); + EXPECT_TRUE(controller_test_api_.handle_selection_called()); + EXPECT_EQ("200,100 400x300", controller_test_api_.selection().ToString()); + + // Rotate to 90 degrees + UpdateDisplay("1500x1000/r"); + controller_test_api_.ResetSelection(); + TraceRect(trace); + EXPECT_TRUE(controller_test_api_.handle_selection_called()); + EXPECT_EQ("100,899 300x400", controller_test_api_.selection().ToString()); + + // Rotate to 180 degrees + UpdateDisplay("1500x1000/u"); + controller_test_api_.ResetSelection(); + TraceRect(trace); + EXPECT_TRUE(controller_test_api_.handle_selection_called()); + EXPECT_EQ("899,599 400x300", controller_test_api_.selection().ToString()); + + // Rotate to 270 degrees + UpdateDisplay("1500x1000/l"); + controller_test_api_.ResetSelection(); + TraceRect(trace); + EXPECT_TRUE(controller_test_api_.handle_selection_called()); + EXPECT_EQ("599,200 300x400", controller_test_api_.selection().ToString()); +} + } // namespace ash
diff --git a/ash/highlighter/highlighter_gesture_util.cc b/ash/highlighter/highlighter_gesture_util.cc index 4fa6ad4..03a26aec 100644 --- a/ash/highlighter/highlighter_gesture_util.cc +++ b/ash/highlighter/highlighter_gesture_util.cc
@@ -17,7 +17,7 @@ constexpr double kClosedShapeSweepThreshold = M_PI * 2 * 0.8; constexpr double kClosedShapeJiggleThreshold = 0.1; -bool DetectHorizontalStroke(const gfx::Rect& box, +bool DetectHorizontalStroke(const gfx::RectF& box, const gfx::SizeF& pen_tip_size) { return box.width() > kHorizontalStrokeLengthThreshold && box.height() < @@ -25,11 +25,11 @@ box.height() < box.width() * kHorizontalStrokeFlatnessThreshold; } -bool DetectClosedShape(const gfx::Rect& box, const FastInkPoints& points) { +bool DetectClosedShape(const gfx::RectF& box, const FastInkPoints& points) { if (points.GetNumberOfPoints() < 3) return false; - const gfx::Point center = box.CenterPoint(); + const gfx::PointF center = box.CenterPoint(); // Analyze vectors pointing from the center to each point. // Compute the cumulative swept angle and count positive
diff --git a/ash/highlighter/highlighter_gesture_util.h b/ash/highlighter/highlighter_gesture_util.h index 978a0e4..d0c34e0 100644 --- a/ash/highlighter/highlighter_gesture_util.h +++ b/ash/highlighter/highlighter_gesture_util.h
@@ -15,14 +15,14 @@ class FastInkPoints; // Returns true if |box| is sufficiently long horizontally and short vertically. -bool ASH_EXPORT DetectHorizontalStroke(const gfx::Rect& box, +bool ASH_EXPORT DetectHorizontalStroke(const gfx::RectF& box, const gfx::SizeF& pen_tip_size); // Returns true if |points| is forming a "closed shape" which is defined as a // sequence of points sweeping at least of 80% of a full circle around the // center of |box|, and going in one direction (clockwise or counterclockwise), // with a little noise tolerated. -bool ASH_EXPORT DetectClosedShape(const gfx::Rect& box, +bool ASH_EXPORT DetectClosedShape(const gfx::RectF& box, const FastInkPoints& points); } // namespace ash
diff --git a/ash/highlighter/highlighter_gesture_util_unittest.cc b/ash/highlighter/highlighter_gesture_util_unittest.cc index 0e2f3c29..0ac615b 100644 --- a/ash/highlighter/highlighter_gesture_util_unittest.cc +++ b/ash/highlighter/highlighter_gesture_util_unittest.cc
@@ -64,11 +64,11 @@ } bool DetectHorizontalStroke() { - return ash::DetectHorizontalStroke(points_.GetBoundingBox(), kPenTipSize); + return ash::DetectHorizontalStroke(points_.GetBoundingBoxF(), kPenTipSize); } bool DetectClosedShape() { - return ash::DetectClosedShape(points_.GetBoundingBox(), points_); + return ash::DetectClosedShape(points_.GetBoundingBoxF(), points_); } private:
diff --git a/ash/highlighter/highlighter_result_view.cc b/ash/highlighter/highlighter_result_view.cc index 1b0d073c..13992d5f 100644 --- a/ash/highlighter/highlighter_result_view.cc +++ b/ash/highlighter/highlighter_result_view.cc
@@ -8,6 +8,7 @@ #include "ash/shell.h" #include "ui/compositor/paint_recorder.h" #include "ui/compositor/scoped_layer_animation_settings.h" +#include "ui/gfx/geometry/rect_conversions.h" #include "ui/views/widget/widget.h" namespace ash { @@ -182,14 +183,14 @@ HighlighterResultView::~HighlighterResultView() {} -void HighlighterResultView::AnimateInPlace(const gfx::Rect& bounds, +void HighlighterResultView::AnimateInPlace(const gfx::RectF& bounds, SkColor color) { ui::Layer* layer = widget_->GetLayer(); // A solid transparent rectangle. result_layer_ = base::MakeUnique<ui::Layer>(ui::LAYER_SOLID_COLOR); result_layer_->set_name("HighlighterResultView:SOLID_LAYER"); - result_layer_->SetBounds(bounds); + result_layer_->SetBounds(gfx::ToEnclosingRect(bounds)); result_layer_->SetFillsBoundsOpaquely(false); result_layer_->SetMasksToBounds(false); result_layer_->SetColor(color); @@ -201,14 +202,14 @@ base::TimeDelta::FromMilliseconds(kResultInPlaceFadeinDurationMs)); } -void HighlighterResultView::AnimateDeflate(const gfx::Rect& bounds) { +void HighlighterResultView::AnimateDeflate(const gfx::RectF& bounds) { ui::Layer* layer = widget_->GetLayer(); - result_layer_ = base::MakeUnique<ResultLayer>(bounds); + result_layer_ = base::MakeUnique<ResultLayer>(gfx::ToEnclosingRect(bounds)); layer->Add(result_layer_.get()); gfx::Transform transform; - const gfx::Point pivot = bounds.CenterPoint(); + const gfx::PointF pivot = bounds.CenterPoint(); transform.Translate(pivot.x() * (1 - kInitialScale), pivot.y() * (1 - kInitialScale)); transform.Scale(kInitialScale, kInitialScale);
diff --git a/ash/highlighter/highlighter_result_view.h b/ash/highlighter/highlighter_result_view.h index 4ec3317..f6376d3 100644 --- a/ash/highlighter/highlighter_result_view.h +++ b/ash/highlighter/highlighter_result_view.h
@@ -36,8 +36,8 @@ ~HighlighterResultView() override; - void AnimateInPlace(const gfx::Rect& bounds, SkColor color); - void AnimateDeflate(const gfx::Rect& bounds); + void AnimateInPlace(const gfx::RectF& bounds, SkColor color); + void AnimateDeflate(const gfx::RectF& bounds); private: void ScheduleFadeIn(const base::TimeDelta& delay,
diff --git a/ash/highlighter/highlighter_view.cc b/ash/highlighter/highlighter_view.cc index 4d56211..0eb294a 100644 --- a/ash/highlighter/highlighter_view.cc +++ b/ash/highlighter/highlighter_view.cc
@@ -108,7 +108,7 @@ RequestRedraw(); } -void HighlighterView::Animate(const gfx::Point& pivot, +void HighlighterView::Animate(const gfx::PointF& pivot, AnimationMode animation_mode) { animation_timer_.reset(new base::Timer( FROM_HERE, base::TimeDelta::FromMilliseconds(kStrokeFadeoutDelayMs), @@ -118,7 +118,7 @@ animation_timer_->Reset(); } -void HighlighterView::FadeOut(const gfx::Point& pivot, +void HighlighterView::FadeOut(const gfx::PointF& pivot, AnimationMode animation_mode) { ui::Layer* layer = GetWidget()->GetLayer();
diff --git a/ash/highlighter/highlighter_view.h b/ash/highlighter/highlighter_view.h index 223e97a..6958fc2 100644 --- a/ash/highlighter/highlighter_view.h +++ b/ash/highlighter/highlighter_view.h
@@ -43,20 +43,18 @@ aura::Window* root_window); ~HighlighterView() override; - gfx::Rect GetBoundingBox() const; - const FastInkPoints& points() const { return points_; } void AddNewPoint(const gfx::PointF& new_point, const base::TimeTicks& time); - void Animate(const gfx::Point& pivot, AnimationMode animation_mode); + void Animate(const gfx::PointF& pivot, AnimationMode animation_mode); private: friend class HighlighterControllerTestApi; void OnRedraw(gfx::Canvas& canvas, const gfx::Vector2d& offset) override; - void FadeOut(const gfx::Point& pivot, AnimationMode animation_mode); + void FadeOut(const gfx::PointF& pivot, AnimationMode animation_mode); FastInkPoints points_; FastInkPoints predicted_points_;
diff --git a/ash/host/DEPS b/ash/host/DEPS index 9b281df..a9a805b 100644 --- a/ash/host/DEPS +++ b/ash/host/DEPS
@@ -17,9 +17,4 @@ # ozone. "+ui/events/ozone/chromeos/cursor_controller.h", ], - # X11 support isn't used and will be removed soon, so it can depend on - # whatever. - "ash_window_tree_host_x11.cc": [ - "+ui/events/devices", - ], }
diff --git a/ash/host/ash_window_tree_host.h b/ash/host/ash_window_tree_host.h index df9bf9d3..82a658fe 100644 --- a/ash/host/ash_window_tree_host.h +++ b/ash/host/ash_window_tree_host.h
@@ -49,11 +49,9 @@ virtual void RegisterMirroringHost(AshWindowTreeHost* mirroring_ash_host) {} -#if defined(USE_OZONE) virtual void SetCursorConfig(const display::Display& display, display::Display::Rotation rotation) = 0; virtual void ClearCursorConfig() = 0; -#endif protected: // Translates the native mouse location into screen coordinates.
diff --git a/ash/host/ash_window_tree_host_platform.cc b/ash/host/ash_window_tree_host_platform.cc index 6878cee4..985c2973 100644 --- a/ash/host/ash_window_tree_host_platform.cc +++ b/ash/host/ash_window_tree_host_platform.cc
@@ -11,20 +11,17 @@ #include "ash/shell.h" #include "ash/shell_delegate.h" #include "base/trace_event/trace_event.h" +#include "services/ui/public/cpp/input_devices/input_device_controller_client.h" +#include "services/ui/public/interfaces/window_manager.mojom.h" #include "ui/aura/window.h" #include "ui/aura/window_tree_host_platform.h" #include "ui/events/event_sink.h" #include "ui/events/null_event_targeter.h" +#include "ui/events/ozone/chromeos/cursor_controller.h" #include "ui/gfx/geometry/insets.h" #include "ui/gfx/transform.h" #include "ui/platform_window/platform_window.h" -#if defined(USE_OZONE) -#include "services/ui/public/cpp/input_devices/input_device_controller_client.h" -#include "services/ui/public/interfaces/window_manager.mojom.h" -#include "ui/events/ozone/chromeos/cursor_controller.h" -#endif - namespace ash { AshWindowTreeHostPlatform::AshWindowTreeHostPlatform( @@ -48,7 +45,6 @@ return true; } -#if defined(USE_OZONE) void AshWindowTreeHostPlatform::SetCursorConfig( const display::Display& display, display::Display::Rotation rotation) { @@ -66,7 +62,6 @@ ui::CursorController::GetInstance()->ClearCursorConfigForWindow( GetAcceleratedWidget()); } -#endif void AshWindowTreeHostPlatform::SetRootWindowTransformer( std::unique_ptr<RootWindowTransformer> transformer) { @@ -130,7 +125,6 @@ } void AshWindowTreeHostPlatform::SetTapToClickPaused(bool state) { -#if defined(USE_OZONE) ui::InputDeviceControllerClient* input_device_controller_client = Shell::Get()->shell_delegate()->GetInputDeviceControllerClient(); if (!input_device_controller_client) @@ -138,7 +132,6 @@ // Temporarily pause tap-to-click when the cursor is hidden. input_device_controller_client->SetTapToClickPaused(state); -#endif } } // namespace ash
diff --git a/ash/host/ash_window_tree_host_platform.h b/ash/host/ash_window_tree_host_platform.h index 63c89390..028b753 100644 --- a/ash/host/ash_window_tree_host_platform.h +++ b/ash/host/ash_window_tree_host_platform.h
@@ -31,11 +31,9 @@ gfx::Insets GetHostInsets() const override; aura::WindowTreeHost* AsWindowTreeHost() override; void PrepareForShutdown() override; -#if defined(USE_OZONE) void SetCursorConfig(const display::Display& display, display::Display::Rotation rotation) override; void ClearCursorConfig() override; -#endif // aura::WindowTreeHostPlatform: void SetRootTransform(const gfx::Transform& transform) override;
diff --git a/ash/mus/ash_window_tree_host_mus.cc b/ash/mus/ash_window_tree_host_mus.cc index 066f8c6..7baeaf5 100644 --- a/ash/mus/ash_window_tree_host_mus.cc +++ b/ash/mus/ash_window_tree_host_mus.cc
@@ -9,15 +9,12 @@ #include "ash/shell.h" #include "ash/shell_delegate.h" #include "base/memory/ptr_util.h" +#include "services/ui/public/cpp/input_devices/input_device_controller_client.h" #include "ui/aura/mus/window_tree_host_mus_init_params.h" #include "ui/aura/window.h" #include "ui/events/event_sink.h" #include "ui/events/null_event_targeter.h" -#if defined(USE_OZONE) -#include "services/ui/public/cpp/input_devices/input_device_controller_client.h" -#endif - namespace ash { AshWindowTreeHostMus::AshWindowTreeHostMus( @@ -68,7 +65,6 @@ NOTIMPLEMENTED(); } -#if defined(USE_OZONE) void AshWindowTreeHostMus::SetCursorConfig( const display::Display& display, display::Display::Rotation rotation) { @@ -78,7 +74,6 @@ void AshWindowTreeHostMus::ClearCursorConfig() { // Nothing to do here, mus takes care of this. } -#endif void AshWindowTreeHostMus::SetRootTransform(const gfx::Transform& transform) { transformer_helper_->SetTransform(transform); @@ -98,7 +93,6 @@ } void AshWindowTreeHostMus::OnCursorVisibilityChangedNative(bool show) { -#if defined(USE_OZONE) ui::InputDeviceControllerClient* input_device_controller_client = Shell::Get()->shell_delegate()->GetInputDeviceControllerClient(); if (!input_device_controller_client) @@ -106,7 +100,6 @@ // Temporarily pause tap-to-click when the cursor is hidden. input_device_controller_client->SetTapToClickPaused(!show); -#endif } } // namespace ash
diff --git a/ash/mus/ash_window_tree_host_mus.h b/ash/mus/ash_window_tree_host_mus.h index f441899..8226fa0 100644 --- a/ash/mus/ash_window_tree_host_mus.h +++ b/ash/mus/ash_window_tree_host_mus.h
@@ -27,11 +27,9 @@ aura::WindowTreeHost* AsWindowTreeHost() override; void PrepareForShutdown() override; void RegisterMirroringHost(AshWindowTreeHost* mirroring_ash_host) override; -#if defined(USE_OZONE) void SetCursorConfig(const display::Display& display, display::Display::Rotation rotation) override; void ClearCursorConfig() override; -#endif // aura::WindowTreeHostMus: void SetRootTransform(const gfx::Transform& transform) override;
diff --git a/ash/mus/bridge/shell_port_mash.cc b/ash/mus/bridge/shell_port_mash.cc index 0c8a5a6..7c9227d 100644 --- a/ash/mus/bridge/shell_port_mash.cc +++ b/ash/mus/bridge/shell_port_mash.cc
@@ -50,13 +50,10 @@ #include "ui/aura/mus/window_tree_host_mus_init_params.h" #include "ui/aura/window.h" #include "ui/display/manager/display_manager.h" +#include "ui/display/manager/forwarding_display_delegate.h" #include "ui/display/types/native_display_delegate.h" #include "ui/views/mus/pointer_watcher_event_router.h" -#if defined(USE_OZONE) -#include "ui/display/manager/forwarding_display_delegate.h" -#endif - namespace ash { namespace mus { @@ -354,7 +351,6 @@ std::unique_ptr<display::NativeDisplayDelegate> ShellPortMash::CreateNativeDisplayDelegate() { -#if defined(USE_OZONE) display::mojom::NativeDisplayDelegatePtr native_display_delegate; if (window_manager_->connector()) { window_manager_->connector()->BindInterface(ui::mojom::kServiceName, @@ -362,11 +358,6 @@ } return base::MakeUnique<display::ForwardingDisplayDelegate>( std::move(native_display_delegate)); -#else - // The bots compile this config, but it is never run. - CHECK(false); - return nullptr; -#endif } std::unique_ptr<AcceleratorController>
diff --git a/ash/mus/shell_delegate_mus.cc b/ash/mus/shell_delegate_mus.cc index 1953fd9..4b945f524 100644 --- a/ash/mus/shell_delegate_mus.cc +++ b/ash/mus/shell_delegate_mus.cc
@@ -18,10 +18,7 @@ #include "components/user_manager/user_info_impl.h" #include "ui/gfx/image/image.h" #include "ui/keyboard/keyboard_ui.h" - -#if defined(USE_OZONE) #include "services/ui/public/cpp/input_devices/input_device_controller_client.h" -#endif namespace ash { @@ -157,7 +154,6 @@ NOTIMPLEMENTED(); } -#if defined(USE_OZONE) ui::InputDeviceControllerClient* ShellDelegateMus::GetInputDeviceControllerClient() { if (!connector_) @@ -169,6 +165,5 @@ } return input_device_controller_client_.get(); } -#endif } // namespace ash
diff --git a/ash/mus/shell_delegate_mus.h b/ash/mus/shell_delegate_mus.h index 519fd45..97c140c 100644 --- a/ash/mus/shell_delegate_mus.h +++ b/ash/mus/shell_delegate_mus.h
@@ -50,18 +50,14 @@ void SetTouchscreenEnabledInPrefs(bool enabled, bool use_local_state) override; void UpdateTouchscreenStatusFromPrefs() override; -#if defined(USE_OZONE) ui::InputDeviceControllerClient* GetInputDeviceControllerClient() override; -#endif private: // |connector_| may be null in tests. service_manager::Connector* connector_; -#if defined(USE_OZONE) std::unique_ptr<ui::InputDeviceControllerClient> input_device_controller_client_; -#endif DISALLOW_COPY_AND_ASSIGN(ShellDelegateMus); };
diff --git a/ash/resources/vector_icons/palette_tray_icon_laser_pointer.icon b/ash/resources/vector_icons/palette_tray_icon_laser_pointer.icon index 5ec3ad0..f853141 100644 --- a/ash/resources/vector_icons/palette_tray_icon_laser_pointer.icon +++ b/ash/resources/vector_icons/palette_tray_icon_laser_pointer.icon
@@ -4,7 +4,7 @@ CANVAS_DIMENSIONS, 32, NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xD3, 0xD3, 0xD3, +PATH_COLOR_ARGB, 0x4D, 0xFF, 0xFF, 0xFF, MOVE_TO, 24.05f, 12, H_LINE_TO, 16.38f, R_LINE_TO, 7.68f, -7.42f,
diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc index 5b6ea2fe..0fd30d7ed 100644 --- a/ash/shell/shell_delegate_impl.cc +++ b/ash/shell/shell_delegate_impl.cc
@@ -159,12 +159,10 @@ void ShellDelegateImpl::UpdateTouchscreenStatusFromPrefs() {} -#if defined(USE_OZONE) ui::InputDeviceControllerClient* ShellDelegateImpl::GetInputDeviceControllerClient() { return nullptr; } -#endif } // namespace shell } // namespace ash
diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h index 4b45608..0924384 100644 --- a/ash/shell/shell_delegate_impl.h +++ b/ash/shell/shell_delegate_impl.h
@@ -52,9 +52,7 @@ void SetTouchscreenEnabledInPrefs(bool enabled, bool use_local_state) override; void UpdateTouchscreenStatusFromPrefs() override; -#if defined(USE_OZONE) ui::InputDeviceControllerClient* GetInputDeviceControllerClient() override; -#endif private: DISALLOW_COPY_AND_ASSIGN(ShellDelegateImpl);
diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h index 8cea02d..98932ce 100644 --- a/ash/shell_delegate.h +++ b/ash/shell_delegate.h
@@ -32,9 +32,7 @@ } namespace ui { -#if defined(USE_OZONE) class InputDeviceControllerClient; -#endif class MenuModel; } @@ -147,10 +145,8 @@ // Suspends all WebContents-associated media sessions to stop managed players. virtual void SuspendMediaSessions() {} -#if defined(USE_OZONE) // Creator of Shell owns this; it's assumed this outlives Shell. virtual ui::InputDeviceControllerClient* GetInputDeviceControllerClient() = 0; -#endif }; } // namespace ash
diff --git a/ash/test_shell_delegate.cc b/ash/test_shell_delegate.cc index 97d8063..a49e7177 100644 --- a/ash/test_shell_delegate.cc +++ b/ash/test_shell_delegate.cc
@@ -160,11 +160,9 @@ media_sessions_suspended_ = true; } -#if defined(USE_OZONE) ui::InputDeviceControllerClient* TestShellDelegate::GetInputDeviceControllerClient() { return nullptr; } -#endif } // namespace ash
diff --git a/ash/test_shell_delegate.h b/ash/test_shell_delegate.h index 3f4e26a..2b12edf 100644 --- a/ash/test_shell_delegate.h +++ b/ash/test_shell_delegate.h
@@ -64,9 +64,7 @@ bool use_local_state) override; void UpdateTouchscreenStatusFromPrefs() override; void SuspendMediaSessions() override; -#if defined(USE_OZONE) ui::InputDeviceControllerClient* GetInputDeviceControllerClient() override; -#endif int num_exit_requests() const { return num_exit_requests_; }
diff --git a/ash/wm/native_cursor_manager_ash_mus.cc b/ash/wm/native_cursor_manager_ash_mus.cc index c36b5314..7cda5de6 100644 --- a/ash/wm/native_cursor_manager_ash_mus.cc +++ b/ash/wm/native_cursor_manager_ash_mus.cc
@@ -13,13 +13,10 @@ #include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_tree_host.h" #include "ui/base/cursor/image_cursors.h" +#include "ui/base/cursor/ozone/cursor_data_factory_ozone.h" #include "ui/base/layout.h" #include "ui/wm/core/cursor_manager.h" -#if defined(USE_OZONE) -#include "ui/base/cursor/ozone/cursor_data_factory_ozone.h" -#endif - namespace ash { namespace { @@ -27,17 +24,10 @@ void SetCursorOnAllRootWindows(gfx::NativeCursor cursor) { ui::CursorData mojo_cursor; - if (cursor.platform()) { -#if defined(USE_OZONE) + if (cursor.platform()) mojo_cursor = ui::CursorDataFactoryOzone::GetCursorData(cursor.platform()); -#else - NOTIMPLEMENTED() - << "Can't pass native platform cursors on non-ozone platforms"; - mojo_cursor = ui::CursorData(ui::CursorType::kPointer); -#endif - } else { + else mojo_cursor = ui::CursorData(cursor.native_type()); - } // As the window manager, tell mus to use |mojo_cursor| everywhere. We do // this instead of trying to set per-window because otherwise we run into the @@ -82,16 +72,14 @@ } // namespace NativeCursorManagerAshMus::NativeCursorManagerAshMus() { -#if defined(USE_OZONE) // If we're in a mus client, we aren't going to have all of ozone initialized // even though we're in an ozone build. All the hard coded USE_OZONE ifdefs - // that handle cursor code expect that there will be a CursorFactoryOzone - // instance. Partially initialize the ozone cursor internals here, like we - // partially initialize other ozone subsystems in + // that handle cursor code in //content/ expect that there will be a + // CursorFactoryOzone instance. Partially initialize the ozone cursor + // internals here, like we partially initialize other ozone subsystems in // ChromeBrowserMainExtraPartsViews. cursor_factory_ozone_ = base::MakeUnique<ui::CursorDataFactoryOzone>(); image_cursors_ = base::MakeUnique<ui::ImageCursors>(); -#endif } NativeCursorManagerAshMus::~NativeCursorManagerAshMus() = default;
diff --git a/ash/wm/native_cursor_manager_ash_mus.h b/ash/wm/native_cursor_manager_ash_mus.h index 75e4186..6baa625 100644 --- a/ash/wm/native_cursor_manager_ash_mus.h +++ b/ash/wm/native_cursor_manager_ash_mus.h
@@ -52,11 +52,8 @@ bool native_cursor_enabled_ = true; -#if defined(USE_OZONE) std::unique_ptr<ui::CursorDataFactoryOzone> cursor_factory_ozone_; -#endif - // Always nullptr when USE_OZONE is false. std::unique_ptr<::ui::ImageCursors> image_cursors_; DISALLOW_COPY_AND_ASSIGN(NativeCursorManagerAshMus);
diff --git a/base/BUILD.gn b/base/BUILD.gn index 23586de..738ebdfc 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn
@@ -2301,7 +2301,6 @@ deps += [ ":base_java", ":base_java_unittest_support", - "//base/android/jni_generator:jni_generator_tests", "//base/test:test_support_java", ] }
diff --git a/base/android/jni_generator/BUILD.gn b/base/android/jni_generator/BUILD.gn index 12c0c39..68e5519 100644 --- a/base/android/jni_generator/BUILD.gn +++ b/base/android/jni_generator/BUILD.gn
@@ -2,6 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//base/android/jni_generator/jni_exception_list.gni") import("//build/config/android/rules.gni") import("//testing/test.gni") @@ -38,13 +39,9 @@ ] } -# This executable doesn't actually run, but at least serves to test that -# generated bindings compile properly. -executable("jni_generator_tests") { +source_set("jni_sample_native_side") { deps = [ - ":jni_generator_py_tests", ":jni_sample_header", - ":jni_sample_java", "//base", ] sources = [ @@ -52,3 +49,39 @@ "sample_for_tests.h", ] } + +shared_library("jni_sample_lib") { + sources = [ + "sample_entry_point.cc", + ] + + deps = [ + ":jni_sample_native_side", + ":sample_jni_registration", + "//base", + ] +} + +android_apk("sample_jni_apk") { + apk_name = "SampleJni" + android_manifest = "//build/android/AndroidManifest.xml" + deps = [ + ":jni_sample_java", + "//base:base_java", + ] + shared_libraries = [ ":jni_sample_lib" ] +} + +generate_jni_registration("sample_jni_registration") { + target = ":sample_jni_apk" + output = "$target_gen_dir/${target_name}.h" + exception_files = jni_exception_files +} + +# Serves to test that generated bindings compile properly. +group("jni_generator_tests") { + deps = [ + ":jni_generator_py_tests", + ":sample_jni_apk", + ] +}
diff --git a/base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForTests.java b/base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForTests.java index 42d8e56..7e9d3afc 100644 --- a/base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForTests.java +++ b/base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForTests.java
@@ -22,6 +22,8 @@ // The C++ counter-part is sample_for_tests.cc. // jni_generator/BUILD.gn has a jni_generator_tests target that will: // * Generate a header file for the JNI bindings based on this file. +// * Generate a header file containing registration methods required to use C++ methods from this +// file. // * Compile sample_for_tests.cc using the generated header file. // * link a native executable to prove the generated header + cc file are self-contained. // All comments are informational only, and are ignored by the jni generator.
diff --git a/base/android/jni_generator/sample_entry_point.cc b/base/android/jni_generator/sample_entry_point.cc new file mode 100644 index 0000000..86f7e480 --- /dev/null +++ b/base/android/jni_generator/sample_entry_point.cc
@@ -0,0 +1,27 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/android/jni_android.h" +#include "base/android/jni_generator/sample_jni_registration.h" +#include "base/android/jni_utils.h" + +// This is called by the VM when the shared library is first loaded. +JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + // By default, all JNI methods are registered. However, since render processes + // don't need very much Java code, we enable selective JNI registration on the + // Java side and only register a subset of JNI methods. + base::android::InitVM(vm); + JNIEnv* env = base::android::AttachCurrentThread(); + + if (!base::android::IsSelectiveJniRegistrationEnabled(env)) { + if (!RegisterNonMainDexNatives(env)) { + return -1; + } + } + + if (!RegisterMainDexNatives(env)) { + return -1; + } + return JNI_VERSION_1_4; +}
diff --git a/base/android/jni_generator/sample_for_tests.cc b/base/android/jni_generator/sample_for_tests.cc index 42b2143..ddc2012 100644 --- a/base/android/jni_generator/sample_for_tests.cc +++ b/base/android/jni_generator/sample_for_tests.cc
@@ -35,10 +35,6 @@ } // static -bool CPPClass::RegisterJNI(JNIEnv* env) { - return RegisterNativesImpl(env); // Generated in SampleForTests_jni.h -} - void CPPClass::Destroy(JNIEnv* env, const JavaParamRef<jobject>& caller) { delete this; }
diff --git a/base/android/jni_generator/sample_for_tests.h b/base/android/jni_generator/sample_for_tests.h index a9cf7b0..6414158 100644 --- a/base/android/jni_generator/sample_for_tests.h +++ b/base/android/jni_generator/sample_for_tests.h
@@ -19,8 +19,9 @@ // - ensure sample_for_tests_jni.h compiles and the functions declared in it // as expected. // -// Methods are called directly from Java (except RegisterJNI). More -// documentation in SampleForTests.java +// Methods are called directly from Java. More documentation in +// SampleForTests.java. See BUILD.gn for the build rules necessary for JNI +// to be used in an APK. // // For C++ to access Java methods: // - GN Build must be configured to generate bindings: @@ -56,39 +57,26 @@ // ] // } // } +// The build rules above are generally that that's needed when adding new +// JNI methods/files. For a full GN example, see +// base/android/jni_generator/BUILD.gn // // For C++ methods to be exposed to Java: -// - The generated RegisterNativesImpl method must be called, this is typically -// done by having a static RegisterJNI method in the C++ class. -// - The RegisterJNI method is added to a module's collection of register -// methods, such as: example_jni_registrar.h/cc files which call -// base::android::RegisterNativeMethods. -// An example_jni_registstrar.cc: -// -// namespace { -// const base::android::RegistrationMethod kRegisteredMethods[] = { -// // Initial string is for debugging only. -// { "ExampleName", base::ExampleNameAndroid::RegisterJNI }, -// { "ExampleName2", base::ExampleName2Android::RegisterJNI }, -// }; -// } // namespace -// -// bool RegisterModuleNameJni(JNIEnv* env) { -// return RegisterNativeMethods(env, kRegisteredMethods, -// arraysize(kRegisteredMethods)); -// } -// -// - Each module's RegisterModuleNameJni must be called by a larger module, -// or application during startup. +// - The Java class must be part of an android_apk target that depends on +// a generate_jni_registration target. This generate_jni_registration target +// automatically generates all necessary registration functions. The +// generated header file exposes two functions that should be called when a +// library is first loaded: +// 1) RegisterMainDexNatives() +// - Registers all methods that are used outside the browser process +// 2) RegisterNonMainDexNatives() +// - Registers all methods used in the browser process // class CPPClass { public: CPPClass(); ~CPPClass(); - // Register C++ methods exposed to Java using JNI. - static bool RegisterJNI(JNIEnv* env); - // Java @CalledByNative methods implicitly available to C++ via the _jni.h // file included in the .cc file.
diff --git a/base/debug/stack_trace_fuchsia.cc b/base/debug/stack_trace_fuchsia.cc index 8a4b1fec..42810fc 100644 --- a/base/debug/stack_trace_fuchsia.cc +++ b/base/debug/stack_trace_fuchsia.cc
@@ -4,14 +4,20 @@ #include "base/debug/stack_trace.h" +#include <link.h> +#include <magenta/crashlogger.h> #include <magenta/process.h> #include <magenta/syscalls.h> +#include <magenta/syscalls/definitions.h> #include <magenta/syscalls/port.h> #include <magenta/types.h> +#include <stddef.h> +#include <string.h> #include <threads.h> #include <unwind.h> #include <algorithm> +#include <iomanip> #include <iostream> #include "base/logging.h" @@ -21,6 +27,9 @@ namespace { +const char kProcessNamePrefix[] = "app:"; +const size_t kProcessNamePrefixLen = arraysize(kProcessNamePrefix) - 1; + struct BacktraceData { void** trace_array; size_t* count; @@ -38,6 +47,110 @@ return _URC_NO_REASON; } +// Stores and queries debugging symbol map info for the current process. +class SymbolMap { + public: + struct Entry { + void* addr; + char name[MX_MAX_NAME_LEN + 1]; + }; + + SymbolMap(); + ~SymbolMap() = default; + + // Gets the symbol map entry for |address|. Returns null if no entry could be + // found for the address, or if the symbol map could not be queried. + Entry* GetForAddress(void* address); + + private: + static const size_t kMaxMapEntries = 64; + + void Populate(); + + // Sorted in descending order by address, for lookup purposes. + Entry entries_[kMaxMapEntries]; + + size_t count_ = 0; + bool valid_ = false; + + DISALLOW_COPY_AND_ASSIGN(SymbolMap); +}; + +SymbolMap::SymbolMap() { + Populate(); +} + +SymbolMap::Entry* SymbolMap::GetForAddress(void* address) { + if (!valid_) { + return nullptr; + } + + // Working backwards in the address space, return the first map entry whose + // address comes before |address| (thereby enclosing it.) + for (size_t i = 0; i < count_; ++i) { + if (address >= entries_[i].addr) { + return &entries_[i]; + } + } + return nullptr; +} + +void SymbolMap::Populate() { + mx_handle_t process = mx_process_self(); + + // Get the process' name. + char app_name[MX_MAX_NAME_LEN + kProcessNamePrefixLen]; + strcpy(app_name, kProcessNamePrefix); + auto status = mx_object_get_property( + process, MX_PROP_NAME, app_name + kProcessNamePrefixLen, + sizeof(app_name) - kProcessNamePrefixLen); + if (status != MX_OK) { + DPLOG(WARNING) + << "Couldn't get name, falling back to 'app' for program name: " + << status; + strlcpy(app_name, "app", sizeof(app_name)); + } + + // Retrieve the debug info struct. + constexpr size_t map_capacity = sizeof(entries_); + uintptr_t debug_addr; + status = mx_object_get_property(process, MX_PROP_PROCESS_DEBUG_ADDR, + &debug_addr, sizeof(debug_addr)); + if (status != MX_OK) { + DPLOG(ERROR) << "Couldn't get symbol map for process: " << status; + return; + } + r_debug* debug_info = reinterpret_cast<r_debug*>(debug_addr); + + // Get the link map from the debug info struct. + link_map* lmap = reinterpret_cast<link_map*>(debug_info->r_map); + if (!lmap) { + DPLOG(ERROR) << "Null link_map for process."; + return; + } + + // Copy the contents of the link map linked list to |entries_|. + while (lmap != nullptr) { + if (count_ == map_capacity) { + break; + } + SymbolMap::Entry* next_entry = &entries_[count_]; + count_++; + + next_entry->addr = reinterpret_cast<void*>(lmap->l_addr); + char* name_to_use = lmap->l_name[0] ? lmap->l_name : app_name; + size_t name_len = strnlen(name_to_use, MX_MAX_NAME_LEN); + strncpy(next_entry->name, name_to_use, name_len + 1); + lmap = lmap->l_next; + } + + std::sort( + &entries_[0], &entries_[count_ - 1], + [](const Entry& a, const Entry& b) -> bool { return a.addr >= b.addr; }); + + valid_ = true; +} + } // namespace // static @@ -60,12 +173,36 @@ OutputToStream(&std::cerr); } +// Sample stack trace output: +// #00 0x1527a058aa00 app:/system/base_unittests+0x18bda00 +// #01 0x1527a0254b5c app:/system/base_unittests+0x1587b5c +// #02 0x15279f446ece app:/system/base_unittests+0x779ece +// ... +// #21 0x1527a05b51b4 app:/system/base_unittests+0x18e81b4 +// #22 0x54fdbf3593de libc.so+0x1c3de +// #23 end void StackTrace::OutputToStream(std::ostream* os) const { - // TODO(fuchsia): Consider doing symbol resolution here. See - // https://crbug.com/706592. - for (size_t i = 0; (i < count_) && os->good(); ++i) { - (*os) << "\t" << trace_[i] << "\n"; + SymbolMap map; + + size_t i = 0; + for (; (i < count_) && os->good(); ++i) { + auto entry = map.GetForAddress(trace_[i]); + if (entry) { + size_t offset = reinterpret_cast<uintptr_t>(trace_[i]) - + reinterpret_cast<uintptr_t>(entry->addr); + *os << "#" << std::setw(2) << std::setfill('0') << i << std::setw(0) + << " " << trace_[i] << " " << entry->name << "+0x" << std::hex + << offset << std::dec << std::setw(0) << "\n"; + } else { + // Fallback if the DSO map isn't available. + // Logged PC values are absolute memory addresses, and the shared object + // name is not emitted. + *os << "#" << std::setw(2) << std::setfill('0') << i << std::setw(0) + << trace_[i] << "\n"; + } } + + (*os) << "#" << std::setw(2) << i << " end\n"; } } // namespace debug
diff --git a/base/metrics/bucket_ranges.h b/base/metrics/bucket_ranges.h index 578119f..1b6d069b 100644 --- a/base/metrics/bucket_ranges.h +++ b/base/metrics/bucket_ranges.h
@@ -68,10 +68,10 @@ // safety against overwriting an existing value since though it is wasteful // to have multiple identical persistent records, it is still safe. void set_persistent_reference(uint32_t ref) const { - subtle::NoBarrier_Store(&persistent_reference_, ref); + subtle::Release_Store(&persistent_reference_, ref); } uint32_t persistent_reference() const { - return subtle::NoBarrier_Load(&persistent_reference_); + return subtle::Acquire_Load(&persistent_reference_); } private:
diff --git a/base/metrics/persistent_histogram_allocator.cc b/base/metrics/persistent_histogram_allocator.cc index cd26327..31fead6 100644 --- a/base/metrics/persistent_histogram_allocator.cc +++ b/base/metrics/persistent_histogram_allocator.cc
@@ -21,6 +21,7 @@ #include "base/metrics/persistent_sample_map.h" #include "base/metrics/sparse_histogram.h" #include "base/metrics/statistics_recorder.h" +#include "base/numerics/safe_conversions.h" #include "base/pickle.h" #include "base/strings/stringprintf.h" #include "base/synchronization/lock.h" @@ -478,8 +479,16 @@ return; } + // TODO(bcwhite): Remove this when crbug/744734 is fixed. + histogram->ValidateHistogramContents(true, -1); + existing->ValidateHistogramContents(true, -2); + // Merge the delta from the passed object to the one in the SR. existing->AddSamples(*histogram->SnapshotDelta()); + + // TODO(bcwhite): Remove this when crbug/744734 is fixed. + histogram->ValidateHistogramContents(true, -3); + existing->ValidateHistogramContents(true, -4); } void PersistentHistogramAllocator::MergeHistogramFinalDeltaToStatisticsRecorder( @@ -771,6 +780,7 @@ std::unique_ptr<MemoryMappedFile> mmfile(new MemoryMappedFile()); if (exists) { + size = saturated_cast<size_t>(file.GetLength()); mmfile->Initialize(std::move(file), MemoryMappedFile::READ_WRITE); } else { mmfile->Initialize(std::move(file), {0, static_cast<int64_t>(size)},
diff --git a/base/metrics/sample_vector.cc b/base/metrics/sample_vector.cc index d4cca56..f05d286 100644 --- a/base/metrics/sample_vector.cc +++ b/base/metrics/sample_vector.cc
@@ -362,7 +362,7 @@ counts_size_(counts->size()), bucket_ranges_(bucket_ranges), index_(0) { - CHECK_GE(bucket_ranges_->bucket_count(), counts_size_); + DCHECK_GE(bucket_ranges_->bucket_count(), counts_size_); SkipEmptyBuckets(); } @@ -374,7 +374,7 @@ counts_size_(counts_size), bucket_ranges_(bucket_ranges), index_(0) { - CHECK_GE(bucket_ranges_->bucket_count(), counts_size_); + DCHECK_GE(bucket_ranges_->bucket_count(), counts_size_); SkipEmptyBuckets(); }
diff --git a/base/process/launch.h b/base/process/launch.h index fe29362..60ed4ff 100644 --- a/base/process/launch.h +++ b/base/process/launch.h
@@ -40,9 +40,8 @@ #elif defined(OS_FUCHSIA) typedef std::vector<mx_handle_t> HandlesToInheritVector; #endif + #if defined(OS_POSIX) -// TODO(fuchsia): Turn this if into an elif, after the OS_FUCHSIA check, once -// callers have been cleaned-up not to rely on it (crbug.com/748350). typedef std::vector<std::pair<int, int>> FileHandleMappingVector; #endif
diff --git a/base/process/process.h b/base/process/process.h index 9902fafd..940ab5a0 100644 --- a/base/process/process.h +++ b/base/process/process.h
@@ -36,7 +36,7 @@ // and can be used to gather some information about that process, but most // methods will obviously fail. // -// POSIX: The underlying PorcessHandle is not guaranteed to remain valid after +// POSIX: The underlying ProcessHandle is not guaranteed to remain valid after // the process dies, and it may be reused by the system, which means that it may // end up pointing to the wrong process. class BASE_EXPORT Process {
diff --git a/build/config/mac/mac_sdk_overrides.gni b/build/config/mac/mac_sdk_overrides.gni index 2c89492..3632678 100644 --- a/build/config/mac/mac_sdk_overrides.gni +++ b/build/config/mac/mac_sdk_overrides.gni
@@ -9,7 +9,7 @@ declare_args() { # Minimum supported version of the Mac SDK. if (_sdk_min_from_env == "") { - mac_sdk_min = "10.10" + mac_sdk_min = "10.12" } else { mac_sdk_min = _sdk_min_from_env } @@ -18,5 +18,5 @@ # Always assert that mac_sdk_min is used on non-macOS platforms to prevent # unused args warnings. if (!is_mac) { - assert(mac_sdk_min == "10.10" || true) + assert(mac_sdk_min == "10.12" || true) }
diff --git a/build/fuchsia/test_runner.py b/build/fuchsia/test_runner.py index a41566f..cc47f5dc9 100755 --- a/build/fuchsia/test_runner.py +++ b/build/fuchsia/test_runner.py
@@ -28,7 +28,11 @@ if dry_run: print 'Run:', args else: - subprocess.check_call(args) + try: + subprocess.check_call(args) + return 0 + except subprocess.CalledProcessError as e: + return e.returncode def DumpFile(dry_run, name, description): @@ -179,7 +183,7 @@ # that to align it properly after the frame index. addr2line_filtered = addr2line_output.strip().replace( '(inlined', ' ' * len(prefix) + '(inlined') - return '#%s: %s' % (prefix, addr2line_filtered) + return '%s%s' % (prefix, addr2line_filtered) def ParallelSymbolizeBacktrace(backtrace): @@ -283,78 +287,90 @@ # currently. See https://crbug.com/749242. bootserver_path = os.path.join(SDK_ROOT, 'tools', 'bootserver') bootserver_command = [bootserver_path, '-1', kernel_path, bootfs] - RunAndCheck(args.dry_run, bootserver_command) + return RunAndCheck(args.dry_run, bootserver_command) + + qemu_path = os.path.join(SDK_ROOT, 'qemu', 'bin', 'qemu-system-x86_64') + qemu_command = [qemu_path, + '-m', '2048', + '-nographic', + '-net', 'none', + '-smp', '4', + '-machine', 'q35', + '-kernel', kernel_path, + '-initrd', bootfs, + + # Use stdio for the guest OS only; don't attach the QEMU interactive + # monitor. + '-serial', 'stdio', + '-monitor', 'none', + + # TERM=dumb tells the guest OS to not emit ANSI commands that trigger + # noisy ANSI spew from the user's terminal emulator. + '-append', 'TERM=dumb kernel.halt_on_panic=true'] + + if int(os.environ.get('CHROME_HEADLESS', 0)) == 0: + qemu_command += ['-enable-kvm', '-cpu', 'host,migratable=no'] else: - qemu_path = os.path.join(SDK_ROOT, 'qemu', 'bin', 'qemu-system-x86_64') + qemu_command += ['-cpu', 'Haswell,+smap,-check'] - qemu_command = [qemu_path, - '-m', '2048', - '-nographic', - '-net', 'none', - '-smp', '4', - '-machine', 'q35', - '-kernel', kernel_path, - '-initrd', bootfs, + if args.dry_run: + print 'Run:', qemu_command + return 0 - # Use stdio for the guest OS only; don't attach the QEMU interactive - # monitor. - '-serial', 'stdio', - '-monitor', 'none', + # Set up backtrace-parsing regexps. + prefix = r'^.*> ' + bt_end_re = re.compile(prefix + '(bt)?#(\d+):? end') + bt_with_offset_re = re.compile( + prefix + 'bt#(\d+): pc 0x[0-9a-f]+ sp (0x[0-9a-f]+) ' + + '\((\S+),(0x[0-9a-f]+)\)$') + in_process_re = re.compile(prefix + + '#(\d+) 0x[0-9a-f]+ \S+\+(0x[0-9a-f]+)$') - # TERM=dumb tells the guest OS to not emit ANSI commands that trigger - # noisy ANSI spew from the user's terminal emulator. - '-append', 'TERM=dumb kernel.halt_on_panic=true'] - if int(os.environ.get('CHROME_HEADLESS', 0)) == 0: - qemu_command += ['-enable-kvm', '-cpu', 'host,migratable=no'] - else: - qemu_command += ['-cpu', 'Haswell,+smap,-check'] + # We pass a separate stdin stream to qemu. Sharing stdin across processes + # leads to flakiness due to the OS prematurely killing the stream and the + # Python script panicking and aborting. + # The precise root cause is still nebulous, but this fix works. + # See crbug.com/741194 . + qemu_popen = subprocess.Popen( + qemu_command, stdout=subprocess.PIPE, stdin=open(os.devnull)) - if args.dry_run: - print 'Run:', qemu_command - else: - prefix = r'^.*> ' - bt_with_offset_re = re.compile(prefix + - 'bt#(\d+): pc 0x[0-9a-f]+ sp (0x[0-9a-f]+) \((\S+),(0x[0-9a-f]+)\)$') - bt_end_re = re.compile(prefix + 'bt#(\d+): end') + # A buffer of backtrace entries awaiting symbolization, stored as tuples. + # Element #0: backtrace frame number (starting at 0). + # Element #1: path to executable code corresponding to the current frame. + # Element #2: memory offset within the executable. + bt_entries = [] - # We pass a separate stdin stream to qemu. Sharing stdin across processes - # leads to flakiness due to the OS prematurely killing the stream and the - # Python script panicking and aborting. - # The precise root cause is still nebulous, but this fix works. - # See crbug.com/741194 . - qemu_popen = subprocess.Popen( - qemu_command, stdout=subprocess.PIPE, stdin=open(os.devnull)) - - # A buffer of backtrace entries awaiting symbolization, stored as tuples. - # Element #0: backtrace frame number (starting at 0). - # Element #1: path to executable code corresponding to the current frame. - # Element #2: memory offset within the executable. + success = False + while True: + line = qemu_popen.stdout.readline().strip() + if not line: + break + print line + if 'SUCCESS: all tests passed.' in line: + success = True + if bt_end_re.match(line): + if bt_entries: + print '----- start symbolized stack' + for processed in ParallelSymbolizeBacktrace(bt_entries): + print processed + print '----- end symbolized stack' bt_entries = [] + else: + # Try to parse this as a Fuchsia system backtrace. + m = bt_with_offset_re.match(line) + if m: + bt_entries.append((m.group(1), args.test_name, m.group(4))) + continue - success = False - while True: - line = qemu_popen.stdout.readline() - if not line: - break - print line, - if 'SUCCESS: all tests passed.' in line: - success = True - if bt_end_re.match(line.strip()): - if bt_entries: - print '----- start symbolized stack' - for processed in ParallelSymbolizeBacktrace(bt_entries): - print processed - print '----- end symbolized stack' - bt_entries = [] - else: - m = bt_with_offset_re.match(line.strip()) - if m: - bt_entries.append((m.group(1), args.test_name, m.group(4))) - qemu_popen.wait() + # Try to parse the line as an in-process backtrace entry. + m = in_process_re.match(line) + if m: + bt_entries.append((m.group(1), args.test_name, m.group(2))) + continue - return 0 if success else 1 + qemu_popen.wait() - return 0 + return 0 if success else 1 if __name__ == '__main__':
diff --git a/build/linux/sysroot_scripts/debian-archive-stretch-stable.gpg b/build/linux/sysroot_scripts/debian-archive-stretch-stable.gpg new file mode 100644 index 0000000..9b2feb2 --- /dev/null +++ b/build/linux/sysroot_scripts/debian-archive-stretch-stable.gpg Binary files differ
diff --git a/build/linux/sysroot_scripts/sysroot-creator-stretch.sh b/build/linux/sysroot_scripts/sysroot-creator-stretch.sh new file mode 100755 index 0000000..ae20271 --- /dev/null +++ b/build/linux/sysroot_scripts/sysroot-creator-stretch.sh
@@ -0,0 +1,283 @@ +#!/bin/bash +# 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. + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +DISTRO=debian +DIST=stretch + +APT_SOURCES_LIST="\ +http://ftp.us.debian.org/debian/ stretch main +http://security.debian.org/ stretch/updates main +http://ftp.us.debian.org/debian/ stretch-updates main" + +# gpg keyring file generated using: +# export KEYS="518E17E1 46925553 2B90D010 C857C906 F66AEC98 8AE22BA9 1A7B6500" +# gpg --recv-keys $KEYS +# gpg --output ./debian-archive-stretch-stable.gpg --export $KEYS +KEYRING_FILE="${SCRIPT_DIR}/debian-archive-stretch-stable.gpg" + +HAS_ARCH_AMD64=1 +HAS_ARCH_I386=1 +HAS_ARCH_ARM=1 +HAS_ARCH_ARM64=1 +HAS_ARCH_MIPS=1 + +# Sysroot packages: these are the packages needed to build chrome. +# NOTE: When DEBIAN_PACKAGES is modified, the packagelist files must be updated +# by running this script in GeneratePackageList mode. +DEBIAN_PACKAGES="\ + comerr-dev + krb5-multidev + libasound2 + libasound2-dev + libatk-bridge2.0-0 + libatk-bridge2.0-dev + libatk1.0-0 + libatk1.0-dev + libatspi2.0-0 + libatspi2.0-dev + libattr1 + libavahi-client3 + libavahi-common3 + libbluetooth3 + libbluetooth-dev + libbrlapi0.6 + libbrlapi-dev + libc6 + libc6-dev + libcairo2 + libcairo2-dev + libcairo-gobject2 + libcairo-script-interpreter2 + libcap-dev + libcap2 + libcomerr2 + libcups2 + libcups2-dev + libcupsimage2 + libcupsimage2-dev + libdbus-1-3 + libdbus-1-dev + libdbus-glib-1-2 + libdrm2 + libdrm-dev + libdrm-amdgpu1 + libdrm-nouveau2 + libdrm-radeon1 + libegl1-mesa + libegl1-mesa-dev + libelf1 + libelf-dev + libepoxy0 + libepoxy-dev + libexpat1 + libexpat1-dev + libffi6 + libffi-dev + libfontconfig1 + libfontconfig1-dev + libfreetype6 + libfreetype6-dev + libgbm1 + libgbm-dev + libgcc-6-dev + libgcc1 + libgconf-2-4 + libgconf2-4 + libgconf2-dev + libgcrypt20 + libgcrypt20-dev + libgdk-pixbuf2.0-0 + libgdk-pixbuf2.0-dev + libgl1-mesa-dev + libgl1-mesa-glx + libglapi-mesa + libglib2.0-0 + libglib2.0-dev + libgnome-keyring0 + libgnome-keyring-dev + libgnutls-dane0 + libgnutls-openssl27 + libgnutlsxx28 + libgnutls28-dev + libgnutls30 + libgomp1 + libgpg-error0 + libgpg-error-dev + libgraphite2-3 + libgraphite2-dev + libgssapi-krb5-2 + libgssrpc4 + libgtk-3-0 + libgtk-3-dev + libgtk2.0-0 + libgtk2.0-dev + libharfbuzz0b + libharfbuzz-dev + libharfbuzz-gobject0 + libharfbuzz-icu0 + libatomic1 + libjsoncpp1 + libjsoncpp-dev + libk5crypto3 + libkadm5clnt-mit11 + libkadm5srv-mit11 + libkdb5-8 + libkeyutils1 + libkrb5-3 + libkrb5-dev + libkrb5support0 + libnspr4 + libnspr4-dev + libnss3 + libnss3-dev + libnss-db + liborbit2 + libp11-2 + libp11-kit0 + libpam0g + libpam0g-dev + libpango-1.0-0 + libpango1.0-dev + libpangoft2-1.0-0 + libpangocairo-1.0-0 + libpangox-1.0-0 + libpangoxft-1.0-0 + libpci3 + libpci-dev + libpcre3 + libpcre16-3 + libpcre32-3 + libpcre3-dev + libpcrecpp0v5 + libpixman-1-0 + libpixman-1-dev + libpng16-16 + libpng-dev + libpthread-stubs0-dev + libpulse0 + libpulse-dev + libpulse-mainloop-glib0 + libselinux1 + libspeechd2 + libspeechd-dev + libssl1.0.2 + libssl1.1 + libssl-dev + libstdc++6 + libstdc++-6-dev + libtasn1-6 + libudev-dev + libudev1 + libwayland-client0 + libwayland-cursor0 + libwayland-dev + libwayland-egl1-mesa + libwayland-server0 + libx11-6 + libx11-dev + libx11-xcb1 + libx11-xcb-dev + libxau6 + libaudit1 + libxau-dev + libxcb1 + libxcb1-dev + libxcb-dri2-0 + libxcb-dri3-0 + libxcb-glx0 + libxcb-present0 + libxcb-render0 + libxcb-render0-dev + libxcb-sync1 + libxcb-shm0 + libxcb-shm0-dev + libxcomposite1 + libxcomposite-dev + libxcursor1 + libxcursor-dev + libxdamage1 + libxdamage-dev + libxdmcp6 + libxdmcp-dev + libxext6 + libxext-dev + libxfixes3 + libxfixes-dev + libxi6 + libxi-dev + libxinerama1 + libxinerama-dev + libxkbcommon0 + libxkbcommon-dev + libxrandr2 + libxrandr-dev + libxrender1 + libxrender-dev + libxshmfence1 + libxss1 + libxss-dev + libxt6 + libxt-dev + libxtst6 + libxtst-dev + libxxf86vm1 + linux-libc-dev + mesa-common-dev + speech-dispatcher + wayland-protocols + x11proto-composite-dev + x11proto-core-dev + x11proto-damage-dev + x11proto-fixes-dev + x11proto-input-dev + x11proto-kb-dev + x11proto-randr-dev + x11proto-record-dev + x11proto-render-dev + x11proto-scrnsaver-dev + x11proto-xext-dev + x11proto-xinerama-dev + zlib1g + zlib1g-dev +" + +DEBIAN_PACKAGES_AMD64=" + liblsan0 + libtsan0 +" + +DEBIAN_PACKAGES_X86=" + libasan3 + libcilkrts5 + libdrm-intel1 + libitm1 + libmpx2 + libquadmath0 + libubsan0 +" + +DEBIAN_PACKAGES_ARM=" + libasan3 + libdrm-exynos1 + libdrm-freedreno1 + libdrm-omap1 + libdrm-tegra0 + libubsan0 +" + +DEBIAN_PACKAGES_ARM64=" + libasan3 + libdatrie1 + libdrm-freedreno1 + libdrm-tegra0 + libgmp10 + libitm1 + libthai0 + libubsan0 +" + +. "${SCRIPT_DIR}/sysroot-creator.sh"
diff --git a/build/linux/sysroot_scripts/sysroot-creator.sh b/build/linux/sysroot_scripts/sysroot-creator.sh index 59ddaa2f..2eef3ce4 100644 --- a/build/linux/sysroot_scripts/sysroot-creator.sh +++ b/build/linux/sysroot_scripts/sysroot-creator.sh
@@ -427,25 +427,9 @@ # skip links with non-absolute paths echo "${target}" | grep -qs ^/ || continue echo "${link}: ${target}" - case "${link}" in - usr/lib/gcc/*-linux-gnu/4.*/* | usr/lib/gcc/arm-linux-gnueabihf/4.*/* | \ - usr/lib/gcc/aarch64-linux-gnu/4.*/*) - # Relativize the symlink. - ln -snfv "../../../../..${target}" "${link}" - ;; - usr/lib/*-linux-gnu/* | usr/lib/arm-linux-gnueabihf/*) - # Relativize the symlink. - ln -snfv "../../..${target}" "${link}" - ;; - usr/lib/*) - # Relativize the symlink. - ln -snfv "../..${target}" "${link}" - ;; - lib64/* | lib/*) - # Relativize the symlink. - ln -snfv "..${target}" "${link}" - ;; - esac + # Relativize the symlink. + prefix=$(echo "${link}" | sed -e 's/[^/]//g' | sed -e 's|/|../|g') + ln -snfv "${prefix}${target}" "${link}" done find $libdirs -type l -printf '%p %l\n' | while read link target; do @@ -687,8 +671,8 @@ set +x echo "Verifying: ${output_file}" - local checksums=$(grep ${file_path} ${release_file} | cut -d " " -f 2) - local sha256sum=$(echo ${checksums} | cut -d " " -f 3) + local sha256sum=$(grep -E "${file_path}\$|:\$" "${release_file}" | \ + grep "SHA256:" -A 1 | xargs echo | awk '{print $2;}') if [ "${#sha256sum}" -ne "64" ]; then echo "Bad sha256sum from ${release_list}"
diff --git a/build/mac_toolchain.py b/build/mac_toolchain.py index 534f9d198..3852dba 100755 --- a/build/mac_toolchain.py +++ b/build/mac_toolchain.py
@@ -50,6 +50,13 @@ TOOLCHAIN_URL = 'gs://chrome-mac-sdk/' +# This logic is duplicated from build/mac/should_use_hermetic_xcode.py. It is a +# temporary hack while waiting for a more comprehensive solution in +# https://crbug.com/742527. +def _IsCorpMachine(): + return os.path.isdir('/Library/GoogleCorpSupport/') + + def PlatformMeetsHermeticXcodeRequirements(target_os): if target_os == 'ios': return True @@ -248,7 +255,7 @@ print 'OS version does not support toolchain.' continue - if target_os == 'ios': + if target_os == 'ios' and not _IsCorpMachine(): default_version = IOS_TOOLCHAIN_VERSION toolchain_filename = 'ios-toolchain-%s.tgz' else:
diff --git a/cc/ipc/cc_param_traits_unittest.cc b/cc/ipc/cc_param_traits_unittest.cc index aea26c17..7fe09380 100644 --- a/cc/ipc/cc_param_traits_unittest.cc +++ b/cc/ipc/cc_param_traits_unittest.cc
@@ -336,8 +336,7 @@ arbitrary_rect1_inside_rect3, arbitrary_rect2_inside_rect3, arbitrary_bool1, arbitrary_color, arbitrary_int); - pass_cmp->CopyFromAndAppendDrawQuad(debugborder_in, - debugborder_in->shared_quad_state); + pass_cmp->CopyFromAndAppendDrawQuad(debugborder_in); SharedQuadState* shared_state2_in = pass_in->CreateAndAppendSharedQuadState(); shared_state2_in->SetAll(arbitrary_matrix2, arbitrary_rect2, arbitrary_rect2, @@ -354,9 +353,8 @@ arbitrary_rect1_inside_rect1, arbitrary_bool1, child_id, arbitrary_resourceid2, arbitrary_rectf1, arbitrary_size1, arbitrary_vector2df2, arbitrary_pointf2, arbitrary_rectf1); - pass_cmp->CopyFromAndAppendRenderPassDrawQuad( - renderpass_in, renderpass_in->shared_quad_state, - renderpass_in->render_pass_id); + pass_cmp->CopyFromAndAppendRenderPassDrawQuad(renderpass_in, + renderpass_in->render_pass_id); SharedQuadState* shared_state3_in = pass_in->CreateAndAppendSharedQuadState(); shared_state3_in->SetAll(arbitrary_matrix1, arbitrary_rect3, arbitrary_rect3, @@ -372,8 +370,7 @@ arbitrary_rect1_inside_rect3, arbitrary_rect2_inside_rect3, arbitrary_bool1, arbitrary_color, arbitrary_bool2); - pass_cmp->CopyFromAndAppendDrawQuad(solidcolor_in, - solidcolor_in->shared_quad_state); + pass_cmp->CopyFromAndAppendDrawQuad(solidcolor_in); StreamVideoDrawQuad* streamvideo_in = pass_in->CreateAndAppendDrawQuad<StreamVideoDrawQuad>(); @@ -381,8 +378,7 @@ shared_state3_in, arbitrary_rect2, arbitrary_rect2_inside_rect2, arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid2, arbitrary_size1, arbitrary_matrix1); - pass_cmp->CopyFromAndAppendDrawQuad(streamvideo_in, - streamvideo_in->shared_quad_state); + pass_cmp->CopyFromAndAppendDrawQuad(streamvideo_in); viz::SurfaceId arbitrary_surface_id( kArbitraryFrameSinkId, @@ -393,8 +389,7 @@ arbitrary_rect2_inside_rect2, arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_surface_id, cc::SurfaceDrawQuadType::PRIMARY, nullptr); - pass_cmp->CopyFromAndAppendDrawQuad(surface_in, - surface_in->shared_quad_state); + pass_cmp->CopyFromAndAppendDrawQuad(surface_in); TextureDrawQuad* texture_in = pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>(); @@ -404,15 +399,14 @@ arbitrary_bool2, arbitrary_pointf1, arbitrary_pointf2, arbitrary_color, arbitrary_float_array, arbitrary_bool4, arbitrary_bool5, arbitrary_bool6); - pass_cmp->CopyFromAndAppendDrawQuad(texture_in, - texture_in->shared_quad_state); + pass_cmp->CopyFromAndAppendDrawQuad(texture_in); TileDrawQuad* tile_in = pass_in->CreateAndAppendDrawQuad<TileDrawQuad>(); tile_in->SetAll(shared_state3_in, arbitrary_rect2, arbitrary_rect2_inside_rect2, arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid3, arbitrary_rectf1, arbitrary_size1, arbitrary_bool2, arbitrary_bool3); - pass_cmp->CopyFromAndAppendDrawQuad(tile_in, tile_in->shared_quad_state); + pass_cmp->CopyFromAndAppendDrawQuad(tile_in); YUVVideoDrawQuad* yuvvideo_in = pass_in->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); @@ -423,8 +417,7 @@ arbitrary_resourceid2, arbitrary_resourceid3, arbitrary_resourceid4, arbitrary_video_color_space, arbitrary_color_space, arbitrary_float1, arbitrary_float2, arbitrary_int, arbitrary_bool2); - pass_cmp->CopyFromAndAppendDrawQuad(yuvvideo_in, - yuvvideo_in->shared_quad_state); + pass_cmp->CopyFromAndAppendDrawQuad(yuvvideo_in); // Make sure the in and cmp RenderPasses match. Compare(child_pass_cmp.get(), child_pass_in.get());
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index b82f7ec0..4aa7b2b 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc
@@ -224,10 +224,13 @@ float max_contents_scale = MaximumTilingContentsScale(); PopulateScaledSharedQuadState(shared_quad_state, max_contents_scale, max_contents_scale); - Occlusion scaled_occlusion = - draw_properties() - .occlusion_in_content_space.GetOcclusionWithGivenDrawTransform( - shared_quad_state->quad_to_target_transform); + Occlusion scaled_occlusion; + if (mask_type_ == Layer::LayerMaskType::NOT_MASK) { + scaled_occlusion = + draw_properties() + .occlusion_in_content_space.GetOcclusionWithGivenDrawTransform( + shared_quad_state->quad_to_target_transform); + } if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { AppendDebugBorderQuad(
diff --git a/cc/layers/render_surface_unittest.cc b/cc/layers/render_surface_unittest.cc index 3d38e638..6199481 100644 --- a/cc/layers/render_surface_unittest.cc +++ b/cc/layers/render_surface_unittest.cc
@@ -305,5 +305,78 @@ render_pass->quad_list.front()->rect.ToString()); } +TEST(RenderSurfaceTest, SanityCheckSurfaceIgnoreMaskLayerOcclusion) { + FakeImplTaskRunnerProvider task_runner_provider; + TestTaskGraphRunner task_graph_runner; + std::unique_ptr<LayerTreeFrameSink> layer_tree_frame_sink = + FakeLayerTreeFrameSink::Create3d(); + FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); + + std::unique_ptr<LayerImpl> root_layer = + LayerImpl::Create(host_impl.active_tree(), 1); + + int owning_layer_id = 2; + std::unique_ptr<LayerImpl> owning_layer = + LayerImpl::Create(host_impl.active_tree(), owning_layer_id); + + int mask_layer_id = 3; + std::unique_ptr<FakePictureLayerImplForRenderSurfaceTest> mask_layer = + FakePictureLayerImplForRenderSurfaceTest::CreateMask( + host_impl.active_tree(), mask_layer_id); + mask_layer->SetBounds(gfx::Size(200, 100)); + mask_layer->SetDrawsContent(true); + std::vector<gfx::Rect> quad_rects; + quad_rects.push_back(gfx::Rect(0, 0, 100, 100)); + quad_rects.push_back(gfx::Rect(100, 0, 100, 100)); + mask_layer->SetQuadRectsForTesting(quad_rects); + + owning_layer->SetBounds(gfx::Size(200, 100)); + owning_layer->SetDrawsContent(true); + owning_layer->test_properties()->SetMaskLayer(std::move(mask_layer)); + root_layer->test_properties()->AddChild(std::move(owning_layer)); + host_impl.active_tree()->SetRootLayerForTesting(std::move(root_layer)); + host_impl.SetVisible(true); + host_impl.InitializeRenderer(layer_tree_frame_sink.get()); + host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); + host_impl.active_tree()->UpdateDrawProperties(); + + ASSERT_TRUE( + GetRenderSurface(host_impl.active_tree()->LayerById(owning_layer_id))); + RenderSurfaceImpl* render_surface = + GetRenderSurface(host_impl.active_tree()->LayerById(owning_layer_id)); + + gfx::Rect content_rect(0, 0, 200, 100); + gfx::Rect occluded(0, 0, 200, 100); + + render_surface->SetContentRectForTesting(content_rect); + host_impl.active_tree() + ->LayerById(mask_layer_id) + ->draw_properties() + .occlusion_in_content_space = + Occlusion(gfx::Transform(), SimpleEnclosedRegion(occluded), + SimpleEnclosedRegion(occluded)); + + std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); + AppendQuadsData append_quads_data; + + render_surface->AppendQuads(DRAW_MODE_HARDWARE, render_pass.get(), + &append_quads_data); + + ASSERT_EQ(1u, render_pass->shared_quad_state_list.size()); + SharedQuadState* shared_quad_state = + render_pass->shared_quad_state_list.front(); + + EXPECT_EQ(content_rect, + gfx::Rect(shared_quad_state->visible_quad_layer_rect)); + + // Neither of the two quads should be occluded since mask occlusion is + // ignored. + ASSERT_EQ(2u, render_pass->quad_list.size()); + EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), + render_pass->quad_list.front()->rect.ToString()); + EXPECT_EQ(gfx::Rect(100, 0, 100, 100).ToString(), + render_pass->quad_list.back()->rect.ToString()); +} + } // namespace } // namespace cc
diff --git a/cc/quads/draw_quad_unittest.cc b/cc/quads/draw_quad_unittest.cc index 22f787d..2d7c10bd5 100644 --- a/cc/quads/draw_quad_unittest.cc +++ b/cc/quads/draw_quad_unittest.cc
@@ -73,15 +73,27 @@ return state; } -void CompareDrawQuad(DrawQuad* quad, - DrawQuad* copy, - SharedQuadState* copy_shared_state) { +void CompareSharedQuadState(const SharedQuadState* source_sqs, + const SharedQuadState* copy_sqs) { + EXPECT_EQ(source_sqs->quad_to_target_transform, + copy_sqs->quad_to_target_transform); + EXPECT_EQ(source_sqs->quad_layer_rect, copy_sqs->quad_layer_rect); + EXPECT_EQ(source_sqs->visible_quad_layer_rect, + copy_sqs->visible_quad_layer_rect); + EXPECT_EQ(source_sqs->clip_rect, copy_sqs->clip_rect); + EXPECT_EQ(source_sqs->is_clipped, copy_sqs->is_clipped); + EXPECT_EQ(source_sqs->opacity, copy_sqs->opacity); + EXPECT_EQ(source_sqs->blend_mode, copy_sqs->blend_mode); + EXPECT_EQ(source_sqs->sorting_context_id, copy_sqs->sorting_context_id); +} + +void CompareDrawQuad(DrawQuad* quad, DrawQuad* copy) { EXPECT_EQ(quad->material, copy->material); EXPECT_EQ(quad->rect, copy->rect); EXPECT_EQ(quad->visible_rect, copy->visible_rect); EXPECT_EQ(quad->opaque_rect, copy->opaque_rect); EXPECT_EQ(quad->needs_blending, copy->needs_blending); - EXPECT_EQ(copy_shared_state, copy->shared_quad_state); + CompareSharedQuadState(quad->shared_quad_state, copy->shared_quad_state); } #define CREATE_SHARED_STATE() \ @@ -99,30 +111,28 @@ bool needs_blending = true; \ ALLOW_UNUSED_LOCAL(needs_blending); -#define SETUP_AND_COPY_QUAD_NEW(Type, quad) \ - DrawQuad* copy_new = \ - render_pass->CopyFromAndAppendDrawQuad(quad_new, copy_shared_state); \ - CompareDrawQuad(quad_new, copy_new, copy_shared_state); \ - const Type* copy_quad = Type::MaterialCast(copy_new); \ - ALLOW_UNUSED_LOCAL(copy_quad); - -#define SETUP_AND_COPY_QUAD_ALL(Type, quad) \ - DrawQuad* copy_all = \ - render_pass->CopyFromAndAppendDrawQuad(quad_all, copy_shared_state); \ - CompareDrawQuad(quad_all, copy_all, copy_shared_state); \ - copy_quad = Type::MaterialCast(copy_all); - -#define SETUP_AND_COPY_QUAD_NEW_RP(Type, quad, a) \ - DrawQuad* copy_new = render_pass->CopyFromAndAppendRenderPassDrawQuad( \ - quad_new, copy_shared_state, a); \ - CompareDrawQuad(quad_new, copy_new, copy_shared_state); \ +#define SETUP_AND_COPY_QUAD_NEW(Type, quad) \ + DrawQuad* copy_new = render_pass->CopyFromAndAppendDrawQuad(quad_new); \ + CompareDrawQuad(quad_new, copy_new); \ const Type* copy_quad = Type::MaterialCast(copy_new); \ ALLOW_UNUSED_LOCAL(copy_quad); -#define SETUP_AND_COPY_QUAD_ALL_RP(Type, quad, a) \ - DrawQuad* copy_all = render_pass->CopyFromAndAppendRenderPassDrawQuad( \ - quad_all, copy_shared_state, a); \ - CompareDrawQuad(quad_all, copy_all, copy_shared_state); \ +#define SETUP_AND_COPY_QUAD_ALL(Type, quad) \ + DrawQuad* copy_all = render_pass->CopyFromAndAppendDrawQuad(quad_all); \ + CompareDrawQuad(quad_all, copy_all); \ + copy_quad = Type::MaterialCast(copy_all); + +#define SETUP_AND_COPY_QUAD_NEW_RP(Type, quad, a) \ + DrawQuad* copy_new = \ + render_pass->CopyFromAndAppendRenderPassDrawQuad(quad_new, a); \ + CompareDrawQuad(quad_new, copy_new); \ + const Type* copy_quad = Type::MaterialCast(copy_new); \ + ALLOW_UNUSED_LOCAL(copy_quad); + +#define SETUP_AND_COPY_QUAD_ALL_RP(Type, quad, a) \ + DrawQuad* copy_all = \ + render_pass->CopyFromAndAppendRenderPassDrawQuad(quad_all, a); \ + CompareDrawQuad(quad_all, copy_all); \ copy_quad = Type::MaterialCast(copy_all); #define CREATE_QUAD_ALL(Type, ...) \
diff --git a/cc/quads/render_pass.cc b/cc/quads/render_pass.cc index 96c9f93..9bee2680 100644 --- a/cc/quads/render_pass.cc +++ b/cc/quads/render_pass.cc
@@ -132,31 +132,32 @@ filters, background_filters, color_space, has_transparent_background, cache_render_pass, has_damage_from_contributing_content); - for (auto* shared_quad_state : shared_quad_state_list) { - SharedQuadState* copy_shared_quad_state = - copy_pass->CreateAndAppendSharedQuadState(); - *copy_shared_quad_state = *shared_quad_state; + + if (shared_quad_state_list.empty()) { + DCHECK(quad_list.empty()); + return copy_pass; } + SharedQuadStateList::ConstIterator sqs_iter = shared_quad_state_list.begin(); - SharedQuadStateList::Iterator copy_sqs_iter = - copy_pass->shared_quad_state_list.begin(); + SharedQuadState* copy_shared_quad_state = + copy_pass->CreateAndAppendSharedQuadState(); + *copy_shared_quad_state = **sqs_iter; for (auto* quad : quad_list) { while (quad->shared_quad_state != *sqs_iter) { ++sqs_iter; - ++copy_sqs_iter; DCHECK(sqs_iter != shared_quad_state_list.end()); + copy_shared_quad_state = copy_pass->CreateAndAppendSharedQuadState(); + *copy_shared_quad_state = **sqs_iter; } DCHECK(quad->shared_quad_state == *sqs_iter); - SharedQuadState* copy_shared_quad_state = *copy_sqs_iter; - if (quad->material == DrawQuad::RENDER_PASS) { const RenderPassDrawQuad* pass_quad = RenderPassDrawQuad::MaterialCast(quad); - copy_pass->CopyFromAndAppendRenderPassDrawQuad( - pass_quad, copy_shared_quad_state, pass_quad->render_pass_id); + copy_pass->CopyFromAndAppendRenderPassDrawQuad(pass_quad, + pass_quad->render_pass_id); } else { - copy_pass->CopyFromAndAppendDrawQuad(quad, copy_shared_quad_state); + copy_pass->CopyFromAndAppendDrawQuad(quad); } } return copy_pass; @@ -261,18 +262,17 @@ RenderPassDrawQuad* RenderPass::CopyFromAndAppendRenderPassDrawQuad( const RenderPassDrawQuad* quad, - const SharedQuadState* shared_quad_state, RenderPassId render_pass_id) { + DCHECK(!shared_quad_state_list.empty()); RenderPassDrawQuad* copy_quad = CopyFromAndAppendTypedDrawQuad<RenderPassDrawQuad>(quad); - copy_quad->shared_quad_state = shared_quad_state; + copy_quad->shared_quad_state = shared_quad_state_list.back(); copy_quad->render_pass_id = render_pass_id; return copy_quad; } -DrawQuad* RenderPass::CopyFromAndAppendDrawQuad( - const DrawQuad* quad, - const SharedQuadState* shared_quad_state) { +DrawQuad* RenderPass::CopyFromAndAppendDrawQuad(const DrawQuad* quad) { + DCHECK(!shared_quad_state_list.empty()); switch (quad->material) { case DrawQuad::DEBUG_BORDER: CopyFromAndAppendTypedDrawQuad<DebugBorderDrawQuad>(quad); @@ -304,7 +304,7 @@ LOG(FATAL) << "Invalid DrawQuad material " << quad->material; break; } - quad_list.back()->shared_quad_state = shared_quad_state; + quad_list.back()->shared_quad_state = shared_quad_state_list.back(); return quad_list.back(); }
diff --git a/cc/quads/render_pass.h b/cc/quads/render_pass.h index 1972a7d..44e9303 100644 --- a/cc/quads/render_pass.h +++ b/cc/quads/render_pass.h
@@ -109,10 +109,8 @@ RenderPassDrawQuad* CopyFromAndAppendRenderPassDrawQuad( const RenderPassDrawQuad* quad, - const SharedQuadState* shared_quad_state, RenderPassId render_pass_id); - DrawQuad* CopyFromAndAppendDrawQuad(const DrawQuad* quad, - const SharedQuadState* shared_quad_state); + DrawQuad* CopyFromAndAppendDrawQuad(const DrawQuad* quad); // Uniquely identifies the render pass in the compositor's current frame. RenderPassId id = 0;
diff --git a/cc/raster/raster_source.cc b/cc/raster/raster_source.cc index efb8404..3fc5d93 100644 --- a/cc/raster/raster_source.cc +++ b/cc/raster/raster_source.cc
@@ -12,6 +12,7 @@ #include "cc/debug/debug_colors.h" #include "cc/debug/traced_value.h" #include "cc/paint/display_item_list.h" +#include "cc/paint/skia_paint_canvas.h" #include "skia/ext/analysis_canvas.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkColorSpaceXformCanvas.h" @@ -35,6 +36,22 @@ other->slow_down_raster_scale_factor_for_debug_) {} RasterSource::~RasterSource() = default; +void RasterSource::SetupCanvasForRaster( + PaintCanvas* canvas, + const gfx::Rect& canvas_bitmap_rect, + const gfx::Rect& canvas_playback_rect, + const gfx::AxisTransform2d& raster_transform, + bool should_clear_canvas) const { + canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); + canvas->clipRect(gfx::RectToSkRect(canvas_playback_rect)); + canvas->translate(raster_transform.translation().x(), + raster_transform.translation().y()); + canvas->scale(raster_transform.scale(), raster_transform.scale()); + + if (should_clear_canvas) + ClearCanvasForPlayback(canvas); +} + void RasterSource::PlaybackToCanvas( SkCanvas* raster_canvas, const gfx::ColorSpace& target_color_space, @@ -50,11 +67,9 @@ ScopedSubnormalFloatDisabler disabler; raster_canvas->save(); - raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); - raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds)); - raster_canvas->translate(raster_transform.translation().x(), - raster_transform.translation().y()); - raster_canvas->scale(raster_transform.scale(), raster_transform.scale()); + SkiaPaintCanvas paint_canvas(raster_canvas); + SetupCanvasForRaster(&paint_canvas, canvas_bitmap_rect, canvas_playback_rect, + raster_transform, !settings.playback_to_shared_canvas); PlaybackToCanvas(raster_canvas, target_color_space, settings); raster_canvas->restore(); } @@ -62,6 +77,7 @@ void RasterSource::PlaybackToCanvas(SkCanvas* input_canvas, const gfx::ColorSpace& target_color_space, const PlaybackSettings& settings) const { + // TODO(enne): color transform needs to be replicated in gles2_cmd_decoder SkCanvas* raster_canvas = input_canvas; std::unique_ptr<SkCanvas> color_transform_canvas; if (target_color_space.IsValid()) { @@ -70,15 +86,10 @@ raster_canvas = color_transform_canvas.get(); } - if (!settings.playback_to_shared_canvas) - PrepareForPlaybackToCanvas(raster_canvas); - RasterCommon(raster_canvas, settings.image_provider); } -void RasterSource::PrepareForPlaybackToCanvas(SkCanvas* canvas) const { - // TODO(hendrikw): See if we can split this up into separate functions. - +void RasterSource::ClearCanvasForPlayback(PaintCanvas* canvas) const { // If this raster source has opaque contents, it is guaranteeing that it will // draw an opaque rect the size of the layer. If it is not, then we must // clear this canvas ourselves. @@ -126,10 +137,9 @@ // rerasterize a tile that used to intersect with the content rect // after the content bounds grew. canvas->save(); - // Use clipRegion to bypass CTM because the rects are device rects. - SkRegion interest_region; - interest_region.setRect(interest_rect); - canvas->clipRegion(interest_region, SkClipOp::kDifference); + // Use clipDeviceRect to bypass CTM because the rects are device rects. + canvas->clipDeviceRect(interest_rect, SkIRect::MakeEmpty(), + SkClipOp::kDifference); canvas->clear(DebugColors::MissingResizeInvalidations()); canvas->restore(); } @@ -137,11 +147,8 @@ // Drawing at most 2 x 2 x (canvas width + canvas height) texels is 2-3X // faster than clearing, so special case this. canvas->save(); - // Use clipRegion to bypass CTM because the rects are device rects. - SkRegion interest_region; - interest_region.setRect(interest_rect); - interest_region.op(opaque_rect, SkRegion::kDifference_Op); - canvas->clipRegion(interest_region); + // Use clipDeviceRect to bypass CTM because the rects are device rects. + canvas->clipDeviceRect(interest_rect, opaque_rect, SkClipOp::kIntersect); canvas->clear(background_color_); canvas->restore(); } @@ -161,7 +168,7 @@ SkPictureRecorder recorder; SkCanvas* canvas = recorder.beginRecording(size_.width(), size_.height()); if (!size_.IsEmpty()) { - PrepareForPlaybackToCanvas(canvas); + canvas->clear(SK_ColorTRANSPARENT); RasterCommon(canvas); }
diff --git a/cc/raster/raster_source.h b/cc/raster/raster_source.h index 41be6ad9..9cce907 100644 --- a/cc/raster/raster_source.h +++ b/cc/raster/raster_source.h
@@ -15,6 +15,7 @@ #include "cc/debug/rendering_stats_instrumentation.h" #include "cc/layers/recording_source.h" #include "cc/paint/image_id.h" +#include "cc/paint/paint_canvas.h" #include "skia/ext/analysis_canvas.h" #include "third_party/skia/include/core/SkPicture.h" #include "ui/gfx/color_space.h" @@ -47,6 +48,12 @@ ImageProvider* image_provider = nullptr; }; + void SetupCanvasForRaster(PaintCanvas* canvas, + const gfx::Rect& canvas_bitmap_rect, + const gfx::Rect& canvas_playback_rect, + const gfx::AxisTransform2d& raster_transform, + bool should_clear_canvas) const; + // Helper function to apply a few common operations before passing the canvas // to the shorter version. This is useful for rastering into tiles. // canvas is expected to be backed by a tile, with a default state. @@ -142,7 +149,7 @@ ImageProvider* image_provider = nullptr, SkPicture::AbortCallback* callback = nullptr) const; - void PrepareForPlaybackToCanvas(SkCanvas* canvas) const; + void ClearCanvasForPlayback(PaintCanvas* canvas) const; DISALLOW_COPY_AND_ASSIGN(RasterSource); };
diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp index c53ab5be..a6c10d4c 100644 --- a/chrome/app/settings_strings.grdp +++ b/chrome/app/settings_strings.grdp
@@ -555,6 +555,21 @@ <message name="IDS_SETTINGS_BLUETOOTH_TOGGLE_ACCESSIBILITY_LABEL" desc="Accessibility only label for Bluetooth enable/disable toggle."> Bluetooth enable </message> + <message name="IDS_SETTINGS_BLUETOOTH_ENTER_KEY" desc="Bluetooth pairing dialog: Text for enter key when pairing keyboard devices." > + enter + </message> + <message name="IDS_SETTINGS_BLUETOOTH_ACCEPT_PASSKEY" desc="Bluetooth pairing dialog: Text for button to accept pairing code."> + Accept + </message> + <message name="IDS_SETTINGS_BLUETOOTH_CONNECT" desc="Bluetooth pairing dialog: Text for dropdown meny item to connect to a device."> + Connect + </message> + <message name="IDS_SETTINGS_BLUETOOTH_DISCONNECT" desc="Bluetooth pairing dialog: dropdown meny item to disconnect from a device."> + Disconnect + </message> + <message name="IDS_SETTINGS_BLUETOOTH_REJECT_PASSKEY" desc="Bluetooth pairing dialog: Text for button to reject pairing a device."> + Reject + </message> <message name="IDS_SETTINGS_BLUETOOTH_EXPAND_ACCESSIBILITY_LABEL" desc="Label for the button that toggles showing available Bluetooth devices. Only visible by screen reader software."> Show available Bluetooth devices </message>
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 9128ae9..4e310e9 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn
@@ -2825,6 +2825,8 @@ "android/logo_bridge.h", "android/logo_service.cc", "android/logo_service.h", + "android/logo_service_factory.cc", + "android/logo_service_factory.h", "android/metrics/launch_metrics.cc", "android/metrics/uma_session_stats.cc", "android/metrics/uma_session_stats.h",
diff --git a/chrome/browser/android/logo_bridge.cc b/chrome/browser/android/logo_bridge.cc index 597fae2..45d72d5 100644 --- a/chrome/browser/android/logo_bridge.cc +++ b/chrome/browser/android/logo_bridge.cc
@@ -12,6 +12,7 @@ #include "base/android/jni_string.h" #include "base/metrics/histogram_macros.h" #include "chrome/browser/android/logo_service.h" +#include "chrome/browser/android/logo_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "components/search_provider_logos/logo_tracker.h"
diff --git a/chrome/browser/android/logo_service.cc b/chrome/browser/android/logo_service.cc index feb9ddc..668cf7a8 100644 --- a/chrome/browser/android/logo_service.cc +++ b/chrome/browser/android/logo_service.cc
@@ -8,7 +8,6 @@ #include "base/feature_list.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" -#include "chrome/browser/android/chrome_feature_list.h" #include "chrome/browser/image_decoder.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search_engines/template_url_service_factory.h" @@ -18,11 +17,10 @@ #include "components/search_engines/template_url_service.h" #include "components/search_provider_logos/fixed_logo_api.h" #include "components/search_provider_logos/google_logo_api.h" +#include "components/search_provider_logos/logo_tracker.h" #include "content/public/browser/browser_thread.h" #include "net/url_request/url_request_context_getter.h" -using content::BrowserThread; -using search_provider_logos::Logo; using search_provider_logos::LogoDelegate; using search_provider_logos::LogoTracker; @@ -88,13 +86,10 @@ } // namespace -// LogoService ---------------------------------------------------------------- +LogoService::LogoService(Profile* profile, bool use_gray_background) + : profile_(profile), use_gray_background_(use_gray_background) {} -LogoService::LogoService(Profile* profile) : profile_(profile) { -} - -LogoService::~LogoService() { -} +LogoService::~LogoService() = default; void LogoService::GetLogo(search_provider_logos::LogoObserver* observer) { TemplateURLService* template_url_service = @@ -137,44 +132,13 @@ GURL google_base_url = GURL(UIThreadSearchTermsData(profile_).GoogleBaseURLValue()); - bool use_gray_background = - !base::FeatureList::IsEnabled(chrome::android::kChromeHomeFeature); - logo_tracker_->SetServerAPI( search_provider_logos::GetGoogleDoodleURL(google_base_url), search_provider_logos::GetGoogleParseLogoResponseCallback( google_base_url), search_provider_logos::GetGoogleAppendQueryparamsCallback( - use_gray_background)); + use_gray_background_)); } logo_tracker_->GetLogo(observer); } - -// LogoServiceFactory --------------------------------------------------------- - -// static -LogoService* LogoServiceFactory::GetForProfile(Profile* profile) { - return static_cast<LogoService*>( - GetInstance()->GetServiceForBrowserContext(profile, true)); -} - -// static -LogoServiceFactory* LogoServiceFactory::GetInstance() { - return base::Singleton<LogoServiceFactory>::get(); -} - -LogoServiceFactory::LogoServiceFactory() - : BrowserContextKeyedServiceFactory( - "LogoService", - BrowserContextDependencyManager::GetInstance()) { -} - -LogoServiceFactory::~LogoServiceFactory() {} - -KeyedService* LogoServiceFactory::BuildServiceInstanceFor( - content::BrowserContext* context) const { - Profile* profile = static_cast<Profile*>(context); - DCHECK(!profile->IsOffTheRecord()); - return new LogoService(profile); -}
diff --git a/chrome/browser/android/logo_service.h b/chrome/browser/android/logo_service.h index ffb0459..96977725 100644 --- a/chrome/browser/android/logo_service.h +++ b/chrome/browser/android/logo_service.h
@@ -5,14 +5,18 @@ #ifndef CHROME_BROWSER_ANDROID_LOGO_SERVICE_H_ #define CHROME_BROWSER_ANDROID_LOGO_SERVICE_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/singleton.h" -#include "components/keyed_service/content/browser_context_keyed_service_factory.h" #include "components/keyed_service/core/keyed_service.h" -#include "components/search_provider_logos/logo_tracker.h" class Profile; +namespace search_provider_logos { +class LogoTracker; +class LogoObserver; +} // namespace search_provider_logos + // Provides the logo for a profile's default search provider. // // Example usage: @@ -21,7 +25,7 @@ // class LogoService : public KeyedService { public: - explicit LogoService(Profile* profile); + LogoService(Profile* profile, bool use_gray_background); ~LogoService() override; // Gets the logo for the default search provider and notifies |observer| @@ -30,27 +34,10 @@ private: Profile* profile_; + const bool use_gray_background_; std::unique_ptr<search_provider_logos::LogoTracker> logo_tracker_; DISALLOW_COPY_AND_ASSIGN(LogoService); }; -// Singleton that owns all LogoServices and associates them with Profiles. -class LogoServiceFactory : public BrowserContextKeyedServiceFactory { - public: - static LogoService* GetForProfile(Profile* profile); - - static LogoServiceFactory* GetInstance(); - - private: - friend struct base::DefaultSingletonTraits<LogoServiceFactory>; - - LogoServiceFactory(); - ~LogoServiceFactory() override; - - // BrowserContextKeyedServiceFactory: - KeyedService* BuildServiceInstanceFor( - content::BrowserContext* context) const override; -}; - #endif // CHROME_BROWSER_ANDROID_LOGO_SERVICE_H_
diff --git a/chrome/browser/android/logo_service_factory.cc b/chrome/browser/android/logo_service_factory.cc new file mode 100644 index 0000000..df1e900 --- /dev/null +++ b/chrome/browser/android/logo_service_factory.cc
@@ -0,0 +1,38 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/android/logo_service_factory.h" + +#include "base/feature_list.h" +#include "chrome/browser/android/chrome_feature_list.h" +#include "chrome/browser/android/logo_service.h" +#include "chrome/browser/profiles/profile.h" +#include "components/keyed_service/content/browser_context_dependency_manager.h" + +// static +LogoService* LogoServiceFactory::GetForProfile(Profile* profile) { + return static_cast<LogoService*>( + GetInstance()->GetServiceForBrowserContext(profile, true)); +} + +// static +LogoServiceFactory* LogoServiceFactory::GetInstance() { + return base::Singleton<LogoServiceFactory>::get(); +} + +LogoServiceFactory::LogoServiceFactory() + : BrowserContextKeyedServiceFactory( + "LogoService", + BrowserContextDependencyManager::GetInstance()) {} + +LogoServiceFactory::~LogoServiceFactory() = default; + +KeyedService* LogoServiceFactory::BuildServiceInstanceFor( + content::BrowserContext* context) const { + Profile* profile = static_cast<Profile*>(context); + DCHECK(!profile->IsOffTheRecord()); + bool use_gray_background = + !base::FeatureList::IsEnabled(chrome::android::kChromeHomeFeature); + return new LogoService(profile, use_gray_background); +}
diff --git a/chrome/browser/android/logo_service_factory.h b/chrome/browser/android/logo_service_factory.h new file mode 100644 index 0000000..f5b2f35 --- /dev/null +++ b/chrome/browser/android/logo_service_factory.h
@@ -0,0 +1,35 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_ANDROID_LOGO_SERVICE_FACTORY_H_ +#define CHROME_BROWSER_ANDROID_LOGO_SERVICE_FACTORY_H_ + +#include "base/macros.h" +#include "base/memory/singleton.h" +#include "components/keyed_service/content/browser_context_keyed_service_factory.h" + +class LogoService; +class Profile; + +// Singleton that owns all LogoServices and associates them with Profiles. +class LogoServiceFactory : public BrowserContextKeyedServiceFactory { + public: + static LogoService* GetForProfile(Profile* profile); + + static LogoServiceFactory* GetInstance(); + + private: + friend struct base::DefaultSingletonTraits<LogoServiceFactory>; + + LogoServiceFactory(); + ~LogoServiceFactory() override; + + // BrowserContextKeyedServiceFactory: + KeyedService* BuildServiceInstanceFor( + content::BrowserContext* context) const override; + + DISALLOW_COPY_AND_ASSIGN(LogoServiceFactory); +}; + +#endif // CHROME_BROWSER_ANDROID_LOGO_SERVICE_FACTORY_H_
diff --git a/chrome/browser/chromeos/extensions/echo_private_api.cc b/chrome/browser/chromeos/extensions/echo_private_api.cc index 3d9a902..6714e13 100644 --- a/chrome/browser/chromeos/extensions/echo_private_api.cc +++ b/chrome/browser/chromeos/extensions/echo_private_api.cc
@@ -12,6 +12,7 @@ #include "base/location.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/task_scheduler/post_task.h" #include "base/time/time.h" #include "base/values.h" #include "chrome/browser/browser_process.h" @@ -25,14 +26,12 @@ #include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_service.h" #include "components/prefs/scoped_user_pref_update.h" -#include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" +#include "extensions/browser/extension_file_task_runner.h" #include "extensions/common/extension.h" namespace echo_api = extensions::api::echo_private; -using content::BrowserThread; - namespace { // URL of "More info" link shown in echo dialog in GetUserConsent function. @@ -141,13 +140,12 @@ } bool EchoPrivateGetOobeTimestampFunction::RunAsync() { - BrowserThread::PostTaskAndReplyWithResult( - BrowserThread::FILE, FROM_HERE, + base::PostTaskAndReplyWithResult( + extensions::GetExtensionFileTaskRunner().get(), FROM_HERE, base::Bind( - &EchoPrivateGetOobeTimestampFunction::GetOobeTimestampOnFileThread, + &EchoPrivateGetOobeTimestampFunction::GetOobeTimestampOnFileSequence, this), - base::Bind( - &EchoPrivateGetOobeTimestampFunction::SendResponse, this)); + base::Bind(&EchoPrivateGetOobeTimestampFunction::SendResponse, this)); return true; } @@ -155,8 +153,9 @@ // The timestamp is used to determine when the user first activates the device. // If we can get the timestamp info, return it as yyyy-mm-dd, otherwise, return // an empty string. -bool EchoPrivateGetOobeTimestampFunction::GetOobeTimestampOnFileThread() { - DCHECK_CURRENTLY_ON(BrowserThread::FILE); +bool EchoPrivateGetOobeTimestampFunction::GetOobeTimestampOnFileSequence() { + DCHECK( + extensions::GetExtensionFileTaskRunner()->RunsTasksInCurrentSequence()); const char kOobeTimestampFile[] = "/home/chronos/.oobe_completed"; std::string timestamp = "";
diff --git a/chrome/browser/chromeos/extensions/echo_private_api.h b/chrome/browser/chromeos/extensions/echo_private_api.h index e281720c..6c76b776 100644 --- a/chrome/browser/chromeos/extensions/echo_private_api.h +++ b/chrome/browser/chromeos/extensions/echo_private_api.h
@@ -49,7 +49,7 @@ bool RunAsync() override; private: - bool GetOobeTimestampOnFileThread(); + bool GetOobeTimestampOnFileSequence(); DECLARE_EXTENSION_FUNCTION("echoPrivate.getOobeTimestamp", ECHOPRIVATE_GETOOBETIMESTAMP) };
diff --git a/chrome/browser/chromeos/login/users/default_user_image/default_user_images.cc b/chrome/browser/chromeos/login/users/default_user_image/default_user_images.cc index f19e387..c2c06cb 100644 --- a/chrome/browser/chromeos/login/users/default_user_image/default_user_images.cc +++ b/chrome/browser/chromeos/login/users/default_user_image/default_user_images.cc
@@ -234,16 +234,6 @@ const int kDefaultImageDescriptionsMaxID = arraysize(kDefaultImageDescriptions); -// Returns a string consisting of the prefix specified and the index of the -// image if its valid. -std::string GetDefaultImageString(int index, const std::string& prefix) { - if (index < 0 || index >= kDefaultImagesCount) { - DCHECK(!base::SysInfo::IsRunningOnChromeOS()); - return std::string(); - } - return base::StringPrintf("%s%d", prefix.c_str(), index); -} - // Returns true if the string specified consists of the prefix and one of // the default images indices. Returns the index of the image in |image_id| // variable. @@ -276,9 +266,9 @@ } // namespace std::string GetDefaultImageUrl(int index) { - if (index == 0) + if (index <= 0 || index >= kDefaultImagesCount) return kZeroDefaultUrl; - return GetDefaultImageString(index, kDefaultUrlPrefix); + return base::StringPrintf("%s%d", kDefaultUrlPrefix, index); } bool IsDefaultImageUrl(const std::string& url, int* image_id) {
diff --git a/chrome/browser/chromeos/login/users/default_user_image/default_user_images.h b/chrome/browser/chromeos/login/users/default_user_image/default_user_images.h index ad3d786..2d4e936 100644 --- a/chrome/browser/chromeos/login/users/default_user_image/default_user_images.h +++ b/chrome/browser/chromeos/login/users/default_user_image/default_user_images.h
@@ -24,7 +24,9 @@ namespace chromeos { namespace default_user_image { -// Returns URL to default user image with specified index. +// Returns the URL to a default user image with the specified index. If the +// index is invalid, returns the default user image for index 0 (anonymous +// avatar image). CHROMEOS_EXPORT std::string GetDefaultImageUrl(int index); // Checks if the given URL points to one of the default images. If it is,
diff --git a/chrome/browser/chromeos/policy/proto/chrome_device_policy.proto b/chrome/browser/chromeos/policy/proto/chrome_device_policy.proto index 79c14c4c..4ebc720 100644 --- a/chrome/browser/chromeos/policy/proto/chrome_device_policy.proto +++ b/chrome/browser/chromeos/policy/proto/chrome_device_policy.proto
@@ -813,6 +813,13 @@ optional U2fMode mode = 1; } +message CastReceiverNameProto { + // The name advertised as a Google Cast destination by the device, + // up to 24 characters. If the name is empty, the device name will + // be used. + optional string name = 1; +} + message ChromeDeviceSettingsProto { optional DevicePolicyRefreshRateProto device_policy_refresh_rate = 1; optional UserWhitelistProto user_whitelist = 2; @@ -875,4 +882,5 @@ device_ecryptfs_migration_strategy = 51; optional DeviceSecondFactorAuthenticationProto device_second_factor_authentication = 52; + optional CastReceiverNameProto cast_receiver_name = 53; }
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc index 8357707..3276d5b 100644 --- a/chrome/browser/chromeos/preferences.cc +++ b/chrome/browser/chromeos/preferences.cc
@@ -121,6 +121,9 @@ registry->RegisterIntegerPref( prefs::kSystemTimezoneAutomaticDetectionPolicy, enterprise_management::SystemTimezoneProto::USERS_DECIDE); + + registry->RegisterStringPref(prefs::kCastReceiverName, ""); + // Register ash prefs. if (!ash_util::IsRunningInMash()) ash::Shell::RegisterLocalStatePrefs(registry); @@ -377,6 +380,8 @@ registry->RegisterBooleanPref(prefs::kEolNotificationDismissed, false); registry->RegisterIntegerPref(prefs::kEolStatus, update_engine::EndOfLifeStatus::kSupported); + + registry->RegisterBooleanPref(prefs::kCastReceiverEnabled, true); } void Preferences::InitUserPrefs(sync_preferences::PrefServiceSyncable* prefs) {
diff --git a/chrome/browser/extensions/api/cast_streaming/cast_streaming_apitest.cc b/chrome/browser/extensions/api/cast_streaming/cast_streaming_apitest.cc index 22e2284..8c7a131d 100644 --- a/chrome/browser/extensions/api/cast_streaming/cast_streaming_apitest.cc +++ b/chrome/browser/extensions/api/cast_streaming/cast_streaming_apitest.cc
@@ -337,13 +337,10 @@ // use the API to send it out. At the same time, this test launches an // in-process Cast receiver, listening on a localhost UDP socket, to receive the // content and check whether it matches expectations. -// -// TODO(miu): Now that this test has been long-stable on Release build bots, it -// should be enabled for the Debug build bots. http://crbug.com/396413 #if defined(NDEBUG) #define MAYBE_EndToEnd EndToEnd #else -#define MAYBE_EndToEnd DISABLED_EndToEnd +#define MAYBE_EndToEnd DISABLED_EndToEnd // crbug.com/396413 #endif IN_PROC_BROWSER_TEST_F(CastStreamingApiTestWithPixelOutput, MAYBE_EndToEnd) { std::unique_ptr<net::UDPServerSocket> receive_socket(
diff --git a/chrome/browser/policy/configuration_policy_handler_list_factory.cc b/chrome/browser/policy/configuration_policy_handler_list_factory.cc index c04bb6a..f4f3fb2 100644 --- a/chrome/browser/policy/configuration_policy_handler_list_factory.cc +++ b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
@@ -676,6 +676,13 @@ { key::kPinUnlockWeakPinsAllowed, prefs::kPinUnlockWeakPinsAllowed, base::Value::Type::BOOLEAN }, + + { key::kCastReceiverEnabled, + prefs::kCastReceiverEnabled, + base::Value::Type::BOOLEAN }, + { key::kCastReceiverName, + prefs::kCastReceiverName, + base::Value::Type::STRING }, #endif { key::kRoamingProfileSupportEnabled,
diff --git a/chrome/browser/profiles/profile_shortcut_manager.h b/chrome/browser/profiles/profile_shortcut_manager.h index 7b971462..1459395 100644 --- a/chrome/browser/profiles/profile_shortcut_manager.h +++ b/chrome/browser/profiles/profile_shortcut_manager.h
@@ -47,6 +47,9 @@ base::string16* name, base::FilePath* icon_path) = 0; + // Any time a profile is created this class might do a lot of work in the + // background that's rarely important to unit tests. + static void DisableForUnitTests(); static bool IsFeatureEnabled(); static ProfileShortcutManager* Create(ProfileManager* manager);
diff --git a/chrome/browser/profiles/profile_shortcut_manager_stub.cc b/chrome/browser/profiles/profile_shortcut_manager_stub.cc index b1a0a0e..c998218 100644 --- a/chrome/browser/profiles/profile_shortcut_manager_stub.cc +++ b/chrome/browser/profiles/profile_shortcut_manager_stub.cc
@@ -4,6 +4,8 @@ #include "chrome/browser/profiles/profile_shortcut_manager.h" +void ProfileShortcutManager::DisableForUnitTests() {} + // static bool ProfileShortcutManager::IsFeatureEnabled() { return false;
diff --git a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc index e4baf76..09d5d8f 100644 --- a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc +++ b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
@@ -7,15 +7,13 @@ #include "base/base_paths.h" #include "base/files/file_util.h" #include "base/location.h" -#include "base/memory/ptr_util.h" #include "base/path_service.h" -#include "base/run_loop.h" -#include "base/single_thread_task_runner.h" #include "base/strings/string16.h" +#include "base/task_runner_util.h" +#include "base/task_scheduler/post_task.h" #include "base/test/scoped_path_override.h" +#include "base/test/scoped_task_environment.h" #include "base/test/test_shortcut_win.h" -#include "base/threading/thread_task_runner_handle.h" -#include "base/win/shortcut.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_attributes_entry.h" #include "chrome/browser/profiles/profile_attributes_storage.h" @@ -30,7 +28,6 @@ #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile_manager.h" -#include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/l10n/l10n_util.h" @@ -60,7 +57,7 @@ } void TearDown() override { - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); // Delete all profiles and ensure their shortcuts got removed. const size_t num_profiles = @@ -71,7 +68,7 @@ const base::FilePath profile_path = entry->GetPath(); base::string16 profile_name = entry->GetName(); profile_attributes_storage_->RemoveProfile(profile_path); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); ASSERT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_name)); // The icon file is not deleted until the profile directory is deleted. const base::FilePath icon_path = @@ -98,7 +95,7 @@ // Also create a non-badged shortcut for Chrome, which is conveniently done // by |CreateProfileShortcut()| since there is only one profile. profile_shortcut_manager_->CreateProfileShortcut(profile_1_path_); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); // Verify that there's now a shortcut with no profile information. ValidateNonProfileShortcut(location); } @@ -123,6 +120,17 @@ GetDefaultShortcutPathForProfile(profile_name)); } + // Posts a task to call base::win::ValidateShortcut on the COM thread. + void PostValidateShortcut( + const tracked_objects::Location& location, + const base::FilePath& shortcut_path, + const base::win::ShortcutProperties& expected_properties) { + base::CreateCOMSTATaskRunnerWithTraits({})->PostTask( + location, base::Bind(&base::win::ValidateShortcut, shortcut_path, + expected_properties)); + RunTasksUntilIdle(); + } + // Calls base::win::ValidateShortcut() with expected properties for the // shortcut at |shortcut_path| for the profile at |profile_path|. void ValidateProfileShortcutAtPath(const tracked_objects::Location& location, @@ -144,7 +152,7 @@ expected_properties.set_arguments( profiles::internal::CreateProfileShortcutFlags(profile_path)); expected_properties.set_icon(icon_path, 0); - base::win::ValidateShortcut(shortcut_path, expected_properties); + PostValidateShortcut(location, shortcut_path, expected_properties); } // Calls base::win::ValidateShortcut() with expected properties for @@ -167,7 +175,7 @@ expected_properties.set_icon(GetExePath(), 0); expected_properties.set_description(GetDistribution()->GetAppDescription()); expected_properties.set_dual_mode(false); - base::win::ValidateShortcut(shortcut_path, expected_properties); + PostValidateShortcut(location, shortcut_path, expected_properties); } void ValidateNonProfileShortcut(const tracked_objects::Location& location) { @@ -185,10 +193,24 @@ std::string(), base::string16(), 0, std::string()); profile_shortcut_manager_->CreateProfileShortcut(profile_path); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); ValidateProfileShortcut(location, profile_name, profile_path); } + // Posts a task to call ShellUtil::CreateOrUpdateShortcut on the COM thread. + void PostCreateOrUpdateShortcut( + const tracked_objects::Location& location, + const ShellUtil::ShortcutProperties& properties) { + base::PostTaskAndReplyWithResult( + base::CreateCOMSTATaskRunnerWithTraits({base::MayBlock()}).get(), + location, + base::Bind(&ShellUtil::CreateOrUpdateShortcut, + ShellUtil::SHORTCUT_LOCATION_DESKTOP, GetDistribution(), + properties, ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS), + base::Bind([](bool succeeded) { EXPECT_TRUE(succeeded); })); + RunTasksUntilIdle(); + } + // Creates a regular (non-profile) desktop shortcut with the given name and // returns its path. Fails the test if an error occurs. base::FilePath CreateRegularShortcutWithName( @@ -202,9 +224,7 @@ ShellUtil::ShortcutProperties properties(ShellUtil::CURRENT_USER); product.AddDefaultShortcutProperties(GetExePath(), &properties); properties.set_shortcut_name(shortcut_name); - EXPECT_TRUE(ShellUtil::CreateOrUpdateShortcut( - ShellUtil::SHORTCUT_LOCATION_DESKTOP, GetDistribution(), properties, - ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)) << location.ToString(); + PostCreateOrUpdateShortcut(location, properties); EXPECT_TRUE(base::PathExists(shortcut_path)) << location.ToString(); return shortcut_path; @@ -216,9 +236,7 @@ installer::Product product(distribution); ShellUtil::ShortcutProperties properties(ShellUtil::SYSTEM_LEVEL); product.AddDefaultShortcutProperties(GetExePath(), &properties); - EXPECT_TRUE(ShellUtil::CreateOrUpdateShortcut( - ShellUtil::SHORTCUT_LOCATION_DESKTOP, distribution, properties, - ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)) << location.ToString(); + PostCreateOrUpdateShortcut(location, properties); const base::FilePath system_level_shortcut_path = GetSystemShortcutsDirectory().Append(distribution->GetShortcutName() + installer::kLnkExt); @@ -235,7 +253,7 @@ GetProfileAttributesWithPath(profile_path, &entry)); ASSERT_NE(entry->GetName(), new_profile_name); entry->SetName(new_profile_name); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); } BrowserDistribution* GetDistribution() { @@ -266,7 +284,8 @@ return system_shortcuts_directory; } - content::TestBrowserThreadBundle thread_bundle_; + void RunTasksUntilIdle() { scoped_task_environment_.RunUntilIdle(); } + std::unique_ptr<TestingProfileManager> profile_manager_; std::unique_ptr<ProfileShortcutManager> profile_shortcut_manager_; ProfileAttributesStorage* profile_attributes_storage_; @@ -278,6 +297,9 @@ base::FilePath profile_2_path_; base::string16 profile_3_name_; base::FilePath profile_3_path_; + + private: + base::test::ScopedTaskEnvironment scoped_task_environment_; }; TEST_F(ProfileShortcutManagerTest, ShortcutFilename) { @@ -355,7 +377,7 @@ profile_attributes_storage_->AddProfile(profile_2_path_, profile_2_name_, std::string(), base::string16(), 0, std::string()); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); // Ensure that the second profile doesn't have a shortcut and that the first // profile's shortcut got renamed and badged. @@ -369,7 +391,7 @@ // Delete one shortcut. profile_attributes_storage_->RemoveProfile(profile_2_path_); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_2_name_)); // Verify that the profile name has been removed from the remaining shortcut. @@ -394,7 +416,7 @@ // Delete the profile that doesn't have a shortcut. profile_attributes_storage_->RemoveProfile(profile_1_path_); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); // Verify that the remaining shortcut does not have a profile name. ValidateNonProfileShortcut(FROM_HERE); @@ -418,7 +440,7 @@ // Delete the profile that has a shortcut. profile_attributes_storage_->RemoveProfile(profile_2_path_); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); // Verify that the remaining shortcut does not have a profile name. ValidateNonProfileShortcut(FROM_HERE); @@ -453,7 +475,7 @@ // Delete the third profile and check that its shortcut is gone and no // shortcuts have been re-created. profile_attributes_storage_->RemoveProfile(profile_3_path_); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); ASSERT_FALSE(base::PathExists(profile_1_shortcut_path)); ASSERT_FALSE(base::PathExists(profile_2_shortcut_path)); ASSERT_FALSE(base::PathExists(profile_3_shortcut_path)); @@ -465,7 +487,7 @@ // Delete one shortcut. profile_attributes_storage_->RemoveProfile(profile_2_path_); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); // Verify that a default shortcut exists (no profile name/avatar). ValidateNonProfileShortcut(FROM_HERE); @@ -494,7 +516,7 @@ // Ensure that a new shortcut does not get made if the old one was renamed. profile_shortcut_manager_->CreateProfileShortcut(profile_2_path_); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_2_name_)); ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2, profile_2_path_); @@ -503,7 +525,7 @@ ASSERT_TRUE(base::DeleteFile(profile_2_shortcut_path_2, false)); EXPECT_FALSE(base::PathExists(profile_2_shortcut_path_2)); profile_shortcut_manager_->CreateProfileShortcut(profile_2_path_); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_); } @@ -532,7 +554,7 @@ // Delete the profile and ensure both shortcuts were also deleted. profile_attributes_storage_->RemoveProfile(profile_2_path_); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); EXPECT_FALSE(base::PathExists(profile_2_shortcut_path_1)); EXPECT_FALSE(base::PathExists(profile_2_shortcut_path_2)); ValidateNonProfileShortcutAtPath(FROM_HERE, @@ -630,7 +652,7 @@ // Delete shortcuts for profile 1 and ensure that they got deleted while the // shortcuts for profile 2 were kept. profile_shortcut_manager_->RemoveProfileShortcuts(profile_1_path_); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); EXPECT_FALSE(base::PathExists(profile_1_shortcut_path_1)); EXPECT_FALSE(base::PathExists(profile_1_shortcut_path_2)); ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_1, @@ -653,7 +675,7 @@ // Profile 2 should have a shortcut initially. profile_shortcut_manager_->HasProfileShortcuts(profile_2_path_, callback); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); EXPECT_TRUE(result.has_shortcuts); // Delete the shortcut and check that the function returns false. @@ -662,7 +684,7 @@ ASSERT_TRUE(base::DeleteFile(profile_2_shortcut_path, false)); EXPECT_FALSE(base::PathExists(profile_2_shortcut_path)); profile_shortcut_manager_->HasProfileShortcuts(profile_2_path_, callback); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); EXPECT_FALSE(result.has_shortcuts); } @@ -674,7 +696,7 @@ profile_attributes_storage_->AddProfile(profile_1_path_, profile_1_name_, std::string(), base::string16(), 0, std::string()); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); ASSERT_EQ(1u, profile_attributes_storage_->GetNumberOfProfiles()); // Ensure system-level continues to exist and user-level was not created. @@ -693,7 +715,7 @@ profile_attributes_storage_->AddProfile(profile_3_path_, profile_3_name_, std::string(), base::string16(), 0, std::string()); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_3_name_)); // Ensure that changing the avatar icon and the name does not result in a @@ -702,12 +724,12 @@ ASSERT_TRUE(profile_attributes_storage_-> GetProfileAttributesWithPath(profile_3_path_, &entry_3)); entry_3->SetAvatarIconIndex(3u); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_3_name_)); const base::string16 new_profile_3_name = L"New Name 3"; entry_3->SetName(new_profile_3_name); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_3_name_)); EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(new_profile_3_name)); @@ -717,7 +739,7 @@ ASSERT_TRUE(profile_attributes_storage_-> GetProfileAttributesWithPath(profile_2_path_, &entry_2)); entry_2->SetName(new_profile_2_name); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_2_name_)); ValidateProfileShortcut(FROM_HERE, new_profile_2_name, profile_2_path_); } @@ -732,7 +754,7 @@ // Delete a profile and verify that only the system-level shortcut still // exists. profile_attributes_storage_->RemoveProfile(profile_1_path_); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); EXPECT_TRUE(base::PathExists(system_level_shortcut_path)); EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(base::string16())); @@ -761,7 +783,7 @@ // shortcut creation path in |DeleteDesktopShortcuts()|, which is // not covered by the |DeleteSecondToLastProfileWithSystemLevelShortcut| test. profile_attributes_storage_->RemoveProfile(profile_2_path_); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); // Verify that only the system-level shortcut still exists. EXPECT_TRUE(base::PathExists(system_level_shortcut_path)); @@ -782,7 +804,7 @@ EXPECT_FALSE(base::PathExists(icon_path)); profile_shortcut_manager_->CreateOrUpdateProfileIcon(profile_1_path_); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); EXPECT_TRUE(base::PathExists(icon_path)); } @@ -813,7 +835,7 @@ // Deleting the default profile will unbadge the new profile's icon and should // result in an icon that is identical to the unbadged default profile icon. profile_attributes_storage_->RemoveProfile(profile_1_path_); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); std::string unbadged_icon_2; EXPECT_TRUE(base::ReadFileToString(icon_path_2, &unbadged_icon_2)); @@ -840,7 +862,7 @@ ASSERT_TRUE(profile_attributes_storage_-> GetProfileAttributesWithPath(profile_1_path_, &entry_1)); entry_1->SetAvatarIconIndex(1u); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); std::string new_badged_icon_1; EXPECT_TRUE(base::ReadFileToString(icon_path_1, &new_badged_icon_1)); @@ -848,7 +870,7 @@ // Ensure the new icon is not the unbadged icon. profile_attributes_storage_->RemoveProfile(profile_2_path_); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); std::string unbadged_icon_1; EXPECT_TRUE(base::ReadFileToString(icon_path_1, &unbadged_icon_1)); @@ -856,7 +878,7 @@ // Ensure the icon doesn't change on avatar change without 2 profiles. entry_1->SetAvatarIconIndex(1u); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); std::string unbadged_icon_1_a; EXPECT_TRUE(base::ReadFileToString(icon_path_1, &unbadged_icon_1_a)); @@ -1002,7 +1024,7 @@ // Delete profile1. profile_attributes_storage_->RemoveProfile(profile_1_path_); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(new_profile_1_name)); // Check that nothing is changed for profile2 and profile3. ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_); @@ -1015,7 +1037,7 @@ GetDefaultShortcutPathForProfile(profile_2_name_))); EXPECT_TRUE(base::PathExists(profile_3_shortcut_path)); profile_attributes_storage_->RemoveProfile(profile_2_path_); - base::RunLoop().RunUntilIdle(); + RunTasksUntilIdle(); EXPECT_FALSE(base::PathExists( GetDefaultShortcutPathForProfile(profile_2_name_))); // Only profile3 exists. There should be non-profile shortcut only.
diff --git a/chrome/browser/profiles/profile_shortcut_manager_win.cc b/chrome/browser/profiles/profile_shortcut_manager_win.cc index 5607157..b44bf1e 100644 --- a/chrome/browser/profiles/profile_shortcut_manager_win.cc +++ b/chrome/browser/profiles/profile_shortcut_manager_win.cc
@@ -22,6 +22,8 @@ #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/task_runner_util.h" +#include "base/task_scheduler/post_task.h" #include "base/win/shortcut.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" @@ -173,13 +175,10 @@ const base::FilePath& profile_path, const SkBitmap& avatar_bitmap_1x, const SkBitmap& avatar_bitmap_2x) { - DCHECK_CURRENTLY_ON(BrowserThread::FILE); + base::ThreadRestrictions::AssertIOAllowed(); - if (!base::PathExists(profile_path)) { - LOG(ERROR) << "Profile directory " << profile_path.value() - << " did not exist when trying to create profile icon"; + if (!base::PathExists(profile_path)) return base::FilePath(); - } std::unique_ptr<gfx::ImageFamily> family = GetAppIconImageFamily(); if (!family) @@ -221,11 +220,8 @@ const bool had_icon = base::PathExists(icon_path); if (!IconUtil::CreateIconFileFromImageFamily(badged_bitmaps, icon_path)) { - // This can happen in theory if the profile directory is deleted between the - // beginning of this function and here; however this is extremely unlikely - // and this check will help catch any regression where this call would start - // failing constantly. - NOTREACHED(); + // This can happen if the profile directory is deleted between the beginning + // of this function and here. return base::FilePath(); } @@ -283,7 +279,7 @@ bool IsChromeShortcut(const base::FilePath& path, const base::FilePath& chrome_exe, base::string16* command_line) { - DCHECK_CURRENTLY_ON(BrowserThread::FILE); + base::ThreadRestrictions::AssertIOAllowed(); if (path.Extension() != installer::kLnkExt) return false; @@ -363,8 +359,7 @@ return true; } -// Renames an existing Chrome desktop profile shortcut. Must be called on the -// FILE thread. +// Renames an existing Chrome desktop profile shortcut. // |profile_shortcuts| are Chrome desktop shortcuts for the profile (there can // be several). // |desktop_contents| is the collection of all user desktop shortcuts @@ -379,7 +374,7 @@ std::set<base::FilePath>* desktop_contents) { DCHECK(profile_shortcuts); DCHECK(desktop_contents); - DCHECK_CURRENTLY_ON(BrowserThread::FILE); + base::ThreadRestrictions::AssertIOAllowed(); base::FilePath user_shortcuts_directory; base::FilePath system_shortcuts_directory; @@ -480,11 +475,11 @@ // Updates all desktop shortcuts for the given profile to have the specified // parameters. If |params.create_mode| is CREATE_WHEN_NONE_FOUND, a new shortcut // is created if no existing ones were found. Whether non-profile shortcuts -// should be updated is specified by |params.action|. Must be called on the FILE -// thread. +// should be updated is specified by |params.action|. File and COM operations +// must be allowed on the calling thread. void CreateOrUpdateDesktopShortcutsAndIconForProfile( const CreateOrUpdateShortcutsParams& params) { - DCHECK_CURRENTLY_ON(BrowserThread::FILE); + base::ThreadRestrictions::AssertIOAllowed(); const base::FilePath shortcut_icon = CreateOrUpdateShortcutIconForProfile(params.profile_path, @@ -585,10 +580,10 @@ // Deletes all desktop shortcuts for the specified profile. If // |ensure_shortcuts_remain| is true, then a regular non-profile shortcut will // be created if this function would otherwise delete the last Chrome desktop -// shortcut(s). Must be called on the FILE thread. +// shortcut(s). File and COM operations must be allowed on the calling thread. void DeleteDesktopShortcuts(const base::FilePath& profile_path, bool ensure_shortcuts_remain) { - DCHECK_CURRENTLY_ON(BrowserThread::FILE); + base::ThreadRestrictions::AssertIOAllowed(); base::FilePath chrome_exe; if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { @@ -632,9 +627,10 @@ } // Returns true if profile at |profile_path| has any shortcuts. Does not -// consider non-profile shortcuts. Must be called on the FILE thread. +// consider non-profile shortcuts. File and COM operations must be allowed on +// the calling thread. bool HasAnyProfileShortcuts(const base::FilePath& profile_path) { - DCHECK_CURRENTLY_ON(BrowserThread::FILE); + base::ThreadRestrictions::AssertIOAllowed(); base::FilePath chrome_exe; if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { @@ -778,8 +774,19 @@ } // namespace internal } // namespace profiles +namespace { +bool disabled_for_unit_tests = false; +} + +void ProfileShortcutManager::DisableForUnitTests() { + disabled_for_unit_tests = true; +} + // static bool ProfileShortcutManager::IsFeatureEnabled() { + if (disabled_for_unit_tests) + return false; + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(switches::kEnableProfileShortcutManager)) return true; @@ -830,17 +837,17 @@ void ProfileShortcutManagerWin::RemoveProfileShortcuts( const base::FilePath& profile_path) { - BrowserThread::PostTask( - BrowserThread::FILE, FROM_HERE, - base::Bind(&DeleteDesktopShortcuts, profile_path, false)); + base::CreateCOMSTATaskRunnerWithTraits({base::MayBlock()}) + ->PostTask(FROM_HERE, + base::Bind(&DeleteDesktopShortcuts, profile_path, false)); } void ProfileShortcutManagerWin::HasProfileShortcuts( const base::FilePath& profile_path, const base::Callback<void(bool)>& callback) { - BrowserThread::PostTaskAndReplyWithResult( - BrowserThread::FILE, FROM_HERE, - base::Bind(&HasAnyProfileShortcuts, profile_path), callback); + base::PostTaskAndReplyWithResult( + base::CreateCOMSTATaskRunnerWithTraits({base::MayBlock()}).get(), + FROM_HERE, base::Bind(&HasAnyProfileShortcuts, profile_path), callback); } void ProfileShortcutManagerWin::GetShortcutProperties( @@ -905,10 +912,9 @@ IGNORE_NON_PROFILE_SHORTCUTS); } - BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, - base::Bind(&DeleteDesktopShortcuts, - profile_path, - deleting_down_to_last_profile)); + base::CreateCOMSTATaskRunnerWithTraits({base::MayBlock()}) + ->PostTask(FROM_HERE, base::Bind(&DeleteDesktopShortcuts, profile_path, + deleting_down_to_last_profile)); } void ProfileShortcutManagerWin::OnProfileNameChanged( @@ -996,14 +1002,15 @@ profiles::GetDefaultAvatarIconResourceIDAtIndex(icon_index); const int resource_id_2x = kProfileAvatarIconResources2x[icon_index]; // Make a copy of the SkBitmaps to ensure that we can safely use the image - // data on the FILE thread. + // data on the thread we post to. params.avatar_image_1x = GetImageResourceSkBitmapCopy(resource_id_1x); params.avatar_image_2x = GetImageResourceSkBitmapCopy(resource_id_2x); } } - BrowserThread::PostTask( - BrowserThread::FILE, FROM_HERE, - base::Bind(&CreateOrUpdateDesktopShortcutsAndIconForProfile, params)); + base::CreateCOMSTATaskRunnerWithTraits({base::MayBlock()}) + ->PostTask( + FROM_HERE, + base::Bind(&CreateOrUpdateDesktopShortcutsAndIconForProfile, params)); entry->SetShortcutName(params.profile_name); }
diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.html b/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.html index 8d8847b..c38d407 100644 --- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.html +++ b/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.html
@@ -1,6 +1,7 @@ <link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/cr_elements/cr_scrollable_behavior.html"> +<link rel="import" href="chrome://resources/chromeos/bluetooth_dialog.html"> <link rel="import" href="chrome://resources/html/i18n_behavior.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-list/iron-list.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spinner.html"> @@ -8,7 +9,6 @@ <link rel="import" href="../i18n_setup.html"> <link rel="import" href="../icons.html"> <link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="bluetooth_device_dialog.html"> <link rel="import" href="bluetooth_device_list_item.html"> <dom-module id="settings-bluetooth-subpage"> @@ -99,14 +99,13 @@ </iron-list> </div> - <bluetooth-device-dialog id="deviceDialog" + <bluetooth-dialog id="deviceDialog" + bluetooth="[[bluetooth]]" bluetooth-private="[[bluetoothPrivate]]" - dialog-id="[[dialogId_]]" - error-message="[[errorMessage_]]" + title="$i18n{bluetoothPairDevicePageTitle}" on-close="onDialogClose_" - on-device-event="onDeviceEvent_" pairing-device="[[pairingDevice_]]"> - </bluetooth-device-dialog> + </bluetooth-dialog> </template> <script src="bluetooth_subpage.js"></script>
diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.js b/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.js index 93affb3..5487662 100644 --- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.js +++ b/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.js
@@ -8,9 +8,6 @@ * properties and devices. */ -// NOTE(dbeam): even though this behavior is only used privately, it must -// be globally accessible for Closure's --polymer_pass to compile happily. - Polymer({ is: 'settings-bluetooth-subpage', @@ -40,7 +37,7 @@ showSpinner_: { type: Boolean, notify: true, - computed: 'computeShowSpinner_(adapterState.*, dialogId_)', + computed: 'computeShowSpinner_(adapterState.*, dialogShown_)', }, /** @@ -97,16 +94,12 @@ }, /** - * Set to the name of the dialog to show. This page uses a single - * dialog to host one of two dialog elements: 'pairDevice' or - * 'connectError'. This allows a seamless transition between dialogs. - * Note: This property should be set before opening the dialog and setting - * the property will not itself cause the dialog to open. + * Whether or not the dialog is shown. * @private */ - dialogId_: { - type: String, - value: '', + dialogShown_: { + type: Boolean, + value: false, }, /** @@ -117,12 +110,6 @@ pairingDevice_: Object, /** - * The translated error message to show when a connect error occurs. - * @private - */ - errorMessage_: String, - - /** * Interface for bluetooth calls. Set in bluetooth-page. * @type {Bluetooth} * @private @@ -200,7 +187,7 @@ /** @private */ computeShowSpinner_: function() { - return !this.dialogId_ && this.get('adapterState.discovering'); + return !this.dialogShown_ && this.get('adapterState.discovering'); }, /** @private */ @@ -268,7 +255,7 @@ */ onBluetoothDeviceUpdated_: function(device) { var address = device.address; - if (this.dialogId_ && this.pairingDevice_ && + if (this.dialogShown_ && this.pairingDevice_ && this.pairingDevice_.address == address) { this.pairingDevice_ = device; } @@ -382,40 +369,22 @@ // If the device is not paired, show the pairing dialog before connecting. if (!device.paired) { this.pairingDevice_ = device; - this.openDialog_('pairDevice'); + this.openDialog_(); } - this.bluetoothPrivate.connect(device.address, result => { - var error; - if (chrome.runtime.lastError) { - error = chrome.runtime.lastError.message; - } else { - switch (result) { - case chrome.bluetoothPrivate.ConnectResultType.IN_PROGRESS: - return; // Do not close the dialog - case chrome.bluetoothPrivate.ConnectResultType.ALREADY_CONNECTED: - case chrome.bluetoothPrivate.ConnectResultType.AUTH_CANCELED: - case chrome.bluetoothPrivate.ConnectResultType.SUCCESS: - break; - default: - error = result; - } - } - - if (!error) { - this.$.deviceDialog.close(); + var address = device.address; + this.bluetoothPrivate.connect(address, result => { + // If |pairingDevice_| has changed, ignore the connect result. + if (this.pairingDevice_ && address != this.pairingDevice_.address) return; + // Let the dialog handle any errors, otherwise close the dialog. + var dialog = this.$.deviceDialog; + if (dialog.handleError(device, chrome.runtime.lastError, result)) { + this.openDialog_(); + } else if ( + result != chrome.bluetoothPrivate.ConnectResultType.IN_PROGRESS) { + this.$.deviceDialog.close(); } - - var name = device.name || device.address; - var id = 'bluetooth_connect_' + error; - if (this.i18nExists(id)) { - this.errorMessage_ = this.i18n(id, name); - } else { - this.errorMessage_ = error; - console.error('Unexpected error connecting to: ' + name + ': ' + error); - } - this.openDialog_('connectError'); }); }, @@ -448,25 +417,19 @@ }); }, - /** - * @param {string} dialogId - * @private - */ - openDialog_: function(dialogId) { - if (this.dialogId_) { - // Dialog already opened, just update the contents. - this.dialogId_ = dialogId; + /** @private */ + openDialog_: function() { + if (this.dialogShown_) return; - } - this.dialogId_ = dialogId; // Call flush so that the dialog gets sized correctly before it is opened. Polymer.dom.flush(); this.$.deviceDialog.open(); + this.dialogShown_ = true; }, /** @private */ onDialogClose_: function() { - this.dialogId_ = ''; + this.dialogShown_ = false; this.pairingDevice_ = undefined; // The list is dynamic so focus the first item. var device = this.$$('#unpairedContainer bluetooth-device-list-item');
diff --git a/chrome/browser/resources/settings/bluetooth_page/compiled_resources2.gyp b/chrome/browser/resources/settings/bluetooth_page/compiled_resources2.gyp index e19b0d8..3d4051ba 100644 --- a/chrome/browser/resources/settings/bluetooth_page/compiled_resources2.gyp +++ b/chrome/browser/resources/settings/bluetooth_page/compiled_resources2.gyp
@@ -32,21 +32,6 @@ 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], }, { - 'target_name': 'bluetooth_device_dialog', - 'dependencies': [ - '<(DEPTH)/ui/webui/resources/cr_elements/cr_dialog/compiled_resources2.gyp:cr_dialog', - '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert', - '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', - '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior', - '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-resizable-behavior/compiled_resources2.gyp:iron-resizable-behavior-extracted', - '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-input/compiled_resources2.gyp:paper-input-extracted', - '<(EXTERNS_GYP):bluetooth', - '<(EXTERNS_GYP):bluetooth_private', - '<(INTERFACES_GYP):bluetooth_private_interface', - ], - 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], - }, - { 'target_name': 'bluetooth_device_list_item', 'dependencies': [ '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
diff --git a/chrome/browser/resources/settings/people_page/setup_pin_dialog.js b/chrome/browser/resources/settings/people_page/setup_pin_dialog.js index 4056aab..924be4a 100644 --- a/chrome/browser/resources/settings/people_page/setup_pin_dialog.js +++ b/chrome/browser/resources/settings/people_page/setup_pin_dialog.js
@@ -256,10 +256,7 @@ } this.hideProblem_(); - if (this.canSubmit_()) { - this.enableSubmit_ = true; - return; - } + this.enableSubmit_ = this.pinKeyboardValue_.length > 0; }, /** @private */ @@ -277,6 +274,9 @@ // The PIN is not guaranteed to be valid in that case. if (!this.canSubmit_()) { this.showProblem_(MessageType.MISMATCH, ProblemType.ERROR); + this.enableSubmit_ = false; + // Focus the PIN keyboard and highlight the entire PIN. + this.$.pinKeyboard.focus(0, this.pinKeyboardValue_.length + 1); return; }
diff --git a/chrome/browser/resources/settings/settings_resources.grd b/chrome/browser/resources/settings/settings_resources.grd index cbd941e..abb6b94 100644 --- a/chrome/browser/resources/settings/settings_resources.grd +++ b/chrome/browser/resources/settings/settings_resources.grd
@@ -1126,12 +1126,6 @@ <structure name="IDR_SETTINGS_ANDROID_SETTINGS_ELEMENT_JS" file="android_apps_page/android_settings_element.js" type="chrome_html" /> - <structure name="IDR_SETTINGS_BLUETOOTH_DEVICE_DIALOG_HTML" - file="bluetooth_page/bluetooth_device_dialog.html" - type="chrome_html" /> - <structure name="IDR_SETTINGS_BLUETOOTH_DEVICE_DIALOG_JS" - file="bluetooth_page/bluetooth_device_dialog.js" - type="chrome_html" /> <structure name="IDR_SETTINGS_BLUETOOTH_DEVICE_LIST_ITEM_HTML" file="bluetooth_page/bluetooth_device_list_item.html" type="chrome_html" />
diff --git a/chrome/browser/resources/vulcanize_gn.py b/chrome/browser/resources/vulcanize_gn.py index a0a1f7d..5b1d517b 100755 --- a/chrome/browser/resources/vulcanize_gn.py +++ b/chrome/browser/resources/vulcanize_gn.py
@@ -29,6 +29,9 @@ _CR_ELEMENTS_PATH = os.path.join(_RESOURCES_PATH, 'cr_elements') +_CHROMEOS_PATH = os.path.join(_RESOURCES_PATH, 'chromeos') + + _CSS_RESOURCES_PATH = os.path.join(_RESOURCES_PATH, 'css') @@ -64,6 +67,7 @@ _URL_MAPPINGS = [ + ('chrome://resources/chromeos/', _CHROMEOS_PATH), ('chrome://resources/cr_elements/', _CR_ELEMENTS_PATH), ('chrome://resources/css/', _CSS_RESOURCES_PATH), ('chrome://resources/html/', _HTML_RESOURCES_PATH),
diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc index d00818ea..28935a2 100644 --- a/chrome/browser/ssl/ssl_browser_tests.cc +++ b/chrome/browser/ssl/ssl_browser_tests.cc
@@ -87,6 +87,7 @@ #include "content/public/browser/interstitial_page.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" +#include "content/public/browser/navigation_handle.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/render_frame_host.h" @@ -897,6 +898,112 @@ AuthState::RAN_INSECURE_CONTENT); } +namespace { + +// A WebContentsObserver that allows the user to wait for a +// DidChangeVisibleSecurityState event. +class SecurityStateWebContentsObserver : public content::WebContentsObserver { + public: + explicit SecurityStateWebContentsObserver(content::WebContents* web_contents) + : content::WebContentsObserver(web_contents) {} + ~SecurityStateWebContentsObserver() override {} + + void WaitForDidChangeVisibleSecurityState() { run_loop_.Run(); } + + // WebContentsObserver: + void DidChangeVisibleSecurityState() override { run_loop_.Quit(); } + + private: + base::RunLoop run_loop_; +}; + +// A WebContentsObserver that allows the user to wait for a same-page +// navigation. Tests using this observer will fail if a non-same-page navigation +// completes after calling WaitForSamePageNavigation. +class SamePageNavigationObserver : public content::WebContentsObserver { + public: + explicit SamePageNavigationObserver(content::WebContents* web_contents) + : content::WebContentsObserver(web_contents) {} + ~SamePageNavigationObserver() override {} + + void WaitForSamePageNavigation() { run_loop_.Run(); } + + // WebContentsObserver: + void DidFinishNavigation( + content::NavigationHandle* navigation_handle) override { + ASSERT_TRUE(navigation_handle->IsSameDocument()); + run_loop_.Quit(); + } + + private: + base::RunLoop run_loop_; +}; + +} // namespace + +// Tests that the mixed content flags are reset when going back to an existing +// navigation entry that had mixed content. Regression test for +// https://crbug.com/750649. +IN_PROC_BROWSER_TEST_F(SSLUITest, GoBackToMixedContent) { + ASSERT_TRUE(embedded_test_server()->Start()); + ASSERT_TRUE(https_server_.Start()); + + // Navigate to a URL and dynamically load mixed content. + content::WebContents* tab = + browser()->tab_strip_model()->GetActiveWebContents(); + ui_test_utils::NavigateToURL(browser(), + https_server_.GetURL("/ssl/google.html")); + CheckAuthenticatedState(tab, AuthState::NONE); + SecurityStateWebContentsObserver observer(tab); + ASSERT_TRUE(content::ExecuteScript(tab, + "var i = document.createElement('img');" + "i.src = 'http://example.test';" + "document.body.appendChild(i);")); + observer.WaitForDidChangeVisibleSecurityState(); + CheckSecurityState(tab, CertError::NONE, security_state::NONE, + AuthState::DISPLAYED_INSECURE_CONTENT); + + // Now navigate somewhere else, and then back to the page that dynamically + // loaded mixed content. + ui_test_utils::NavigateToURL( + browser(), embedded_test_server()->GetURL("/ssl/google.html")); + CheckUnauthenticatedState( + browser()->tab_strip_model()->GetActiveWebContents(), AuthState::NONE); + chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB); + content::WaitForLoadStop(tab); + // After going back, the mixed content indicator should no longer be present. + CheckAuthenticatedState(tab, AuthState::NONE); +} + +// Tests that the mixed content flags are not reset for an in-page navigation. +IN_PROC_BROWSER_TEST_F(SSLUITest, MixedContentWithSamePageNavigation) { + ASSERT_TRUE(https_server_.Start()); + + // Navigate to a URL and dynamically load mixed content. + content::WebContents* tab = + browser()->tab_strip_model()->GetActiveWebContents(); + ui_test_utils::NavigateToURL(browser(), + https_server_.GetURL("/ssl/google.html")); + CheckAuthenticatedState(tab, AuthState::NONE); + SecurityStateWebContentsObserver security_state_observer(tab); + ASSERT_TRUE(content::ExecuteScript(tab, + "var i = document.createElement('img');" + "i.src = 'http://example.test';" + "document.body.appendChild(i);")); + security_state_observer.WaitForDidChangeVisibleSecurityState(); + CheckSecurityState(tab, CertError::NONE, security_state::NONE, + AuthState::DISPLAYED_INSECURE_CONTENT); + + // Initiate a same-page navigation and check that the page is still marked as + // having displayed mixed content. + SamePageNavigationObserver navigation_observer(tab); + ui_test_utils::NavigateToURL(browser(), + https_server_.GetURL("/ssl/google.html#foo")); + navigation_observer.WaitForSamePageNavigation(); + CheckSecurityState(tab, CertError::NONE, security_state::NONE, + AuthState::DISPLAYED_INSECURE_CONTENT); +} + // Tests that the WebContents's flag for displaying content with cert // errors get cleared upon navigation. IN_PROC_BROWSER_TEST_F(SSLUITest,
diff --git a/chrome/browser/ui/app_list/search/answer_card/answer_card_search_provider.cc b/chrome/browser/ui/app_list/search/answer_card/answer_card_search_provider.cc index b2940b4..c2c29ec 100644 --- a/chrome/browser/ui/app_list/search/answer_card/answer_card_search_provider.cc +++ b/chrome/browser/ui/app_list/search/answer_card/answer_card_search_provider.cc
@@ -95,10 +95,10 @@ // Lifetime of |prefixed_query| should be longer than the one of // |replacements|. - base::string16 prefixed_query( - base::UTF8ToUTF16("q=") + query + - base::UTF8ToUTF16(features::AnswerServerQuerySuffix())); - GURL::ReplacementsW replacements; + const std::string prefixed_query( + "q=" + net::EscapeQueryParamValue(base::UTF16ToUTF8(query), true) + + features::AnswerServerQuerySuffix()); + GURL::Replacements replacements; replacements.SetQueryStr(prefixed_query); current_request_url_ = answer_server_url_.ReplaceComponents(replacements); contents_->LoadURL(current_request_url_);
diff --git a/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm b/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm index b872cfa..8e3ac4d 100644 --- a/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm +++ b/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm
@@ -115,13 +115,12 @@ // an NSTableView. Future events may make cause the table view to query its // dataSource, which will have been deallocated. // -// NSTableView.dataSource becomes a zeroing weak reference starting in 10.11, -// so this workaround can be removed once we're on the 10.11 SDK. +// Linking against the 10.12 SDK does not "fix" this issue, since +// NSTableView.dataSource is a "weak" reference, which in non-ARC land still +// translates to "raw pointer". // -// See https://crbug.com/653093 and rdar://29409207 for more information. - -#if !defined(MAC_OS_X_VERSION_10_11) || \ - MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11 +// See https://crbug.com/653093, https://crbug.com/750242 and rdar://29409207 +// for more information. void ClearTableViewDataSources(NSView* view) { if (auto table_view = base::mac::ObjCCast<NSTableView>(view)) { @@ -151,12 +150,6 @@ base::Unretained(leaked_window))); } -#else - -void ClearTableViewDataSourcesIfNeeded(NSWindow*) {} - -#endif // MAC_OS_X_VERSION_10_11 - } // namespace @implementation SSLClientCertificateSelectorCocoa
diff --git a/chrome/browser/ui/webui/memory_internals_ui.cc b/chrome/browser/ui/webui/memory_internals_ui.cc index d36228ad..2b0130bc 100644 --- a/chrome/browser/ui/webui/memory_internals_ui.cc +++ b/chrome/browser/ui/webui/memory_internals_ui.cc
@@ -9,11 +9,16 @@ #include "base/bind.h" #include "base/memory/ptr_util.h" #include "base/memory/weak_ptr.h" +#include "base/path_service.h" #include "base/process/process_handle.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/task_scheduler/post_task.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiling_host/profiling_process_host.h" +#include "chrome/common/chrome_paths.h" +#include "chrome/common/profiling/constants.mojom.h" +#include "chrome/common/profiling/memlog.mojom.h" #include "chrome/common/url_constants.h" #include "chrome/grit/browser_resources.h" #include "content/public/browser/browser_child_process_host_iterator.h" @@ -24,6 +29,9 @@ #include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_message_handler.h" #include "content/public/common/process_type.h" +#include "content/public/common/service_manager_connection.h" +#include "mojo/public/cpp/system/platform_handle.h" +#include "services/service_manager/public/cpp/connector.h" namespace { @@ -71,6 +79,8 @@ static void GetChildProcessesOnIOThread( base::WeakPtr<MemoryInternalsDOMHandler> dom_handler); void ReturnProcessListOnUIThread(std::vector<base::Value> children); + static void GetOutputFileOnFileThread(int32_t sender_id); + static void HandleDumpProcessOnUIThread(int32_t sender_id, base::File file); base::WeakPtrFactory<MemoryInternalsDOMHandler> weak_factory_; @@ -108,17 +118,18 @@ } void MemoryInternalsDOMHandler::HandleDumpProcess(const base::ListValue* args) { - profiling::ProfilingProcessHost* pph = profiling::ProfilingProcessHost::Get(); - if (!pph) - return; - if (!args->is_list() || args->GetList().size() != 1) return; const base::Value& pid_value = args->GetList()[0]; if (!pid_value.is_int()) return; - pph->RequestProcessDump(pid_value.GetInt()); + // TODO(ajwong): Convert from pid to sender_id. https://crbug.com/751283. + + base::PostTaskWithTraits( + FROM_HERE, {base::TaskPriority::USER_VISIBLE, base::MayBlock()}, + base::BindOnce(&MemoryInternalsDOMHandler::GetOutputFileOnFileThread, + pid_value.GetInt())); } void MemoryInternalsDOMHandler::GetChildProcessesOnIOThread( @@ -180,6 +191,33 @@ DisallowJavascript(); } +// static +void MemoryInternalsDOMHandler::GetOutputFileOnFileThread(int32_t sender_id) { + base::FilePath user_data_dir; + PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); + base::FilePath output_path = user_data_dir.AppendASCII("memlog_dump"); + base::File f(output_path, + base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); + + content::BrowserThread::PostTask( + content::BrowserThread::UI, FROM_HERE, + base::BindOnce(&MemoryInternalsDOMHandler::HandleDumpProcessOnUIThread, + sender_id, std::move(f))); +} + +// static +void MemoryInternalsDOMHandler::HandleDumpProcessOnUIThread(int32_t sender_id, + base::File file) { + profiling::mojom::MemlogPtr memlog; + service_manager::Connector* connector = + content::ServiceManagerConnection::GetForProcess()->GetConnector(); + connector->BindInterface(profiling::mojom::kServiceName, + mojo::MakeRequest(&memlog)); + + mojo::ScopedHandle sh = mojo::WrapPlatformFile(file.TakePlatformFile()); + memlog->DumpProcess(sender_id, std::move(sh)); +} + } // namespace MemoryInternalsUI::MemoryInternalsUI(content::WebUI* web_ui)
diff --git a/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc index 286f9c200..0a39641 100644 --- a/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc +++ b/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc
@@ -368,15 +368,14 @@ #if defined(OS_CHROMEOS) void AddBluetoothStrings(content::WebUIDataSource* html_source) { LocalizedString localized_strings[] = { - {"bluetoothAccept", IDS_OPTIONS_SETTINGS_BLUETOOTH_ACCEPT_PASSKEY}, + {"bluetoothAccept", IDS_SETTINGS_BLUETOOTH_ACCEPT_PASSKEY}, {"bluetoothConnected", IDS_SETTINGS_BLUETOOTH_CONNECTED}, {"bluetoothConnecting", IDS_SETTINGS_BLUETOOTH_CONNECTING}, {"bluetoothDeviceListPaired", IDS_SETTINGS_BLUETOOTH_DEVICE_LIST_PAIRED}, {"bluetoothDeviceListUnpaired", IDS_SETTINGS_BLUETOOTH_DEVICE_LIST_UNPAIRED}, - {"bluetoothConnect", IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECT}, - {"bluetoothDisconnect", IDS_OPTIONS_SETTINGS_BLUETOOTH_DISCONNECT}, - {"bluetoothDismiss", IDS_OPTIONS_SETTINGS_BLUETOOTH_DISMISS_ERROR}, + {"bluetoothConnect", IDS_SETTINGS_BLUETOOTH_CONNECT}, + {"bluetoothDisconnect", IDS_SETTINGS_BLUETOOTH_DISCONNECT}, {"bluetoothToggleA11yLabel", IDS_SETTINGS_BLUETOOTH_TOGGLE_ACCESSIBILITY_LABEL}, {"bluetoothExpandA11yLabel", @@ -388,11 +387,11 @@ {"bluetoothPair", IDS_SETTINGS_BLUETOOTH_PAIR}, {"bluetoothPairDevicePageTitle", IDS_SETTINGS_BLUETOOTH_PAIR_DEVICE_TITLE}, - {"bluetoothReject", IDS_OPTIONS_SETTINGS_BLUETOOTH_REJECT_PASSKEY}, + {"bluetoothReject", IDS_SETTINGS_BLUETOOTH_REJECT_PASSKEY}, {"bluetoothRemove", IDS_SETTINGS_BLUETOOTH_REMOVE}, // Device connecting and pairing. {"bluetoothStartConnecting", IDS_SETTINGS_BLUETOOTH_START_CONNECTING}, - {"bluetoothEnterKey", IDS_OPTIONS_SETTINGS_BLUETOOTH_ENTER_KEY}, + {"bluetoothEnterKey", IDS_SETTINGS_BLUETOOTH_ENTER_KEY}, // These ids are generated in JS using 'bluetooth_' + a value from // bluetoothPrivate.PairingEventType (see bluetooth_private.idl). // 'keysEntered', and 'requestAuthorization' have no associated message.
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 3a01fa9..e2aafe0 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc
@@ -998,6 +998,13 @@ // Boolean pref indicating whether a user has enabled Tether. const char kInstantTetheringEnabled[] = "tether.enabled"; + +// Boolean pref indicating whether someone can cast to the device. +const char kCastReceiverEnabled[] = "cast_receiver.enabled"; + +// String pref indicating what name should be advertised for casting to. +// If the string is empty or blank the system name will be used. +const char kCastReceiverName[] = "cast_receiver.name"; #endif // defined(OS_CHROMEOS) // A boolean pref set to true if a Home button to open the Home pages should be
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 8e291b9..2d1ee74 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h
@@ -333,6 +333,8 @@ extern const char kEnableQuickUnlockFingerprint[]; extern const char kInstantTetheringAllowed[]; extern const char kInstantTetheringEnabled[]; +extern const char kCastReceiverEnabled[]; +extern const char kCastReceiverName[]; #endif // defined(OS_CHROMEOS) extern const char kShowHomeButton[]; extern const char kSpeechRecognitionFilterProfanities[];
diff --git a/chrome/common/profiling/memlog.mojom b/chrome/common/profiling/memlog.mojom index 2ef7ad3..f7d48863 100644 --- a/chrome/common/profiling/memlog.mojom +++ b/chrome/common/profiling/memlog.mojom
@@ -4,11 +4,20 @@ module profiling.mojom; +import "mojo/common/file.mojom"; + +// The profiling process is still in prototype stage, and is behind a +// compile-time flag. There will be a security review before removing the +// compile-time flag. https://crbug.com/751759. interface Memlog { // Adds a new platform-specific pipe to read memlog trace data from. // In normal usage, each child process launch will have a corresponding call // to this. AddSender(handle sender_pipe, int32 sender_id); - DumpProcess(int32 sender_id); + // Dumps the memory log of the process with the given |sender_id| into + // |output_file|. This currently dumps the memory log of an arbitrary + // process, since there does not yet a mechanism to identify specific + // processes. See https://crbug.com/751283. + DumpProcess(int32 sender_id, handle output_file); };
diff --git a/chrome/common/profiling/memlog_sender_pipe_win.cc b/chrome/common/profiling/memlog_sender_pipe_win.cc index 8cf82c5..52cdd28 100644 --- a/chrome/common/profiling/memlog_sender_pipe_win.cc +++ b/chrome/common/profiling/memlog_sender_pipe_win.cc
@@ -10,8 +10,8 @@ namespace profiling { -MemlogSenderPipe::MemlogSenderPipe(mojo::edk::ScopedPlatformHandle handle) - : handle_(std::move(handle)) {} +MemlogSenderPipe::MemlogSenderPipe(base::ScopedPlatformFile file) + : file_(std::move(file)) {} MemlogSenderPipe::~MemlogSenderPipe() { } @@ -23,8 +23,8 @@ // Note: don't use logging here (CHECK, DCHECK) because they will allocate, // and this function is called from within a malloc hook. DWORD bytes_written = 0; - if (!::WriteFile(handle_.get().handle, data, static_cast<DWORD>(sz), - &bytes_written, NULL)) + if (!::WriteFile(file_.Get(), data, static_cast<DWORD>(sz), &bytes_written, + NULL)) return false; return true; }
diff --git a/chrome/common/profiling/memlog_sender_pipe_win.h b/chrome/common/profiling/memlog_sender_pipe_win.h index 5fcb22c4..0d2bd83 100644 --- a/chrome/common/profiling/memlog_sender_pipe_win.h +++ b/chrome/common/profiling/memlog_sender_pipe_win.h
@@ -9,21 +9,21 @@ #include <string> +#include "base/files/platform_file.h" #include "base/macros.h" #include "base/strings/string16.h" -#include "mojo/edk/embedder/scoped_platform_handle.h" namespace profiling { class MemlogSenderPipe { public: - explicit MemlogSenderPipe(mojo::edk::ScopedPlatformHandle handle); + explicit MemlogSenderPipe(base::ScopedPlatformFile file); ~MemlogSenderPipe(); bool Send(const void* data, size_t sz); private: - mojo::edk::ScopedPlatformHandle handle_; + base::ScopedPlatformFile file_; DISALLOW_COPY_AND_ASSIGN(MemlogSenderPipe); };
diff --git a/chrome/profiling/allocation_tracker.h b/chrome/profiling/allocation_tracker.h index 685bd10..668f5537 100644 --- a/chrome/profiling/allocation_tracker.h +++ b/chrome/profiling/allocation_tracker.h
@@ -31,6 +31,8 @@ void OnFree(const FreePacket& free_packet) override; void OnComplete() override; + const AllocationEventSet& live_allocs() { return live_allocs_; } + private: CompleteCallback complete_callback_;
diff --git a/chrome/profiling/json_exporter.cc b/chrome/profiling/json_exporter.cc index 3e20a85..9e0bf06 100644 --- a/chrome/profiling/json_exporter.cc +++ b/chrome/profiling/json_exporter.cc
@@ -201,7 +201,6 @@ } // namespace void ExportAllocationEventSetToJSON(int pid, - const BacktraceStorage* backtrace_storage, const AllocationEventSet& event_set, std::ostream& out) { out << "{ \"traceEvents\": [";
diff --git a/chrome/profiling/json_exporter.h b/chrome/profiling/json_exporter.h index d44eec0..6f7ac767 100644 --- a/chrome/profiling/json_exporter.h +++ b/chrome/profiling/json_exporter.h
@@ -11,10 +11,7 @@ namespace profiling { -class BacktraceStorage; - void ExportAllocationEventSetToJSON(int pid, - const BacktraceStorage* backtrace_storage, const AllocationEventSet& set, std::ostream& out);
diff --git a/chrome/profiling/memlog_connection_manager.cc b/chrome/profiling/memlog_connection_manager.cc index a325a45..b801ccd 100644 --- a/chrome/profiling/memlog_connection_manager.cc +++ b/chrome/profiling/memlog_connection_manager.cc
@@ -9,6 +9,7 @@ #include "base/strings/stringprintf.h" #include "base/threading/thread.h" #include "chrome/profiling/allocation_tracker.h" +#include "chrome/profiling/json_exporter.h" #include "chrome/profiling/memlog_receiver_pipe.h" #include "chrome/profiling/memlog_stream_parser.h" @@ -45,6 +46,7 @@ void MemlogConnectionManager::OnNewConnection(base::ScopedPlatformFile file, int sender_id) { + base::AutoLock l(connections_lock_); DCHECK(connections_.find(sender_id) == connections_.end()); scoped_refptr<MemlogReceiverPipe> new_pipe = @@ -71,6 +73,7 @@ } void MemlogConnectionManager::OnConnectionComplete(int sender_id) { + base::AutoLock l(connections_lock_); auto found = connections_.find(sender_id); CHECK(found != connections_.end()); found->second.release(); @@ -89,4 +92,34 @@ base::Unretained(this), sender_id)); } +void MemlogConnectionManager::DumpProcess(int32_t sender_id, + base::File output_file) { + base::AutoLock l(connections_lock_); + + if (connections_.empty()) { + LOG(ERROR) << "No connections found for memory dump."; + return; + } + + // Lock all connections to prevent deallocations of atoms from + // BacktraceStorage. This only works if no new connections are made, which + // connections_lock_ guarantees. + std::vector<std::unique_ptr<base::AutoLock>> locks; + for (auto& it : connections_) { + Connection* connection = it.second.get(); + locks.push_back( + base::MakeUnique<base::AutoLock>(*connection->parser->GetLock())); + } + + // Pick the first connection, since there's no way to identify connections + // right now. https://crbug.com/751283. + Connection* connection = connections_.begin()->second.get(); + + std::ostringstream oss; + ExportAllocationEventSetToJSON(sender_id, connection->tracker.live_allocs(), + oss); + std::string reply = oss.str(); + output_file.WriteAtCurrentPos(reply.c_str(), reply.size()); +} + } // namespace profiling
diff --git a/chrome/profiling/memlog_connection_manager.h b/chrome/profiling/memlog_connection_manager.h index 89e6e06..9c6afb3 100644 --- a/chrome/profiling/memlog_connection_manager.h +++ b/chrome/profiling/memlog_connection_manager.h
@@ -8,8 +8,10 @@ #include <string> #include "base/containers/flat_map.h" +#include "base/files/file.h" #include "base/files/platform_file.h" #include "base/macros.h" +#include "base/synchronization/lock.h" #include "build/build_config.h" #include "chrome/profiling/backtrace_storage.h" @@ -33,6 +35,9 @@ BacktraceStorage* backtrace_storage); ~MemlogConnectionManager(); + // Dumps the memory log for the given process into |output_file|. + void DumpProcess(int32_t sender_id, base::File output_file); + void OnNewConnection(base::ScopedPlatformFile file, int sender_id); private: @@ -53,6 +58,7 @@ // Maps process ID to the connection information for it. base::flat_map<int, std::unique_ptr<Connection>> connections_; + base::Lock connections_lock_; DISALLOW_COPY_AND_ASSIGN(MemlogConnectionManager); };
diff --git a/chrome/profiling/memlog_impl.cc b/chrome/profiling/memlog_impl.cc index 208ab30..5d83a99 100644 --- a/chrome/profiling/memlog_impl.cc +++ b/chrome/profiling/memlog_impl.cc
@@ -32,8 +32,20 @@ base::ScopedPlatformFile(platform_file), sender_id)); } -void MemlogImpl::DumpProcess(int32_t sender_id) { - LOG(ERROR) << "DumpProcess called for " << sender_id; +void MemlogImpl::DumpProcess(int32_t sender_id, + mojo::ScopedHandle output_file) { + base::PlatformFile platform_file; + MojoResult result = + UnwrapPlatformFile(std::move(output_file), &platform_file); + if (result != MOJO_RESULT_OK) { + LOG(ERROR) << "Failed to unwrap output file " << result; + return; + } + base::File file(platform_file); + io_runner_->PostTask( + FROM_HERE, base::BindOnce(&MemlogConnectionManager::DumpProcess, + base::Unretained(connection_manager_.get()), + sender_id, std::move(file))); } } // namespace profiling
diff --git a/chrome/profiling/memlog_impl.h b/chrome/profiling/memlog_impl.h index 4b6544f..bd033c612 100644 --- a/chrome/profiling/memlog_impl.h +++ b/chrome/profiling/memlog_impl.h
@@ -28,7 +28,7 @@ ~MemlogImpl() override; void AddSender(mojo::ScopedHandle sender_pipe, int32_t sender_id) override; - void DumpProcess(int32_t sender_id) override; + void DumpProcess(int32_t sender_id, mojo::ScopedHandle output_file) override; private: // Helper for managing lifetime of MemlogConnectionManager.
diff --git a/chrome/profiling/memlog_receiver_pipe_win.cc b/chrome/profiling/memlog_receiver_pipe_win.cc index 62f4b3c..d2288ee 100644 --- a/chrome/profiling/memlog_receiver_pipe_win.cc +++ b/chrome/profiling/memlog_receiver_pipe_win.cc
@@ -27,7 +27,7 @@ MemlogReceiverPipe::MemlogReceiverPipe(base::ScopedPlatformFile handle) : handle_(std::move(handle)), read_buffer_(new char[kReadBufferSize]) { ZeroOverlapped(); - base::MessageLoopForIO::current()->RegisterIOHandler(handle_.get(), this); + base::MessageLoopForIO::current()->RegisterIOHandler(handle_.Get(), this); } MemlogReceiverPipe::~MemlogReceiverPipe() { @@ -55,7 +55,7 @@ DCHECK(!read_outstanding_); read_outstanding_ = true; - if (!::ReadFile(handle_.get(), read_buffer_.get(), kReadBufferSize, + if (!::ReadFile(handle_.Get(), read_buffer_.get(), kReadBufferSize, &bytes_read, &context_.overlapped)) { if (GetLastError() == ERROR_IO_PENDING) { return;
diff --git a/chrome/profiling/memlog_receiver_pipe_win.h b/chrome/profiling/memlog_receiver_pipe_win.h index 7290935..9ae15ae 100644 --- a/chrome/profiling/memlog_receiver_pipe_win.h +++ b/chrome/profiling/memlog_receiver_pipe_win.h
@@ -9,6 +9,7 @@ #include <string> +#include "base/files/platform_file.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_pump_win.h"
diff --git a/chrome/profiling/memlog_stream_parser.cc b/chrome/profiling/memlog_stream_parser.cc index ef4fe4e..f9ed004 100644 --- a/chrome/profiling/memlog_stream_parser.cc +++ b/chrome/profiling/memlog_stream_parser.cc
@@ -35,6 +35,7 @@ } void MemlogStreamParser::OnStreamData(std::unique_ptr<char[]> data, size_t sz) { + base::AutoLock l(lock_); if (!receiver_) return; // When no receiver is connected, do nothing with incoming data. @@ -74,6 +75,7 @@ } void MemlogStreamParser::OnStreamComplete() { + base::AutoLock l(lock_); if (receiver_) receiver_->OnComplete(); }
diff --git a/chrome/profiling/memlog_stream_parser.h b/chrome/profiling/memlog_stream_parser.h index 5ca00cd3..a6e8679 100644 --- a/chrome/profiling/memlog_stream_parser.h +++ b/chrome/profiling/memlog_stream_parser.h
@@ -8,6 +8,7 @@ #include <deque> #include "base/macros.h" +#include "base/synchronization/lock.h" #include "chrome/profiling/memlog_receiver.h" #include "chrome/profiling/memlog_stream_receiver.h" @@ -27,6 +28,8 @@ void OnStreamData(std::unique_ptr<char[]> data, size_t sz) override; void OnStreamComplete() override; + base::Lock* GetLock() { return &lock_; } + private: struct Block { Block(std::unique_ptr<char[]> d, size_t s); @@ -67,6 +70,11 @@ // Current offset into blocks_[0] of the next packet to process. size_t block_zero_offset_ = 0; + // This lock must be acquired anytime the stream is being parsed. This + // prevents concurrent access to data structures used by both the parser and + // the memory dumper. + base::Lock lock_; + DISALLOW_COPY_AND_ASSIGN(MemlogStreamParser); };
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index 67fdaae..dda2e6a 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -514,7 +514,9 @@ void ChromeContentRendererClient::RenderFrameCreated( content::RenderFrame* render_frame) { - new ChromeRenderFrameObserver(render_frame); + ChromeRenderFrameObserver* render_frame_observer = + new ChromeRenderFrameObserver(render_frame); + service_manager::BinderRegistry* registry = render_frame_observer->registry(); bool should_whitelist_for_content_settings = base::CommandLine::ForCurrentProcess()->HasSwitch( @@ -525,7 +527,8 @@ ChromeExtensionsRendererClient::GetInstance()->extension_dispatcher(); #endif ContentSettingsObserver* content_settings = new ContentSettingsObserver( - render_frame, ext_dispatcher, should_whitelist_for_content_settings); + render_frame, ext_dispatcher, should_whitelist_for_content_settings, + registry); if (chrome_observer_.get()) { content_settings->SetContentSettingRules( chrome_observer_->content_setting_rules()); @@ -533,7 +536,7 @@ #if BUILDFLAG(ENABLE_EXTENSIONS) ChromeExtensionsRendererClient::GetInstance()->RenderFrameCreated( - render_frame); + render_frame, registry); #endif #if BUILDFLAG(ENABLE_PLUGINS) @@ -571,7 +574,7 @@ // Set up a mojo service to test if this page is a distiller page. new dom_distiller::DistillerJsRenderFrameObserver( - render_frame, chrome::ISOLATED_WORLD_ID_CHROME_INTERNAL); + render_frame, chrome::ISOLATED_WORLD_ID_CHROME_INTERNAL, registry); base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(switches::kEnableDistillabilityService)) { @@ -581,14 +584,15 @@ } // Set up a mojo service to test if this page is a contextual search page. - new contextual_search::OverlayJsRenderFrameObserver(render_frame); + new contextual_search::OverlayJsRenderFrameObserver(render_frame, registry); PasswordAutofillAgent* password_autofill_agent = - new PasswordAutofillAgent(render_frame); + new PasswordAutofillAgent(render_frame, registry); PasswordGenerationAgent* password_generation_agent = - new PasswordGenerationAgent(render_frame, password_autofill_agent); + new PasswordGenerationAgent(render_frame, password_autofill_agent, + registry); new AutofillAgent(render_frame, password_autofill_agent, - password_generation_agent); + password_generation_agent, registry); // There is no render thread, thus no UnverifiedRulesetDealer in // ChromeRenderViewTests. @@ -605,7 +609,7 @@ #if BUILDFLAG(ENABLE_SPELLCHECK) new SpellCheckProvider(render_frame, spellcheck_.get()); #if BUILDFLAG(HAS_SPELLCHECK_PANEL) - new SpellCheckPanel(render_frame); + new SpellCheckPanel(render_frame, registry); #endif // BUILDFLAG(HAS_SPELLCHECK_PANEL) #endif }
diff --git a/chrome/renderer/chrome_render_frame_observer.h b/chrome/renderer/chrome_render_frame_observer.h index efddd68..5261aaa9 100644 --- a/chrome/renderer/chrome_render_frame_observer.h +++ b/chrome/renderer/chrome_render_frame_observer.h
@@ -43,6 +43,8 @@ explicit ChromeRenderFrameObserver(content::RenderFrame* render_frame); ~ChromeRenderFrameObserver() override; + service_manager::BinderRegistry* registry() { return ®istry_; } + private: enum TextCaptureType { PRELIMINARY_CAPTURE, FINAL_CAPTURE };
diff --git a/chrome/renderer/content_settings_observer.cc b/chrome/renderer/content_settings_observer.cc index 21149806..49e8c6e 100644 --- a/chrome/renderer/content_settings_observer.cc +++ b/chrome/renderer/content_settings_observer.cc
@@ -12,7 +12,6 @@ #include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_view.h" #include "extensions/features/features.h" -#include "services/service_manager/public/cpp/binder_registry.h" #include "third_party/WebKit/public/platform/URLConversion.h" #include "third_party/WebKit/public/platform/WebClientHintsType.h" #include "third_party/WebKit/public/platform/WebContentSettingCallbacks.h" @@ -90,7 +89,8 @@ ContentSettingsObserver::ContentSettingsObserver( content::RenderFrame* render_frame, extensions::Dispatcher* extension_dispatcher, - bool should_whitelist) + bool should_whitelist, + service_manager::BinderRegistry* registry) : content::RenderFrameObserver(render_frame), content::RenderFrameObserverTracker<ContentSettingsObserver>( render_frame), @@ -105,7 +105,7 @@ ClearBlockedContentSettings(); render_frame->GetWebFrame()->SetContentSettingsClient(this); - registry_.AddInterface( + registry->AddInterface( base::Bind(&ContentSettingsObserver::OnInsecureContentRendererRequest, base::Unretained(this))); @@ -159,12 +159,6 @@ } } -void ContentSettingsObserver::OnInterfaceRequestForFrame( - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe) { - registry_.TryBindInterface(interface_name, interface_pipe); -} - bool ContentSettingsObserver::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserver, message)
diff --git a/chrome/renderer/content_settings_observer.h b/chrome/renderer/content_settings_observer.h index 350e089..9d96555 100644 --- a/chrome/renderer/content_settings_observer.h +++ b/chrome/renderer/content_settings_observer.h
@@ -47,7 +47,8 @@ // should be whitelisted for content settings. ContentSettingsObserver(content::RenderFrame* render_frame, extensions::Dispatcher* extension_dispatcher, - bool should_whitelist); + bool should_whitelist, + service_manager::BinderRegistry* registry); ~ContentSettingsObserver() override; // Sets the content setting rules which back |allowImage()|, |allowScript()|, @@ -106,9 +107,6 @@ FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, PluginsTemporarilyAllowed); // RenderFrameObserver implementation. - void OnInterfaceRequestForFrame( - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe) override; bool OnMessageReceived(const IPC::Message& message) override; void DidCommitProvisionalLoad(bool is_new_navigation, bool is_same_document_navigation) override; @@ -184,8 +182,6 @@ mojo::BindingSet<chrome::mojom::InsecureContentRenderer> insecure_content_renderer_bindings_; - service_manager::BinderRegistry registry_; - DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver); };
diff --git a/chrome/renderer/content_settings_observer_browsertest.cc b/chrome/renderer/content_settings_observer_browsertest.cc index 2b0f359..41ca17f 100644 --- a/chrome/renderer/content_settings_observer_browsertest.cc +++ b/chrome/renderer/content_settings_observer_browsertest.cc
@@ -25,7 +25,8 @@ class MockContentSettingsObserver : public ContentSettingsObserver { public: - explicit MockContentSettingsObserver(content::RenderFrame* render_frame); + MockContentSettingsObserver(content::RenderFrame* render_frame, + service_manager::BinderRegistry* registry); virtual bool Send(IPC::Message* message); @@ -39,11 +40,11 @@ }; MockContentSettingsObserver::MockContentSettingsObserver( - content::RenderFrame* render_frame) - : ContentSettingsObserver(render_frame, NULL, false), + content::RenderFrame* render_frame, + service_manager::BinderRegistry* registry) + : ContentSettingsObserver(render_frame, NULL, false, registry), image_url_("http://www.foo.com/image.jpg"), - image_origin_("http://www.foo.com") { -} + image_origin_("http://www.foo.com") {} bool MockContentSettingsObserver::Send(IPC::Message* message) { IPC_BEGIN_MESSAGE_MAP(MockContentSettingsObserver, *message) @@ -60,7 +61,8 @@ } // namespace TEST_F(ChromeRenderViewTest, DidBlockContentType) { - MockContentSettingsObserver observer(view_->GetMainRenderFrame()); + MockContentSettingsObserver observer(view_->GetMainRenderFrame(), + registry_.get()); EXPECT_CALL(observer, OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, base::string16())); observer.DidBlockContentType(CONTENT_SETTINGS_TYPE_COOKIES); @@ -75,7 +77,8 @@ TEST_F(ChromeRenderViewTest, DISABLED_AllowDOMStorage) { // Load some HTML, so we have a valid security origin. LoadHTML("<html></html>"); - MockContentSettingsObserver observer(view_->GetMainRenderFrame()); + MockContentSettingsObserver observer(view_->GetMainRenderFrame(), + registry_.get()); ON_CALL(observer, OnAllowDOMStorage(_, _, _, _, _)).WillByDefault(DeleteArg<4>()); EXPECT_CALL(observer, @@ -174,7 +177,8 @@ } TEST_F(ChromeRenderViewTest, ImagesBlockedByDefault) { - MockContentSettingsObserver mock_observer(view_->GetMainRenderFrame()); + MockContentSettingsObserver mock_observer(view_->GetMainRenderFrame(), + registry_.get()); // Load some HTML. LoadHTML("<html>Foo</html>"); @@ -212,7 +216,8 @@ } TEST_F(ChromeRenderViewTest, ImagesAllowedByDefault) { - MockContentSettingsObserver mock_observer(view_->GetMainRenderFrame()); + MockContentSettingsObserver mock_observer(view_->GetMainRenderFrame(), + registry_.get()); // Load some HTML. LoadHTML("<html>Foo</html>"); @@ -386,7 +391,8 @@ // Checks that same document navigations don't update content settings for the // page. TEST_F(ChromeRenderViewTest, ContentSettingsSameDocumentNavigation) { - MockContentSettingsObserver mock_observer(view_->GetMainRenderFrame()); + MockContentSettingsObserver mock_observer(view_->GetMainRenderFrame(), + registry_.get()); // Load a page which contains a script. const char kHtml[] = "<html>" @@ -427,7 +433,8 @@ } TEST_F(ChromeRenderViewTest, ContentSettingsInterstitialPages) { - MockContentSettingsObserver mock_observer(view_->GetMainRenderFrame()); + MockContentSettingsObserver mock_observer(view_->GetMainRenderFrame(), + registry_.get()); // Block scripts. RendererContentSettingRules content_setting_rules; ContentSettingsForOneType& script_setting_rules = @@ -477,7 +484,8 @@ } TEST_F(ChromeRenderViewTest, AutoplayContentSettings) { - MockContentSettingsObserver mock_observer(view_->GetMainRenderFrame()); + MockContentSettingsObserver mock_observer(view_->GetMainRenderFrame(), + registry_.get()); // Load some HTML. LoadHTML("<html>Foo</html>");
diff --git a/chrome/renderer/extensions/chrome_extensions_renderer_client.cc b/chrome/renderer/extensions/chrome_extensions_renderer_client.cc index e33e827..c407ed5 100644 --- a/chrome/renderer/extensions/chrome_extensions_renderer_client.cc +++ b/chrome/renderer/extensions/chrome_extensions_renderer_client.cc
@@ -170,8 +170,9 @@ } void ChromeExtensionsRendererClient::RenderFrameCreated( - content::RenderFrame* render_frame) { - new extensions::ExtensionsRenderFrameObserver(render_frame); + content::RenderFrame* render_frame, + service_manager::BinderRegistry* registry) { + new extensions::ExtensionsRenderFrameObserver(render_frame, registry); new extensions::ExtensionFrameHelper(render_frame, extension_dispatcher_.get()); extension_dispatcher_->OnRenderFrameCreated(render_frame);
diff --git a/chrome/renderer/extensions/chrome_extensions_renderer_client.h b/chrome/renderer/extensions/chrome_extensions_renderer_client.h index 2f8f5e5a..0aa0e19 100644 --- a/chrome/renderer/extensions/chrome_extensions_renderer_client.h +++ b/chrome/renderer/extensions/chrome_extensions_renderer_client.h
@@ -10,6 +10,7 @@ #include "base/macros.h" #include "extensions/renderer/extensions_renderer_client.h" +#include "services/service_manager/public/cpp/binder_registry.h" #include "ui/base/page_transition_types.h" class ChromeExtensionsDispatcherDelegate; @@ -53,7 +54,8 @@ // See ChromeContentRendererClient methods with the same names. void RenderThreadStarted(); - void RenderFrameCreated(content::RenderFrame* render_frame); + void RenderFrameCreated(content::RenderFrame* render_frame, + service_manager::BinderRegistry* registry); void RenderViewCreated(content::RenderView* render_view); bool OverrideCreatePlugin(content::RenderFrame* render_frame, const blink::WebPluginParams& params);
diff --git a/chrome/test/base/chrome_render_view_test.cc b/chrome/test/base/chrome_render_view_test.cc index 9b471e4..0ae0b83 100644 --- a/chrome/test/base/chrome_render_view_test.cc +++ b/chrome/test/base/chrome_render_view_test.cc
@@ -62,10 +62,12 @@ public: MockAutofillAgent(RenderFrame* render_frame, PasswordAutofillAgent* password_autofill_agent, - PasswordGenerationAgent* password_generation_agent) + PasswordGenerationAgent* password_generation_agent, + service_manager::BinderRegistry* registry) : AutofillAgent(render_frame, password_autofill_agent, - password_generation_agent) { + password_generation_agent, + registry) { ON_CALL(*this, IsUserGesture()).WillByDefault(Return(true)); } @@ -111,6 +113,8 @@ chrome_render_thread_ = new ChromeMockRenderThread(); render_thread_.reset(chrome_render_thread_); + registry_ = base::MakeUnique<service_manager::BinderRegistry>(); + content::RenderViewTest::SetUp(); RegisterMainFrameRemoteInterfaces(); @@ -118,14 +122,13 @@ // RenderFrame doesn't expose its Agent objects, because it has no need to // store them directly (they're stored as RenderFrameObserver*). So just // create another set. - password_autofill_agent_ = - new autofill::TestPasswordAutofillAgent(view_->GetMainRenderFrame()); - password_generation_ = - new autofill::TestPasswordGenerationAgent(view_->GetMainRenderFrame(), - password_autofill_agent_); - autofill_agent_ = new NiceMock<MockAutofillAgent>(view_->GetMainRenderFrame(), - password_autofill_agent_, - password_generation_); + password_autofill_agent_ = new autofill::TestPasswordAutofillAgent( + view_->GetMainRenderFrame(), registry_.get()); + password_generation_ = new autofill::TestPasswordGenerationAgent( + view_->GetMainRenderFrame(), password_autofill_agent_, registry_.get()); + autofill_agent_ = new NiceMock<MockAutofillAgent>( + view_->GetMainRenderFrame(), password_autofill_agent_, + password_generation_, registry_.get()); } void ChromeRenderViewTest::TearDown() { @@ -142,6 +145,7 @@ __lsan_do_leak_check(); #endif content::RenderViewTest::TearDown(); + registry_.reset(); } content::ContentClient* ChromeRenderViewTest::CreateContentClient() {
diff --git a/chrome/test/base/chrome_render_view_test.h b/chrome/test/base/chrome_render_view_test.h index d598dab2..05a60004 100644 --- a/chrome/test/base/chrome_render_view_test.h +++ b/chrome/test/base/chrome_render_view_test.h
@@ -11,6 +11,7 @@ #include "chrome/renderer/chrome_mock_render_thread.h" #include "content/public/test/render_view_test.h" #include "extensions/features/features.h" +#include "services/service_manager/public/cpp/binder_registry.h" class ChromeContentRendererClient; @@ -57,6 +58,8 @@ autofill::TestPasswordGenerationAgent* password_generation_; autofill::AutofillAgent* autofill_agent_; + std::unique_ptr<service_manager::BinderRegistry> registry_; + // Naked pointer as ownership is with content::RenderViewTest::render_thread_. ChromeMockRenderThread* chrome_render_thread_; };
diff --git a/chrome/test/base/chrome_unit_test_suite.cc b/chrome/test/base/chrome_unit_test_suite.cc index 9a75475..3e2717c 100644 --- a/chrome/test/base/chrome_unit_test_suite.cc +++ b/chrome/test/base/chrome_unit_test_suite.cc
@@ -10,6 +10,7 @@ #include "base/process/process_handle.h" #include "build/build_config.h" #include "chrome/browser/chrome_content_browser_client.h" +#include "chrome/browser/profiles/profile_shortcut_manager.h" #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" #include "chrome/browser/update_client/chrome_update_query_params_delegate.h" #include "chrome/common/chrome_content_client.h" @@ -112,6 +113,7 @@ InitializeResourceBundle(); base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_); + ProfileShortcutManager::DisableForUnitTests(); } void ChromeUnitTestSuite::Shutdown() {
diff --git a/chrome/test/data/policy/policy_test_cases.json b/chrome/test/data/policy/policy_test_cases.json index 9230d3d2..39768db 100644 --- a/chrome/test/data/policy/policy_test_cases.json +++ b/chrome/test/data/policy/policy_test_cases.json
@@ -3136,6 +3136,23 @@ ] }, + "CastReceiverEnabled": { + "os": ["chromeos"], + "test_policy": { "CastReceiverEnabled": true }, + "pref_mappings": [ + { "pref": "cast_receiver.enabled" } + ] + }, + + "CastReceiverName": { + "os": ["chromeos"], + "test_policy": { "CastReceiverName": "Hallway" }, + "pref_mappings": [ + { "pref": "cast_receiver.name", + "local_state": true } + ] + }, + "----- Chrome Frame policies -------------------------------------------": {}, "ChromeFrameRendererSettings": {
diff --git a/chrome/test/data/webui/settings/quick_unlock_authenticate_browsertest_chromeos.js b/chrome/test/data/webui/settings/quick_unlock_authenticate_browsertest_chromeos.js index 0d46c22..4bdc2d8 100644 --- a/chrome/test/data/webui/settings/quick_unlock_authenticate_browsertest_chromeos.js +++ b/chrome/test/data/webui/settings/quick_unlock_authenticate_browsertest_chromeos.js
@@ -500,6 +500,28 @@ assertDeepEquals(['PIN'], quickUnlockPrivateApi.activeModes); assertDeepEquals(['1111'], quickUnlockPrivateApi.credentials); }); + + test('TestContinueButtonState', function() { + pinKeyboard.value = '1111'; + MockInteractions.tap(continueButton); + + // Verify the button is disabled when we first enter the confirm step, + // since the PIN value is empty. + assertEquals('', pinKeyboard.value); + assertTrue(continueButton.disabled); + + // Verify the button is enabled after we enter one digit. + pinKeyboard.value = '1'; + assertFalse(continueButton.disabled); + + // Verify the button is disabled after we try to submit a wrong PIN. + MockInteractions.tap(continueButton); + assertTrue(continueButton.disabled); + + // Verify the button is enabled after we enter one digit again. + pinKeyboard.value = '11'; + assertFalse(continueButton.disabled); + }); }); }
diff --git a/components/autofill/content/common/autofill_types_struct_traits.cc b/components/autofill/content/common/autofill_types_struct_traits.cc index d76e5b0..ed4c5c4 100644 --- a/components/autofill/content/common/autofill_types_struct_traits.cc +++ b/components/autofill/content/common/autofill_types_struct_traits.cc
@@ -604,24 +604,25 @@ } // static -void* StructTraits<mojom::PasswordFormFieldPredictionMapDataView, - PasswordFormFieldPredictionMap>:: - SetUpContext(const PasswordFormFieldPredictionMap& r) { - // Extracts keys vector and values vector from the map, saves them as a pair. - auto* pair = new KeysValuesPair(); - for (const auto& i : r) { - pair->first.push_back(i.first); - pair->second.push_back(i.second); - } - - return pair; +std::vector<autofill::FormFieldData> StructTraits< + mojom::PasswordFormFieldPredictionMapDataView, + PasswordFormFieldPredictionMap>::keys(const PasswordFormFieldPredictionMap& + r) { + std::vector<autofill::FormFieldData> data; + for (const auto& i : r) + data.push_back(i.first); + return data; } // static -void StructTraits<mojom::PasswordFormFieldPredictionMapDataView, - PasswordFormFieldPredictionMap>:: - TearDownContext(const PasswordFormFieldPredictionMap& r, void* context) { - delete static_cast<KeysValuesPair*>(context); +std::vector<autofill::PasswordFormFieldPredictionType> +StructTraits<mojom::PasswordFormFieldPredictionMapDataView, + PasswordFormFieldPredictionMap>:: + values(const PasswordFormFieldPredictionMap& r) { + std::vector<autofill::PasswordFormFieldPredictionType> types; + for (const auto& i : r) + types.push_back(i.second); + return types; } // static @@ -646,23 +647,23 @@ } // static -void* StructTraits<mojom::FormsPredictionsMapDataView, - FormsPredictionsMap>::SetUpContext(const FormsPredictionsMap& - r) { - // Extracts keys vector and values vector from the map, saves them as a pair. - auto* pair = new KeysValuesPair(); - for (const auto& i : r) { - pair->first.push_back(i.first); - pair->second.push_back(i.second); - } - - return pair; +std::vector<autofill::FormData> +StructTraits<mojom::FormsPredictionsMapDataView, FormsPredictionsMap>::keys( + const FormsPredictionsMap& r) { + std::vector<autofill::FormData> data; + for (const auto& i : r) + data.push_back(i.first); + return data; } // static -void StructTraits<mojom::FormsPredictionsMapDataView, FormsPredictionsMap>:: - TearDownContext(const FormsPredictionsMap& r, void* context) { - delete static_cast<KeysValuesPair*>(context); +std::vector<autofill::PasswordFormFieldPredictionMap> +StructTraits<mojom::FormsPredictionsMapDataView, FormsPredictionsMap>::values( + const FormsPredictionsMap& r) { + std::vector<autofill::PasswordFormFieldPredictionMap> maps; + for (const auto& i : r) + maps.push_back(i.second); + return maps; } // static
diff --git a/components/autofill/content/common/autofill_types_struct_traits.h b/components/autofill/content/common/autofill_types_struct_traits.h index 0c51ed5..b98c9dc 100644 --- a/components/autofill/content/common/autofill_types_struct_traits.h +++ b/components/autofill/content/common/autofill_types_struct_traits.h
@@ -519,26 +519,11 @@ template <> struct StructTraits<autofill::mojom::PasswordFormFieldPredictionMapDataView, autofill::PasswordFormFieldPredictionMap> { - using KeysValuesPair = - std::pair<std::vector<autofill::FormFieldData>, - std::vector<autofill::PasswordFormFieldPredictionType>>; + static std::vector<autofill::FormFieldData> keys( + const autofill::PasswordFormFieldPredictionMap& r); - static void* SetUpContext(const autofill::PasswordFormFieldPredictionMap& r); - - static void TearDownContext(const autofill::PasswordFormFieldPredictionMap& r, - void* context); - - static const std::vector<autofill::FormFieldData>& keys( - const autofill::PasswordFormFieldPredictionMap& r, - void* context) { - return static_cast<KeysValuesPair*>(context)->first; - } - - static const std::vector<autofill::PasswordFormFieldPredictionType>& values( - const autofill::PasswordFormFieldPredictionMap& r, - void* context) { - return static_cast<KeysValuesPair*>(context)->second; - } + static std::vector<autofill::PasswordFormFieldPredictionType> values( + const autofill::PasswordFormFieldPredictionMap& r); static bool Read(autofill::mojom::PasswordFormFieldPredictionMapDataView data, autofill::PasswordFormFieldPredictionMap* out); @@ -547,26 +532,11 @@ template <> struct StructTraits<autofill::mojom::FormsPredictionsMapDataView, autofill::FormsPredictionsMap> { - using KeysValuesPair = - std::pair<std::vector<autofill::FormData>, - std::vector<autofill::PasswordFormFieldPredictionMap>>; + static std::vector<autofill::FormData> keys( + const autofill::FormsPredictionsMap& r); - static void* SetUpContext(const autofill::FormsPredictionsMap& r); - - static void TearDownContext(const autofill::FormsPredictionsMap& r, - void* context); - - static const std::vector<autofill::FormData>& keys( - const autofill::FormsPredictionsMap& r, - void* context) { - return static_cast<KeysValuesPair*>(context)->first; - } - - static const std::vector<autofill::PasswordFormFieldPredictionMap>& values( - const autofill::FormsPredictionsMap& r, - void* context) { - return static_cast<KeysValuesPair*>(context)->second; - } + static std::vector<autofill::PasswordFormFieldPredictionMap> values( + const autofill::FormsPredictionsMap& r); static bool Read(autofill::mojom::FormsPredictionsMapDataView data, autofill::FormsPredictionsMap* out);
diff --git a/components/autofill/content/renderer/BUILD.gn b/components/autofill/content/renderer/BUILD.gn index e87dc920..8450307 100644 --- a/components/autofill/content/renderer/BUILD.gn +++ b/components/autofill/content/renderer/BUILD.gn
@@ -70,6 +70,7 @@ deps = [ "//components/autofill/content/renderer", "//ipc", + "//services/service_manager/public/cpp", "//skia", "//third_party/WebKit/public:blink", ]
diff --git a/components/autofill/content/renderer/autofill_agent.cc b/components/autofill/content/renderer/autofill_agent.cc index e727cef..d3ff7bf 100644 --- a/components/autofill/content/renderer/autofill_agent.cc +++ b/components/autofill/content/renderer/autofill_agent.cc
@@ -42,7 +42,6 @@ #include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_view.h" #include "net/cert/cert_status_flags.h" -#include "services/service_manager/public/cpp/binder_registry.h" #include "services/service_manager/public/cpp/interface_provider.h" #include "third_party/WebKit/public/platform/WebKeyboardEvent.h" #include "third_party/WebKit/public/platform/WebURLRequest.h" @@ -142,7 +141,8 @@ AutofillAgent::AutofillAgent(content::RenderFrame* render_frame, PasswordAutofillAgent* password_autofill_agent, - PasswordGenerationAgent* password_generation_agent) + PasswordGenerationAgent* password_generation_agent, + service_manager::BinderRegistry* registry) : content::RenderFrameObserver(render_frame), form_cache_(*render_frame->GetWebFrame()), password_autofill_agent_(password_autofill_agent), @@ -160,7 +160,7 @@ render_frame->GetWebFrame()->SetAutofillClient(this); password_autofill_agent->SetAutofillAgent(this); - registry_.AddInterface( + registry->AddInterface( base::Bind(&AutofillAgent::BindRequest, base::Unretained(this))); } @@ -176,12 +176,6 @@ std::tie(rhs.name, rhs.origin, rhs.action, rhs.is_form_tag); } -void AutofillAgent::OnInterfaceRequestForFrame( - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe) { - registry_.TryBindInterface(interface_name, interface_pipe); -} - void AutofillAgent::DidCommitProvisionalLoad(bool is_new_navigation, bool is_same_document_navigation) { blink::WebFrame* frame = render_frame()->GetWebFrame();
diff --git a/components/autofill/content/renderer/autofill_agent.h b/components/autofill/content/renderer/autofill_agent.h index 1c41b1f..e242130 100644 --- a/components/autofill/content/renderer/autofill_agent.h +++ b/components/autofill/content/renderer/autofill_agent.h
@@ -56,7 +56,8 @@ // guaranteed to outlive AutofillAgent. AutofillAgent(content::RenderFrame* render_frame, PasswordAutofillAgent* password_autofill_manager, - PasswordGenerationAgent* password_generation_agent); + PasswordGenerationAgent* password_generation_agent, + service_manager::BinderRegistry* registry); ~AutofillAgent() override; void BindRequest(mojom::AutofillAgentRequest request); @@ -132,9 +133,6 @@ }; // content::RenderFrameObserver: - void OnInterfaceRequestForFrame( - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe) override; void DidCommitProvisionalLoad(bool is_new_navigation, bool is_same_document_navigation) override; void DidFinishDocumentLoad() override; @@ -296,8 +294,6 @@ mojom::AutofillDriverPtr autofill_driver_; - service_manager::BinderRegistry registry_; - base::WeakPtrFactory<AutofillAgent> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(AutofillAgent);
diff --git a/components/autofill/content/renderer/password_autofill_agent.cc b/components/autofill/content/renderer/password_autofill_agent.cc index b29e15e..83c717d 100644 --- a/components/autofill/content/renderer/password_autofill_agent.cc +++ b/components/autofill/content/renderer/password_autofill_agent.cc
@@ -36,7 +36,6 @@ #include "content/public/renderer/navigation_state.h" #include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_view.h" -#include "services/service_manager/public/cpp/binder_registry.h" #include "services/service_manager/public/cpp/interface_provider.h" #include "third_party/WebKit/public/platform/WebInputEvent.h" #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" @@ -678,7 +677,9 @@ //////////////////////////////////////////////////////////////////////////////// // PasswordAutofillAgent, public: -PasswordAutofillAgent::PasswordAutofillAgent(content::RenderFrame* render_frame) +PasswordAutofillAgent::PasswordAutofillAgent( + content::RenderFrame* render_frame, + service_manager::BinderRegistry* registry) : content::RenderFrameObserver(render_frame), logging_state_active_(false), was_username_autofilled_(false), @@ -687,7 +688,7 @@ checked_safe_browsing_reputation_(false), binding_(this), form_element_observer_(nullptr) { - registry_.AddInterface( + registry->AddInterface( base::Bind(&PasswordAutofillAgent::BindRequest, base::Unretained(this))); } @@ -1286,12 +1287,6 @@ } } -void PasswordAutofillAgent::OnInterfaceRequestForFrame( - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe) { - registry_.TryBindInterface(interface_name, interface_pipe); -} - void PasswordAutofillAgent::DidFinishDocumentLoad() { // The |frame| contents have been parsed, but not yet rendered. Let the // PasswordManager know that forms are loaded, even though we can't yet tell
diff --git a/components/autofill/content/renderer/password_autofill_agent.h b/components/autofill/content/renderer/password_autofill_agent.h index abed524..29a0daa 100644 --- a/components/autofill/content/renderer/password_autofill_agent.h +++ b/components/autofill/content/renderer/password_autofill_agent.h
@@ -43,7 +43,8 @@ class PasswordAutofillAgent : public content::RenderFrameObserver, public mojom::PasswordAutofillAgent { public: - explicit PasswordAutofillAgent(content::RenderFrame* render_frame); + PasswordAutofillAgent(content::RenderFrame* render_frame, + service_manager::BinderRegistry* registry); ~PasswordAutofillAgent() override; void BindRequest(mojom::PasswordAutofillAgentRequest request); @@ -202,9 +203,6 @@ }; // RenderFrameObserver: - void OnInterfaceRequestForFrame( - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe) override; void DidFinishDocumentLoad() override; void DidFinishLoad() override; void FrameDetached() override; @@ -317,8 +315,6 @@ blink::WebFormElementObserver* form_element_observer_; - service_manager::BinderRegistry registry_; - DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); };
diff --git a/components/autofill/content/renderer/password_generation_agent.cc b/components/autofill/content/renderer/password_generation_agent.cc index f73ab39..9440e5d5 100644 --- a/components/autofill/content/renderer/password_generation_agent.cc +++ b/components/autofill/content/renderer/password_generation_agent.cc
@@ -26,7 +26,6 @@ #include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_view.h" #include "google_apis/gaia/gaia_urls.h" -#include "services/service_manager/public/cpp/binder_registry.h" #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" #include "third_party/WebKit/public/platform/WebVector.h" #include "third_party/WebKit/public/web/WebDocument.h" @@ -155,7 +154,8 @@ PasswordGenerationAgent::PasswordGenerationAgent( content::RenderFrame* render_frame, - PasswordAutofillAgent* password_agent) + PasswordAutofillAgent* password_agent, + service_manager::BinderRegistry* registry) : content::RenderFrameObserver(render_frame), password_is_generated_(false), is_manually_triggered_(false), @@ -167,7 +167,7 @@ password_agent_(password_agent), binding_(this) { LogBoolean(Logger::STRING_GENERATION_RENDERER_ENABLED, enabled_); - registry_.AddInterface(base::Bind(&PasswordGenerationAgent::BindRequest, + registry->AddInterface(base::Bind(&PasswordGenerationAgent::BindRequest, base::Unretained(this))); } PasswordGenerationAgent::~PasswordGenerationAgent() {} @@ -177,12 +177,6 @@ binding_.Bind(std::move(request)); } -void PasswordGenerationAgent::OnInterfaceRequestForFrame( - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe) { - registry_.TryBindInterface(interface_name, interface_pipe); -} - void PasswordGenerationAgent::DidFinishDocumentLoad() { // Update stats for main frame navigation. if (!render_frame()->GetWebFrame()->Parent()) {
diff --git a/components/autofill/content/renderer/password_generation_agent.h b/components/autofill/content/renderer/password_generation_agent.h index f8ab6a0..c925787 100644 --- a/components/autofill/content/renderer/password_generation_agent.h +++ b/components/autofill/content/renderer/password_generation_agent.h
@@ -36,7 +36,8 @@ public mojom::PasswordGenerationAgent { public: PasswordGenerationAgent(content::RenderFrame* render_frame, - PasswordAutofillAgent* password_agent); + PasswordAutofillAgent* password_agent, + service_manager::BinderRegistry* registry); ~PasswordGenerationAgent() override; void BindRequest(mojom::PasswordGenerationAgentRequest request); @@ -88,9 +89,6 @@ typedef std::vector<AccountCreationFormData> AccountCreationFormDataList; // RenderFrameObserver: - void OnInterfaceRequestForFrame( - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe) override; void DidFinishDocumentLoad() override; void DidFinishLoad() override; void OnDestruct() override; @@ -197,8 +195,6 @@ mojo::Binding<mojom::PasswordGenerationAgent> binding_; - service_manager::BinderRegistry registry_; - DISALLOW_COPY_AND_ASSIGN(PasswordGenerationAgent); };
diff --git a/components/autofill/content/renderer/test_password_autofill_agent.cc b/components/autofill/content/renderer/test_password_autofill_agent.cc index 394279f..9fc1a4f 100644 --- a/components/autofill/content/renderer/test_password_autofill_agent.cc +++ b/components/autofill/content/renderer/test_password_autofill_agent.cc
@@ -7,9 +7,9 @@ namespace autofill { TestPasswordAutofillAgent::TestPasswordAutofillAgent( - content::RenderFrame* render_frame) - : PasswordAutofillAgent(render_frame) { -} + content::RenderFrame* render_frame, + service_manager::BinderRegistry* registry) + : PasswordAutofillAgent(render_frame, registry) {} TestPasswordAutofillAgent::~TestPasswordAutofillAgent() {}
diff --git a/components/autofill/content/renderer/test_password_autofill_agent.h b/components/autofill/content/renderer/test_password_autofill_agent.h index afa8d78..4e037de8 100644 --- a/components/autofill/content/renderer/test_password_autofill_agent.h +++ b/components/autofill/content/renderer/test_password_autofill_agent.h
@@ -11,7 +11,8 @@ class TestPasswordAutofillAgent : public PasswordAutofillAgent { public: - explicit TestPasswordAutofillAgent(content::RenderFrame* render_frame); + TestPasswordAutofillAgent(content::RenderFrame* render_frame, + service_manager::BinderRegistry* registry); ~TestPasswordAutofillAgent() override; private:
diff --git a/components/autofill/content/renderer/test_password_generation_agent.cc b/components/autofill/content/renderer/test_password_generation_agent.cc index 84d937a..4076003b 100644 --- a/components/autofill/content/renderer/test_password_generation_agent.cc +++ b/components/autofill/content/renderer/test_password_generation_agent.cc
@@ -7,8 +7,10 @@ namespace autofill { TestPasswordGenerationAgent::TestPasswordGenerationAgent( - content::RenderFrame* render_frame, PasswordAutofillAgent* password_agent) - : PasswordGenerationAgent(render_frame, password_agent) { + content::RenderFrame* render_frame, + PasswordAutofillAgent* password_agent, + service_manager::BinderRegistry* registry) + : PasswordGenerationAgent(render_frame, password_agent, registry) { // Always enable when testing. set_enabled(true); }
diff --git a/components/autofill/content/renderer/test_password_generation_agent.h b/components/autofill/content/renderer/test_password_generation_agent.h index 6ab5509d..f752803 100644 --- a/components/autofill/content/renderer/test_password_generation_agent.h +++ b/components/autofill/content/renderer/test_password_generation_agent.h
@@ -9,13 +9,15 @@ #include "base/macros.h" #include "components/autofill/content/renderer/password_generation_agent.h" +#include "services/service_manager/public/cpp/binder_registry.h" namespace autofill { class TestPasswordGenerationAgent : public PasswordGenerationAgent { public: TestPasswordGenerationAgent(content::RenderFrame* render_frame, - PasswordAutofillAgent* password_agent); + PasswordAutofillAgent* password_agent, + service_manager::BinderRegistry* registry); ~TestPasswordGenerationAgent() override; // PasswordGenreationAgent implementation:
diff --git a/components/autofill/core/browser/autofill_profile.cc b/components/autofill/core/browser/autofill_profile.cc index 6f70f4d..b79fbf10 100644 --- a/components/autofill/core/browser/autofill_profile.cc +++ b/components/autofill/core/browser/autofill_profile.cc
@@ -720,6 +720,10 @@ AutofillProfile::ValidityState AutofillProfile::GetValidityState( ServerFieldType type) { + // Return valid for types that autofill does not validate. + if (!IsValidationSupportedForType(type)) + return UNSUPPORTED; + if (!base::ContainsKey(validity_states_, type)) return UNVALIDATED; @@ -728,6 +732,10 @@ void AutofillProfile::SetValidityState(ServerFieldType type, ValidityState validity) { + // Do not save validity of unsupported types. + if (!IsValidationSupportedForType(type)) + return; + std::map<ServerFieldType, ValidityState>::iterator it = validity_states_.find(type); @@ -738,6 +746,21 @@ } } +bool AutofillProfile::IsValidationSupportedForType(ServerFieldType type) { + switch (type) { + case ADDRESS_HOME_STATE: + case ADDRESS_HOME_ZIP: + case ADDRESS_HOME_COUNTRY: + case ADDRESS_HOME_CITY: + case ADDRESS_HOME_DEPENDENT_LOCALITY: + case EMAIL_ADDRESS: + case PHONE_HOME_WHOLE_NUMBER: + return true; + default: + return false; + } +} + // static void AutofillProfile::CreateInferredLabelsHelper( const std::vector<AutofillProfile*>& profiles,
diff --git a/components/autofill/core/browser/autofill_profile.h b/components/autofill/core/browser/autofill_profile.h index 33ab3fa..cbc9ec5 100644 --- a/components/autofill/core/browser/autofill_profile.h +++ b/components/autofill/core/browser/autofill_profile.h
@@ -49,6 +49,9 @@ // The field is valid. VALID, + + // The validation for the field is unsupported. + UNSUPPORTED, }; AutofillProfile(const std::string& guid, const std::string& origin); @@ -206,6 +209,9 @@ // Sets the validity state of the specified autofill type. void SetValidityState(ServerFieldType type, ValidityState validity); + // Returns whether autofill does the validation of the specified |type|. + bool IsValidationSupportedForType(ServerFieldType type); + private: typedef std::vector<const FormGroup*> FormGroupList;
diff --git a/components/autofill/core/browser/autofill_profile_unittest.cc b/components/autofill/core/browser/autofill_profile_unittest.cc index e94cfe0..1e9fe4f 100644 --- a/components/autofill/core/browser/autofill_profile_unittest.cc +++ b/components/autofill/core/browser/autofill_profile_unittest.cc
@@ -1105,15 +1105,35 @@ // The default validity state should be UNVALIDATED. EXPECT_EQ(AutofillProfile::UNVALIDATED, - profile.GetValidityState(ADDRESS_HOME_LINE1)); + profile.GetValidityState(ADDRESS_HOME_COUNTRY)); // Make sure setting the validity state works. - profile.SetValidityState(ADDRESS_HOME_LINE1, AutofillProfile::VALID); + profile.SetValidityState(ADDRESS_HOME_COUNTRY, AutofillProfile::VALID); profile.SetValidityState(ADDRESS_HOME_CITY, AutofillProfile::INVALID); EXPECT_EQ(AutofillProfile::VALID, - profile.GetValidityState(ADDRESS_HOME_LINE1)); + profile.GetValidityState(ADDRESS_HOME_COUNTRY)); EXPECT_EQ(AutofillProfile::INVALID, profile.GetValidityState(ADDRESS_HOME_CITY)); } +TEST(AutofillProfileTest, ValidityStates_UnsupportedTypes) { + AutofillProfile profile; + + // The validity state of unsupported types should be UNSUPPORTED. + EXPECT_EQ(AutofillProfile::UNSUPPORTED, + profile.GetValidityState(ADDRESS_HOME_LINE1)); + + // Make sure setting the validity state of an unsupported type does nothing. + profile.SetValidityState(ADDRESS_HOME_LINE1, AutofillProfile::VALID); + profile.SetValidityState(ADDRESS_HOME_LINE2, AutofillProfile::INVALID); + profile.SetValidityState(PHONE_HOME_CITY_AND_NUMBER, + AutofillProfile::UNVALIDATED); + EXPECT_EQ(AutofillProfile::UNSUPPORTED, + profile.GetValidityState(ADDRESS_HOME_LINE1)); + EXPECT_EQ(AutofillProfile::UNSUPPORTED, + profile.GetValidityState(ADDRESS_HOME_LINE2)); + EXPECT_EQ(AutofillProfile::UNSUPPORTED, + profile.GetValidityState(PHONE_HOME_CITY_AND_NUMBER)); +} + } // namespace autofill
diff --git a/components/autofill/core/browser/personal_data_manager_unittest.cc b/components/autofill/core/browser/personal_data_manager_unittest.cc index fdca82a..5bc060c4 100644 --- a/components/autofill/core/browser/personal_data_manager_unittest.cc +++ b/components/autofill/core/browser/personal_data_manager_unittest.cc
@@ -156,7 +156,7 @@ personal_data_->is_autofill_profile_cleanup_pending_ = true; } - void SetupReferenceProfile() { + void SetUpReferenceProfile() { ASSERT_EQ(0U, personal_data_->GetProfiles().size()); AutofillProfile profile(base::GenerateGUID(), "https://www.example.com"); @@ -206,14 +206,14 @@ // different: two are from different companies and the third doesn't have a // number. All three have different owners and credit card number. This allows // to test the suggestions based on name as well as on credit card number. - void SetupReferenceLocalCreditCards() { + void SetUpReferenceLocalCreditCards() { ASSERT_EQ(0U, personal_data_->GetCreditCards().size()); CreditCard credit_card0("287151C8-6AB1-487C-9095-28E80BE5DA15", "https://www.example.com"); test::SetCreditCardInfo(&credit_card0, "Clyde Barrow", - "347666888555" /* American Express */, "04", "2999", - "1"); + "378282246310005" /* American Express */, "04", + "2999", "1"); credit_card0.set_use_count(3); credit_card0.set_use_date(AutofillClock::Now() - base::TimeDelta::FromDays(1)); @@ -225,7 +225,7 @@ credit_card1.set_use_date(AutofillClock::Now() - base::TimeDelta::FromDays(10)); test::SetCreditCardInfo(&credit_card1, "John Dillinger", - "423456789012" /* Visa */, "01", "2999", "1"); + "4234567890123456" /* Visa */, "01", "2999", "1"); personal_data_->AddCreditCard(credit_card1); CreditCard credit_card2("002149C1-EE28-4213-A3B9-DA243FFF021B", @@ -234,7 +234,8 @@ credit_card2.set_use_date(AutofillClock::Now() - base::TimeDelta::FromDays(1)); test::SetCreditCardInfo(&credit_card2, "Bonnie Parker", - "518765432109" /* Mastercard */, "12", "2999", "1"); + "5105105105105100" /* Mastercard */, "12", "2999", + "1"); personal_data_->AddCreditCard(credit_card2); EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) @@ -290,6 +291,13 @@ EXPECT_EQ(0, expected.Compare(*results[0])); } + // Verifies that the web database has been updated and the notification sent. + void WaitForOnPersonalDataChanged() { + EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) + .WillOnce(QuitMainMessageLoop()); + base::RunLoop().Run(); + } + // The temporary directory should be deleted at the end to ensure that // files are not used anymore and deletion succeeds. base::ScopedTempDir temp_dir_; @@ -318,7 +326,7 @@ new WebDatabaseService(path, base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get()); - // Setup account tracker. + // Set up account tracker. signin_client_.reset(new TestSigninClient(prefs_.get())); account_tracker_.reset(new AccountTrackerService()); account_tracker_->Initialize(signin_client_.get()); @@ -468,10 +476,7 @@ personal_data_->AddProfile(profile0); personal_data_->AddProfile(profile1); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); std::vector<AutofillProfile*> profiles; profiles.push_back(&profile0); @@ -484,10 +489,7 @@ personal_data_->RemoveByGUID(profile1.guid()); personal_data_->AddProfile(profile2); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); profiles.clear(); profiles.push_back(&profile0); @@ -507,25 +509,23 @@ EnableWalletCardImport(); CreditCard credit_card0(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&credit_card0, "John Dillinger", - "423456789012" /* Visa */, "01", "2999", "1"); + "4234567890123456" /* Visa */, "01", "2999", "1"); CreditCard credit_card1(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&credit_card1, "Bonnie Parker", - "518765432109" /* Mastercard */, "12", "2999", "1"); + "5105105105105100" /* Mastercard */, "12", "2999", + "1"); CreditCard credit_card2(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&credit_card2, "Clyde Barrow", - "347666888555" /* American Express */, "04", "2999", - "1"); + "378282246310005" /* American Express */, "04", + "2999", "1"); // Add two test credit cards to the database. personal_data_->AddCreditCard(credit_card0); personal_data_->AddCreditCard(credit_card1); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); std::vector<CreditCard*> cards; cards.push_back(&credit_card0); @@ -538,10 +538,7 @@ personal_data_->RemoveByGUID(credit_card1.guid()); personal_data_->AddCreditCard(credit_card2); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); cards.clear(); cards.push_back(&credit_card0); @@ -566,10 +563,12 @@ credit_card3.set_record_type(CreditCard::FULL_SERVER_CARD); credit_card3.set_server_id("server_id"); + // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); personal_data_->AddFullServerCreditCard(credit_card3); + base::RunLoop().Run(); cards.push_back(&credit_card3); @@ -602,7 +601,7 @@ // Add a credit card to the database. CreditCard credit_card(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&credit_card, "John Dillinger", - "423456789012" /* Visa */, "01", "2999", "1"); + "4234567890123456" /* Visa */, "01", "2999", "1"); personal_data_->AddCreditCard(credit_card); // Reload the database. @@ -630,17 +629,14 @@ CreditCard credit_card(base::GenerateGUID(), "https://www.example.com/"); test::SetCreditCardInfo(&credit_card, "John Dillinger", - "423456789012" /* Visa */, "01", "2999", "1"); + "4234567890123456" /* Visa */, "01", "2999", "1"); EXPECT_FALSE(credit_card.IsVerified()); // Add the data to the database. personal_data_->AddProfile(profile); personal_data_->AddCreditCard(credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); const std::vector<AutofillProfile*>& profiles1 = personal_data_->GetProfiles(); @@ -681,10 +677,7 @@ personal_data_->UpdateProfile(profile); personal_data_->UpdateCreditCard(credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); const std::vector<AutofillProfile*>& profiles3 = personal_data_->GetProfiles(); @@ -712,14 +705,12 @@ std::vector<CreditCard> server_cards; server_cards.push_back(CreditCard(CreditCard::FULL_SERVER_CARD, "c789")); test::SetCreditCardInfo(&server_cards.back(), "Clyde Barrow", - "347666888555" /* American Express */, "04", "2999", - "1"); + "378282246310005" /* American Express */, "04", + "2999", "1"); test::SetServerCreditCards(autofill_table_, server_cards); personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); ASSERT_EQ(1U, personal_data_->GetCreditCards().size()); EXPECT_EQ(CreditCard::MASKED_SERVER_CARD, @@ -741,9 +732,10 @@ CreditCard server_card(CreditCard::FULL_SERVER_CARD, "c789"); test::SetCreditCardInfo(&server_card, "Clyde Barrow", - "347666888555" /* American Express */, "04", "2999", - "1"); + "378282246310005" /* American Express */, "04", + "2999", "1"); + // Verify that the web database has been updated and the notification sent. EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) .WillOnce(QuitMainMessageLoop()); @@ -773,25 +765,23 @@ std::vector<CreditCard> server_cards; server_cards.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "a123")); test::SetCreditCardInfo(&server_cards.back(), "John Dillinger", - "9012" /* Visa */, "01", "2999", "1"); + "3456" /* Visa */, "01", "2999", "1"); server_cards.back().SetNetworkForMaskedCard(kVisaCard); server_cards.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "b456")); test::SetCreditCardInfo(&server_cards.back(), "Bonnie Parker", - "2109" /* Mastercard */, "12", "2999", "1"); + "5100" /* Mastercard */, "12", "2999", "1"); server_cards.back().SetNetworkForMaskedCard(kMasterCard); server_cards.push_back(CreditCard(CreditCard::FULL_SERVER_CARD, "c789")); test::SetCreditCardInfo(&server_cards.back(), "Clyde Barrow", - "347666888555" /* American Express */, "04", "2999", - "1"); + "378282246310005" /* American Express */, "04", + "2999", "1"); test::SetServerCreditCards(autofill_table_, server_cards); personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); @@ -810,28 +800,24 @@ CreditCard* unmasked_card = &server_cards.front(); unmasked_card->set_record_type(CreditCard::FULL_SERVER_CARD); - unmasked_card->SetNumber(base::ASCIIToUTF16("423456789012")); + unmasked_card->SetNumber(base::ASCIIToUTF16("4234567890123456")); EXPECT_NE(0, server_cards.front().Compare( *personal_data_->GetCreditCards().front())); personal_data_->UpdateServerCreditCard(*unmasked_card); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); for (size_t i = 0; i < 3; ++i) EXPECT_EQ(0, server_cards[i].Compare(*personal_data_->GetCreditCards()[i])); CreditCard* remasked_card = &server_cards.back(); remasked_card->set_record_type(CreditCard::MASKED_SERVER_CARD); - remasked_card->SetNumber(base::ASCIIToUTF16("8555")); + remasked_card->SetNumber(base::ASCIIToUTF16("0005")); EXPECT_NE( 0, server_cards.back().Compare(*personal_data_->GetCreditCards().back())); personal_data_->UpdateServerCreditCard(*remasked_card); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); for (size_t i = 0; i < 3; ++i) EXPECT_EQ(0, server_cards[i].Compare(*personal_data_->GetCreditCards()[i])); @@ -842,16 +828,14 @@ std::vector<CreditCard> server_cards; server_cards.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "a123")); test::SetCreditCardInfo(&server_cards.back(), "John Dillinger", - "9012" /* Visa */, "01", "2999", "1"); + "3456" /* Visa */, "01", "2999", "1"); server_cards.back().SetNetworkForMaskedCard(kVisaCard); server_cards.back().set_card_type(CreditCard::CARD_TYPE_DEBIT); test::SetServerCreditCards(autofill_table_, server_cards); personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); auto cards = personal_data_->GetCreditCards(); ASSERT_EQ(1U, cards.size()); @@ -873,20 +857,18 @@ CreditCard credit_card0(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&credit_card0, "John Dillinger", - "423456789012" /* Visa */, "01", "2999", "1"); + "4234567890123456" /* Visa */, "01", "2999", "1"); CreditCard credit_card1(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&credit_card1, "Bonnie Parker", - "518765432109" /* Mastercard */, "12", "2999", "1"); + "5105105105105100" /* Mastercard */, "12", "2999", + "1"); // Add two test profiles to the database. personal_data_->AddProfile(profile0); personal_data_->AddProfile(profile1); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); std::vector<AutofillProfile*> profiles; profiles.push_back(&profile0); @@ -897,10 +879,7 @@ personal_data_->AddCreditCard(credit_card0); personal_data_->AddCreditCard(credit_card1); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); std::vector<CreditCard*> cards; cards.push_back(&credit_card0); @@ -927,10 +906,7 @@ // Add the profile0 to the db. personal_data_->AddProfile(profile0); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Verify that we've loaded the profiles from the web database. const std::vector<AutofillProfile*>& results2 = personal_data_->GetProfiles(); @@ -943,10 +919,7 @@ "z", "", "", "", "", "", "", "", "", "", "", ""); personal_data_->AddProfile(profile1); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Make sure the two profiles have different GUIDs, both valid. const std::vector<AutofillProfile*>& results3 = personal_data_->GetProfiles(); @@ -1009,8 +982,7 @@ ResetPersonalDataManager(USER_MODE_NORMAL); // Verify that we've loaded the profiles from the web database. - const std::vector<AutofillProfile*>& results2 = personal_data_->GetProfiles(); - ASSERT_EQ(0U, results2.size()); + ASSERT_EQ(0U, personal_data_->GetProfiles().size()); } TEST_F(PersonalDataManagerTest, SetEmptyCreditCard) { @@ -1028,8 +1000,7 @@ ResetPersonalDataManager(USER_MODE_NORMAL); // Verify that we've loaded the credit cards from the web database. - const std::vector<CreditCard*>& results2 = personal_data_->GetCreditCards(); - ASSERT_EQ(0U, results2.size()); + ASSERT_EQ(0U, personal_data_->GetCreditCards().size()); } TEST_F(PersonalDataManagerTest, Refresh) { @@ -1049,10 +1020,7 @@ personal_data_->AddProfile(profile0); personal_data_->AddProfile(profile1); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); std::vector<AutofillProfile*> profiles; profiles.push_back(&profile0); @@ -1069,10 +1037,7 @@ personal_data_->Refresh(); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); profiles.clear(); profiles.push_back(&profile0); @@ -1094,10 +1059,7 @@ personal_data_->AddProfile(profile1); personal_data_->AddProfile(profile2); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); const std::vector<AutofillProfile*>& results = personal_data_->GetProfiles(); ASSERT_EQ(1U, results.size()); @@ -1131,10 +1093,7 @@ form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure)); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", NULL, @@ -1169,8 +1128,7 @@ form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_FALSE(ImportAddressProfiles(form_structure)); - const std::vector<AutofillProfile*>& results = personal_data_->GetProfiles(); - ASSERT_EQ(0U, results.size()); + ASSERT_EQ(0U, personal_data_->GetProfiles().size()); } // Tests that a 'confirm email' field does not block profile import. @@ -1198,8 +1156,10 @@ FormStructure form_structure(form); form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure)); - const std::vector<AutofillProfile*>& results = personal_data_->GetProfiles(); - ASSERT_EQ(1U, results.size()); + + WaitForOnPersonalDataChanged(); + + ASSERT_EQ(1U, personal_data_->GetProfiles().size()); } // Tests two email fields containing different values blocks profile import. @@ -1227,8 +1187,8 @@ FormStructure form_structure(form); form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_FALSE(ImportAddressProfiles(form_structure)); - const std::vector<AutofillProfile*>& results = personal_data_->GetProfiles(); - ASSERT_EQ(0U, results.size()); + + ASSERT_EQ(0U, personal_data_->GetProfiles().size()); } // Tests that not enough filled fields will result in not importing an address. @@ -1248,10 +1208,8 @@ form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_FALSE(ImportAddressProfiles(form_structure)); - const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles(); - ASSERT_EQ(0U, profiles.size()); - const std::vector<CreditCard*>& cards = personal_data_->GetCreditCards(); - ASSERT_EQ(0U, cards.size()); + ASSERT_EQ(0U, personal_data_->GetProfiles().size()); + ASSERT_EQ(0U, personal_data_->GetCreditCards().size()); } TEST_F(PersonalDataManagerTest, ImportAddressProfiles_MinimumAddressUSA) { @@ -1275,8 +1233,10 @@ FormStructure form_structure(form); form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure)); - const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles(); - ASSERT_EQ(1U, profiles.size()); + + WaitForOnPersonalDataChanged(); + + ASSERT_EQ(1U, personal_data_->GetProfiles().size()); } TEST_F(PersonalDataManagerTest, ImportAddressProfiles_MinimumAddressGB) { @@ -1300,8 +1260,10 @@ FormStructure form_structure(form); form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure)); - const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles(); - ASSERT_EQ(1U, profiles.size()); + + WaitForOnPersonalDataChanged(); + + ASSERT_EQ(1U, personal_data_->GetProfiles().size()); } TEST_F(PersonalDataManagerTest, ImportAddressProfiles_MinimumAddressGI) { @@ -1320,8 +1282,10 @@ FormStructure form_structure(form); form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure)); - const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles(); - ASSERT_EQ(1U, profiles.size()); + + WaitForOnPersonalDataChanged(); + + ASSERT_EQ(1U, personal_data_->GetProfiles().size()); } TEST_F(PersonalDataManagerTest, @@ -1359,10 +1323,7 @@ form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure)); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", NULL, @@ -1403,10 +1364,7 @@ form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure)); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", NULL, @@ -1444,10 +1402,7 @@ form_structure1.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure1)); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", NULL, @@ -1482,10 +1437,7 @@ form_structure2.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure2)); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); AutofillProfile expected2(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected2, "John", NULL, @@ -1543,10 +1495,7 @@ form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure)); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", NULL, "Washington", @@ -1598,12 +1547,10 @@ test::CreateTestFormField("Last name:", "last_name", "", "text", &field); field.is_focusable = false; form.fields.push_back(field); - test::CreateTestFormField("Email:", "email", "", "text", - &field); + test::CreateTestFormField("Email:", "email", "", "text", &field); field.is_focusable = false; form.fields.push_back(field); - test::CreateTestFormField("Address:", "address1", "", "text", - &field); + test::CreateTestFormField("Address:", "address1", "", "text", &field); field.is_focusable = false; form.fields.push_back(field); test::CreateTestFormField("City:", "city", "", "text", &field); @@ -1621,10 +1568,7 @@ form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure)); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", NULL, "Washington", @@ -1705,10 +1649,7 @@ form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure)); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Only two are saved. AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); @@ -1760,10 +1701,7 @@ form_structure1.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure1)); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", nullptr, "Washington", @@ -1808,10 +1746,7 @@ form_structure2.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure2)); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); const std::vector<AutofillProfile*>& results2 = personal_data_->GetProfiles(); @@ -1847,10 +1782,7 @@ form_structure1.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure1)); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", NULL, @@ -1885,10 +1817,7 @@ form_structure2.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure2)); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); const std::vector<AutofillProfile*>& results2 = personal_data_->GetProfiles(); @@ -1930,10 +1859,7 @@ form_structure1.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure1)); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", NULL, @@ -1969,10 +1895,7 @@ form_structure2.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure2)); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); const std::vector<AutofillProfile*>& results2 = personal_data_->GetProfiles(); @@ -2011,10 +1934,8 @@ // sure no changes were written out. ResetPersonalDataManager(USER_MODE_NORMAL); - const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles(); - ASSERT_EQ(0U, profiles.size()); - const std::vector<CreditCard*>& cards = personal_data_->GetCreditCards(); - ASSERT_EQ(0U, cards.size()); + ASSERT_EQ(0U, personal_data_->GetProfiles().size()); + ASSERT_EQ(0U, personal_data_->GetCreditCards().size()); } // Ensure that if a verified profile already exists, aggregated profiles cannot @@ -2033,10 +1954,7 @@ // Add the profile to the database. personal_data_->AddProfile(profile); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Simulate a form submission with conflicting info. FormData form; @@ -2065,9 +1983,7 @@ EXPECT_TRUE(ImportAddressProfiles(form_structure)); // Wait for the refresh, which in this case is a no-op. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Expect that no new profile is saved. const std::vector<AutofillProfile*>& results = personal_data_->GetProfiles(); @@ -2086,9 +2002,7 @@ EXPECT_TRUE(ImportAddressProfiles(form_structure2)); // Wait for the refresh, which in this case is a no-op. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Expect that no new profile is saved. const std::vector<AutofillProfile*>& results2 = personal_data_->GetProfiles(); @@ -2130,10 +2044,8 @@ // sure no changes were written out. ResetPersonalDataManager(USER_MODE_NORMAL); - const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles(); - ASSERT_EQ(0U, profiles.size()); - const std::vector<CreditCard*>& cards = personal_data_->GetCreditCards(); - ASSERT_EQ(0U, cards.size()); + ASSERT_EQ(0U, personal_data_->GetProfiles().size()); + ASSERT_EQ(0U, personal_data_->GetCreditCards().size()); } // Tests that a profile is created for countries with composed names. @@ -2167,10 +2079,7 @@ form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */); EXPECT_TRUE(ImportAddressProfiles(form_structure)); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); test::SetProfileInfo(&expected, "George", nullptr, "Washington", @@ -2220,10 +2129,8 @@ // sure no changes were written out. ResetPersonalDataManager(USER_MODE_NORMAL); - const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles(); - ASSERT_EQ(0U, profiles.size()); - const std::vector<CreditCard*>& cards = personal_data_->GetCreditCards(); - ASSERT_EQ(0U, cards.size()); + ASSERT_EQ(0U, personal_data_->GetProfiles().size()); + ASSERT_EQ(0U, personal_data_->GetCreditCards().size()); } // ImportCreditCard tests. @@ -2246,14 +2153,11 @@ EXPECT_FALSE(imported_credit_card_matches_masked_server_credit_card); personal_data_->SaveImportedCreditCard(*imported_credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); CreditCard expected(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&expected, "Biggie Smalls", "4111111111111111", "01", - "2999", ""); // Imported cards have not billing info. + "2999", ""); // Imported cards have no billing info. const std::vector<CreditCard*>& results = personal_data_->GetCreditCards(); ASSERT_EQ(1U, results.size()); EXPECT_EQ(0, expected.Compare(*results[0])); @@ -2278,8 +2182,7 @@ // sure no changes were written out. ResetPersonalDataManager(USER_MODE_NORMAL); - const std::vector<CreditCard*>& results = personal_data_->GetCreditCards(); - ASSERT_EQ(0U, results.size()); + ASSERT_EQ(0U, personal_data_->GetCreditCards().size()); } // Tests that a valid credit card is extracted when the option text for month @@ -2313,15 +2216,12 @@ EXPECT_FALSE(imported_credit_card_matches_masked_server_credit_card); personal_data_->SaveImportedCreditCard(*imported_credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // See that the invalid option text was converted to the right value. CreditCard expected(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&expected, "Biggie Smalls", "4111111111111111", "02", - "2999", ""); // Imported cards have not billing info. + "2999", ""); // Imported cards have no billing info. const std::vector<CreditCard*>& results = personal_data_->GetCreditCards(); ASSERT_EQ(1U, results.size()); EXPECT_EQ(0, expected.Compare(*results[0])); @@ -2344,14 +2244,11 @@ EXPECT_FALSE(imported_credit_card_matches_masked_server_credit_card); personal_data_->SaveImportedCreditCard(*imported_credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); CreditCard expected(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&expected, "Biggie Smalls", "4111111111111111", "01", - "2999", ""); // Imported cards have not billing info. + "2999", ""); // Imported cards have no billing info. const std::vector<CreditCard*>& results = personal_data_->GetCreditCards(); ASSERT_EQ(1U, results.size()); EXPECT_EQ(0, expected.Compare(*results[0])); @@ -2370,14 +2267,11 @@ EXPECT_FALSE(imported_credit_card_matches_masked_server_credit_card); personal_data_->SaveImportedCreditCard(*imported_credit_card2); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); CreditCard expected2(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&expected2, "", "5500000000000004", "02", "2999", - ""); // Imported cards have not billing info. + ""); // Imported cards have no billing info. std::vector<CreditCard*> cards; cards.push_back(&expected); cards.push_back(&expected2); @@ -2460,10 +2354,16 @@ "4111111111111111", "05", "2045"); } -// Tests that a credit card is extracted because it only matches a masked server -// card. +// Tests that a credit card is not extracted because the +// kAutofillOfferLocalSaveIfServerCardManuallyEntered feature flag is off even +// though the card matches a masked server card. TEST_F(PersonalDataManagerTest, - ImportCreditCard_DuplicateServerCards_MaskedCard) { + ImportCreditCard_DuplicateServerCards_MaskedCard_ExperimentOff) { + // Ensure feature flag is off. + base::test::ScopedFeatureList scoped_feature_list_; + scoped_feature_list_.InitAndDisableFeature( + kAutofillOfferLocalSaveIfServerCardManuallyEntered); + // Add a masked server card. std::vector<CreditCard> server_cards; server_cards.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "a123")); @@ -2472,12 +2372,57 @@ server_cards.back().SetNetworkForMaskedCard(kVisaCard); test::SetServerCreditCards(autofill_table_, server_cards); + // Make sure everything is set up correctly. + personal_data_->Refresh(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); + // Type the same data as the masked card into a form. FormData form; AddFullCreditCardForm(&form, "John Dillinger", "4111111111111111", "01", "2999"); - // The card should be offered to be saved locally because it only matches the + // The card should not be offered to be saved locally because the feature flag + // is disabled. + FormStructure form_structure(form); + form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */); + std::unique_ptr<CreditCard> imported_credit_card; + bool imported_credit_card_matches_masked_server_credit_card; + EXPECT_FALSE(ImportCreditCard( + form_structure, false, &imported_credit_card, + &imported_credit_card_matches_masked_server_credit_card)); + ASSERT_FALSE(imported_credit_card); +} + +// Tests that a credit card is extracted because it matches a masked server card +// and the kAutofillOfferLocalSaveIfServerCardManuallyEntered feature flag is +// enabled. +TEST_F(PersonalDataManagerTest, + ImportCreditCard_DuplicateServerCards_MaskedCard_ExperimentOn) { + // Enable feature flag. + base::test::ScopedFeatureList scoped_feature_list_; + scoped_feature_list_.InitAndEnableFeature( + kAutofillOfferLocalSaveIfServerCardManuallyEntered); + + // Add a masked server card. + std::vector<CreditCard> server_cards; + server_cards.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "a123")); + test::SetCreditCardInfo(&server_cards.back(), "John Dillinger", + "1111" /* Visa */, "01", "2999", ""); + server_cards.back().SetNetworkForMaskedCard(kVisaCard); + test::SetServerCreditCards(autofill_table_, server_cards); + + // Make sure everything is set up correctly. + personal_data_->Refresh(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); + + // Type the same data as the masked card into a form. + FormData form; + AddFullCreditCardForm(&form, "John Dillinger", "4111111111111111", "01", + "2999"); + + // The card should be offered to be saved locally because it matches the // masked server card. FormStructure form_structure(form); form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */); @@ -2487,13 +2432,10 @@ form_structure, false, &imported_credit_card, &imported_credit_card_matches_masked_server_credit_card)); ASSERT_TRUE(imported_credit_card); - EXPECT_FALSE(imported_credit_card_matches_masked_server_credit_card); + EXPECT_TRUE(imported_credit_card_matches_masked_server_credit_card); personal_data_->SaveImportedCreditCard(*imported_credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); } // Tests that a credit card is not extracted because it matches a full server @@ -2504,13 +2446,18 @@ std::vector<CreditCard> server_cards; server_cards.push_back(CreditCard(CreditCard::FULL_SERVER_CARD, "c789")); test::SetCreditCardInfo(&server_cards.back(), "Clyde Barrow", - "347666888555" /* American Express */, "04", "2999", - ""); // Imported cards have not billing info. + "378282246310005" /* American Express */, "04", + "2999", ""); // Imported cards have no billing info. test::SetServerCreditCards(autofill_table_, server_cards); + // Make sure everything is set up correctly. + personal_data_->Refresh(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); + // Type the same data as the unmasked card into a form. FormData form; - AddFullCreditCardForm(&form, "Clyde Barrow", "347666888555", "04", "2999"); + AddFullCreditCardForm(&form, "Clyde Barrow", "378282246310005", "04", "2999"); // The card should not be offered to be saved locally because it only matches // the full server card. @@ -2541,14 +2488,11 @@ EXPECT_FALSE(imported_credit_card_matches_masked_server_credit_card); personal_data_->SaveImportedCreditCard(*imported_credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); CreditCard expected(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&expected, "Biggie Smalls", "4111111111111111", "01", - "2998", ""); // Imported cards have not billing info. + "2998", ""); // Imported cards have no billing info. const std::vector<CreditCard*>& results = personal_data_->GetCreditCards(); ASSERT_EQ(1U, results.size()); EXPECT_EQ(0, expected.Compare(*results[0])); @@ -2567,16 +2511,13 @@ &imported_credit_card_matches_masked_server_credit_card)); EXPECT_FALSE(imported_credit_card2); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Expect that the newer information is saved. In this case the year is // updated to "2999". CreditCard expected2(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&expected2, "Biggie Smalls", "4111111111111111", "01", - "2999", ""); // Imported cards have not billing info. + "2999", ""); // Imported cards have no billing info. const std::vector<CreditCard*>& results2 = personal_data_->GetCreditCards(); ASSERT_EQ(1U, results2.size()); EXPECT_EQ(0, expected2.Compare(*results2[0])); @@ -2599,14 +2540,11 @@ EXPECT_FALSE(imported_credit_card_matches_masked_server_credit_card); personal_data_->SaveImportedCreditCard(*imported_credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); CreditCard expected(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&expected, "Biggie Smalls", "4111111111111111", "01", - "2998", ""); // Imported cards have not billing info. + "2998", ""); // Imported cards have no billing info. const std::vector<CreditCard*>& results = personal_data_->GetCreditCards(); ASSERT_EQ(1U, results.size()); EXPECT_EQ(0, expected.Compare(*results[0])); @@ -2628,16 +2566,13 @@ EXPECT_TRUE(imported_credit_card2); EXPECT_FALSE(imported_credit_card_matches_masked_server_credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Expect that the newer information is saved. In this case the year is // updated to "2999". CreditCard expected2(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&expected2, "Biggie Smalls", "4111111111111111", "01", - "2999", ""); // Imported cards have not billing info. + "2999", ""); // Imported cards have no billing info. const std::vector<CreditCard*>& results2 = personal_data_->GetCreditCards(); ASSERT_EQ(1U, results2.size()); EXPECT_EQ(0, expected2.Compare(*results2[0])); @@ -2660,14 +2595,11 @@ EXPECT_FALSE(imported_credit_card_matches_masked_server_credit_card); personal_data_->SaveImportedCreditCard(*imported_credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); CreditCard expected(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&expected, "Biggie Smalls", "4111111111111111", "01", - "2998", ""); // Imported cards have not billing info. + "2998", ""); // Imported cards have no billing info. const std::vector<CreditCard*>& results = personal_data_->GetCreditCards(); ASSERT_EQ(1U, results.size()); EXPECT_EQ(0, expected.Compare(*results[0])); @@ -2715,10 +2647,7 @@ EXPECT_FALSE(imported_credit_card_matches_masked_server_credit_card); personal_data_->SaveImportedCreditCard(*imported_credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); CreditCard expected(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&expected, "Biggie Smalls", "4111111111111111", "01", @@ -2788,10 +2717,7 @@ "01", "2998", "1"); personal_data_->AddCreditCard(saved_credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); const std::vector<CreditCard*>& results1 = personal_data_->GetCreditCards(); ASSERT_EQ(1U, results1.size()); @@ -2812,10 +2738,7 @@ &imported_credit_card_matches_masked_server_credit_card)); EXPECT_FALSE(imported_credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Expect that the newer information is saved. In this case the year is // added to the existing credit card. @@ -2837,10 +2760,7 @@ "4111 1111 1111 1111" /* Visa */, "01", "2999", ""); personal_data_->AddCreditCard(saved_credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); const std::vector<CreditCard*>& results1 = personal_data_->GetCreditCards(); ASSERT_EQ(1U, results1.size()); @@ -2883,10 +2803,10 @@ // Add the credit card to the database. personal_data_->AddCreditCard(credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + // Make sure everything is set up correctly. + personal_data_->Refresh(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); // Simulate a form submission with conflicting expiration year. FormData form; @@ -2954,10 +2874,7 @@ EXPECT_FALSE(imported_credit_card_matches_masked_server_credit_card); personal_data_->SaveImportedCreditCard(*imported_credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Test that the address has been saved. AutofillProfile expected_address(base::GenerateGUID(), @@ -3036,10 +2953,7 @@ EXPECT_FALSE(imported_credit_card_matches_masked_server_credit_card); personal_data_->SaveImportedCreditCard(*imported_credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Test that both addresses have been saved. EXPECT_EQ(2U, personal_data_->GetProfiles().size()); @@ -3067,10 +2981,9 @@ // Add the profile to the database. personal_data_->AddProfile(profile); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + // Make sure everything is set up correctly. + WaitForOnPersonalDataChanged(); + EXPECT_EQ(1U, personal_data_->GetProfiles().size()); AutofillProfile new_verified_profile = profile; new_verified_profile.set_guid(base::GenerateGUID()); @@ -3081,10 +2994,7 @@ personal_data_->SaveImportedProfile(new_verified_profile); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // The new profile should be merged into the existing one. const std::vector<AutofillProfile*>& results = personal_data_->GetProfiles(); @@ -3109,10 +3019,9 @@ // Add the credit card to the database. personal_data_->AddCreditCard(credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + // Make sure everything is set up correctly. + WaitForOnPersonalDataChanged(); + EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); CreditCard new_verified_card = credit_card; new_verified_card.set_guid(base::GenerateGUID()); @@ -3122,10 +3031,7 @@ personal_data_->SaveImportedCreditCard(new_verified_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Expect that the saved credit card is updated. const std::vector<CreditCard*>& results = personal_data_->GetCreditCards(); @@ -3149,10 +3055,9 @@ personal_data_->AddProfile(profile0); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + // Make sure everything is set up correctly. + WaitForOnPersonalDataChanged(); + EXPECT_EQ(1U, personal_data_->GetProfiles().size()); personal_data_->GetNonEmptyTypes(&non_empty_types); EXPECT_EQ(15U, non_empty_types.size()); @@ -3188,10 +3093,8 @@ personal_data_->AddProfile(profile1); personal_data_->AddProfile(profile2); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(3U, personal_data_->GetProfiles().size()); personal_data_->GetNonEmptyTypes(&non_empty_types); EXPECT_EQ(19U, non_empty_types.size()); @@ -3218,13 +3121,11 @@ // Test with credit card information also stored. CreditCard credit_card(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&credit_card, "John Dillinger", - "423456789012" /* Visa */, "01", "2999", ""); + "4234567890123456" /* Visa */, "01", "2999", ""); personal_data_->AddCreditCard(credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); personal_data_->GetNonEmptyTypes(&non_empty_types); EXPECT_EQ(29U, non_empty_types.size()); @@ -3345,9 +3246,11 @@ "", "1 Taiga TKTR", "", "Calgary", "AB", "T2B 2K2", "CA", "(800) 555-9000"); personal_data_->AddProfile(moose); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + + // Make sure everything is set up correctly. + WaitForOnPersonalDataChanged(); + EXPECT_EQ(1U, personal_data_->GetProfiles().size()); + // The value is cached and doesn't change even after adding an address. EXPECT_EQ(default_country, personal_data_->GetDefaultCountryCodeForNewAddress()); @@ -3429,16 +3332,15 @@ "91601", "US", "12345678910"); personal_data_->AddProfile(profile); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + // Make sure everything is set up correctly. + WaitForOnPersonalDataChanged(); + EXPECT_EQ(1U, personal_data_->web_profiles().size()); + EXPECT_EQ(1U, personal_data_->GetProfiles().size()); profile.set_language_code("en"); personal_data_->UpdateProfile(profile); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); const std::vector<AutofillProfile*>& results = personal_data_->GetProfiles(); ASSERT_EQ(1U, results.size()); @@ -3709,10 +3611,11 @@ server_cards.back().SetNetworkForMaskedCard(kVisaCard); test::SetServerCreditCards(autofill_table_, server_cards); + + // Make sure everything is set up correctly. personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions(AutofillType(CREDIT_CARD_NUMBER), @@ -3724,7 +3627,7 @@ // Test that local credit cards are ordered as expected. TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions_LocalCardsRanking) { - SetupReferenceLocalCreditCards(); + SetUpReferenceLocalCreditCards(); // Sublabel is card number when filling name (exact format depends on // the platform, but the last 4 digits should appear). @@ -3736,13 +3639,13 @@ // Ordered as expected. EXPECT_EQ(base::ASCIIToUTF16("John Dillinger"), suggestions[0].value); - EXPECT_TRUE(suggestions[0].label.find(base::ASCIIToUTF16("9012")) != + EXPECT_TRUE(suggestions[0].label.find(base::ASCIIToUTF16("3456")) != base::string16::npos); EXPECT_EQ(base::ASCIIToUTF16("Clyde Barrow"), suggestions[1].value); - EXPECT_TRUE(suggestions[1].label.find(base::ASCIIToUTF16("8555")) != + EXPECT_TRUE(suggestions[1].label.find(base::ASCIIToUTF16("0005")) != base::string16::npos); EXPECT_EQ(base::ASCIIToUTF16("Bonnie Parker"), suggestions[2].value); - EXPECT_TRUE(suggestions[2].label.find(base::ASCIIToUTF16("2109")) != + EXPECT_TRUE(suggestions[2].label.find(base::ASCIIToUTF16("5100")) != base::string16::npos); } @@ -3750,7 +3653,7 @@ TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions_LocalAndServerCardsRanking) { EnableWalletCardImport(); - SetupReferenceLocalCreditCards(); + SetUpReferenceLocalCreditCards(); // Add some server cards. std::vector<CreditCard> server_cards; @@ -3770,10 +3673,11 @@ base::TimeDelta::FromDays(1)); test::SetServerCreditCards(autofill_table_, server_cards); + + // Make sure everything is set up correctly. personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(5U, personal_data_->GetCreditCards().size()); std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( @@ -3798,15 +3702,16 @@ CreditCard credit_card0("002149C1-EE28-4213-A3B9-DA243FFF021B", "https://www.example.com"); test::SetCreditCardInfo(&credit_card0, "Bonnie Parker", - "518765432109" /* Mastercard */, "04", "2999", "1"); + "5105105105105100" /* Mastercard */, "04", "2999", + "1"); personal_data_->AddCreditCard(credit_card0); // Add an expired card with a higher frecency score. CreditCard credit_card1("287151C8-6AB1-487C-9095-28E80BE5DA15", "https://www.example.com"); test::SetCreditCardInfo(&credit_card1, "Clyde Barrow", - "347666888555" /* American Express */, "04", "1999", - "1"); + "378282246310005" /* American Express */, "04", + "1999", "1"); credit_card1.set_use_count(300); credit_card1.set_use_date(AutofillClock::Now() - base::TimeDelta::FromDays(10)); @@ -3819,13 +3724,11 @@ credit_card2.set_use_date(AutofillClock::Now() - base::TimeDelta::FromDays(1)); test::SetCreditCardInfo(&credit_card2, "John Dillinger", - "423456789012" /* Visa */, "01", "1998", "1"); + "4234567890123456" /* Visa */, "01", "1998", "1"); personal_data_->AddCreditCard(credit_card2); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); - + // Make sure everything is set up correctly. + WaitForOnPersonalDataChanged(); ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); std::vector<Suggestion> suggestions = @@ -3851,8 +3754,8 @@ CreditCard credit_card0("287151C8-6AB1-487C-9095-28E80BE5DA15", "https://www.example.com"); test::SetCreditCardInfo(&credit_card0, "Clyde Barrow", - "347666888555" /* American Express */, "04", "2999", - "1"); + "378282246310005" /* American Express */, "04", + "2999", "1"); credit_card0.set_use_count(3); credit_card0.set_use_date(AutofillClock::Now() - base::TimeDelta::FromDays(1)); @@ -3867,10 +3770,8 @@ "1"); personal_data_->AddCreditCard(credit_card1); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); - + // Make sure everything is set up correctly. + WaitForOnPersonalDataChanged(); ASSERT_EQ(2U, personal_data_->GetCreditCards().size()); // Sublabel is expiration date when filling card number. The second card @@ -3881,7 +3782,7 @@ /* field_contents= */ base::string16()); ASSERT_EQ(1U, suggestions.size()); EXPECT_EQ( - base::UTF8ToUTF16(std::string("Amex") + kUTF8MidlineEllipsis + "8555"), + base::UTF8ToUTF16(std::string("Amex") + kUTF8MidlineEllipsis + "0005"), suggestions[0].value); EXPECT_EQ(base::ASCIIToUTF16("04/99"), suggestions[0].label); } @@ -3889,7 +3790,7 @@ // Tests the suggestions of duplicate local and server credit cards. TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions_ServerDuplicates) { EnableWalletCardImport(); - SetupReferenceLocalCreditCards(); + SetUpReferenceLocalCreditCards(); // Add some server cards. If there are local dupes, the locals should be // hidden. @@ -3899,7 +3800,7 @@ // suggestions since the locally saved card takes precedence. server_cards.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "a123")); test::SetCreditCardInfo(&server_cards.back(), "John Dillinger", - "9012" /* Visa */, "01", "2999", "1"); + "3456" /* Visa */, "01", "2999", "1"); server_cards.back().set_use_count(2); server_cards.back().set_use_date(AutofillClock::Now() - base::TimeDelta::FromDays(15)); @@ -3908,7 +3809,7 @@ // This server card is identical to a local card, but has a different // card type. Not a dupe and therefore both should appear in the suggestions. server_cards.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "b456")); - test::SetCreditCardInfo(&server_cards.back(), "Bonnie Parker", "2109", "12", + test::SetCreditCardInfo(&server_cards.back(), "Bonnie Parker", "5100", "12", "2999", "1"); server_cards.back().set_use_count(3); server_cards.back().set_use_date(AutofillClock::Now() - @@ -3920,17 +3821,18 @@ // precedence over local cards. server_cards.push_back(CreditCard(CreditCard::FULL_SERVER_CARD, "c789")); test::SetCreditCardInfo(&server_cards.back(), "Clyde Barrow", - "347666888555" /* American Express */, "04", "2999", - "1"); + "378282246310005" /* American Express */, "04", + "2999", "1"); server_cards.back().set_use_count(1); server_cards.back().set_use_date(AutofillClock::Now() - base::TimeDelta::FromDays(15)); test::SetServerCreditCards(autofill_table_, server_cards); + + // Make sure everything is set up correctly. personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(6U, personal_data_->GetCreditCards().size()); std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( @@ -3946,16 +3848,16 @@ AutofillType(CREDIT_CARD_NUMBER), /* field_contents= */ base::string16()); ASSERT_EQ(4U, suggestions.size()); EXPECT_EQ( - base::UTF8ToUTF16(std::string("Visa") + kUTF8MidlineEllipsis + "9012"), + base::UTF8ToUTF16(std::string("Visa") + kUTF8MidlineEllipsis + "3456"), suggestions[0].value); EXPECT_EQ( - base::UTF8ToUTF16(std::string("Amex") + kUTF8MidlineEllipsis + "8555"), + base::UTF8ToUTF16(std::string("Amex") + kUTF8MidlineEllipsis + "0005"), suggestions[1].value); EXPECT_EQ(base::UTF8ToUTF16(std::string("Mastercard") + kUTF8MidlineEllipsis + - "2109"), + "5100"), suggestions[2].value); EXPECT_EQ( - base::UTF8ToUTF16(std::string("Visa") + kUTF8MidlineEllipsis + "2109"), + base::UTF8ToUTF16(std::string("Visa") + kUTF8MidlineEllipsis + "5100"), suggestions[3].value); } @@ -3963,7 +3865,7 @@ TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions_ServerCardDuplicateOfMultipleLocalCards) { EnableWalletCardImport(); - SetupReferenceLocalCreditCards(); + SetUpReferenceLocalCreditCards(); // Add a duplicate server card. std::vector<CreditCard> server_cards; @@ -3971,14 +3873,15 @@ // the local card should appear in the suggestions. server_cards.push_back(CreditCard(CreditCard::FULL_SERVER_CARD, "c789")); test::SetCreditCardInfo(&server_cards.back(), "Clyde Barrow", - "347666888555" /* American Express */, "04", "2999", - "1"); + "378282246310005" /* American Express */, "04", + "2999", "1"); test::SetServerCreditCards(autofill_table_, server_cards); + + // Make sure everything is set up correctly. personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(4U, personal_data_->GetCreditCards().size()); std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( @@ -3993,9 +3896,7 @@ test::SetCreditCardInfo(&credit_card3, "Clyde Barrow", "", "04", "", ""); personal_data_->AddCreditCard(credit_card3); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); suggestions = personal_data_->GetCreditCardSuggestions( AutofillType(CREDIT_CARD_NAME_FULL), @@ -4003,7 +3904,7 @@ ASSERT_EQ(3U, suggestions.size()); } -// Tests that server cards will shown bank name when bank name available and +// Tests that server cards will show bank name when bank name is available and // feature flag on. TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions_ShowBankNameOfServerCards) { @@ -4017,8 +3918,8 @@ CreditCard credit_card0("287151C8-6AB1-487C-9095-28E80BE5DA15", "https://www.example.com"); test::SetCreditCardInfo(&credit_card0, "Clyde Barrow", - "347666888555" /* American Express */, "04", "2999", - "1"); + "378282246310005" /* American Express */, "04", + "2999", "1"); credit_card0.set_use_count(3); credit_card0.set_use_date(AutofillClock::Now() - base::TimeDelta::FromDays(1)); @@ -4047,9 +3948,10 @@ test::SetServerCreditCards(autofill_table_, server_cards); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + // Make sure everything is set up correctly. + personal_data_->Refresh(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(3U, personal_data_->GetCreditCards().size()); std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( @@ -4059,7 +3961,7 @@ // Local cards will show network. EXPECT_EQ( - base::UTF8ToUTF16(std::string("Amex") + kUTF8MidlineEllipsis + "8555"), + base::UTF8ToUTF16(std::string("Amex") + kUTF8MidlineEllipsis + "0005"), suggestions[0].value); // Server card without bank name will show network. EXPECT_EQ( @@ -4081,7 +3983,7 @@ CreditCard local_card("287151C8-6AB1-487C-9095-28E80BE5DA15", "https://www.example.com"); test::SetCreditCardInfo(&local_card, "Homer Simpson", - "423456789012" /* Visa */, "01", "2999", "1"); + "4234567890123456" /* Visa */, "01", "2999", "1"); local_card.set_use_count(3); local_card.set_use_date(AutofillClock::Now() - base::TimeDelta::FromDays(1)); credit_cards.push_back(&local_card); @@ -4089,7 +3991,7 @@ // Create a full server card that is a duplicate of one of the local cards. CreditCard full_server_card(CreditCard::FULL_SERVER_CARD, "c789"); test::SetCreditCardInfo(&full_server_card, "Homer Simpson", - "423456789012" /* Visa */, "01", "2999", "1"); + "4234567890123456" /* Visa */, "01", "2999", "1"); full_server_card.set_use_count(1); full_server_card.set_use_date(AutofillClock::Now() - base::TimeDelta::FromDays(15)); @@ -4112,12 +4014,12 @@ local_card.set_use_count(300); local_card.set_use_date(AutofillClock::Now() - base::TimeDelta::FromDays(10)); test::SetCreditCardInfo(&local_card, "Homer Simpson", - "423456789012" /* Visa */, "01", "2999", "1"); + "4234567890123456" /* Visa */, "01", "2999", "1"); credit_cards.push_back(&local_card); // Create a masked server card that is a duplicate of a local card. CreditCard masked_card(CreditCard::MASKED_SERVER_CARD, "a123"); - test::SetCreditCardInfo(&masked_card, "Homer Simpson", "9012" /* Visa */, + test::SetCreditCardInfo(&masked_card, "Homer Simpson", "3456" /* Visa */, "01", "2999", "1"); masked_card.set_use_count(2); masked_card.set_use_date(AutofillClock::Now() - @@ -4139,7 +4041,7 @@ // Create a full server card that is a duplicate of one of the local cards. CreditCard full_server_card(CreditCard::FULL_SERVER_CARD, "c789"); test::SetCreditCardInfo(&full_server_card, "Homer Simpson", - "423456789012" /* Visa */, "01", "2999", "1"); + "4234567890123456" /* Visa */, "01", "2999", "1"); full_server_card.set_use_count(1); full_server_card.set_use_date(AutofillClock::Now() - base::TimeDelta::FromDays(15)); @@ -4147,7 +4049,7 @@ // Create a masked server card that is a duplicate of a local card. CreditCard masked_card(CreditCard::MASKED_SERVER_CARD, "a123"); - test::SetCreditCardInfo(&masked_card, "Homer Simpson", "9012" /* Visa */, + test::SetCreditCardInfo(&masked_card, "Homer Simpson", "3456" /* Visa */, "01", "2999", "1"); masked_card.set_use_count(2); masked_card.set_use_date(AutofillClock::Now() - @@ -4170,12 +4072,12 @@ credit_card2.set_use_date(AutofillClock::Now() - base::TimeDelta::FromDays(1)); test::SetCreditCardInfo(&credit_card2, "Homer Simpson", - "518765432109" /* Mastercard */, "", "", ""); + "5105105105105100" /* Mastercard */, "", "", ""); credit_cards.push_back(&credit_card2); // Create a masked server card that is slightly different of the local card. CreditCard credit_card4(CreditCard::MASKED_SERVER_CARD, "b456"); - test::SetCreditCardInfo(&credit_card4, "Homer Simpson", "2109", "12", "2999", + test::SetCreditCardInfo(&credit_card4, "Homer Simpson", "5100", "12", "2999", "1"); credit_card4.set_use_count(3); credit_card4.set_use_date(AutofillClock::Now() - @@ -4187,8 +4089,8 @@ // cards. CreditCard credit_card5(CreditCard::FULL_SERVER_CARD, "c789"); test::SetCreditCardInfo(&credit_card5, "Homer Simpson", - "347666888555" /* American Express */, "04", "2999", - "1"); + "378282246310005" /* American Express */, "04", + "2999", "1"); credit_card5.set_use_count(1); credit_card5.set_use_date(AutofillClock::Now() - base::TimeDelta::FromDays(15)); @@ -4211,15 +4113,15 @@ CreditCard credit_card(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&credit_card, "John Dillinger", - "423456789012" /* Visa */, "01", "2999", "1"); + "4234567890123456" /* Visa */, "01", "2999", "1"); EXPECT_EQ(1U, credit_card.use_count()); EXPECT_EQ(kArbitraryTime, credit_card.use_date()); EXPECT_EQ(kArbitraryTime, credit_card.modification_date()); personal_data_->AddCreditCard(credit_card); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + // Make sure everything is set up correctly. + WaitForOnPersonalDataChanged(); + EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); // Set the current time to another value. test_clock.SetNow(kSomeLaterTime); @@ -4243,9 +4145,7 @@ EXPECT_EQ(kArbitraryTime, added_card->modification_date()); personal_data_->RecordUseOf(credit_card); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Verify usage stats are updated. added_profile = personal_data_->GetProfileByGUID(profile.guid()); @@ -4267,7 +4167,7 @@ std::vector<CreditCard> server_cards; server_cards.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "a123")); test::SetCreditCardInfo(&server_cards.back(), "John Dillinger", - "9012" /* Visa */, "01", "2999", "1"); + "3456" /* Visa */, "01", "2999", "1"); server_cards.back().SetNetworkForMaskedCard(kVisaCard); server_cards.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "b456")); @@ -4277,21 +4177,19 @@ server_cards.push_back(CreditCard(CreditCard::FULL_SERVER_CARD, "c789")); test::SetCreditCardInfo(&server_cards.back(), "Clyde Barrow", - "347666888555" /* American Express */, "04", "2999", - "1"); + "378282246310005" /* American Express */, "04", + "2999", "1"); // Create the test clock and set the time to a specific value. TestAutofillClock test_clock; test_clock.SetNow(kArbitraryTime); test::SetServerCreditCards(autofill_table_, server_cards); + + // Make sure everything is set up correctly. personal_data_->Refresh(); - - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); - - ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(3U, personal_data_->GetCreditCards().size()); if (!OfferStoreUnmaskedCards()) { for (CreditCard* card : personal_data_->GetCreditCards()) { @@ -4308,14 +4206,12 @@ CreditCard* unmasked_card = &server_cards.front(); unmasked_card->set_record_type(CreditCard::FULL_SERVER_CARD); - unmasked_card->SetNumber(base::ASCIIToUTF16("423456789012")); + unmasked_card->SetNumber(base::ASCIIToUTF16("4234567890123456")); EXPECT_NE(0, unmasked_card->Compare( *personal_data_->GetCreditCards().front())); personal_data_->UpdateServerCreditCard(*unmasked_card); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); for (size_t i = 0; i < 3; ++i) @@ -4340,11 +4236,9 @@ server_cards.back().set_guid(personal_data_->GetCreditCards()[2]->guid()); personal_data_->RecordUseOf(server_cards.back()); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); - ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); + WaitForOnPersonalDataChanged(); + ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); EXPECT_EQ(2U, personal_data_->GetCreditCards()[0]->use_count()); EXPECT_EQ(kArbitraryTime, personal_data_->GetCreditCards()[0]->use_date()); @@ -4359,9 +4253,8 @@ // Can record usage stats on masked cards. server_cards[1].set_guid(personal_data_->GetCreditCards()[1]->guid()); personal_data_->RecordUseOf(server_cards[1]); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + + WaitForOnPersonalDataChanged(); ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); EXPECT_EQ(2U, personal_data_->GetCreditCards()[1]->use_count()); EXPECT_EQ(kSomeLaterTime, personal_data_->GetCreditCards()[1]->use_date()); @@ -4377,9 +4270,8 @@ server_cards[1].set_guid(personal_data_->GetCreditCards()[1]->guid()); personal_data_->RecordUseOf(server_cards[1]); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + + WaitForOnPersonalDataChanged(); ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); EXPECT_EQ(3U, personal_data_->GetCreditCards()[1]->use_count()); EXPECT_EQ(kMuchLaterTime, personal_data_->GetCreditCards()[1]->use_date()); @@ -4390,7 +4282,7 @@ std::vector<CreditCard> server_cards; server_cards.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "a123")); test::SetCreditCardInfo(&server_cards.back(), "John Dillinger", - "9012" /* Visa */, "01", "2999", "1"); + "3456" /* Visa */, "01", "2999", "1"); server_cards.back().SetNetworkForMaskedCard(kVisaCard); test::SetServerCreditCards(autofill_table_, server_cards); personal_data_->Refresh(); @@ -4424,14 +4316,15 @@ server_cards.push_back(CreditCard(CreditCard::FULL_SERVER_CARD, "c789")); test::SetCreditCardInfo(&server_cards.back(), "Clyde Barrow", - "347666888555" /* American Express */, "04", "2999", - ""); + "378282246310005" /* American Express */, "04", + "2999", ""); test::SetServerCreditCards(autofill_table_, server_cards); + + // Make sure everything is set up correctly. personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(2U, personal_data_->GetCreditCards().size()); // A valid credit card form. A user re-enters one of their masked cards. // We should offer to save locally so that user can fill future credit card @@ -4460,10 +4353,7 @@ EXPECT_TRUE(imported_credit_card_matches_masked_server_credit_card); personal_data_->SaveImportedCreditCard(*imported_credit_card); - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); CreditCard local_card(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&local_card, "John Dillinger", "4012888888881881", @@ -4486,14 +4376,15 @@ server_cards.push_back(CreditCard(CreditCard::FULL_SERVER_CARD, "c789")); test::SetCreditCardInfo(&server_cards.back(), "Clyde Barrow", - "347666888555" /* American Express */, "04", "2999", - ""); + "378282246310005" /* American Express */, "04", + "2999", ""); test::SetServerCreditCards(autofill_table_, server_cards); + + // Make sure everything is set up correctly. personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(2U, personal_data_->GetCreditCards().size()); // A valid credit card form. A user re-enters one of their masked cards. // We should not offer to save locally because the @@ -4533,14 +4424,15 @@ server_cards.push_back(CreditCard(CreditCard::FULL_SERVER_CARD, "c789")); test::SetCreditCardInfo(&server_cards.back(), "Clyde Barrow", - "347666888555" /* American Express */, "04", "2999", - "1"); + "378282246310005" /* American Express */, "04", + "2999", "1"); test::SetServerCreditCards(autofill_table_, server_cards); + + // Make sure everything is set up correctly. personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(2U, personal_data_->GetCreditCards().size()); // A user re-types (or fills with) an unmasked card. Don't offer to save // here, either. Since it's unmasked, we know for certain that it's the same @@ -4550,7 +4442,7 @@ test::CreateTestFormField("Name on card:", "name_on_card", "Clyde Barrow", "text", &field); form.fields.push_back(field); - test::CreateTestFormField("Card Number:", "card_number", "347666888555", + test::CreateTestFormField("Card Number:", "card_number", "378282246310005", "text", &field); form.fields.push_back(field); test::CreateTestFormField("Exp Month:", "exp_month", "04", "text", &field); @@ -4579,10 +4471,11 @@ "4444333322221111" /* Visa */, "04", "2111", "1"); test::SetServerCreditCards(autofill_table_, server_cards); + + // Make sure everything is set up correctly. personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); // A user fills/enters the card's information on a checkout form. Ensure that // an expiration date match is recorded. @@ -4624,10 +4517,11 @@ "4444333322221111" /* Visa */, "04", "2111", "1"); test::SetServerCreditCards(autofill_table_, server_cards); + + // Make sure everything is set up correctly. personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); // A user fills/enters the card's information on a checkout form but changes // the expiration date of the card. Ensure that an expiration date mismatch @@ -4671,10 +4565,11 @@ server_cards.back().SetNetworkForMaskedCard(kVisaCard); test::SetServerCreditCards(autofill_table_, server_cards); + + // Make sure everything is set up correctly. personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); // A user fills/enters the card's information on a checkout form. Ensure that // an expiration date match is recorded. @@ -4717,10 +4612,11 @@ server_cards.back().SetNetworkForMaskedCard(kVisaCard); test::SetServerCreditCards(autofill_table_, server_cards); + + // Make sure everything is set up correctly. personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); // A user fills/enters the card's information on a checkout form but changes // the expiration date of the card. Ensure that an expiration date mismatch @@ -4790,7 +4686,7 @@ new WebDatabaseService(path, base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get()); - // Setup account tracker. + // Set up account tracker. signin_client_.reset(new TestSigninClient(prefs_.get())); account_tracker_.reset(new AccountTrackerService()); account_tracker_->Initialize(signin_client_.get()); @@ -4840,7 +4736,7 @@ // Set the time to a specific value. test_clock.SetNow(kArbitraryTime); - SetupReferenceProfile(); + SetUpReferenceProfile(); const std::vector<AutofillProfile*>& initial_profiles = personal_data_->GetProfiles(); @@ -5539,18 +5435,19 @@ // verifying results. CreditCard credit_card1(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&credit_card1, "Clyde Barrow", - "347666888555" /* American Express */, "04", "2999", - "1"); + "378282246310005" /* American Express */, "04", + "2999", "1"); credit_card1.set_use_count(10); CreditCard credit_card2(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&credit_card2, "John Dillinger", - "423456789012" /* Visa */, "01", "2999", "1"); + "4234567890123456" /* Visa */, "01", "2999", "1"); credit_card2.set_use_count(5); CreditCard credit_card3(base::GenerateGUID(), "https://www.example.com"); test::SetCreditCardInfo(&credit_card3, "Bonnie Parker", - "518765432109" /* Mastercard */, "12", "2999", "1"); + "5105105105105100" /* Mastercard */, "12", "2999", + "1"); credit_card3.set_use_count(1); // Associate the first card with profile1. @@ -5569,9 +5466,8 @@ personal_data_->AddCreditCard(credit_card1); personal_data_->AddCreditCard(credit_card2); personal_data_->AddCreditCard(credit_card3); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + + WaitForOnPersonalDataChanged(); // Make sure the 6 profiles and 3 credit cards were saved. EXPECT_EQ(6U, personal_data_->GetProfiles().size()); @@ -5582,9 +5478,7 @@ EnableAutofillProfileCleanup(); EXPECT_TRUE(personal_data_->ApplyDedupingRoutine()); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Get the profiles and cards sorted by frecency to have a deterministic // order. @@ -5645,9 +5539,8 @@ personal_data_->AddProfile(profile1); personal_data_->AddProfile(profile2); personal_data_->AddProfile(profile3); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + + WaitForOnPersonalDataChanged(); // Make sure the 3 profiles were saved; EXPECT_EQ(3U, personal_data_->GetProfiles().size()); @@ -5659,9 +5552,7 @@ base::HistogramTester histogram_tester; EXPECT_TRUE(personal_data_->ApplyDedupingRoutine()); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); std::vector<AutofillProfile*> profiles = personal_data_->GetProfiles(); @@ -5738,9 +5629,8 @@ personal_data_->AddProfile(profile1); personal_data_->AddProfile(profile2); personal_data_->AddProfile(profile3); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + + WaitForOnPersonalDataChanged(); // Make sure the 3 profiles were saved. EXPECT_EQ(3U, personal_data_->GetProfiles().size()); @@ -5752,9 +5642,7 @@ base::HistogramTester histogram_tester; EXPECT_TRUE(personal_data_->ApplyDedupingRoutine()); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); std::vector<AutofillProfile*> profiles = personal_data_->GetProfiles(); @@ -5807,9 +5695,8 @@ personal_data_->AddProfile(profile1); personal_data_->AddProfile(profile2); personal_data_->AddProfile(profile3); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + + WaitForOnPersonalDataChanged(); // Make sure the 3 profiles were saved. EXPECT_EQ(3U, personal_data_->GetProfiles().size()); @@ -5821,9 +5708,7 @@ base::HistogramTester histogram_tester; EXPECT_TRUE(personal_data_->ApplyDedupingRoutine()); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); std::vector<AutofillProfile*> profiles = personal_data_->GetProfiles(); @@ -5875,9 +5760,8 @@ personal_data_->AddProfile(profile1); personal_data_->AddProfile(profile2); personal_data_->AddProfile(profile3); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + + WaitForOnPersonalDataChanged(); // Make sure the 3 profiles were saved. EXPECT_EQ(3U, personal_data_->GetProfiles().size()); @@ -5889,9 +5773,7 @@ base::HistogramTester histogram_tester; EXPECT_TRUE(personal_data_->ApplyDedupingRoutine()); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Get the profiles, sorted by frecency to have a deterministic order. std::vector<AutofillProfile*> profiles = @@ -5946,9 +5828,9 @@ personal_data_->AddProfile(profile1); personal_data_->AddProfile(profile2); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + + WaitForOnPersonalDataChanged(); + EXPECT_EQ(2U, personal_data_->GetProfiles().size()); // Get a sorted list of profiles. |profile1| will be first and |profile2| will // be second. @@ -5970,9 +5852,7 @@ test_clock.SetNow(kSomeLaterTime); personal_data_->ApplyProfileUseDatesFix(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Get a sorted list of profiles. saved_profiles = personal_data_->GetProfilesToSuggest(); @@ -6009,9 +5889,8 @@ personal_data_->AddProfile(profile1); personal_data_->AddProfile(profile2); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); + EXPECT_EQ(2U, personal_data_->GetProfiles().size()); // Get a sorted list of profiles. |profile1| will be first and |profile2| will // be second. @@ -6097,9 +5976,8 @@ personal_data_->AddProfile(Marge1); personal_data_->AddProfile(Marge2); personal_data_->AddProfile(Barney); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + + WaitForOnPersonalDataChanged(); // Make sure the 7 profiles were saved; EXPECT_EQ(7U, personal_data_->GetProfiles().size()); @@ -6114,9 +5992,7 @@ // |Homer3|. |Marge2| should be discarded in favor of |Marge1| which is // verified. |Homer4| and |Barney| should not be deduped at all. EXPECT_TRUE(personal_data_->ApplyDedupingRoutine()); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Get the profiles, sorted by frecency to have a deterministic order. std::vector<AutofillProfile*> profiles = @@ -6187,9 +6063,7 @@ personal_data_->AddProfile(profile1); personal_data_->AddProfile(profile2); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Make sure both profiles were saved. EXPECT_EQ(2U, personal_data_->GetProfiles().size()); @@ -6215,10 +6089,8 @@ "", "Springfield", "IL", "91601", "US", ""); personal_data_->AddProfile(profile); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); EXPECT_EQ(1U, personal_data_->GetProfiles().size()); // Enable the profile cleanup now. Otherwise it would be triggered by the @@ -6244,10 +6116,8 @@ personal_data_->AddProfile(profile1); personal_data_->AddProfile(profile2); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); EXPECT_EQ(2U, personal_data_->GetProfiles().size()); // Enable the profile cleanup now. Otherwise it would be triggered by the @@ -6256,9 +6126,7 @@ // The deduping routine should be run a first time. EXPECT_TRUE(personal_data_->ApplyDedupingRoutine()); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); std::vector<AutofillProfile*> profiles = personal_data_->GetProfiles(); @@ -6272,9 +6140,7 @@ "", "Springfield", "IL", "91601", "", ""); personal_data_->AddProfile(profile3); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Make sure |profile3| was saved. EXPECT_EQ(2U, personal_data_->GetProfiles().size()); @@ -6331,8 +6197,8 @@ CreditCard local_card("287151C8-6AB1-487C-9095-28E80BE5DA15", "https://www.example.com"); test::SetCreditCardInfo(&local_card, "Clyde Barrow", - "347666888555" /* American Express */, "04", "2999", - "1"); + "378282246310005" /* American Express */, "04", + "2999", "1"); local_card.set_billing_address_id(kServerAddressId); personal_data_->AddCreditCard(local_card); @@ -6345,11 +6211,9 @@ server_cards.back().set_billing_address_id(kServerAddressId); test::SetServerCreditCards(autofill_table_, server_cards); - // Make sure everything is setup correctly. + // Make sure everything is set up correctly. personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); EXPECT_EQ(1U, personal_data_->web_profiles().size()); EXPECT_EQ(1U, personal_data_->GetServerProfiles().size()); EXPECT_EQ(2U, personal_data_->GetCreditCards().size()); @@ -6362,9 +6226,7 @@ /////////////////////////////////////////////////////////////////////// // Validation. /////////////////////////////////////////////////////////////////////// - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // The Wallet address should have been added as a new local profile. EXPECT_EQ(2U, personal_data_->web_profiles().size()); @@ -6440,8 +6302,8 @@ CreditCard local_card("287151C8-6AB1-487C-9095-28E80BE5DA15", "https://www.example.com"); test::SetCreditCardInfo(&local_card, "Clyde Barrow", - "347666888555" /* American Express */, "04", "2999", - "1"); + "378282246310005" /* American Express */, "04", + "2999", "1"); local_card.set_billing_address_id(kServerAddressId); personal_data_->AddCreditCard(local_card); @@ -6454,11 +6316,9 @@ server_cards.back().set_billing_address_id(kServerAddressId); test::SetServerCreditCards(autofill_table_, server_cards); - // Make sure everything is setup correctly. + // Make sure everything is set up correctly. personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); EXPECT_EQ(1U, personal_data_->web_profiles().size()); EXPECT_EQ(1U, personal_data_->GetServerProfiles().size()); EXPECT_EQ(2U, personal_data_->GetCreditCards().size()); @@ -6471,9 +6331,7 @@ /////////////////////////////////////////////////////////////////////// // Validation. /////////////////////////////////////////////////////////////////////// - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // The Wallet address should have been merged with the existing local profile. EXPECT_EQ(1U, personal_data_->web_profiles().size()); @@ -6530,11 +6388,9 @@ // will be ignored when the profile is written to the DB. autofill_table_->SetServerProfiles(GetServerProfiles); - // Make sure everything is setup correctly. + // Make sure everything is set up correctly. personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); EXPECT_EQ(0U, personal_data_->web_profiles().size()); EXPECT_EQ(1U, personal_data_->GetServerProfiles().size()); @@ -6551,9 +6407,7 @@ EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()).Times(0); personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // There should be no local profiles added. EXPECT_EQ(0U, personal_data_->web_profiles().size()); @@ -6616,8 +6470,8 @@ CreditCard local_card("287151C8-6AB1-487C-9095-28E80BE5DA15", "https://www.example.com"); test::SetCreditCardInfo(&local_card, "Clyde Barrow", - "347666888555" /* American Express */, "04", "2999", - "1"); + "378282246310005" /* American Express */, "04", + "2999", "1"); local_card.set_billing_address_id(kServerAddressId); personal_data_->AddCreditCard(local_card); @@ -6630,11 +6484,9 @@ server_cards.back().set_billing_address_id(kServerAddressId2); test::SetServerCreditCards(autofill_table_, server_cards); - // Make sure everything is setup correctly. + // Make sure everything is set up correctly. personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); EXPECT_EQ(1U, personal_data_->web_profiles().size()); EXPECT_EQ(2U, personal_data_->GetServerProfiles().size()); EXPECT_EQ(2U, personal_data_->GetCreditCards().size()); @@ -6647,9 +6499,7 @@ /////////////////////////////////////////////////////////////////////// // Validation. /////////////////////////////////////////////////////////////////////// - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // The first Wallet address should have been added as a new local profile and // the second one should have merged with the first. @@ -6727,20 +6577,16 @@ server_cards.back().set_billing_address_id(kServerAddressId); test::SetServerCreditCards(autofill_table_, server_cards); - // Make sure everything is setup correctly. + // Make sure everything is set up correctly. personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); EXPECT_EQ(1U, personal_data_->GetServerProfiles().size()); EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); // Run the conversion. personal_data_->ConvertWalletAddressesAndUpdateWalletCards(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // The Wallet address should have been converted to a new local profile. EXPECT_EQ(1U, personal_data_->web_profiles().size()); @@ -6765,11 +6611,9 @@ server_cards.back().set_billing_address_id(kServerAddressId); test::SetServerCreditCards(autofill_table_, server_cards); - // Make sure everything is setup correctly. + // Make sure everything is set up correctly. personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); EXPECT_EQ(1U, personal_data_->web_profiles().size()); EXPECT_EQ(2U, personal_data_->GetCreditCards().size()); @@ -6781,9 +6625,7 @@ /////////////////////////////////////////////////////////////////////// // Validation. /////////////////////////////////////////////////////////////////////// - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // The conversion should still be recorded in the Wallet address. EXPECT_TRUE(personal_data_->GetServerProfiles().back()->has_converted()); @@ -6827,8 +6669,8 @@ profile0.guid()); CreditCard server_card0(CreditCard::FULL_SERVER_CARD, "c789"); test::SetCreditCardInfo(&server_card0, "John Barrow", - "347666888555" /* American Express */, "04", "2999", - profile0.guid()); + "378282246310005" /* American Express */, "04", + "2999", profile0.guid()); server_cards.push_back(server_card0); // Do the same but for profile1. @@ -6838,8 +6680,8 @@ profile1.guid()); CreditCard server_card1(CreditCard::FULL_SERVER_CARD, "c789"); test::SetCreditCardInfo(&server_card1, "John Barrow", - "347666888555" /* American Express */, "04", "2999", - profile1.guid()); + "378282246310005" /* American Express */, "04", + "2999", profile1.guid()); server_cards.push_back(server_card1); // Add the data to the database. @@ -6849,10 +6691,9 @@ personal_data_->AddCreditCard(local_card1); test::SetServerCreditCards(autofill_table_, server_cards); + // Verify that the web database has been updated and the notification sent. personal_data_->Refresh(); - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Make sure everything was saved properly. EXPECT_EQ(2U, personal_data_->GetProfiles().size()); @@ -6868,9 +6709,7 @@ /////////////////////////////////////////////////////////////////////// // Wait for the data to be refreshed. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::RunLoop().Run(); + WaitForOnPersonalDataChanged(); // Make sure only profile0 was deleted. ASSERT_EQ(1U, personal_data_->GetProfiles().size()); @@ -6943,7 +6782,7 @@ const base::Time kNow = AutofillClock::Now(); constexpr size_t kNumProfiles = 10; - // Setup the profile vectors with last use dates ranging from |now| to 270 + // Set up the profile vectors with last use dates ranging from |now| to 270 // days ago, in 30 day increments. Note that the profiles are sorted by // decreasing last use date. std::vector<AutofillProfile> all_profile_data;
diff --git a/components/cdm/browser/media_drm_storage_impl.cc b/components/cdm/browser/media_drm_storage_impl.cc index 2f9ee4f..6660263 100644 --- a/components/cdm/browser/media_drm_storage_impl.cc +++ b/components/cdm/browser/media_drm_storage_impl.cc
@@ -6,6 +6,7 @@ #include "base/logging.h" #include "base/memory/ptr_util.h" +#include "base/value_conversions.h" #include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_service.h" #include "components/prefs/scoped_user_pref_update.h" @@ -17,7 +18,7 @@ // // { // $origin: { -// "origin_id": $origin_id +// "origin_id": $unguessable_origin_id // "creation_time": $creation_time // "sessions" : { // $session_id: { @@ -40,13 +41,7 @@ const char kSessions[] = "sessions"; const char kKeySetId[] = "key_set_id"; const char kMimeType[] = "mime_type"; - -std::unique_ptr<base::DictionaryValue> CreateOriginDictionary() { - auto dict = base::MakeUnique<base::DictionaryValue>(); - // TODO(xhwang): Create |origin_id|. - dict->SetDouble(kCreationTime, base::Time::Now().ToDoubleT()); - return dict; -} +const char kOriginId[] = "origin_id"; std::unique_ptr<base::DictionaryValue> CreateSessionDictionary( const std::vector<uint8_t>& key_set_id, @@ -74,6 +69,47 @@ return true; } +// Return the origin ID stored in |origin_dict|. Return empty ID if: +// 1. Origin ID doesn't exist, which may happen if the origin map is created +// with an older version app. +// 2. Data format is incorrect. +base::UnguessableToken GetOriginId(const base::DictionaryValue* origin_dict) { + DCHECK(origin_dict); + + const base::Value* origin_id_value = nullptr; + if (!origin_dict->Get(kOriginId, &origin_id_value)) { + return base::UnguessableToken(); + } + + DCHECK(origin_id_value); + + base::UnguessableToken origin_id; + if (!base::GetValueAsUnguessableToken(*origin_id_value, &origin_id)) { + return base::UnguessableToken(); + } + + return origin_id; +} + +void SetOriginId(base::DictionaryValue* origin_dict, + const base::UnguessableToken& origin_id) { + DCHECK(origin_dict); + DCHECK(!origin_dict->HasKey(kOriginId)); + DCHECK(origin_id); + + origin_dict->Set(kOriginId, base::CreateUnguessableTokenValue(origin_id)); +} + +std::unique_ptr<base::DictionaryValue> CreateOriginDictionary( + const base::UnguessableToken& origin_id) { + DCHECK(origin_id); + + auto dict = base::MakeUnique<base::DictionaryValue>(); + dict->SetDouble(kCreationTime, base::Time::Now().ToDoubleT()); + SetOriginId(dict.get(), origin_id); + return dict; +} + #if DCHECK_IS_ON() // Returns whether |dict| has a value assocaited with the |key|. bool HasEntry(const base::DictionaryValue& dict, const std::string& key) { @@ -95,7 +131,6 @@ media::mojom::MediaDrmStorageRequest request) : render_frame_host_(render_frame_host), pref_service_(pref_service), - origin_(origin), origin_string_(origin.Serialize()), binding_(this, std::move(request)) { DVLOG(1) << __func__ << ": origin = " << origin; @@ -113,21 +148,43 @@ DCHECK(thread_checker_.CalledOnValidThread()); } -// TODO(xhwang): Update this function to return an origin ID. If the origin is -// not the same as |origin_|, return an empty origin ID. -void MediaDrmStorageImpl::Initialize(const url::Origin& origin) { - DVLOG(1) << __func__ << ": origin = " << origin; +void MediaDrmStorageImpl::Initialize(InitializeCallback callback) { + DVLOG(1) << __func__ << ": origin = " << origin_string_; DCHECK(thread_checker_.CalledOnValidThread()); - DCHECK(!initialized_); + DCHECK(!origin_id_); - initialized_ = true; + DictionaryPrefUpdate update(pref_service_, kMediaDrmStorage); + base::DictionaryValue* storage_dict = update.Get(); + DCHECK(storage_dict); + + base::DictionaryValue* origin_dict = nullptr; + // The origin string may contain dots. Do not use path expansion. + bool exist = storage_dict->GetDictionaryWithoutPathExpansion(origin_string_, + &origin_dict); + + base::UnguessableToken origin_id; + if (exist) { + DCHECK(origin_dict); + origin_id = GetOriginId(origin_dict); + } + + // |origin_id| can be empty even if |origin_dict| exists. This can happen if + // |origin_dict| is created with an old version app. + if (origin_id.is_empty()) { + origin_id = base::UnguessableToken::Create(); + } + + origin_id_ = origin_id; + + DCHECK(origin_id); + std::move(callback).Run(origin_id); } void MediaDrmStorageImpl::OnProvisioned(OnProvisionedCallback callback) { DVLOG(1) << __func__; DCHECK(thread_checker_.CalledOnValidThread()); - if (!initialized_) { + if (!IsInitialized()) { DVLOG(1) << __func__ << ": Not initialized."; std::move(callback).Run(false); return; @@ -143,7 +200,7 @@ << " already exists and will be cleared"; storage_dict->SetWithoutPathExpansion(origin_string_, - CreateOriginDictionary()); + CreateOriginDictionary(origin_id_)); std::move(callback).Run(true); } @@ -154,7 +211,7 @@ DVLOG(2) << __func__; DCHECK(thread_checker_.CalledOnValidThread()); - if (!initialized_) { + if (!IsInitialized()) { DVLOG(1) << __func__ << ": Not initialized."; std::move(callback).Run(false); return; @@ -170,12 +227,14 @@ // This could happen if the profile is removed, but the device is still // provisioned for the origin. In this case, just create a new entry. + // Since we're using random origin ID in MediaDrm, it's rare to enter the if + // branch. Deleting the profile causes reprovisioning of the origin. if (!origin_dict) { DVLOG(1) << __func__ << ": Entry for origin " << origin_string_ << " does not exist; create a new one."; storage_dict->SetWithoutPathExpansion(origin_string_, - CreateOriginDictionary()); + CreateOriginDictionary(origin_id_)); storage_dict->GetDictionaryWithoutPathExpansion(origin_string_, &origin_dict); DCHECK(origin_dict); @@ -205,7 +264,7 @@ DVLOG(2) << __func__; DCHECK(thread_checker_.CalledOnValidThread()); - if (!initialized_) { + if (!IsInitialized()) { DVLOG(1) << __func__ << ": Not initialized."; std::move(callback).Run(nullptr); return; @@ -220,7 +279,7 @@ if (!origin_dict) { DVLOG(1) << __func__ << ": Failed to save persistent session data; entry for origin " - << origin_ << " does not exist."; + << origin_string_ << " does not exist."; std::move(callback).Run(nullptr); return; } @@ -258,7 +317,7 @@ DVLOG(2) << __func__; DCHECK(thread_checker_.CalledOnValidThread()); - if (!initialized_) { + if (!IsInitialized()) { DVLOG(1) << __func__ << ": Not initialized."; std::move(callback).Run(false); return;
diff --git a/components/cdm/browser/media_drm_storage_impl.h b/components/cdm/browser/media_drm_storage_impl.h index f6970f6..e16cad59 100644 --- a/components/cdm/browser/media_drm_storage_impl.h +++ b/components/cdm/browser/media_drm_storage_impl.h
@@ -6,6 +6,7 @@ #define COMPONENTS_CDM_BROWSER_MEDIA_DRM_STORAGE_IMPL_H_ #include "base/threading/thread_checker.h" +#include "base/unguessable_token.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents_observer.h" #include "media/mojo/interfaces/media_drm_storage.mojom.h" @@ -36,7 +37,7 @@ ~MediaDrmStorageImpl() final; // media::mojom::MediaDrmStorage implementation. - void Initialize(const url::Origin& origin) final; + void Initialize(InitializeCallback callback) final; void OnProvisioned(OnProvisionedCallback callback) final; void SavePersistentSession(const std::string& session_id, media::mojom::SessionDataPtr session_data, @@ -50,6 +51,8 @@ void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) final; void DidFinishNavigation(content::NavigationHandle* navigation_handle) final; + bool IsInitialized() const { return !!origin_id_; } + private: base::ThreadChecker thread_checker_; @@ -58,9 +61,14 @@ content::RenderFrameHost* const render_frame_host_ = nullptr; PrefService* const pref_service_ = nullptr; - const url::Origin origin_; + + // String for the current origin. It will be used as a key in storage + // dictionary. const std::string origin_string_; - bool initialized_ = false; + + // ID for the current origin. Per EME spec on individualization, + // implementation should not expose application-specific information. + base::UnguessableToken origin_id_; mojo::Binding<media::mojom::MediaDrmStorage> binding_; };
diff --git a/components/cdm/browser/media_drm_storage_impl_unittest.cc b/components/cdm/browser/media_drm_storage_impl_unittest.cc index daf0c8f6..840437e 100644 --- a/components/cdm/browser/media_drm_storage_impl_unittest.cc +++ b/components/cdm/browser/media_drm_storage_impl_unittest.cc
@@ -8,6 +8,7 @@ #include "base/run_loop.h" #include "base/test/test_message_loop.h" +#include "base/unguessable_token.h" #include "components/prefs/testing_pref_service.h" #include "media/mojo/services/mojo_media_drm_storage.h" #include "mojo/public/cpp/bindings/interface_request.h" @@ -30,18 +31,7 @@ PrefRegistrySimple* registry = pref_service_->registry(); MediaDrmStorageImpl::RegisterProfilePrefs(registry); - media::mojom::MediaDrmStoragePtr media_drm_storage_ptr; - auto request = mojo::MakeRequest(&media_drm_storage_ptr); - - media_drm_storage_.reset( - new media::MojoMediaDrmStorage(std::move(media_drm_storage_ptr))); - - // The created object will be destroyed on connection error. - new MediaDrmStorageImpl(nullptr, // Use null RenderFrameHost for testing. - pref_service_.get(), url::Origin(GURL(kTestOrigin)), - std::move(request)); - - media_drm_storage_->Initialize(url::Origin(GURL(kTestOrigin))); + media_drm_storage_ = CreateAndInitMediaDrmStorage(&origin_id_); } void TearDown() override { @@ -52,6 +42,35 @@ protected: using SessionData = media::MediaDrmStorage::SessionData; + std::unique_ptr<media::MediaDrmStorage> CreateAndInitMediaDrmStorage( + base::UnguessableToken* origin_id) { + DCHECK(origin_id); + + media::mojom::MediaDrmStoragePtr media_drm_storage_ptr; + auto request = mojo::MakeRequest(&media_drm_storage_ptr); + + auto media_drm_storage = base::MakeUnique<media::MojoMediaDrmStorage>( + std::move(media_drm_storage_ptr)); + + // The created object will be destroyed on connection error. + new MediaDrmStorageImpl(nullptr, // Use null RenderFrameHost for testing. + pref_service_.get(), url::Origin(GURL(kTestOrigin)), + std::move(request)); + + media_drm_storage->Initialize(base::BindOnce( + [](base::UnguessableToken* out_origin_id, + const base::UnguessableToken& origin_id) { + DCHECK(origin_id); + *out_origin_id = origin_id; + }, + origin_id)); + + base::RunLoop().RunUntilIdle(); + + DCHECK(*origin_id); + return media_drm_storage; + } + void OnProvisioned() { media_drm_storage_->OnProvisioned(ExpectResult(true)); } @@ -120,8 +139,20 @@ base::TestMessageLoop message_loop_; std::unique_ptr<TestingPrefServiceSimple> pref_service_; std::unique_ptr<media::MediaDrmStorage> media_drm_storage_; + base::UnguessableToken origin_id_; }; +// TODO(yucliu): Test origin ID is re-generated after clearing licenses. +TEST_F(MediaDrmStorageImplTest, Initialize_OriginIdNotChanged) { + OnProvisioned(); + base::RunLoop().RunUntilIdle(); + + base::UnguessableToken origin_id; + std::unique_ptr<media::MediaDrmStorage> storage = + CreateAndInitMediaDrmStorage(&origin_id); + EXPECT_EQ(origin_id, origin_id_); +} + TEST_F(MediaDrmStorageImplTest, OnProvisioned) { OnProvisioned(); base::RunLoop().RunUntilIdle();
diff --git a/components/contextual_search/renderer/overlay_js_render_frame_observer.cc b/components/contextual_search/renderer/overlay_js_render_frame_observer.cc index 728d0ad..a2b5c19c 100644 --- a/components/contextual_search/renderer/overlay_js_render_frame_observer.cc +++ b/components/contextual_search/renderer/overlay_js_render_frame_observer.cc
@@ -18,32 +18,27 @@ namespace contextual_search { OverlayJsRenderFrameObserver::OverlayJsRenderFrameObserver( - content::RenderFrame* render_frame) + content::RenderFrame* render_frame, + service_manager::BinderRegistry* registry) : RenderFrameObserver(render_frame), is_contextual_search_overlay_(false), - weak_factory_(this) {} - -OverlayJsRenderFrameObserver::~OverlayJsRenderFrameObserver() {} - -void OverlayJsRenderFrameObserver::OnInterfaceRequestForFrame( - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe) { - registry_.TryBindInterface(interface_name, interface_pipe); -} - -void OverlayJsRenderFrameObserver::DidStartProvisionalLoad( - blink::WebDocumentLoader* document_loader) { - RegisterMojoInterface(); -} - -void OverlayJsRenderFrameObserver::RegisterMojoInterface() { - registry_.AddInterface(base::Bind( + weak_factory_(this) { + registry->AddInterface(base::Bind( &OverlayJsRenderFrameObserver::CreateOverlayPageNotifierService, weak_factory_.GetWeakPtr())); } +OverlayJsRenderFrameObserver::~OverlayJsRenderFrameObserver() {} + +void OverlayJsRenderFrameObserver::DidStartProvisionalLoad( + blink::WebDocumentLoader* document_loader) { + can_bind_requests_ = true; +} + void OverlayJsRenderFrameObserver::CreateOverlayPageNotifierService( mojom::OverlayPageNotifierServiceRequest request) { + if (!can_bind_requests_) + return; mojo::MakeStrongBinding( base::MakeUnique<OverlayPageNotifierServiceImpl>( weak_factory_.GetWeakPtr()), @@ -68,7 +63,7 @@ } void OverlayJsRenderFrameObserver::DestroyOverlayPageNotifierService() { - registry_.RemoveInterface<mojom::OverlayPageNotifierService>(); + can_bind_requests_ = false; } void OverlayJsRenderFrameObserver::OnDestruct() {
diff --git a/components/contextual_search/renderer/overlay_js_render_frame_observer.h b/components/contextual_search/renderer/overlay_js_render_frame_observer.h index 55cd3ada6..f55275a 100644 --- a/components/contextual_search/renderer/overlay_js_render_frame_observer.h +++ b/components/contextual_search/renderer/overlay_js_render_frame_observer.h
@@ -22,13 +22,11 @@ // in an overlay panel. class OverlayJsRenderFrameObserver : public content::RenderFrameObserver { public: - explicit OverlayJsRenderFrameObserver(content::RenderFrame* render_frame); + OverlayJsRenderFrameObserver(content::RenderFrame* render_frame, + service_manager::BinderRegistry* registry); ~OverlayJsRenderFrameObserver() override; // RenderFrameObserver implementation. - void OnInterfaceRequestForFrame( - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe) override; void DidStartProvisionalLoad( blink::WebDocumentLoader* document_loader) override; void DidClearWindowObject() override; @@ -41,9 +39,6 @@ // RenderFrameObserver implementation. void OnDestruct() override; - // Add the mojo interface to a RenderFrame's - // service_manager::InterfaceRegistry. - void RegisterMojoInterface(); // Creates the OverlayPageNotifierService connecting the browser to this // observer. void CreateOverlayPageNotifierService( @@ -54,7 +49,9 @@ // Track if the current page is presented in the contextual search overlay. bool is_contextual_search_overlay_; - service_manager::BinderRegistry registry_; + // Requests for mojom::OverlayPageNotifierService are only bound while + // a load is active. + bool can_bind_requests_ = false; base::WeakPtrFactory<OverlayJsRenderFrameObserver> weak_factory_;
diff --git a/components/dom_distiller/content/renderer/distiller_js_render_frame_observer.cc b/components/dom_distiller/content/renderer/distiller_js_render_frame_observer.cc index e21b6903..1e42153 100644 --- a/components/dom_distiller/content/renderer/distiller_js_render_frame_observer.cc +++ b/components/dom_distiller/content/renderer/distiller_js_render_frame_observer.cc
@@ -19,30 +19,29 @@ DistillerJsRenderFrameObserver::DistillerJsRenderFrameObserver( content::RenderFrame* render_frame, - const int distiller_isolated_world_id) + const int distiller_isolated_world_id, + service_manager::BinderRegistry* registry) : RenderFrameObserver(render_frame), distiller_isolated_world_id_(distiller_isolated_world_id), is_distiller_page_(false), - weak_factory_(this) {} + weak_factory_(this) { + registry->AddInterface(base::Bind( + &DistillerJsRenderFrameObserver::CreateDistillerPageNotifierService, + weak_factory_.GetWeakPtr())); +} DistillerJsRenderFrameObserver::~DistillerJsRenderFrameObserver() {} -void DistillerJsRenderFrameObserver::OnInterfaceRequestForFrame( - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe) { - registry_.TryBindInterface(interface_name, interface_pipe); -} - void DistillerJsRenderFrameObserver::DidStartProvisionalLoad( blink::WebDocumentLoader* document_loader) { - RegisterMojoInterface(); + load_active_ = true; } void DistillerJsRenderFrameObserver::DidFinishLoad() { // If no message about the distilled page was received at this point, there - // will not be one; remove the mojom::DistillerPageNotifierService from the - // registry. - registry_.RemoveInterface<mojom::DistillerPageNotifierService>(); + // will not be one; stop binding requests for + // mojom::DistillerPageNotifierService. + load_active_ = false; } void DistillerJsRenderFrameObserver::DidCreateScriptContext( @@ -57,14 +56,10 @@ native_javascript_handle_->AddJavaScriptObjectToFrame(context); } -void DistillerJsRenderFrameObserver::RegisterMojoInterface() { - registry_.AddInterface(base::Bind( - &DistillerJsRenderFrameObserver::CreateDistillerPageNotifierService, - weak_factory_.GetWeakPtr())); -} - void DistillerJsRenderFrameObserver::CreateDistillerPageNotifierService( mojom::DistillerPageNotifierServiceRequest request) { + if (!load_active_) + return; mojo::MakeStrongBinding( base::MakeUnique<DistillerPageNotifierServiceImpl>(this), std::move(request));
diff --git a/components/dom_distiller/content/renderer/distiller_js_render_frame_observer.h b/components/dom_distiller/content/renderer/distiller_js_render_frame_observer.h index 19ce6919..e8cbe79 100644 --- a/components/dom_distiller/content/renderer/distiller_js_render_frame_observer.h +++ b/components/dom_distiller/content/renderer/distiller_js_render_frame_observer.h
@@ -24,22 +24,17 @@ class DistillerJsRenderFrameObserver : public content::RenderFrameObserver { public: DistillerJsRenderFrameObserver(content::RenderFrame* render_frame, - const int distiller_isolated_world_id); + const int distiller_isolated_world_id, + service_manager::BinderRegistry* registry); ~DistillerJsRenderFrameObserver() override; // RenderFrameObserver implementation. - void OnInterfaceRequestForFrame( - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe) override; void DidStartProvisionalLoad( blink::WebDocumentLoader* document_loader) override; void DidFinishLoad() override; void DidCreateScriptContext(v8::Local<v8::Context> context, int world_id) override; - // Add the mojo interface to a RenderFrame's - // service_manager::InterfaceRegistry. - void RegisterMojoInterface(); // Flag the current page as a distiller page. void SetIsDistillerPage(); @@ -56,7 +51,9 @@ // Track if the current page is distilled. This is needed for testing. bool is_distiller_page_; - service_manager::BinderRegistry registry_; + // True if a load is in progress and we are currently able to bind requests + // for mojom::DistillerPageNotifierService. + bool load_active_ = false; // Handle to "distiller" JavaScript object functionality. std::unique_ptr<DistillerNativeJavaScript> native_javascript_handle_;
diff --git a/components/policy/resources/policy_templates.json b/components/policy/resources/policy_templates.json index 815217c5..451c477b 100644 --- a/components/policy/resources/policy_templates.json +++ b/components/policy/resources/policy_templates.json
@@ -143,7 +143,7 @@ # persistent IDs for all fields (but not for groups!) are needed. These are # specified by the 'id' keys of each policy. NEVER CHANGE EXISTING IDs, # because doing so would break the deployed wire format! -# For your editing convenience: highest ID currently used: 377 +# For your editing convenience: highest ID currently used: 379 # And don't forget to also update the EnterprisePolicies enum of # histograms.xml (run 'python tools/metrics/histograms/update_policies.py'). # @@ -9157,8 +9157,8 @@ { 'name': 'GoogleCast', 'type': 'group', - 'caption': '''Google Cast''', - 'desc': '''Configure policies for Google Cast, a feature that allows users to send the contents of tabs, sites or the desktop from the browser to remote displays and sound systems.''', + 'caption': '''<ph name="PRODUCT_NAME">Google Cast</ph>''', + 'desc': '''Configure policies for <ph name="PRODUCT_NAME">Google Cast</ph>, a feature that allows users to send the contents of tabs, sites or the desktop from the browser to remote displays and sound systems.''', 'policies': [ { 'name': 'EnableMediaRouter', @@ -9171,11 +9171,11 @@ }, 'example_value': True, 'id': 333, - 'caption': '''Enables Google Cast''', + 'caption': '''Enables <ph name="PRODUCT_NAME">Google Cast</ph>''', 'tags': [], - 'desc': '''If this policy is set to true or is not set, Google Cast will be enabled, and users will be able to launch it from the app menu, page context menus, media controls on Cast-enabled websites, and (if shown) the Cast toolbar icon. + 'desc': '''If this policy is set to true or is not set, <ph name="PRODUCT_NAME">Google Cast</ph> will be enabled, and users will be able to launch it from the app menu, page context menus, media controls on Cast-enabled websites, and (if shown) the Cast toolbar icon. - If this policy set to false, Google Cast will be disabled.''' + If this policy set to false, <ph name="PRODUCT_NAME">Google Cast</ph> will be disabled.''' }, { 'name': 'ShowCastIconInToolbar', @@ -9188,7 +9188,7 @@ }, 'example_value': False, 'id': 362, - 'caption': '''Shows the Google Cast toolbar icon''', + 'caption': '''Shows the <ph name="PRODUCT_NAME">Google Cast</ph> toolbar icon''', 'tags': [], 'desc': '''If this policy is set to true, the Cast toolbar icon will always be shown on the toolbar or the overflow menu, and users will not be able to remove it. @@ -9811,6 +9811,52 @@ If the policy is left unset, there will be no restrictions on the set of apps the user can enable on the lock screen imposed by the policy.''' }, + { + 'name': 'CastReceiver', + 'type': 'group', + 'caption': '''Cast Receiver''', + 'desc': '''Configure the Cast Receiver in <ph name="PRODUCT_NAME">$2<ex>Google Chrome OS</ex></ph>.''', + 'policies': [ + { + 'name': 'CastReceiverEnabled', + 'type': 'main', + 'schema': { 'type': 'boolean' }, + 'supported_on': ['chrome_os:62-'], + 'future': True, + 'features': { + 'dynamic_refresh': True, + 'per_profile': True, + }, + 'example_value': False, + 'id': 378, + 'default_for_enterprise_users': False, + 'caption': '''Enable casting content to the device''', + 'tags': [], + 'desc': '''Allow content to be cast to the device using <ph name="PRODUCT_NAME">Google Cast</ph>. + + If this policy is set to False, users will not be able to cast content to their device. If this policy is set to True, users are allowed to cast content. If this policy is not set, users are not allowed to cast content to enrolled Chrome OS devices, but are allowed to do so otherwise.''', + }, + { + 'name': 'CastReceiverName', + 'type': 'string', + 'schema': { 'type': 'string' }, + 'supported_on': ['chrome_os:62-'], + 'device_only': True, + 'future': True, + 'features': { + 'dynamic_refresh': True, + 'per_profile': False, + }, + 'example_value': 'My Chromebook', + 'id': 379, + 'caption': '''Name of the <ph name="PRODUCT_NAME">Google Cast</ph> destination''', + 'tags': [], + 'desc': '''Determine the name advertised as a <ph name="PRODUCT_NAME">Google Cast</ph> destination. + + If this policy is set to a non empty string, that string will be used as the name of the <ph name="PRODUCT_NAME">Google Cast</ph> destination. Otherwise, the destination name will be the device name. If this policy is not set, the destination name will be the device name and the device owner will be allowed to change it. The name is limited to 24 characters.''' + }, + ] + } ], 'messages': { # Messages that are not associated to any policies.
diff --git a/components/spellcheck/renderer/spellcheck_panel.cc b/components/spellcheck/renderer/spellcheck_panel.cc index f045f90f..f432c39 100644 --- a/components/spellcheck/renderer/spellcheck_panel.cc +++ b/components/spellcheck/renderer/spellcheck_panel.cc
@@ -9,7 +9,6 @@ #include "content/public/common/service_names.mojom.h" #include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_thread.h" -#include "services/service_manager/public/cpp/binder_registry.h" #include "services/service_manager/public/cpp/connector.h" #include "third_party/WebKit/public/platform/WebString.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" @@ -25,23 +24,18 @@ } } -SpellCheckPanel::SpellCheckPanel(content::RenderFrame* render_frame) +SpellCheckPanel::SpellCheckPanel(content::RenderFrame* render_frame, + service_manager::BinderRegistry* registry) : content::RenderFrameObserver(render_frame), spelling_panel_visible_(false) { DCHECK(render_frame); - registry_.AddInterface(base::Bind(&SpellCheckPanel::SpellCheckPanelRequest, + registry->AddInterface(base::Bind(&SpellCheckPanel::SpellCheckPanelRequest, base::Unretained(this))); render_frame->GetWebFrame()->SetSpellCheckPanelHostClient(this); } SpellCheckPanel::~SpellCheckPanel() = default; -void SpellCheckPanel::OnInterfaceRequestForFrame( - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe) { - registry_.TryBindInterface(interface_name, interface_pipe); -} - void SpellCheckPanel::OnDestruct() { delete this; }
diff --git a/components/spellcheck/renderer/spellcheck_panel.h b/components/spellcheck/renderer/spellcheck_panel.h index 5f1d646..ad336e4 100644 --- a/components/spellcheck/renderer/spellcheck_panel.h +++ b/components/spellcheck/renderer/spellcheck_panel.h
@@ -21,14 +21,12 @@ public blink::WebSpellCheckPanelHostClient, public spellcheck::mojom::SpellCheckPanel { public: - explicit SpellCheckPanel(content::RenderFrame* render_frame); + SpellCheckPanel(content::RenderFrame* render_frame, + service_manager::BinderRegistry* registry); ~SpellCheckPanel() override; private: // content::RenderFrameObserver: - void OnInterfaceRequestForFrame( - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe) override; void OnDestruct() override; // blink::WebSpellCheckPanelHostClient: @@ -51,8 +49,6 @@ // True if the browser is showing the spelling panel. bool spelling_panel_visible_; - service_manager::BinderRegistry registry_; - DISALLOW_COPY_AND_ASSIGN(SpellCheckPanel); };
diff --git a/components/viz/host/host_frame_sink_manager.cc b/components/viz/host/host_frame_sink_manager.cc index 189e7be..ab5f100 100644 --- a/components/viz/host/host_frame_sink_manager.cc +++ b/components/viz/host/host_frame_sink_manager.cc
@@ -106,7 +106,6 @@ CompositorFrameSinkSupportClient* client, const FrameSinkId& frame_sink_id, bool is_root, - bool handles_frame_sink_id_invalidation, bool needs_sync_points) { DCHECK(frame_sink_manager_impl_); @@ -115,7 +114,7 @@ auto support = CompositorFrameSinkSupport::Create( client, frame_sink_manager_impl_, frame_sink_id, is_root, - handles_frame_sink_id_invalidation, needs_sync_points); + needs_sync_points); support->SetDestructionCallback( base::BindOnce(&HostFrameSinkManager::DestroyCompositorFrameSink, weak_ptr_factory_.GetWeakPtr(), frame_sink_id));
diff --git a/components/viz/host/host_frame_sink_manager.h b/components/viz/host/host_frame_sink_manager.h index 4b3dbde0..3121d21 100644 --- a/components/viz/host/host_frame_sink_manager.h +++ b/components/viz/host/host_frame_sink_manager.h
@@ -90,7 +90,6 @@ CompositorFrameSinkSupportClient* client, const FrameSinkId& frame_sink_id, bool is_root, - bool handles_frame_sink_id_invalidation, bool needs_sync_points) override; private:
diff --git a/components/viz/host/host_frame_sink_manager_unittests.cc b/components/viz/host/host_frame_sink_manager_unittests.cc index c266eb9..298beed 100644 --- a/components/viz/host/host_frame_sink_manager_unittests.cc +++ b/components/viz/host/host_frame_sink_manager_unittests.cc
@@ -100,7 +100,6 @@ bool is_root) { return host_manager_->CreateCompositorFrameSinkSupport( nullptr /* client */, frame_sink_id, is_root, - true /* handles_frame_sink_id_invalidation */, false /* needs_sync_points */); }
diff --git a/components/viz/service/display/display_unittest.cc b/components/viz/service/display/display_unittest.cc index ac94de6..8a4c825 100644 --- a/components/viz/service/display/display_unittest.cc +++ b/components/viz/service/display/display_unittest.cc
@@ -95,7 +95,6 @@ &manager_, kArbitraryFrameSinkId, true /* is_root */, - true /* handles_frame_sink_id_invalidation */, true /* needs_sync_points */)), task_runner_(new base::NullTaskRunner) {} @@ -613,7 +612,6 @@ // Set up second frame sink + display. auto support2 = CompositorFrameSinkSupport::Create( nullptr, &manager_, kAnotherFrameSinkId, true /* is_root */, - true /* handles_frame_sink_id_invalidation */, true /* needs_sync_points */); auto begin_frame_source2 = base::MakeUnique<StubBeginFrameSource>(); auto scheduler_for_display2 = base::MakeUnique<TestDisplayScheduler>(
diff --git a/components/viz/service/display/surface_aggregator.cc b/components/viz/service/display/surface_aggregator.cc index 5e0ef59..9b4a6b6f 100644 --- a/components/viz/service/display/surface_aggregator.cc +++ b/components/viz/service/display/surface_aggregator.cc
@@ -431,7 +431,6 @@ cc::RenderPass* dest_pass, const SurfaceId& surface_id) { const cc::SharedQuadState* last_copied_source_shared_quad_state = nullptr; - const cc::SharedQuadState* dest_shared_quad_state = nullptr; // If the current frame has copy requests or cached render passes, then // aggregate the entire thing, as otherwise parts of the copy requests may be // ignored and we could cache partially drawn render pass. @@ -475,7 +474,7 @@ &damage_rect_in_quad_space_valid); } else { if (quad->shared_quad_state != last_copied_source_shared_quad_state) { - dest_shared_quad_state = CopySharedQuadState( + const cc::SharedQuadState* dest_shared_quad_state = CopySharedQuadState( quad->shared_quad_state, target_transform, clip_rect, dest_pass); last_copied_source_shared_quad_state = quad->shared_quad_state; if (aggregate_only_damaged_ && !has_copy_requests_ && @@ -507,23 +506,22 @@ dest_pass->has_damage_from_contributing_content = true; dest_quad = dest_pass->CopyFromAndAppendRenderPassDrawQuad( - pass_quad, dest_shared_quad_state, remapped_pass_id); + pass_quad, remapped_pass_id); } else if (quad->material == cc::DrawQuad::TEXTURE_CONTENT) { const auto* texture_quad = cc::TextureDrawQuad::MaterialCast(quad); if (texture_quad->secure_output_only && (!output_is_secure_ || copy_request_passes_.count(dest_pass->id))) { auto* solid_color_quad = dest_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); - solid_color_quad->SetNew(dest_shared_quad_state, quad->rect, - quad->visible_rect, SK_ColorBLACK, false); + solid_color_quad->SetNew(dest_pass->shared_quad_state_list.back(), + quad->rect, quad->visible_rect, + SK_ColorBLACK, false); dest_quad = solid_color_quad; } else { - dest_quad = dest_pass->CopyFromAndAppendDrawQuad( - quad, dest_shared_quad_state); + dest_quad = dest_pass->CopyFromAndAppendDrawQuad(quad); } } else { - dest_quad = - dest_pass->CopyFromAndAppendDrawQuad(quad, dest_shared_quad_state); + dest_quad = dest_pass->CopyFromAndAppendDrawQuad(quad); } if (!child_to_parent_map.empty()) { for (ResourceId& resource_id : dest_quad->resources) {
diff --git a/components/viz/service/display/surface_aggregator_perftest.cc b/components/viz/service/display/surface_aggregator_perftest.cc index 8ba9052e..c4cc3846 100644 --- a/components/viz/service/display/surface_aggregator_perftest.cc +++ b/components/viz/service/display/surface_aggregator_perftest.cc
@@ -24,7 +24,6 @@ constexpr bool kIsRoot = true; constexpr bool kIsChildRoot = false; -constexpr bool kHandlesFrameSinkIdInvalidation = true; constexpr bool kNeedsSyncPoints = true; const base::UnguessableToken kArbitraryToken = base::UnguessableToken::Create(); @@ -51,7 +50,7 @@ for (int i = 0; i < num_surfaces; i++) { child_supports[i] = CompositorFrameSinkSupport::Create( nullptr, &manager_, FrameSinkId(1, i + 1), kIsChildRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); } aggregator_ = base::MakeUnique<SurfaceAggregator>( manager_.surface_manager(), resource_provider_.get(), optimize_damage); @@ -107,7 +106,7 @@ auto root_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, FrameSinkId(1, num_surfaces + 1), kIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); timer_.Reset(); do { auto pass = cc::RenderPass::Create();
diff --git a/components/viz/service/display/surface_aggregator_pixeltest.cc b/components/viz/service/display/surface_aggregator_pixeltest.cc index 1367fb6..ebaa6ab6 100644 --- a/components/viz/service/display/surface_aggregator_pixeltest.cc +++ b/components/viz/service/display/surface_aggregator_pixeltest.cc
@@ -29,7 +29,6 @@ constexpr FrameSinkId kArbitraryRightFrameSinkId(4, 4); constexpr bool kIsRoot = true; constexpr bool kIsChildRoot = false; -constexpr bool kHandlesFrameSinkIdInvalidation = true; constexpr bool kNeedsSyncPoints = true; class SurfaceAggregatorPixelTest : public cc::RendererPixelTest<GLRenderer> { @@ -40,7 +39,6 @@ &manager_, kArbitraryRootFrameSinkId, kIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)) {} ~SurfaceAggregatorPixelTest() override { support_->EvictCurrentSurface(); } @@ -104,9 +102,9 @@ TEST_F(SurfaceAggregatorPixelTest, DrawSimpleAggregatedFrame) { gfx::Size child_size(200, 100); std::unique_ptr<CompositorFrameSinkSupport> child_support = - CompositorFrameSinkSupport::Create( - nullptr, &manager_, kArbitraryChildFrameSinkId, kIsChildRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + CompositorFrameSinkSupport::Create(nullptr, &manager_, + kArbitraryChildFrameSinkId, + kIsChildRoot, kNeedsSyncPoints); LocalSurfaceId child_local_surface_id = allocator_.GenerateId(); SurfaceId child_surface_id(child_support->frame_sink_id(), @@ -188,13 +186,13 @@ // right_child -> top_blue_quad (100x100 @ 0x0), // bottom_green_quad (100x100 @ 0x100) std::unique_ptr<CompositorFrameSinkSupport> left_support = - CompositorFrameSinkSupport::Create( - nullptr, &manager_, kArbitraryLeftFrameSinkId, kIsChildRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + CompositorFrameSinkSupport::Create(nullptr, &manager_, + kArbitraryLeftFrameSinkId, + kIsChildRoot, kNeedsSyncPoints); std::unique_ptr<CompositorFrameSinkSupport> right_support = - CompositorFrameSinkSupport::Create( - nullptr, &manager_, kArbitraryRightFrameSinkId, kIsChildRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + CompositorFrameSinkSupport::Create(nullptr, &manager_, + kArbitraryRightFrameSinkId, + kIsChildRoot, kNeedsSyncPoints); LocalSurfaceId left_child_local_id = allocator_.GenerateId(); SurfaceId left_child_id(left_support->frame_sink_id(), left_child_local_id); LocalSurfaceId right_child_local_id = allocator_.GenerateId();
diff --git a/components/viz/service/display/surface_aggregator_unittest.cc b/components/viz/service/display/surface_aggregator_unittest.cc index 984d8cda..a950fc9 100644 --- a/components/viz/service/display/surface_aggregator_unittest.cc +++ b/components/viz/service/display/surface_aggregator_unittest.cc
@@ -47,7 +47,6 @@ const base::UnguessableToken kArbitraryToken = base::UnguessableToken::Create(); constexpr bool kRootIsRoot = true; constexpr bool kChildIsRoot = false; -constexpr bool kHandlesFrameSinkIdInvalidation = true; constexpr bool kNeedsSyncPoints = false; SurfaceId InvalidSurfaceId() { @@ -70,7 +69,6 @@ &manager_, kArbitraryRootFrameSinkId, kRootIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)), aggregator_(manager_.surface_manager(), NULL, use_damage_rect) { manager_.surface_manager()->AddObserver(&observer_); @@ -286,7 +284,7 @@ &manager_, kArbitraryReservedFrameSinkId, kChildIsRoot, - kHandlesFrameSinkIdInvalidation, + kNeedsSyncPoints)) {} SurfaceAggregatorValidSurfaceTest() : SurfaceAggregatorValidSurfaceTest(false) {} @@ -389,7 +387,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) { auto embedded_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryFrameSinkId1, kRootIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); SurfaceId embedded_surface_id(embedded_support->frame_sink_id(), embedded_local_surface_id); @@ -500,7 +498,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { auto embedded_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryFrameSinkId1, kRootIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); SurfaceId embedded_surface_id(embedded_support->frame_sink_id(), embedded_local_surface_id); @@ -538,14 +536,14 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReference) { auto primary_child_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId primary_child_local_surface_id = allocator_.GenerateId(); SurfaceId primary_child_surface_id(primary_child_support->frame_sink_id(), primary_child_local_surface_id); auto fallback_child_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryFrameSinkId2, kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId fallback_child_local_surface_id = allocator_.GenerateId(); SurfaceId fallback_child_surface_id(fallback_child_support->frame_sink_id(), fallback_child_local_surface_id); @@ -620,7 +618,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReferenceWithPrimary) { auto primary_child_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId primary_child_local_surface_id = allocator_.GenerateId(); SurfaceId primary_child_surface_id(primary_child_support->frame_sink_id(), primary_child_local_surface_id); @@ -636,7 +634,7 @@ auto fallback_child_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryFrameSinkId2, kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId fallback_child_local_surface_id = allocator_.GenerateId(); SurfaceId fallback_child_surface_id(fallback_child_support->frame_sink_id(), fallback_child_local_surface_id); @@ -679,7 +677,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { auto embedded_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); SurfaceId embedded_surface_id(embedded_support->frame_sink_id(), embedded_local_surface_id); @@ -734,7 +732,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { auto embedded_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryFrameSinkId2, kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); SurfaceId embedded_surface_id(embedded_support->frame_sink_id(), embedded_local_surface_id); @@ -810,10 +808,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { auto embedded_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); auto parent_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryFrameSinkId2, kRootIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); SurfaceId embedded_surface_id(embedded_support->frame_sink_id(), embedded_local_surface_id); @@ -1264,13 +1262,13 @@ }; auto grandchild_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); auto child_one_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryFrameSinkId2, kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); auto child_two_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryFrameSinkId3, kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); int pass_id = 1; LocalSurfaceId grandchild_local_surface_id = allocator_.GenerateId(); SurfaceId grandchild_surface_id(grandchild_support->frame_sink_id(), @@ -1388,7 +1386,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { auto middle_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryMiddleFrameSinkId, kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); // Innermost child surface. LocalSurfaceId child_local_surface_id = allocator_.GenerateId(); SurfaceId child_surface_id(child_support_->frame_sink_id(), @@ -1553,7 +1551,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { auto parent_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryMiddleFrameSinkId, kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); Quad child_quads[] = {Quad::RenderPassQuad(1)}; Pass child_passes[] = {Pass(child_quads, arraysize(child_quads), 1)}; @@ -2196,7 +2194,7 @@ cc::FakeCompositorFrameSinkSupportClient client; auto support = CompositorFrameSinkSupport::Create( &client, &manager_, kArbitraryRootFrameSinkId, kRootIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId local_surface_id(7u, base::UnguessableToken::Create()); SurfaceId surface_id(support->frame_sink_id(), local_surface_id); @@ -2232,7 +2230,7 @@ cc::FakeCompositorFrameSinkSupportClient client; auto support = CompositorFrameSinkSupport::Create( &client, &manager_, kArbitraryRootFrameSinkId, kRootIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId local_surface_id1(7u, base::UnguessableToken::Create()); LocalSurfaceId local_surface_id2(8u, base::UnguessableToken::Create()); SurfaceId surface_id1(support->frame_sink_id(), local_surface_id1); @@ -2269,7 +2267,7 @@ cc::FakeCompositorFrameSinkSupportClient client; auto support = CompositorFrameSinkSupport::Create( &client, &manager_, kArbitraryRootFrameSinkId, kRootIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId local_surface_id(7u, base::UnguessableToken::Create()); SurfaceId surface_id(support->frame_sink_id(), local_surface_id); @@ -2298,11 +2296,9 @@ TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { cc::FakeCompositorFrameSinkSupportClient client; auto support1 = CompositorFrameSinkSupport::Create( - &client, &manager_, FrameSinkId(1, 1), kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + &client, &manager_, FrameSinkId(1, 1), kChildIsRoot, kNeedsSyncPoints); auto support2 = CompositorFrameSinkSupport::Create( - &client, &manager_, FrameSinkId(2, 2), kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + &client, &manager_, FrameSinkId(2, 2), kChildIsRoot, kNeedsSyncPoints); LocalSurfaceId local_frame1_id(7u, base::UnguessableToken::Create()); SurfaceId surface1_id(support1->frame_sink_id(), local_frame1_id); @@ -2345,13 +2341,13 @@ TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { auto root_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryRootFrameSinkId, kRootIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); auto middle_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryMiddleFrameSinkId, kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); auto child_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId root_local_surface_id(7u, kArbitraryToken); SurfaceId root_surface_id(root_support->frame_sink_id(), root_local_surface_id); @@ -2401,11 +2397,9 @@ TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) { auto support1 = CompositorFrameSinkSupport::Create( - nullptr, &manager_, FrameSinkId(1, 1), kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + nullptr, &manager_, FrameSinkId(1, 1), kChildIsRoot, kNeedsSyncPoints); auto support2 = CompositorFrameSinkSupport::Create( - nullptr, &manager_, FrameSinkId(2, 2), kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + nullptr, &manager_, FrameSinkId(2, 2), kChildIsRoot, kNeedsSyncPoints); LocalSurfaceId local_frame1_id(7u, base::UnguessableToken::Create()); SurfaceId surface1_id(support1->frame_sink_id(), local_frame1_id); @@ -2586,7 +2580,7 @@ HasDamageByChangingGrandChildSurface) { auto grand_child_support = CompositorFrameSinkSupport::Create( nullptr, &manager_, kArbitraryMiddleFrameSinkId, kChildIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); Quad child_surface_quads[] = {Quad::RenderPassQuad(1)}; Pass child_surface_passes[] = {
diff --git a/components/viz/service/frame_sinks/compositor_frame_sink_support.cc b/components/viz/service/frame_sinks/compositor_frame_sink_support.cc index 3ddce72..a451d023 100644 --- a/components/viz/service/frame_sinks/compositor_frame_sink_support.cc +++ b/components/viz/service/frame_sinks/compositor_frame_sink_support.cc
@@ -24,12 +24,10 @@ FrameSinkManagerImpl* frame_sink_manager, const FrameSinkId& frame_sink_id, bool is_root, - bool handles_frame_sink_id_invalidation, bool needs_sync_tokens) { std::unique_ptr<CompositorFrameSinkSupport> support = base::WrapUnique(new CompositorFrameSinkSupport( - client, frame_sink_id, is_root, handles_frame_sink_id_invalidation, - needs_sync_tokens)); + client, frame_sink_id, is_root, needs_sync_tokens)); support->Init(frame_sink_manager); return support; } @@ -52,8 +50,6 @@ EvictCurrentSurface(); frame_sink_manager_->UnregisterFrameSinkManagerClient(frame_sink_id_); - if (handles_frame_sink_id_invalidation_) - surface_manager_->InvalidateFrameSinkId(frame_sink_id_); } void CompositorFrameSinkSupport::SetDestructionCallback( @@ -209,8 +205,8 @@ bool result = current_surface->QueueFrame( std::move(frame), frame_index, - base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, - weak_factory_.GetWeakPtr()), + base::BindOnce(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, + weak_factory_.GetWeakPtr()), base::BindRepeating(&CompositorFrameSinkSupport::WillDrawSurface, weak_factory_.GetWeakPtr())); @@ -299,30 +295,25 @@ CompositorFrameSinkSupportClient* client, const FrameSinkId& frame_sink_id, bool is_root, - bool handles_frame_sink_id_invalidation, bool needs_sync_tokens) : client_(client), frame_sink_id_(frame_sink_id), surface_resource_holder_(this), is_root_(is_root), needs_sync_tokens_(needs_sync_tokens), - handles_frame_sink_id_invalidation_(handles_frame_sink_id_invalidation), weak_factory_(this) {} void CompositorFrameSinkSupport::Init( FrameSinkManagerImpl* frame_sink_manager) { frame_sink_manager_ = frame_sink_manager; surface_manager_ = frame_sink_manager->surface_manager(); - if (handles_frame_sink_id_invalidation_) - surface_manager_->RegisterFrameSinkId(frame_sink_id_); frame_sink_manager_->RegisterFrameSinkManagerClient(frame_sink_id_, this); } void CompositorFrameSinkSupport::OnBeginFrame(const BeginFrameArgs& args) { UpdateNeedsBeginFramesInternal(); - if (current_surface_id_.is_valid()) { + if (current_surface_id_.is_valid()) surface_manager_->SurfaceDamageExpected(current_surface_id_, args); - } last_begin_frame_args_ = args; if (client_) client_->OnBeginFrame(args);
diff --git a/components/viz/service/frame_sinks/compositor_frame_sink_support.h b/components/viz/service/frame_sinks/compositor_frame_sink_support.h index d18477c9..0148854 100644 --- a/components/viz/service/frame_sinks/compositor_frame_sink_support.h +++ b/components/viz/service/frame_sinks/compositor_frame_sink_support.h
@@ -46,7 +46,6 @@ FrameSinkManagerImpl* frame_sink_manager, const FrameSinkId& frame_sink_id, bool is_root, - bool handles_frame_sink_id_invalidation, bool needs_sync_tokens); ~CompositorFrameSinkSupport() override; @@ -83,7 +82,6 @@ CompositorFrameSinkSupport(CompositorFrameSinkSupportClient* client, const FrameSinkId& frame_sink_id, bool is_root, - bool handles_frame_sink_id_invalidation, bool needs_sync_tokens); void Init(FrameSinkManagerImpl* frame_sink_manager); @@ -148,18 +146,6 @@ const bool needs_sync_tokens_; bool seen_first_frame_activation_ = false; - // TODO(staraz): Remove this flag once ui::Compositor no longer needs to call - // RegisterFrameSinkId(). - // A surfaceSequence's validity is bound to the lifetime of the parent - // FrameSink that created it. We track the lifetime of FrameSinks through - // RegisterFrameSinkId and InvalidateFrameSinkId. During startup and GPU - // restart, a SurfaceSequence created by the top most layer compositor may be - // used prior to the creation of the associated CompositorFrameSinkSupport. - // CompositorFrameSinkSupport is created asynchronously when a new GPU channel - // is established. Once we switch to SurfaceReferences, this ordering concern - // goes away and we can remove this bool. - const bool handles_frame_sink_id_invalidation_; - // A callback that will be run at the start of the destructor if set. base::OnceCallback<void()> destruction_callback_;
diff --git a/components/viz/service/frame_sinks/compositor_frame_sink_support_manager.h b/components/viz/service/frame_sinks/compositor_frame_sink_support_manager.h index 91a4e80..c4f1026a 100644 --- a/components/viz/service/frame_sinks/compositor_frame_sink_support_manager.h +++ b/components/viz/service/frame_sinks/compositor_frame_sink_support_manager.h
@@ -23,7 +23,6 @@ CreateCompositorFrameSinkSupport(CompositorFrameSinkSupportClient* client, const FrameSinkId& frame_sink_id, bool is_root, - bool handles_frame_sink_id_invalidation, bool needs_sync_points) = 0; protected:
diff --git a/components/viz/service/frame_sinks/compositor_frame_sink_support_unittest.cc b/components/viz/service/frame_sinks/compositor_frame_sink_support_unittest.cc index 2a81acb3..77d93da2 100644 --- a/components/viz/service/frame_sinks/compositor_frame_sink_support_unittest.cc +++ b/components/viz/service/frame_sinks/compositor_frame_sink_support_unittest.cc
@@ -34,7 +34,6 @@ constexpr bool kIsRoot = true; constexpr bool kIsChildRoot = false; -constexpr bool kHandlesFrameSinkIdInvalidation = true; constexpr bool kNeedsSyncPoints = true; constexpr FrameSinkId kArbitraryFrameSinkId(1, 1); @@ -96,21 +95,19 @@ class CompositorFrameSinkSupportTest : public testing::Test { public: CompositorFrameSinkSupportTest() - : support_( - CompositorFrameSinkSupport::Create(&fake_support_client_, - &manager_, - kArbitraryFrameSinkId, - kIsRoot, - kHandlesFrameSinkIdInvalidation, - kNeedsSyncPoints)), - begin_frame_source_(0.f, false), + : begin_frame_source_(0.f, false), local_surface_id_(3, kArbitraryToken), frame_sync_token_(GenTestSyncToken(4)), consumer_sync_token_(GenTestSyncToken(5)) { manager_.surface_manager()->AddObserver(&surface_observer_); + manager_.RegisterFrameSinkId(kArbitraryFrameSinkId); + support_ = CompositorFrameSinkSupport::Create( + &fake_support_client_, &manager_, kArbitraryFrameSinkId, kIsRoot, + kNeedsSyncPoints); support_->SetBeginFrameSource(&begin_frame_source_); } ~CompositorFrameSinkSupportTest() override { + manager_.InvalidateFrameSinkId(kArbitraryFrameSinkId); manager_.surface_manager()->RemoveObserver(&surface_observer_); support_->EvictCurrentSurface(); } @@ -488,10 +485,11 @@ } TEST_F(CompositorFrameSinkSupportTest, AddDuringEviction) { + manager_.RegisterFrameSinkId(kAnotherArbitraryFrameSinkId); test::MockCompositorFrameSinkSupportClient mock_client; auto support = CompositorFrameSinkSupport::Create( &mock_client, &manager_, kAnotherArbitraryFrameSinkId, kIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId local_surface_id(6, kArbitraryToken); support->SubmitCompositorFrame(local_surface_id, test::MakeCompositorFrame()); @@ -502,14 +500,16 @@ })) .WillRepeatedly(testing::Return()); support->EvictCurrentSurface(); + manager_.InvalidateFrameSinkId(kAnotherArbitraryFrameSinkId); } // Tests doing an EvictCurrentSurface before shutting down the factory. TEST_F(CompositorFrameSinkSupportTest, EvictCurrentSurface) { + manager_.RegisterFrameSinkId(kAnotherArbitraryFrameSinkId); test::MockCompositorFrameSinkSupportClient mock_client; auto support = CompositorFrameSinkSupport::Create( &mock_client, &manager_, kAnotherArbitraryFrameSinkId, kIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId local_surface_id(7, kArbitraryToken); SurfaceId id(kAnotherArbitraryFrameSinkId, local_surface_id); @@ -530,15 +530,17 @@ .Times(1); support->EvictCurrentSurface(); EXPECT_FALSE(GetSurfaceForId(id)); + manager_.InvalidateFrameSinkId(kAnotherArbitraryFrameSinkId); } // Tests doing an EvictCurrentSurface which has unregistered dependency. TEST_F(CompositorFrameSinkSupportTest, EvictCurrentSurfaceDependencyUnRegistered) { + manager_.RegisterFrameSinkId(kAnotherArbitraryFrameSinkId); test::MockCompositorFrameSinkSupportClient mock_client; auto support = CompositorFrameSinkSupport::Create( &mock_client, &manager_, kAnotherArbitraryFrameSinkId, kIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId local_surface_id(7, kArbitraryToken); TransferableResource resource; @@ -564,15 +566,17 @@ .Times(1); support->EvictCurrentSurface(); EXPECT_FALSE(GetSurfaceForId(surface_id)); + manager_.InvalidateFrameSinkId(kAnotherArbitraryFrameSinkId); } // Tests doing an EvictCurrentSurface which has registered dependency. TEST_F(CompositorFrameSinkSupportTest, EvictCurrentSurfaceDependencyRegistered) { + manager_.RegisterFrameSinkId(kAnotherArbitraryFrameSinkId); test::MockCompositorFrameSinkSupportClient mock_client; auto support = CompositorFrameSinkSupport::Create( &mock_client, &manager_, kAnotherArbitraryFrameSinkId, kIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId local_surface_id(7, kArbitraryToken); TransferableResource resource; @@ -606,13 +610,15 @@ manager_.surface_manager()->SatisfySequence( SurfaceSequence(kYetAnotherArbitraryFrameSinkId, 4)); EXPECT_FALSE(GetSurfaceForId(surface_id)); + manager_.InvalidateFrameSinkId(kAnotherArbitraryFrameSinkId); } TEST_F(CompositorFrameSinkSupportTest, DestroySequence) { + manager_.RegisterFrameSinkId(kYetAnotherArbitraryFrameSinkId); LocalSurfaceId local_surface_id2(5, kArbitraryToken); auto support2 = CompositorFrameSinkSupport::Create( &fake_support_client_, &manager_, kYetAnotherArbitraryFrameSinkId, - kIsChildRoot, kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kIsChildRoot, kNeedsSyncPoints); SurfaceId id2(kYetAnotherArbitraryFrameSinkId, local_surface_id2); support2->SubmitCompositorFrame(local_surface_id2, test::MakeCompositorFrame()); @@ -637,6 +643,7 @@ SurfaceSequence(kAnotherArbitraryFrameSinkId, 6)); support2->EvictCurrentSurface(); DCHECK(!GetSurfaceForId(id2)); + manager_.InvalidateFrameSinkId(kYetAnotherArbitraryFrameSinkId); } // Tests that SurfaceId namespace invalidation correctly allows @@ -658,7 +665,7 @@ // Verify the dependency has prevented the surface from getting destroyed. EXPECT_TRUE(GetSurfaceForId(id)); - manager_.surface_manager()->InvalidateFrameSinkId(frame_sink_id); + manager_.InvalidateFrameSinkId(frame_sink_id); // Verify that the invalidated namespace caused the unsatisfied sequence // to be ignored. @@ -666,12 +673,12 @@ } TEST_F(CompositorFrameSinkSupportTest, DestroyCycle) { + manager_.RegisterFrameSinkId(kAnotherArbitraryFrameSinkId); LocalSurfaceId local_surface_id2(5, kArbitraryToken); SurfaceId id2(kYetAnotherArbitraryFrameSinkId, local_surface_id2); auto support2 = CompositorFrameSinkSupport::Create( &fake_support_client_, &manager_, kYetAnotherArbitraryFrameSinkId, - kIsChildRoot, kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); - manager_.surface_manager()->RegisterFrameSinkId(kAnotherArbitraryFrameSinkId); + kIsChildRoot, kNeedsSyncPoints); // Give local_surface_id_ an initial frame so another client can refer to // that surface. { @@ -713,6 +720,7 @@ SurfaceId(support_->frame_sink_id(), local_surface_id_))); local_surface_id_ = LocalSurfaceId(); + manager_.InvalidateFrameSinkId(kAnotherArbitraryFrameSinkId); } void CopyRequestTestCallback(bool* called,
diff --git a/components/viz/service/frame_sinks/direct_layer_tree_frame_sink.cc b/components/viz/service/frame_sinks/direct_layer_tree_frame_sink.cc index c4540aa..d431bc9c 100644 --- a/components/viz/service/frame_sinks/direct_layer_tree_frame_sink.cc +++ b/components/viz/service/frame_sinks/direct_layer_tree_frame_sink.cc
@@ -73,9 +73,8 @@ cp->SetLostContextCallback(base::Closure()); constexpr bool is_root = true; - constexpr bool handles_frame_sink_id_invalidation = false; support_ = support_manager_->CreateCompositorFrameSinkSupport( - this, frame_sink_id_, is_root, handles_frame_sink_id_invalidation, + this, frame_sink_id_, is_root, capabilities_.delegated_sync_points_required); begin_frame_source_ = base::MakeUnique<ExternalBeginFrameSource>(this); client_->SetBeginFrameSource(begin_frame_source_.get());
diff --git a/components/viz/service/frame_sinks/direct_layer_tree_frame_sink_unittest.cc b/components/viz/service/frame_sinks/direct_layer_tree_frame_sink_unittest.cc index 0dd445e5..ac33034 100644 --- a/components/viz/service/frame_sinks/direct_layer_tree_frame_sink_unittest.cc +++ b/components/viz/service/frame_sinks/direct_layer_tree_frame_sink_unittest.cc
@@ -51,11 +51,9 @@ CompositorFrameSinkSupportClient* client, const FrameSinkId& frame_sink_id, bool is_root, - bool handles_frame_sink_id_invalidation, bool needs_sync_points) override { return CompositorFrameSinkSupport::Create( - client, frame_sink_manager_, frame_sink_id, is_root, - handles_frame_sink_id_invalidation, needs_sync_points); + client, frame_sink_manager_, frame_sink_id, is_root, needs_sync_points); } private:
diff --git a/components/viz/service/frame_sinks/gpu_compositor_frame_sink.cc b/components/viz/service/frame_sinks/gpu_compositor_frame_sink.cc index 2299367..ca3b1ca0 100644 --- a/components/viz/service/frame_sinks/gpu_compositor_frame_sink.cc +++ b/components/viz/service/frame_sinks/gpu_compositor_frame_sink.cc
@@ -20,7 +20,6 @@ frame_sink_manager, frame_sink_id, false /* is_root */, - false /* handles_frame_sink_id_invalidation */, true /* needs_sync_points */)), client_(std::move(client)), compositor_frame_sink_binding_(this, std::move(request)) {
diff --git a/components/viz/service/frame_sinks/gpu_root_compositor_frame_sink.cc b/components/viz/service/frame_sinks/gpu_root_compositor_frame_sink.cc index 91418ec..430cb44 100644 --- a/components/viz/service/frame_sinks/gpu_root_compositor_frame_sink.cc +++ b/components/viz/service/frame_sinks/gpu_root_compositor_frame_sink.cc
@@ -26,7 +26,6 @@ frame_sink_manager, frame_sink_id, true /* is_root */, - false /* handles_frame_sink_id_invalidation */, true /* needs_sync_points */)), display_begin_frame_source_(std::move(begin_frame_source)), display_(std::move(display)),
diff --git a/components/viz/service/frame_sinks/surface_references_unittest.cc b/components/viz/service/frame_sinks/surface_references_unittest.cc index 2ead07d..327dfc7 100644 --- a/components/viz/service/frame_sinks/surface_references_unittest.cc +++ b/components/viz/service/frame_sinks/surface_references_unittest.cc
@@ -59,12 +59,11 @@ const FrameSinkId& frame_sink_id) { auto& support_ptr = supports_[frame_sink_id]; if (!support_ptr) { + manager_->RegisterFrameSinkId(frame_sink_id); constexpr bool is_root = false; - constexpr bool handles_frame_sink_id_invalidation = true; constexpr bool needs_sync_points = true; support_ptr = CompositorFrameSinkSupport::Create( - nullptr, manager_.get(), frame_sink_id, is_root, - handles_frame_sink_id_invalidation, needs_sync_points); + nullptr, manager_.get(), frame_sink_id, is_root, needs_sync_points); } return *support_ptr; } @@ -73,6 +72,7 @@ auto support_ptr = supports_.find(frame_sink_id); ASSERT_NE(support_ptr, supports_.end()); supports_.erase(support_ptr); + manager_->InvalidateFrameSinkId(frame_sink_id); } void RemoveSurfaceReference(const SurfaceId& parent_id,
diff --git a/components/viz/service/frame_sinks/surface_synchronization_unittest.cc b/components/viz/service/frame_sinks/surface_synchronization_unittest.cc index d6af320..2dcd8ea7 100644 --- a/components/viz/service/frame_sinks/surface_synchronization_unittest.cc +++ b/components/viz/service/frame_sinks/surface_synchronization_unittest.cc
@@ -27,7 +27,6 @@ constexpr bool kIsRoot = true; constexpr bool kIsChildRoot = false; -constexpr bool kHandlesFrameSinkIdInvalidation = true; constexpr bool kNeedsSyncPoints = true; constexpr FrameSinkId kDisplayFrameSink(2, 0); constexpr FrameSinkId kParentFrameSink(3, 0); @@ -154,19 +153,19 @@ frame_sink_manager_.surface_manager()->AddObserver(&surface_observer_); supports_[kDisplayFrameSink] = CompositorFrameSinkSupport::Create( &support_client_, &frame_sink_manager_, kDisplayFrameSink, kIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); supports_[kParentFrameSink] = CompositorFrameSinkSupport::Create( &support_client_, &frame_sink_manager_, kParentFrameSink, kIsChildRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); supports_[kChildFrameSink1] = CompositorFrameSinkSupport::Create( &support_client_, &frame_sink_manager_, kChildFrameSink1, kIsChildRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); supports_[kChildFrameSink2] = CompositorFrameSinkSupport::Create( &support_client_, &frame_sink_manager_, kChildFrameSink2, kIsChildRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); // Normally, the BeginFrameSource would be registered by the Display. We // register it here so that BeginFrames are received by the display support,
diff --git a/components/viz/service/surfaces/surface.cc b/components/viz/service/surfaces/surface.cc index 28c24c3..78d5b965 100644 --- a/components/viz/service/surfaces/surface.cc +++ b/components/viz/service/surfaces/surface.cc
@@ -98,7 +98,7 @@ bool Surface::QueueFrame(cc::CompositorFrame frame, uint64_t frame_index, - const base::Closure& callback, + base::OnceClosure callback, const WillDrawCallback& will_draw_callback) { late_activation_dependencies_.clear(); @@ -116,7 +116,7 @@ std::vector<ReturnedResource> resources = TransferableResource::ReturnResources(frame.resource_list); surface_client_->ReturnResources(resources); - callback.Run(); + std::move(callback).Run(); return true; } @@ -137,11 +137,11 @@ if (activation_dependencies_.empty()) { // If there are no blockers, then immediately activate the frame. - ActivateFrame( - FrameData(std::move(frame), frame_index, callback, will_draw_callback)); + ActivateFrame(FrameData(std::move(frame), frame_index, std::move(callback), + will_draw_callback)); } else { - pending_frame_data_ = - FrameData(std::move(frame), frame_index, callback, will_draw_callback); + pending_frame_data_ = FrameData(std::move(frame), frame_index, + std::move(callback), will_draw_callback); RejectCompositorFramesToFallbackSurfaces(); @@ -208,11 +208,11 @@ Surface::FrameData::FrameData(cc::CompositorFrame&& frame, uint64_t frame_index, - const base::Closure& draw_callback, + base::OnceClosure draw_callback, const WillDrawCallback& will_draw_callback) : frame(std::move(frame)), frame_index(frame_index), - draw_callback(draw_callback), + draw_callback(std::move(draw_callback)), will_draw_callback(will_draw_callback) {} Surface::FrameData::FrameData(FrameData&& other) = default; @@ -340,11 +340,8 @@ } void Surface::RunDrawCallback() { - if (active_frame_data_ && !active_frame_data_->draw_callback.is_null()) { - base::Closure callback = active_frame_data_->draw_callback; - active_frame_data_->draw_callback = base::Closure(); - callback.Run(); - } + if (active_frame_data_ && !active_frame_data_->draw_callback.is_null()) + std::move(active_frame_data_->draw_callback).Run(); } void Surface::RunWillDrawCallback(const gfx::Rect& damage_rect) { @@ -386,7 +383,7 @@ surface_client_->UnrefResources(resources); if (!frame_data->draw_callback.is_null()) - frame_data->draw_callback.Run(); + std::move(frame_data->draw_callback).Run(); } void Surface::ClearCopyRequests() {
diff --git a/components/viz/service/surfaces/surface.h b/components/viz/service/surfaces/surface.h index be17b604..c8e6405 100644 --- a/components/viz/service/surfaces/surface.h +++ b/components/viz/service/surfaces/surface.h
@@ -119,7 +119,7 @@ // there is visible damage. bool QueueFrame(cc::CompositorFrame frame, uint64_t frame_index, - const base::Closure& draw_callback, + base::OnceClosure draw_callback, const WillDrawCallback& will_draw_callback); void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> copy_request); @@ -202,14 +202,14 @@ struct FrameData { FrameData(cc::CompositorFrame&& frame, uint64_t frame_index, - const base::Closure& draw_callback, + base::OnceClosure draw_callback, const WillDrawCallback& will_draw_callback); FrameData(FrameData&& other); ~FrameData(); FrameData& operator=(FrameData&& other); cc::CompositorFrame frame; uint64_t frame_index; - base::Closure draw_callback; + base::OnceClosure draw_callback; WillDrawCallback will_draw_callback; };
diff --git a/components/viz/service/surfaces/surface_hittest_unittest.cc b/components/viz/service/surfaces/surface_hittest_unittest.cc index 27997723..72bee5f2 100644 --- a/components/viz/service/surfaces/surface_hittest_unittest.cc +++ b/components/viz/service/surfaces/surface_hittest_unittest.cc
@@ -24,7 +24,6 @@ constexpr bool kIsRoot = true; constexpr bool kIsChildRoot = false; -constexpr bool kHandlesFrameSinkIdInvalidation = true; constexpr bool kNeedsSyncPoints = true; constexpr FrameSinkId kRootFrameSink(2, 0); constexpr FrameSinkId kChildFrameSink(65563, 0); @@ -88,10 +87,10 @@ supports_.push_back(CompositorFrameSinkSupport::Create( &support_client_, &frame_sink_manager_, kRootFrameSink, kIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); + kNeedsSyncPoints)); supports_.push_back(CompositorFrameSinkSupport::Create( &support_client_, &frame_sink_manager_, kChildFrameSink, kIsChildRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); + kNeedsSyncPoints)); } void TearDown() override { supports_.clear(); }
diff --git a/components/viz/service/surfaces/surface_unittest.cc b/components/viz/service/surfaces/surface_unittest.cc index f56d463..8fc38f9 100644 --- a/components/viz/service/surfaces/surface_unittest.cc +++ b/components/viz/service/surfaces/surface_unittest.cc
@@ -21,7 +21,6 @@ constexpr FrameSinkId kArbitraryFrameSinkId(1, 1); constexpr bool kIsRoot = true; -constexpr bool kHandlesFrameSinkIdInvalidation = true; constexpr bool kNeedsSyncPoints = true; TEST(SurfaceTest, SurfaceLifetime) { @@ -30,7 +29,7 @@ SurfaceManager* surface_manager = frame_sink_manager.surface_manager(); auto support = CompositorFrameSinkSupport::Create( nullptr, &frame_sink_manager, kArbitraryFrameSinkId, kIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId local_surface_id(6, base::UnguessableToken::Create()); SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id); @@ -62,7 +61,7 @@ SurfaceManager* surface_manager = frame_sink_manager.surface_manager(); auto support = CompositorFrameSinkSupport::Create( nullptr, &frame_sink_manager, kArbitraryFrameSinkId, kIsRoot, - kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); + kNeedsSyncPoints); LocalSurfaceId local_surface_id(6, base::UnguessableToken::Create()); SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id);
diff --git a/components/viz/test/test_layer_tree_frame_sink.cc b/components/viz/test/test_layer_tree_frame_sink.cc index 9c07d55..27b4d843 100644 --- a/components/viz/test/test_layer_tree_frame_sink.cc +++ b/components/viz/test/test_layer_tree_frame_sink.cc
@@ -98,11 +98,10 @@ context_provider()->SetLostContextCallback(base::Closure()); constexpr bool is_root = false; - constexpr bool handles_frame_sink_id_invalidation = true; constexpr bool needs_sync_points = true; - support_ = CompositorFrameSinkSupport::Create( - this, frame_sink_manager_.get(), frame_sink_id_, is_root, - handles_frame_sink_id_invalidation, needs_sync_points); + support_ = CompositorFrameSinkSupport::Create(this, frame_sink_manager_.get(), + frame_sink_id_, is_root, + needs_sync_points); client_->SetBeginFrameSource(&external_begin_frame_source_); if (begin_frame_source_) { frame_sink_manager_->RegisterBeginFrameSource(begin_frame_source_.get(),
diff --git a/content/browser/frame_host/render_widget_host_view_child_frame.cc b/content/browser/frame_host/render_widget_host_view_child_frame.cc index d3597a9..b1b7bba2 100644 --- a/content/browser/frame_host/render_widget_host_view_child_frame.cc +++ b/content/browser/frame_host/render_widget_host_view_child_frame.cc
@@ -848,11 +848,9 @@ DCHECK(!support_); constexpr bool is_root = false; - constexpr bool handles_frame_sink_id_invalidation = false; constexpr bool needs_sync_points = true; support_ = GetHostFrameSinkManager()->CreateCompositorFrameSinkSupport( - this, frame_sink_id_, is_root, handles_frame_sink_id_invalidation, - needs_sync_points); + this, frame_sink_id_, is_root, needs_sync_points); if (parent_frame_sink_id_.is_valid()) { GetHostFrameSinkManager()->RegisterFrameSinkHierarchy(parent_frame_sink_id_, frame_sink_id_);
diff --git a/content/browser/loader/resource_scheduler_unittest.cc b/content/browser/loader/resource_scheduler_unittest.cc index c3d9877..6ae28ef 100644 --- a/content/browser/loader/resource_scheduler_unittest.cc +++ b/content/browser/loader/resource_scheduler_unittest.cc
@@ -777,7 +777,8 @@ NewRequest("http://host/high", net::HIGHEST)); EXPECT_TRUE(high->started()); - const int kMaxNumDelayableRequestsPerClient = 10; // Should match the .cc. + const int kDefaultMaxNumDelayableRequestsPerClient = + 10; // Should match the .cc. const int kMaxNumDelayableRequestsPerHost = 6; std::vector<std::unique_ptr<TestRequest>> lows_singlehost; // Queue up to the per-host limit (we subtract the current high-pri request). @@ -804,8 +805,8 @@ EXPECT_TRUE(last_singlehost->started()); // Queue more requests from different hosts until we reach the total limit. - int expected_slots_left = - kMaxNumDelayableRequestsPerClient - kMaxNumDelayableRequestsPerHost; + int expected_slots_left = kDefaultMaxNumDelayableRequestsPerClient - + kMaxNumDelayableRequestsPerHost; EXPECT_GT(expected_slots_left, 0); std::vector<std::unique_ptr<TestRequest>> lows_different_host; base::RunLoop().RunUntilIdle(); @@ -852,9 +853,10 @@ EXPECT_FALSE(request->started()); EXPECT_FALSE(idle->started()); - const int kMaxNumDelayableRequestsPerClient = 10; // Should match the .cc. + const int kDefaultMaxNumDelayableRequestsPerClient = + 10; // Should match the .cc. std::vector<std::unique_ptr<TestRequest>> lows; - for (int i = 0; i < kMaxNumDelayableRequestsPerClient - 1; ++i) { + for (int i = 0; i < kDefaultMaxNumDelayableRequestsPerClient - 1; ++i) { string url = "http://host/low" + base::IntToString(i); lows.push_back(NewRequest(url.c_str(), net::LOWEST)); } @@ -884,10 +886,11 @@ EXPECT_FALSE(request->started()); EXPECT_FALSE(idle->started()); - const int kMaxNumDelayableRequestsPerClient = 10; // Should match the .cc. + const int kDefaultMaxNumDelayableRequestsPerClient = + 10; // Should match the .cc. // 2 fewer filler requests: 1 for the "low" dummy at the start, and 1 for the // one at the end, which will be tested. - const int kNumFillerRequests = kMaxNumDelayableRequestsPerClient - 2; + const int kNumFillerRequests = kDefaultMaxNumDelayableRequestsPerClient - 2; std::vector<std::unique_ptr<TestRequest>> lows; for (int i = 0; i < kNumFillerRequests; ++i) { string url = "http://host" + base::IntToString(i) + "/low"; @@ -914,9 +917,10 @@ EXPECT_FALSE(request->started()); EXPECT_FALSE(idle->started()); - const int kMaxNumDelayableRequestsPerClient = 10; // Should match the .cc. + const int kDefaultMaxNumDelayableRequestsPerClient = + 10; // Should match the .cc. std::vector<std::unique_ptr<TestRequest>> lows; - for (int i = 0; i < kMaxNumDelayableRequestsPerClient; ++i) { + for (int i = 0; i < kDefaultMaxNumDelayableRequestsPerClient; ++i) { string url = "http://host/low" + base::IntToString(i); lows.push_back(NewRequest(url.c_str(), net::LOWEST)); } @@ -943,9 +947,10 @@ NewRequest("http://host/high", net::HIGHEST)); std::unique_ptr<TestRequest> low(NewRequest("http://host/low", net::LOWEST)); - const int kMaxNumDelayableRequestsPerClient = 10; // Should match the .cc. + const int kDefaultMaxNumDelayableRequestsPerClient = + 10; // Should match the .cc. std::vector<std::unique_ptr<TestRequest>> lows; - for (int i = 0; i < kMaxNumDelayableRequestsPerClient; ++i) { + for (int i = 0; i < kDefaultMaxNumDelayableRequestsPerClient; ++i) { string url = "http://host/low" + base::IntToString(i); lows.push_back(NewRequest(url.c_str(), net::IDLE)); } @@ -1028,13 +1033,14 @@ InitializeScheduler(); scheduler()->OnWillInsertBody(kChildId, kRouteId); - const int kMaxNumDelayableRequestsPerClient = 10; // Should match the .cc. + const int kDefaultMaxNumDelayableRequestsPerClient = + 10; // Should match the .cc. std::unique_ptr<TestRequest> low1_spdy( NewRequest("http://spdyhost1:8080/low", net::LOWEST)); // Cancel a request after we learn the server supports SPDY. std::vector<std::unique_ptr<TestRequest>> lows; - for (int i = 0; i < kMaxNumDelayableRequestsPerClient - 1; ++i) { + for (int i = 0; i < kDefaultMaxNumDelayableRequestsPerClient - 1; ++i) { string url = "http://host" + base::IntToString(i) + "/low"; lows.push_back(NewRequest(url.c_str(), net::LOWEST)); } @@ -1067,13 +1073,14 @@ InitializeScheduler(); scheduler()->OnWillInsertBody(kChildId, kRouteId); - const int kMaxNumDelayableRequestsPerClient = 10; // Should match the .cc. + const int kDefaultMaxNumDelayableRequestsPerClient = + 10; // Should match the .cc. std::unique_ptr<TestRequest> low1_spdy( NewRequest("http://spdyhost1:8080/low", net::LOWEST)); // Cancel a request after we learn the server supports SPDY. std::vector<std::unique_ptr<TestRequest>> lows; - for (int i = 0; i < kMaxNumDelayableRequestsPerClient - 1; ++i) { + for (int i = 0; i < kDefaultMaxNumDelayableRequestsPerClient - 1; ++i) { string url = "http://host" + base::IntToString(i) + "/low"; lows.push_back(NewRequest(url.c_str(), net::LOWEST)); } @@ -1129,9 +1136,9 @@ &network_quality_estimator_); std::unique_ptr<TestRequest> high(NewRequestWithChildAndRoute( "http://host/high", net::HIGHEST, kChildId2, kRouteId2)); - const int kMaxNumDelayableRequestsPerClient = 10; + const int kDefaultMaxNumDelayableRequestsPerClient = 10; std::vector<std::unique_ptr<TestRequest>> delayable_requests; - for (int i = 0; i < kMaxNumDelayableRequestsPerClient + 1; ++i) { + for (int i = 0; i < kDefaultMaxNumDelayableRequestsPerClient + 1; ++i) { delayable_requests.push_back(NewRequestWithChildAndRoute( "http://host/lowest", net::LOWEST, kChildId2, kRouteId2)); } @@ -1187,12 +1194,12 @@ EXPECT_TRUE(high->started()); // Should be in sync with resource_scheduler.cc. - const int kMaxNumDelayableRequestsPerClient = 10; + const int kDefaultMaxNumDelayableRequestsPerClient = 10; std::vector<std::unique_ptr<TestRequest>> lows_singlehost; // Queue up to the maximum limit. Use different host names to prevent the // per host limit from kicking in. - for (int i = 0; i < kMaxNumDelayableRequestsPerClient; ++i) { + for (int i = 0; i < kDefaultMaxNumDelayableRequestsPerClient; ++i) { // Keep unique hostnames to prevent the per host limit from kicking in. std::string url = "http://host" + base::IntToString(i) + "/low"; lows_singlehost.push_back(NewRequest(url.c_str(), net::LOWEST)); @@ -1234,12 +1241,12 @@ EXPECT_TRUE(high->started()); // Should be in sync with resource_scheduler.cc. - const int kMaxNumDelayableRequestsPerClient = 10; + const int kDefaultMaxNumDelayableRequestsPerClient = 10; std::vector<std::unique_ptr<TestRequest>> lows_singlehost; // Queue up to the maximum limit. Use different host names to prevent the // per host limit from kicking in. - for (int i = 0; i < kMaxNumDelayableRequestsPerClient; ++i) { + for (int i = 0; i < kDefaultMaxNumDelayableRequestsPerClient; ++i) { // Keep unique hostnames to prevent the per host limit from kicking in. std::string url = "http://host" + base::IntToString(i) + "/low"; lows_singlehost.push_back(NewRequest(url.c_str(), net::LOWEST));
diff --git a/content/browser/renderer_host/delegated_frame_host.cc b/content/browser/renderer_host/delegated_frame_host.cc index 032fc45..40577a71 100644 --- a/content/browser/renderer_host/delegated_frame_host.cc +++ b/content/browser/renderer_host/delegated_frame_host.cc
@@ -841,14 +841,12 @@ void DelegatedFrameHost::CreateCompositorFrameSinkSupport() { DCHECK(!support_); constexpr bool is_root = false; - constexpr bool handles_frame_sink_id_invalidation = false; constexpr bool needs_sync_points = true; ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); support_ = factory->GetContextFactoryPrivate() ->GetHostFrameSinkManager() - ->CreateCompositorFrameSinkSupport( - this, frame_sink_id_, is_root, - handles_frame_sink_id_invalidation, needs_sync_points); + ->CreateCompositorFrameSinkSupport(this, frame_sink_id_, + is_root, needs_sync_points); if (compositor_) compositor_->AddFrameSink(frame_sink_id_); if (needs_begin_frame_)
diff --git a/content/browser/renderer_host/input/legacy_input_router_impl.cc b/content/browser/renderer_host/input/legacy_input_router_impl.cc index bbc5ea34..899b2e1 100644 --- a/content/browser/renderer_host/input/legacy_input_router_impl.cc +++ b/content/browser/renderer_host/input/legacy_input_router_impl.cc
@@ -509,7 +509,11 @@ void LegacyInputRouterImpl::OnSetWhiteListedTouchAction( cc::TouchAction white_listed_touch_action, - uint32_t unique_touch_event_id) { + uint32_t unique_touch_event_id, + InputEventAckState ack_result) { + // TODO(hayleyferr): Catch the cases that we have filtered out sending the + // touchstart. + touch_action_filter_.OnSetWhiteListedTouchAction(white_listed_touch_action); client_->OnSetWhiteListedTouchAction(white_listed_touch_action); }
diff --git a/content/browser/renderer_host/input/legacy_input_router_impl.h b/content/browser/renderer_host/input/legacy_input_router_impl.h index d54a972..aa7415c 100644 --- a/content/browser/renderer_host/input/legacy_input_router_impl.h +++ b/content/browser/renderer_host/input/legacy_input_router_impl.h
@@ -150,7 +150,8 @@ void OnHasTouchEventHandlers(bool has_handlers); void OnSetTouchAction(cc::TouchAction touch_action); void OnSetWhiteListedTouchAction(cc::TouchAction white_listed_touch_action, - uint32_t unique_touch_event_id); + uint32_t unique_touch_event_id, + InputEventAckState ack_result); void OnDidStopFlinging(); // Indicates the source of an ack provided to |ProcessInputEventAck()|.
diff --git a/content/browser/renderer_host/input/legacy_input_router_impl_unittest.cc b/content/browser/renderer_host/input/legacy_input_router_impl_unittest.cc index 9cf4b8b..19129b2 100644 --- a/content/browser/renderer_host/input/legacy_input_router_impl_unittest.cc +++ b/content/browser/renderer_host/input/legacy_input_router_impl_unittest.cc
@@ -415,9 +415,10 @@ } void OnSetWhiteListedTouchAction(cc::TouchAction white_listed_touch_action, - uint32_t unique_touch_event_id) { + uint32_t unique_touch_event_id, + InputEventAckState ack_result) { input_router_->OnMessageReceived(InputHostMsg_SetWhiteListedTouchAction( - 0, white_listed_touch_action, unique_touch_event_id)); + 0, white_listed_touch_action, unique_touch_event_id, ack_result)); } size_t GetSentMessageCountAndResetSink() { @@ -2061,8 +2062,8 @@ // |SetWhiteListedTouchAction| IPC messages. TEST_F(LegacyInputRouterImplTest, OnSetWhiteListedTouchAction) { cc::TouchAction touch_action = cc::kTouchActionPanY; - input_router_->OnMessageReceived( - InputHostMsg_SetWhiteListedTouchAction(0, touch_action, 0)); + input_router_->OnMessageReceived(InputHostMsg_SetWhiteListedTouchAction( + 0, touch_action, 0, INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); cc::TouchAction white_listed_touch_action = client_->GetAndResetWhiteListedTouchAction(); EXPECT_EQ(touch_action, white_listed_touch_action);
diff --git a/content/browser/renderer_host/input/web_input_event_builders_mac_unittest.mm b/content/browser/renderer_host/input/web_input_event_builders_mac_unittest.mm index 5434a6031..2b619cc0 100644 --- a/content/browser/renderer_host/input/web_input_event_builders_mac_unittest.mm +++ b/content/browser/renderer_host/input/web_input_event_builders_mac_unittest.mm
@@ -379,6 +379,35 @@ } } +// 'Dvorak - QWERTY Command' layout will map the key back to QWERTY when Command +// is pressed. +// e.g. Key 'b' maps to 'x' but 'Command-b' remains 'Command-b'. +TEST(WebInputEventBuilderMacTest, USDvorakQWERTYCommand) { + struct DomKeyTestCase { + int mac_key_code; + unichar cmd_character; + } table[] = {{kVK_ANSI_0, '0'}, {kVK_ANSI_1, '1'}, {kVK_ANSI_2, '2'}, + {kVK_ANSI_3, '3'}, {kVK_ANSI_4, '4'}, {kVK_ANSI_5, '5'}, + {kVK_ANSI_6, '6'}, {kVK_ANSI_7, '7'}, {kVK_ANSI_8, '8'}, + {kVK_ANSI_9, '9'}, {kVK_ANSI_A, 'a'}, {kVK_ANSI_B, 'b'}, + {kVK_ANSI_C, 'c'}, {kVK_ANSI_D, 'd'}, {kVK_ANSI_E, 'e'}, + {kVK_ANSI_F, 'f'}, {kVK_ANSI_G, 'g'}, {kVK_ANSI_H, 'h'}, + {kVK_ANSI_I, 'i'}, {kVK_ANSI_J, 'j'}, {kVK_ANSI_K, 'k'}, + {kVK_ANSI_L, 'l'}, {kVK_ANSI_M, 'm'}, {kVK_ANSI_N, 'n'}, + {kVK_ANSI_O, 'o'}, {kVK_ANSI_P, 'p'}, {kVK_ANSI_Q, 'q'}, + {kVK_ANSI_R, 'r'}, {kVK_ANSI_S, 's'}, {kVK_ANSI_T, 't'}, + {kVK_ANSI_U, 'u'}, {kVK_ANSI_V, 'v'}, {kVK_ANSI_W, 'w'}, + {kVK_ANSI_X, 'x'}, {kVK_ANSI_Y, 'y'}, {kVK_ANSI_Z, 'z'}}; + + for (const DomKeyTestCase& entry : table) { + NSEvent* mac_event = BuildFakeKeyEvent( + entry.mac_key_code, entry.cmd_character, NSCommandKeyMask, NSKeyDown); + WebKeyboardEvent web_event = WebKeyboardEventBuilder::Build(mac_event); + EXPECT_EQ(ui::DomKey::FromCharacter(entry.cmd_character), + web_event.dom_key); + } +} + // Test conversion from key combination with Control to DomKey. // TODO(chongz): Move DomKey tests for all platforms into one place. // http://crbug.com/587589
diff --git a/content/browser/ssl/ssl_manager.cc b/content/browser/ssl/ssl_manager.cc index c895bd32..9d1668c 100644 --- a/content/browser/ssl/ssl_manager.cc +++ b/content/browser/ssl/ssl_manager.cc
@@ -191,7 +191,8 @@ void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) { NavigationEntryImpl* entry = controller_->GetLastCommittedEntry(); - int content_status_flags = 0; + int add_content_status_flags = 0; + int remove_content_status_flags = 0; if (!details.is_main_frame) { // If it wasn't a main-frame navigation, then carry over content // status flags. (For example, the mixed content flag shouldn't @@ -199,10 +200,16 @@ NavigationEntryImpl* previous_entry = controller_->GetEntryAtIndex(details.previous_entry_index); if (previous_entry) { - content_status_flags = previous_entry->GetSSL().content_status; + add_content_status_flags = previous_entry->GetSSL().content_status; } + } else if (!details.is_same_document) { + // For main-frame non-same-page navigations, clear content status + // flags. These flags are set based on the content on the page, and thus + // should reflect the current content, even if the navigation was to an + // existing entry that already had content status flags set. + remove_content_status_flags = ~0; } - UpdateEntry(entry, content_status_flags, 0); + UpdateEntry(entry, add_content_status_flags, remove_content_status_flags); // Always notify the WebContents that the SSL state changed when a // load is committed, in case the active navigation entry has changed. NotifyDidChangeVisibleSSLState(); @@ -411,8 +418,8 @@ SSLStatus original_ssl_status = entry->GetSSL(); // Copy! entry->GetSSL().initialized = true; - entry->GetSSL().content_status |= add_content_status_flags; entry->GetSSL().content_status &= ~remove_content_status_flags; + entry->GetSSL().content_status |= add_content_status_flags; SiteInstance* site_instance = entry->site_instance(); // Note that |site_instance| can be NULL here because NavigationEntries don't
diff --git a/content/browser/ssl/ssl_manager.h b/content/browser/ssl/ssl_manager.h index a99dfbd6..ddcd8e9 100644 --- a/content/browser/ssl/ssl_manager.h +++ b/content/browser/ssl/ssl_manager.h
@@ -113,13 +113,14 @@ void OnCertErrorInternal(std::unique_ptr<SSLErrorHandler> handler, int options_mask); - // Updates the NavigationEntry's |content_status| flags according to - // state in |ssl_host_state_delegate|. |add_content_status_flags| and - // |remove_content_status_flags| are bitmasks of - // SSLStatus::ContentStatusFlags that will be added or removed from - // the |content_status| field. (Pass 0 to add/remove no content status - // flags.) This method will notify the WebContents of an SSL state - // change if a change was actually made. + // Updates the NavigationEntry's |content_status| flags according to state in + // |ssl_host_state_delegate|. |add_content_status_flags| and + // |remove_content_status_flags| are bitmasks of SSLStatus::ContentStatusFlags + // that will be added or removed from the |content_status| field. (Pass 0 to + // add/remove no content status flags.) |remove_content_status_flags| are + // removed before |add_content_status_flags| are added. This method will + // notify the WebContents of an SSL state change if a change was actually + // made. void UpdateEntry(NavigationEntryImpl* entry, int add_content_status_flags, int remove_content_status_flags);
diff --git a/content/browser/webui/shared_resources_data_source.cc b/content/browser/webui/shared_resources_data_source.cc index 86f1cce..d520ab3 100644 --- a/content/browser/webui/shared_resources_data_source.cc +++ b/content/browser/webui/shared_resources_data_source.cc
@@ -37,7 +37,11 @@ "polymer/v1_0/web-animations-js/"}, {"../../views/resources/default_100_percent/common/", "images/apps/"}, {"../../views/resources/default_200_percent/common/", "images/2x/apps/"}, - {"../../webui/resources/cr_elements/", "cr_elements/"}}; +#if defined(OS_CHROMEOS) + {"../../webui/resources/chromeos/", "chromeos/"}, +#endif + {"../../webui/resources/cr_elements/", "cr_elements/"}, +}; const struct { const char* const path;
diff --git a/content/common/input/input_event_struct_traits.cc b/content/common/input/input_event_struct_traits.cc index a02c660..1c57527 100644 --- a/content/common/input/input_event_struct_traits.cc +++ b/content/common/input/input_event_struct_traits.cc
@@ -366,178 +366,175 @@ return event.ReadLatency(&((*out)->latency_info)); } -void* StructTraits<content::mojom::EventDataView, - InputEventUniquePtr>::SetUpContext(const InputEventUniquePtr& - event) { - InputEventSerializationContext* context = - new InputEventSerializationContext(); +// static +content::mojom::KeyDataPtr +StructTraits<content::mojom::EventDataView, InputEventUniquePtr>::key_data( + const InputEventUniquePtr& event) { + if (!event->web_event || + !blink::WebInputEvent::IsKeyboardEventType(event->web_event->GetType())) + return nullptr; + const blink::WebKeyboardEvent* key_event = + static_cast<const blink::WebKeyboardEvent*>(event->web_event.get()); + return content::mojom::KeyData::New( + key_event->dom_key, key_event->dom_code, key_event->windows_key_code, + key_event->native_key_code, key_event->is_system_key, + key_event->is_browser_shortcut, key_event->text, + key_event->unmodified_text); +} +// static +content::mojom::PointerDataPtr +StructTraits<content::mojom::EventDataView, InputEventUniquePtr>::pointer_data( + const InputEventUniquePtr& event) { if (!event->web_event) - return context; - - if (blink::WebInputEvent::IsKeyboardEventType(event->web_event->GetType())) { - const blink::WebKeyboardEvent* key_event = - static_cast<const blink::WebKeyboardEvent*>(event->web_event.get()); - context->key_data = content::mojom::KeyData::New( - key_event->dom_key, key_event->dom_code, key_event->windows_key_code, - key_event->native_key_code, key_event->is_system_key, - key_event->is_browser_shortcut, key_event->text, - key_event->unmodified_text); - return context; - } - if (blink::WebInputEvent::IsGestureEventType(event->web_event->GetType())) { - const blink::WebGestureEvent* gesture_event = - static_cast<const blink::WebGestureEvent*>(event->web_event.get()); - - context->gesture_data = content::mojom::GestureData::New(); - content::mojom::GestureDataPtr& gesture_data = context->gesture_data; - gesture_data->screen_position = gesture_event->PositionInScreen(); - gesture_data->widget_position = gesture_event->PositionInWidget(); - gesture_data->source_device = gesture_event->source_device; - gesture_data->unique_touch_event_id = gesture_event->unique_touch_event_id; - gesture_data->resending_plugin_id = gesture_event->resending_plugin_id; - - switch (gesture_event->GetType()) { - default: - break; - case blink::WebInputEvent::Type::kGestureTapDown: - gesture_data->contact_size = - gfx::Size(gesture_event->data.tap_down.width, - gesture_event->data.tap_down.height); - break; - case blink::WebInputEvent::Type::kGestureShowPress: - gesture_data->contact_size = - gfx::Size(gesture_event->data.show_press.width, - gesture_event->data.show_press.height); - break; - case blink::WebInputEvent::Type::kGestureTap: - case blink::WebInputEvent::Type::kGestureTapUnconfirmed: - case blink::WebInputEvent::Type::kGestureDoubleTap: - gesture_data->contact_size = gfx::Size(gesture_event->data.tap.width, - gesture_event->data.tap.height); - gesture_data->tap_data = - content::mojom::TapData::New(gesture_event->data.tap.tap_count); - break; - case blink::WebInputEvent::Type::kGestureLongPress: - gesture_data->contact_size = - gfx::Size(gesture_event->data.long_press.width, - gesture_event->data.long_press.height); - break; - - case blink::WebInputEvent::Type::kGestureTwoFingerTap: - gesture_data->contact_size = - gfx::Size(gesture_event->data.two_finger_tap.first_finger_width, - gesture_event->data.two_finger_tap.first_finger_height); - break; - case blink::WebInputEvent::Type::kGestureScrollBegin: - gesture_data->scroll_data = content::mojom::ScrollData::New( - gesture_event->data.scroll_begin.delta_x_hint, - gesture_event->data.scroll_begin.delta_y_hint, - gesture_event->data.scroll_begin.delta_hint_units, - gesture_event->data.scroll_begin.target_viewport, - gesture_event->data.scroll_begin.inertial_phase, - gesture_event->data.scroll_begin.synthetic, - gesture_event->data.scroll_begin.pointer_count, nullptr); - break; - case blink::WebInputEvent::Type::kGestureScrollEnd: - gesture_data->scroll_data = content::mojom::ScrollData::New( - 0, 0, gesture_event->data.scroll_end.delta_units, false, - gesture_event->data.scroll_end.inertial_phase, - gesture_event->data.scroll_end.synthetic, 0, nullptr); - break; - case blink::WebInputEvent::Type::kGestureScrollUpdate: - gesture_data->scroll_data = content::mojom::ScrollData::New( - gesture_event->data.scroll_update.delta_x, - gesture_event->data.scroll_update.delta_y, - gesture_event->data.scroll_update.delta_units, false, - gesture_event->data.scroll_update.inertial_phase, false, 0, - content::mojom::ScrollUpdate::New( - gesture_event->data.scroll_update.velocity_x, - gesture_event->data.scroll_update.velocity_y, - gesture_event->data.scroll_update - .previous_update_in_sequence_prevented, - gesture_event->data.scroll_update.prevent_propagation)); - break; - case blink::WebInputEvent::Type::kGestureFlingStart: - gesture_data->fling_data = content::mojom::FlingData::New( - gesture_event->data.fling_start.velocity_x, - gesture_event->data.fling_start.velocity_y, - gesture_event->data.fling_start.target_viewport, false); - break; - case blink::WebInputEvent::Type::kGestureFlingCancel: - gesture_data->fling_data = content::mojom::FlingData::New( - 0, 0, gesture_event->data.fling_cancel.target_viewport, - gesture_event->data.fling_cancel.prevent_boosting); - break; - case blink::WebInputEvent::Type::kGesturePinchUpdate: - gesture_data->pinch_data = content::mojom::PinchData::New( - gesture_event->data.pinch_update.zoom_disabled, - gesture_event->data.pinch_update.scale); - break; - } - return context; - } - if (blink::WebInputEvent::IsTouchEventType(event->web_event->GetType())) { - const blink::WebTouchEvent* touch_event = - static_cast<const blink::WebTouchEvent*>(event->web_event.get()); - - context->touch_data = content::mojom::TouchData::New( - touch_event->dispatch_type, touch_event->moved_beyond_slop_region, - touch_event->touch_start_or_first_touch_move, - touch_event->unique_touch_event_id, - std::vector<content::mojom::TouchPointPtr>()); - - for (unsigned i = 0; i < touch_event->touches_length; ++i) { - content::mojom::PointerDataPtr pointer_data = - PointerDataFromPointerProperties(touch_event->touches[i], nullptr); - context->touch_data->touches.emplace_back(content::mojom::TouchPoint::New( - touch_event->touches[i].state, touch_event->touches[i].radius_x, - touch_event->touches[i].radius_y, - touch_event->touches[i].rotation_angle, std::move(pointer_data))); - } - - return context; - } - + return nullptr; bool is_wheel_event = event->web_event->GetType() == blink::WebInputEvent::Type::kMouseWheel; - if (blink::WebInputEvent::IsMouseEventType(event->web_event->GetType()) || - is_wheel_event) { - const blink::WebMouseEvent* mouse_event = - static_cast<const blink::WebMouseEvent*>(event->web_event.get()); + if (!blink::WebInputEvent::IsMouseEventType(event->web_event->GetType()) && + !is_wheel_event) { + return nullptr; + } + const blink::WebMouseEvent* mouse_event = + static_cast<const blink::WebMouseEvent*>(event->web_event.get()); - content::mojom::WheelDataPtr wheel_data; - if (is_wheel_event) { - const blink::WebMouseWheelEvent* wheel_event = - static_cast<const blink::WebMouseWheelEvent*>(mouse_event); - wheel_data = content::mojom::WheelData::New( - wheel_event->delta_x, wheel_event->delta_y, - wheel_event->wheel_ticks_x, wheel_event->wheel_ticks_y, - wheel_event->acceleration_ratio_x, wheel_event->acceleration_ratio_y, - wheel_event->resending_plugin_id, wheel_event->phase, - wheel_event->momentum_phase, wheel_event->scroll_by_page, - wheel_event->has_precise_scrolling_deltas, - wheel_event->dispatch_type); - } - - context->pointer_data = PointerDataFromPointerProperties( - *mouse_event, content::mojom::MouseData::New(mouse_event->click_count, - std::move(wheel_data))); - return context; + content::mojom::WheelDataPtr wheel_data; + if (is_wheel_event) { + const blink::WebMouseWheelEvent* wheel_event = + static_cast<const blink::WebMouseWheelEvent*>(mouse_event); + wheel_data = content::mojom::WheelData::New( + wheel_event->delta_x, wheel_event->delta_y, wheel_event->wheel_ticks_x, + wheel_event->wheel_ticks_y, wheel_event->acceleration_ratio_x, + wheel_event->acceleration_ratio_y, wheel_event->resending_plugin_id, + wheel_event->phase, wheel_event->momentum_phase, + wheel_event->scroll_by_page, wheel_event->has_precise_scrolling_deltas, + wheel_event->dispatch_type); } - return context; + return PointerDataFromPointerProperties( + *mouse_event, content::mojom::MouseData::New(mouse_event->click_count, + std::move(wheel_data))); } -void StructTraits<content::mojom::EventDataView, InputEventUniquePtr>:: - TearDownContext(const InputEventUniquePtr& event, void* context) { - delete static_cast<InputEventSerializationContext*>(context); +// static +content::mojom::GestureDataPtr +StructTraits<content::mojom::EventDataView, InputEventUniquePtr>::gesture_data( + const InputEventUniquePtr& event) { + if (!event->web_event || + !blink::WebInputEvent::IsGestureEventType(event->web_event->GetType())) + return nullptr; + const blink::WebGestureEvent* gesture_event = + static_cast<const blink::WebGestureEvent*>(event->web_event.get()); + auto gesture_data = content::mojom::GestureData::New(); + gesture_data->screen_position = gesture_event->PositionInScreen(); + gesture_data->widget_position = gesture_event->PositionInWidget(); + gesture_data->source_device = gesture_event->source_device; + gesture_data->unique_touch_event_id = gesture_event->unique_touch_event_id; + gesture_data->resending_plugin_id = gesture_event->resending_plugin_id; + switch (gesture_event->GetType()) { + default: + break; + case blink::WebInputEvent::Type::kGestureTapDown: + gesture_data->contact_size = + gfx::Size(gesture_event->data.tap_down.width, + gesture_event->data.tap_down.height); + break; + case blink::WebInputEvent::Type::kGestureShowPress: + gesture_data->contact_size = + gfx::Size(gesture_event->data.show_press.width, + gesture_event->data.show_press.height); + break; + case blink::WebInputEvent::Type::kGestureTap: + case blink::WebInputEvent::Type::kGestureTapUnconfirmed: + case blink::WebInputEvent::Type::kGestureDoubleTap: + gesture_data->contact_size = gfx::Size(gesture_event->data.tap.width, + gesture_event->data.tap.height); + gesture_data->tap_data = + content::mojom::TapData::New(gesture_event->data.tap.tap_count); + break; + case blink::WebInputEvent::Type::kGestureLongPress: + gesture_data->contact_size = + gfx::Size(gesture_event->data.long_press.width, + gesture_event->data.long_press.height); + break; + + case blink::WebInputEvent::Type::kGestureTwoFingerTap: + gesture_data->contact_size = + gfx::Size(gesture_event->data.two_finger_tap.first_finger_width, + gesture_event->data.two_finger_tap.first_finger_height); + break; + case blink::WebInputEvent::Type::kGestureScrollBegin: + gesture_data->scroll_data = content::mojom::ScrollData::New( + gesture_event->data.scroll_begin.delta_x_hint, + gesture_event->data.scroll_begin.delta_y_hint, + gesture_event->data.scroll_begin.delta_hint_units, + gesture_event->data.scroll_begin.target_viewport, + gesture_event->data.scroll_begin.inertial_phase, + gesture_event->data.scroll_begin.synthetic, + gesture_event->data.scroll_begin.pointer_count, nullptr); + break; + case blink::WebInputEvent::Type::kGestureScrollEnd: + gesture_data->scroll_data = content::mojom::ScrollData::New( + 0, 0, gesture_event->data.scroll_end.delta_units, false, + gesture_event->data.scroll_end.inertial_phase, + gesture_event->data.scroll_end.synthetic, 0, nullptr); + break; + case blink::WebInputEvent::Type::kGestureScrollUpdate: + gesture_data->scroll_data = content::mojom::ScrollData::New( + gesture_event->data.scroll_update.delta_x, + gesture_event->data.scroll_update.delta_y, + gesture_event->data.scroll_update.delta_units, false, + gesture_event->data.scroll_update.inertial_phase, false, 0, + content::mojom::ScrollUpdate::New( + gesture_event->data.scroll_update.velocity_x, + gesture_event->data.scroll_update.velocity_y, + gesture_event->data.scroll_update + .previous_update_in_sequence_prevented, + gesture_event->data.scroll_update.prevent_propagation)); + break; + case blink::WebInputEvent::Type::kGestureFlingStart: + gesture_data->fling_data = content::mojom::FlingData::New( + gesture_event->data.fling_start.velocity_x, + gesture_event->data.fling_start.velocity_y, + gesture_event->data.fling_start.target_viewport, false); + break; + case blink::WebInputEvent::Type::kGestureFlingCancel: + gesture_data->fling_data = content::mojom::FlingData::New( + 0, 0, gesture_event->data.fling_cancel.target_viewport, + gesture_event->data.fling_cancel.prevent_boosting); + break; + case blink::WebInputEvent::Type::kGesturePinchUpdate: + gesture_data->pinch_data = content::mojom::PinchData::New( + gesture_event->data.pinch_update.zoom_disabled, + gesture_event->data.pinch_update.scale); + break; + } + return gesture_data; } -StructTraits<content::mojom::EventDataView, InputEventUniquePtr>:: - InputEventSerializationContext::InputEventSerializationContext() {} +// static +content::mojom::TouchDataPtr +StructTraits<content::mojom::EventDataView, InputEventUniquePtr>::touch_data( + const InputEventUniquePtr& event) { + if (!event->web_event || + !blink::WebInputEvent::IsTouchEventType(event->web_event->GetType())) + return nullptr; -StructTraits<content::mojom::EventDataView, InputEventUniquePtr>:: - InputEventSerializationContext::~InputEventSerializationContext() {} + const blink::WebTouchEvent* touch_event = + static_cast<const blink::WebTouchEvent*>(event->web_event.get()); + auto touch_data = content::mojom::TouchData::New( + touch_event->dispatch_type, touch_event->moved_beyond_slop_region, + touch_event->touch_start_or_first_touch_move, + touch_event->unique_touch_event_id, + std::vector<content::mojom::TouchPointPtr>()); + for (unsigned i = 0; i < touch_event->touches_length; ++i) { + content::mojom::PointerDataPtr pointer_data = + PointerDataFromPointerProperties(touch_event->touches[i], nullptr); + touch_data->touches.emplace_back(content::mojom::TouchPoint::New( + touch_event->touches[i].state, touch_event->touches[i].radius_x, + touch_event->touches[i].radius_y, + touch_event->touches[i].rotation_angle, std::move(pointer_data))); + } + return touch_data; +} } // namespace mojo
diff --git a/content/common/input/input_event_struct_traits.h b/content/common/input/input_event_struct_traits.h index 9237448..d63ca68 100644 --- a/content/common/input/input_event_struct_traits.h +++ b/content/common/input/input_event_struct_traits.h
@@ -33,44 +33,15 @@ return event->latency_info; } - static const content::mojom::KeyDataPtr& key_data( - const InputEventUniquePtr& event, - void* context) { - return static_cast<InputEventSerializationContext*>(context)->key_data; - } - - static const content::mojom::PointerDataPtr& pointer_data( - const InputEventUniquePtr& event, - void* context) { - return static_cast<InputEventSerializationContext*>(context)->pointer_data; - } - - static const content::mojom::GestureDataPtr& gesture_data( - const InputEventUniquePtr& event, - void* context) { - return static_cast<InputEventSerializationContext*>(context)->gesture_data; - } - - static const content::mojom::TouchDataPtr& touch_data( - const InputEventUniquePtr& event, - void* context) { - return static_cast<InputEventSerializationContext*>(context)->touch_data; - } + static content::mojom::KeyDataPtr key_data(const InputEventUniquePtr& event); + static content::mojom::PointerDataPtr pointer_data( + const InputEventUniquePtr& event); + static content::mojom::GestureDataPtr gesture_data( + const InputEventUniquePtr& event); + static content::mojom::TouchDataPtr touch_data( + const InputEventUniquePtr& event); static bool Read(content::mojom::EventDataView r, InputEventUniquePtr* out); - static void* SetUpContext(const InputEventUniquePtr& handle); - static void TearDownContext(const InputEventUniquePtr& handle, void* context); - - private: - struct InputEventSerializationContext { - content::mojom::KeyDataPtr key_data; - content::mojom::GestureDataPtr gesture_data; - content::mojom::PointerDataPtr pointer_data; - content::mojom::TouchDataPtr touch_data; - - InputEventSerializationContext(); - ~InputEventSerializationContext(); - }; }; } // namespace mojo
diff --git a/content/common/input_messages.h b/content/common/input_messages.h index bbecc64c..142f8db4 100644 --- a/content/common/input_messages.h +++ b/content/common/input_messages.h
@@ -330,10 +330,13 @@ // The whitelisted touch action and the associated unique touch event id // for a new touch point sent by the compositor. The unique touch event id is // only needed to verify that the whitelisted touch action is being associated -// with the correct touch event. -IPC_MESSAGE_ROUTED2(InputHostMsg_SetWhiteListedTouchAction, +// with the correct touch event. The input event ack state is needed when +// the touchstart message was not sent to the renderer and the touch +// actions need to be reset and the touch ack timeout needs to be started. +IPC_MESSAGE_ROUTED3(InputHostMsg_SetWhiteListedTouchAction, cc::TouchAction /* white_listed_touch_action */, - uint32_t /* unique_touch_event_id */) + uint32_t /* unique_touch_event_id */, + content::InputEventAckState /* ack_result */) // Sent by the compositor when input scroll events are dropped due to bounds // restrictions on the root scroll offset.
diff --git a/content/common/service_worker/service_worker_fetch_request_struct_traits.cc b/content/common/service_worker/service_worker_fetch_request_struct_traits.cc index dec7383..f5f94399 100644 --- a/content/common/service_worker/service_worker_fetch_request_struct_traits.cc +++ b/content/common/service_worker/service_worker_fetch_request_struct_traits.cc
@@ -10,19 +10,6 @@ namespace mojo { -namespace { - -// Struct traits context for the FetchAPIRequest type. Since getters are invoked -// twice when serializing the type, this reduces the load for heavy members. -struct ServiceWorkerFetchRequestStructTraitsContext { - ServiceWorkerFetchRequestStructTraitsContext() = default; - ~ServiceWorkerFetchRequestStructTraitsContext() = default; - - std::map<std::string, std::string> headers; -}; - -} // namespace - using blink::mojom::FetchCredentialsMode; using blink::mojom::FetchRedirectMode; using blink::mojom::FetchRequestMode; @@ -404,29 +391,13 @@ return false; } -void* StructTraits<blink::mojom::FetchAPIRequestDataView, - content::ServiceWorkerFetchRequest>:: - SetUpContext(const content::ServiceWorkerFetchRequest& request) { - ServiceWorkerFetchRequestStructTraitsContext* context = - new ServiceWorkerFetchRequestStructTraitsContext(); - context->headers.insert(request.headers.begin(), request.headers.end()); - - return context; -} - -void StructTraits<blink::mojom::FetchAPIRequestDataView, - content::ServiceWorkerFetchRequest>:: - TearDownContext(const content::ServiceWorkerFetchRequest& request, - void* context) { - delete static_cast<ServiceWorkerFetchRequestStructTraitsContext*>(context); -} - -const std::map<std::string, std::string>& +std::map<std::string, std::string> StructTraits<blink::mojom::FetchAPIRequestDataView, content::ServiceWorkerFetchRequest>:: - headers(const content::ServiceWorkerFetchRequest& request, void* context) { - return static_cast<ServiceWorkerFetchRequestStructTraitsContext*>(context) - ->headers; + headers(const content::ServiceWorkerFetchRequest& request) { + std::map<std::string, std::string> header_map; + header_map.insert(request.headers.begin(), request.headers.end()); + return header_map; } bool StructTraits<blink::mojom::FetchAPIRequestDataView,
diff --git a/content/common/service_worker/service_worker_fetch_request_struct_traits.h b/content/common/service_worker/service_worker_fetch_request_struct_traits.h index 80912e2..c357154 100644 --- a/content/common/service_worker/service_worker_fetch_request_struct_traits.h +++ b/content/common/service_worker/service_worker_fetch_request_struct_traits.h
@@ -73,10 +73,6 @@ template <> struct StructTraits<blink::mojom::FetchAPIRequestDataView, content::ServiceWorkerFetchRequest> { - static void* SetUpContext(const content::ServiceWorkerFetchRequest& request); - static void TearDownContext(const content::ServiceWorkerFetchRequest& request, - void* context); - static content::FetchRequestMode mode( const content::ServiceWorkerFetchRequest& request) { return request.mode; @@ -106,9 +102,8 @@ return request.method; } - static const std::map<std::string, std::string>& headers( - const content::ServiceWorkerFetchRequest& request, - void* context); + static std::map<std::string, std::string> headers( + const content::ServiceWorkerFetchRequest& request); static const std::string& blob_uuid( const content::ServiceWorkerFetchRequest& request) {
diff --git a/content/renderer/android/synchronous_layer_tree_frame_sink.cc b/content/renderer/android/synchronous_layer_tree_frame_sink.cc index 37ee2952b..e4458134 100644 --- a/content/renderer/android/synchronous_layer_tree_frame_sink.cc +++ b/content/renderer/android/synchronous_layer_tree_frame_sink.cc
@@ -175,14 +175,13 @@ constexpr bool root_support_is_root = true; constexpr bool child_support_is_root = false; - constexpr bool handles_frame_sink_id_invalidation = true; constexpr bool needs_sync_points = true; root_support_ = viz::CompositorFrameSinkSupport::Create( this, frame_sink_manager_.get(), kRootFrameSinkId, root_support_is_root, - handles_frame_sink_id_invalidation, needs_sync_points); + needs_sync_points); child_support_ = viz::CompositorFrameSinkSupport::Create( this, frame_sink_manager_.get(), kChildFrameSinkId, child_support_is_root, - handles_frame_sink_id_invalidation, needs_sync_points); + needs_sync_points); viz::RendererSettings software_renderer_settings;
diff --git a/content/renderer/input/input_event_filter.cc b/content/renderer/input/input_event_filter.cc index d088153be..bba934a 100644 --- a/content/renderer/input/input_event_filter.cc +++ b/content/renderer/input/input_event_filter.cc
@@ -130,12 +130,12 @@ } } -void InputEventFilter::SetWhiteListedTouchAction( - int routing_id, - cc::TouchAction touch_action, - uint32_t unique_touch_event_id) { +void InputEventFilter::SetWhiteListedTouchAction(int routing_id, + cc::TouchAction touch_action, + uint32_t unique_touch_event_id, + InputEventAckState ack_state) { SendMessage(base::MakeUnique<InputHostMsg_SetWhiteListedTouchAction>( - routing_id, touch_action, unique_touch_event_id)); + routing_id, touch_action, unique_touch_event_id, ack_state)); } void InputEventFilter::OnFilterAdded(IPC::Channel* channel) {
diff --git a/content/renderer/input/input_event_filter.h b/content/renderer/input/input_event_filter.h index d3f0cd2..83ed2471 100644 --- a/content/renderer/input/input_event_filter.h +++ b/content/renderer/input/input_event_filter.h
@@ -79,7 +79,8 @@ const ui::LatencyInfo& latency_info) override; void SetWhiteListedTouchAction(int routing_id, cc::TouchAction touch_action, - uint32_t unique_touch_event_id) override; + uint32_t unique_touch_event_id, + InputEventAckState ack_state) override; // IPC::MessageFilter methods: void OnFilterAdded(IPC::Channel* channel) override;
diff --git a/content/renderer/input/input_handler_manager.cc b/content/renderer/input/input_handler_manager.cc index cd816cdb..71019ea 100644 --- a/content/renderer/input/input_handler_manager.cc +++ b/content/renderer/input/input_handler_manager.cc
@@ -285,9 +285,12 @@ void InputHandlerManager::SetWhiteListedTouchAction( int routing_id, cc::TouchAction touch_action, - uint32_t unique_touch_event_id) { - client_->SetWhiteListedTouchAction(routing_id, touch_action, - unique_touch_event_id); + uint32_t unique_touch_event_id, + InputHandlerProxy::EventDisposition event_disposition) { + InputEventAckState input_event_ack_state = + InputEventDispositionToAck(event_disposition); + client_->SetWhiteListedTouchAction( + routing_id, touch_action, unique_touch_event_id, input_event_ack_state); } } // namespace content
diff --git a/content/renderer/input/input_handler_manager.h b/content/renderer/input/input_handler_manager.h index 59e184c..ed11376 100644 --- a/content/renderer/input/input_handler_manager.h +++ b/content/renderer/input/input_handler_manager.h
@@ -113,9 +113,11 @@ const ui::LatencyInfo& latency_info); // Called from the compositor's thread. - void SetWhiteListedTouchAction(int routing_id, - cc::TouchAction touch_action, - uint32_t unique_touch_event_id); + void SetWhiteListedTouchAction( + int routing_id, + cc::TouchAction touch_action, + uint32_t unique_touch_event_id, + ui::InputHandlerProxy::EventDisposition event_disposition); private: // Called from the compositor's thread.
diff --git a/content/renderer/input/input_handler_manager_client.h b/content/renderer/input/input_handler_manager_client.h index a756ac35..4802e54 100644 --- a/content/renderer/input/input_handler_manager_client.h +++ b/content/renderer/input/input_handler_manager_client.h
@@ -56,7 +56,8 @@ const ui::LatencyInfo& latency_info) = 0; virtual void SetWhiteListedTouchAction(int routing_id, cc::TouchAction touch_action, - uint32_t unique_touch_event_id) = 0; + uint32_t unique_touch_event_id, + InputEventAckState ack_state) = 0; protected: InputHandlerManagerClient() {}
diff --git a/content/renderer/input/input_handler_wrapper.cc b/content/renderer/input/input_handler_wrapper.cc index 840865f5..29308940 100644 --- a/content/renderer/input/input_handler_wrapper.cc +++ b/content/renderer/input/input_handler_wrapper.cc
@@ -111,9 +111,10 @@ void InputHandlerWrapper::SetWhiteListedTouchAction( cc::TouchAction touch_action, - uint32_t unique_touch_event_id) { - input_handler_manager_->SetWhiteListedTouchAction(routing_id_, touch_action, - unique_touch_event_id); + uint32_t unique_touch_event_id, + ui::InputHandlerProxy::EventDisposition event_disposition) { + input_handler_manager_->SetWhiteListedTouchAction( + routing_id_, touch_action, unique_touch_event_id, event_disposition); } } // namespace content
diff --git a/content/renderer/input/input_handler_wrapper.h b/content/renderer/input/input_handler_wrapper.h index ae4c4b3..b8c01c8 100644 --- a/content/renderer/input/input_handler_wrapper.h +++ b/content/renderer/input/input_handler_wrapper.h
@@ -57,8 +57,10 @@ void DidAnimateForInput() override; void GenerateScrollBeginAndSendToMainThread( const blink::WebGestureEvent& update_event) override; - void SetWhiteListedTouchAction(cc::TouchAction touch_action, - uint32_t unique_touch_event_id) override; + void SetWhiteListedTouchAction( + cc::TouchAction touch_action, + uint32_t unique_touch_event_id, + ui::InputHandlerProxy::EventDisposition event_disposition) override; private: InputHandlerManager* input_handler_manager_;
diff --git a/content/renderer/input/widget_input_handler_manager.cc b/content/renderer/input/widget_input_handler_manager.cc index cb88bd1..e59b52e 100644 --- a/content/renderer/input/widget_input_handler_manager.cc +++ b/content/renderer/input/widget_input_handler_manager.cc
@@ -181,9 +181,12 @@ void WidgetInputHandlerManager::SetWhiteListedTouchAction( cc::TouchAction touch_action, - uint32_t unique_touch_event_id) { + uint32_t unique_touch_event_id, + ui::InputHandlerProxy::EventDisposition event_disposition) { + InputEventAckState ack_state = InputEventDispositionToAck(event_disposition); legacy_host_message_sender_->Send(new InputHostMsg_SetWhiteListedTouchAction( - legacy_host_message_routing_id_, touch_action, unique_touch_event_id)); + legacy_host_message_routing_id_, touch_action, unique_touch_event_id, + ack_state)); } void WidgetInputHandlerManager::ObserveGestureEventOnMainThread(
diff --git a/content/renderer/input/widget_input_handler_manager.h b/content/renderer/input/widget_input_handler_manager.h index ea55b23..3fc9a7ac 100644 --- a/content/renderer/input/widget_input_handler_manager.h +++ b/content/renderer/input/widget_input_handler_manager.h
@@ -58,8 +58,10 @@ void DidAnimateForInput() override; void GenerateScrollBeginAndSendToMainThread( const blink::WebGestureEvent& update_event) override; - void SetWhiteListedTouchAction(cc::TouchAction touch_action, - uint32_t unique_touch_event_id) override; + void SetWhiteListedTouchAction( + cc::TouchAction touch_action, + uint32_t unique_touch_event_id, + ui::InputHandlerProxy::EventDisposition event_disposition) override; void ObserveGestureEventOnMainThread( const blink::WebGestureEvent& gesture_event,
diff --git a/extensions/renderer/extensions_render_frame_observer.cc b/extensions/renderer/extensions_render_frame_observer.cc index 2133e38..b5f7970 100644 --- a/extensions/renderer/extensions_render_frame_observer.cc +++ b/extensions/renderer/extensions_render_frame_observer.cc
@@ -12,7 +12,6 @@ #include "content/public/renderer/render_view.h" #include "extensions/common/extension_messages.h" #include "extensions/common/stack_frame.h" -#include "services/service_manager/public/cpp/binder_registry.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebView.h" @@ -78,10 +77,11 @@ } // namespace ExtensionsRenderFrameObserver::ExtensionsRenderFrameObserver( - content::RenderFrame* render_frame) + content::RenderFrame* render_frame, + service_manager::BinderRegistry* registry) : content::RenderFrameObserver(render_frame), webview_visually_deemphasized_(false) { - registry_.AddInterface( + registry->AddInterface( base::Bind(&ExtensionsRenderFrameObserver::BindAppWindowRequest, base::Unretained(this))); } @@ -105,12 +105,6 @@ render_frame()->GetRenderView()->GetWebView()->SetPageOverlayColor(color); } -void ExtensionsRenderFrameObserver::OnInterfaceRequestForFrame( - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe) { - registry_.TryBindInterface(interface_name, interface_pipe); -} - void ExtensionsRenderFrameObserver::DetailedConsoleMessageAdded( const base::string16& message, const base::string16& source,
diff --git a/extensions/renderer/extensions_render_frame_observer.h b/extensions/renderer/extensions_render_frame_observer.h index 732108c..48644c8 100644 --- a/extensions/renderer/extensions_render_frame_observer.h +++ b/extensions/renderer/extensions_render_frame_observer.h
@@ -20,8 +20,8 @@ class ExtensionsRenderFrameObserver : public content::RenderFrameObserver, public mojom::AppWindow { public: - explicit ExtensionsRenderFrameObserver( - content::RenderFrame* render_frame); + ExtensionsRenderFrameObserver(content::RenderFrame* render_frame, + service_manager::BinderRegistry* registry); ~ExtensionsRenderFrameObserver() override; private: @@ -32,9 +32,6 @@ void SetVisuallyDeemphasized(bool deemphasized) override; // RenderFrameObserver implementation. - void OnInterfaceRequestForFrame( - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe) override; void DetailedConsoleMessageAdded(const base::string16& message, const base::string16& source, const base::string16& stack_trace, @@ -47,8 +44,6 @@ mojo::BindingSet<mojom::AppWindow> bindings_; - service_manager::BinderRegistry registry_; - DISALLOW_COPY_AND_ASSIGN(ExtensionsRenderFrameObserver); };
diff --git a/ios/chrome/browser/ntp_tiles/ntp_tiles_egtest.mm b/ios/chrome/browser/ntp_tiles/ntp_tiles_egtest.mm index 27f20db..8e7404e6 100644 --- a/ios/chrome/browser/ntp_tiles/ntp_tiles_egtest.mm +++ b/ios/chrome/browser/ntp_tiles/ntp_tiles_egtest.mm
@@ -4,6 +4,7 @@ #import <EarlGrey/EarlGrey.h> +#include "base/ios/ios_util.h" #import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/history_test_util.h" #import "ios/chrome/test/app/tab_test_util.h" @@ -66,6 +67,13 @@ // Tests that only one NTP tile is displayed for a TopSite that involves a // redirect. - (void)testTopSitesTileAfterRedirect { + // TODO(crbug.com/751224): This test fails on "Plus" devices, so disabling + // it on iOS 11 to unblock running the test case on iPhone 6 Plus, iOS 11. + // Re-enable this test once the bug is fixed. + if (base::ios::IsRunningOnIOS11OrLater()) { + EARL_GREY_TEST_DISABLED(@"Disabled on iOS 11."); + } + std::map<GURL, HtmlResponseProviderImpl::Response> responses; const GURL firstRedirectURL = HttpServer::MakeUrl("http://firstRedirect/"); const GURL destinationURL = HttpServer::MakeUrl("http://destination/");
diff --git a/ios/chrome/browser/ui/ntp/new_tab_page_egtest.mm b/ios/chrome/browser/ui/ntp/new_tab_page_egtest.mm index 51fdcfb..816e6c52 100644 --- a/ios/chrome/browser/ui/ntp/new_tab_page_egtest.mm +++ b/ios/chrome/browser/ui/ntp/new_tab_page_egtest.mm
@@ -5,6 +5,7 @@ #import <EarlGrey/EarlGrey.h> #import <XCTest/XCTest.h> +#include "base/ios/ios_util.h" #include "components/strings/grit/components_strings.h" #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" #include "ios/chrome/browser/ui/commands/ios_command_ids.h" @@ -143,6 +144,11 @@ EARL_GREY_TEST_DISABLED(@"Disabled for iPad due to device rotation bug."); } + // TODO(crbug.com/751803): Re-enable this test once the bug is fixed. + if (base::ios::IsRunningOnIOS11OrLater()) { + EARL_GREY_TEST_DISABLED(@"Disabled on iOS 11.") + } + NSString* ntpOmniboxLabel = l10n_util::GetNSString(IDS_OMNIBOX_EMPTY_HINT); NSString* focusedOmniboxLabel = l10n_util::GetNSString(IDS_ACCNAME_LOCATION); SelectNewTabPagePanel(NewTabPage::kHomePanel); @@ -214,6 +220,11 @@ // Tests focusing and defocusing the NTP's omnibox. - (void)testOmnibox { + // TODO(crbug.com/751803): Re-enable this test once the bug is fixed. + if (base::ios::IsRunningOnIOS11OrLater()) { + EARL_GREY_TEST_DISABLED(@"Disabled on iOS 11.") + } + // Empty the pasteboard: if it contains a link the Google Landing will not be // interactable. [UIPasteboard generalPasteboard].string = @""; @@ -282,6 +293,11 @@ EARL_GREY_TEST_SKIPPED(@"Skipped for iPad (no hidden toolbar in tablet)"); } + // TODO(crbug.com/751803): Re-enable this test once the bug is fixed. + if (base::ios::IsRunningOnIOS11OrLater()) { + EARL_GREY_TEST_DISABLED(@"Disabled on iOS 11.") + } + NSString* toolsMenuLabel = l10n_util::GetNSString(IDS_IOS_TOOLBAR_SETTINGS); // Check that the toolbar's tab switcher and tools menu buttons are visible.
diff --git a/media/base/android/media_drm_bridge.cc b/media/base/android/media_drm_bridge.cc index fed86f74..c9c4b4dd 100644 --- a/media/base/android/media_drm_bridge.cc +++ b/media/base/android/media_drm_bridge.cc
@@ -49,6 +49,9 @@ namespace { +using CreateMediaDrmBridgeCB = + base::OnceCallback<scoped_refptr<MediaDrmBridge>(void)>; + // These must be in sync with Android MediaDrm REQUEST_TYPE_XXX constants! // https://developer.android.com/reference/android/media/MediaDrm.KeyRequest.html enum class RequestType : uint32_t { @@ -268,6 +271,24 @@ base::android::BuildInfo::GetInstance()->sdk_int() >= 23; } +// Callback for MediaDrmStorageBridge::Initialize. +// |create_media_drm_bridge_cb|, factory method to create MediaDrmBridge. +// |created_cb|, callback to return the MediaDrmBridge to caller of +// MediaDrmBridge::Create. +void OnStorageInitialized(CreateMediaDrmBridgeCB create_media_drm_bridge_cb, + MediaDrmBridge::CreatedCB created_cb, + MediaDrmStorageBridge* storage) { + DCHECK(storage); + + // MediaDrmStorageBridge should always return a valid origin ID after + // initialize. Otherwise the pipe is broken and we should not create + // MediaDrmBridge here. + std::move(created_cb) + .Run(storage->origin_id().empty() + ? nullptr + : std::move(create_media_drm_bridge_cb).Run()); +} + } // namespace // MediaDrm is not generally usable without MediaCodec. Thus, both the MediaDrm @@ -319,7 +340,7 @@ } // static -void MediaDrmBridge::CreateInternal( +scoped_refptr<MediaDrmBridge> MediaDrmBridge::CreateInternal( const std::vector<uint8_t>& scheme_uuid, SecurityLevel security_level, std::unique_ptr<MediaDrmStorageBridge> storage, @@ -327,8 +348,7 @@ const SessionMessageCB& session_message_cb, const SessionClosedCB& session_closed_cb, const SessionKeysChangeCB& session_keys_change_cb, - const SessionExpirationUpdateCB& session_expiration_update_cb, - CreatedCB created_cb) { + const SessionExpirationUpdateCB& session_expiration_update_cb) { // All paths requires the MediaDrmApis. DCHECK(AreMediaDrmApisAvailable()); DCHECK(!scheme_uuid.empty()); @@ -339,11 +359,9 @@ session_expiration_update_cb)); if (media_drm_bridge->j_media_drm_.is_null()) - media_drm_bridge = nullptr; + return nullptr; - // Return |media_drm_bridge| asynchronously to make the callback binding - // easier. - std::move(created_cb).Run(std::move(media_drm_bridge)); + return media_drm_bridge; } // static @@ -375,18 +393,19 @@ auto storage = base::MakeUnique<MediaDrmStorageBridge>(); MediaDrmStorageBridge* raw_storage = storage.get(); - base::OnceClosure create_media_drm_cb = base::BindOnce( + CreateMediaDrmBridgeCB create_media_drm_bridge_cb = base::BindOnce( &MediaDrmBridge::CreateInternal, scheme_uuid, security_level, - base::Passed(&storage), create_fetcher_cb, session_message_cb, - session_closed_cb, session_keys_change_cb, session_expiration_update_cb, - base::Passed(&created_cb)); + std::move(storage), create_fetcher_cb, session_message_cb, + session_closed_cb, session_keys_change_cb, session_expiration_update_cb); if (IsPersistentLicenseTypeSupported(key_system) && !security_origin.is_empty() && !create_storage_cb.is_null()) { - raw_storage->Initialize(url::Origin(security_origin), create_storage_cb, - std::move(create_media_drm_cb)); + raw_storage->Initialize( + create_storage_cb, base::BindOnce(&OnStorageInitialized, + std::move(create_media_drm_bridge_cb), + std::move(created_cb), raw_storage)); } else { - std::move(create_media_drm_cb).Run(); + std::move(created_cb).Run(std::move(create_media_drm_bridge_cb).Run()); } } @@ -868,16 +887,9 @@ // CreateWithoutSessionSupport, which is used to reset credentials. !storage_->origin_id().empty(); - // TODO(yucliu): Per EME spec on individualization, implementation should not - // expose application-specific information. Considering encode origin before - // passing to MediaDrm. ScopedJavaLocalRef<jstring> j_security_origin = ConvertUTF8ToJavaString( env, use_origin_isolated_storage ? storage_->origin_id() : ""); - // TODO(yucliu): Use |create_storage_cb_| to create MediaDrmStorage which can - // be used by Java side to store/retrieve persistent data. This should only - // be used when |use_origin_isolated_storage| is true. - // Note: OnMediaCryptoReady() could be called in this call. j_media_drm_.Reset(Java_MediaDrmBridge_create( env, j_scheme_uuid, j_security_origin, j_security_level,
diff --git a/media/base/android/media_drm_bridge.h b/media/base/android/media_drm_bridge.h index 5e922c2..a257d6cc 100644 --- a/media/base/android/media_drm_bridge.h +++ b/media/base/android/media_drm_bridge.h
@@ -250,7 +250,7 @@ // For DeleteSoon() in DeleteOnCorrectThread(). friend class base::DeleteHelper<MediaDrmBridge>; - static void CreateInternal( + static scoped_refptr<MediaDrmBridge> CreateInternal( const std::vector<uint8_t>& scheme_uuid, SecurityLevel security_level, std::unique_ptr<MediaDrmStorageBridge> storage, @@ -258,8 +258,7 @@ const SessionMessageCB& session_message_cb, const SessionClosedCB& session_closed_cb, const SessionKeysChangeCB& session_keys_change_cb, - const SessionExpirationUpdateCB& session_expiration_update_cb, - CreatedCB bound_cdm_created_cb); + const SessionExpirationUpdateCB& session_expiration_update_cb); // Constructs a MediaDrmBridge for |scheme_uuid| and |security_level|. The // default security level will be used if |security_level| is
diff --git a/media/base/android/media_drm_storage.h b/media/base/android/media_drm_storage.h index a71c207c..120934c7 100644 --- a/media/base/android/media_drm_storage.h +++ b/media/base/android/media_drm_storage.h
@@ -17,6 +17,10 @@ #include "media/base/media_export.h" #include "url/origin.h" +namespace base { +class UnguessableToken; +} // namespace base + namespace media { // Allows MediaDrmBridge to store and retrieve persistent data. This is needed @@ -39,17 +43,21 @@ // Callback to return whether the operation succeeded. using ResultCB = base::OnceCallback<void(bool)>; + // Callback for storage initialization. + using InitCB = + base::OnceCallback<void(const base::UnguessableToken& origin_id)>; + // Callback to return the result of LoadPersistentSession. |key_set_id| and // |mime_type| must be non-empty if |success| is true, and vice versa. using LoadPersistentSessionCB = base::OnceCallback<void(std::unique_ptr<SessionData> session_data)>; - // Binds |this| to |origin|. - // TODO(xhwang): The host of the service should know about the last committed - // origin. We should solely use that origin, or check the |origin| against it. - // TODO(xhwang): We should NOT use the real origin for provisioning. Use a - // random origin ID instead. - virtual void Initialize(const url::Origin& origin) = 0; + // Initialize the storage for current origin. The implementation already know + // the origin for the storage. + // Implementation should return a random origin id in |init_cb|. The ID should + // be unique and persisted. Origin ID must be valid. If any corruption is + // detected, the old map should be removed in OnProvisioned. + virtual void Initialize(InitCB init_cb) = 0; // Called when MediaDrm is provisioned for the origin bound to |this|. // The implementation should keep track of the storing time so that the
diff --git a/media/base/android/media_drm_storage_bridge.cc b/media/base/android/media_drm_storage_bridge.cc index b300b57..dadd395c 100644 --- a/media/base/android/media_drm_storage_bridge.cc +++ b/media/base/android/media_drm_storage_bridge.cc
@@ -15,6 +15,7 @@ #include "base/bind.h" #include "base/single_thread_task_runner.h" #include "base/threading/thread_task_runner_handle.h" +#include "base/unguessable_token.h" #include "jni/MediaDrmStorageBridge_jni.h" #include "media/base/android/android_util.h" @@ -38,18 +39,14 @@ MediaDrmStorageBridge::~MediaDrmStorageBridge() = default; -void MediaDrmStorageBridge::Initialize(const url::Origin& origin, - const CreateStorageCB& create_storage_cb, - base::OnceClosure on_init) { +void MediaDrmStorageBridge::Initialize(const CreateStorageCB& create_storage_cb, + base::OnceClosure init_cb) { DCHECK(create_storage_cb); impl_ = create_storage_cb.Run(); - // TODO(yucliu): MediaDrmStorage should generate and return origin id - // asynchronously in a callback. - impl_->Initialize(origin); - origin_id_ = origin.Serialize(); - - std::move(on_init).Run(); + impl_->Initialize(base::BindOnce(&MediaDrmStorageBridge::OnInitialized, + weak_factory_.GetWeakPtr(), + std::move(init_cb))); } void MediaDrmStorageBridge::OnProvisioned( @@ -139,6 +136,17 @@ RunCallbackAndroid(*j_callback, success); } +void MediaDrmStorageBridge::OnInitialized( + base::OnceClosure init_cb, + const base::UnguessableToken& origin_id) { + DCHECK(origin_id_.empty()); + + if (origin_id) + origin_id_ = origin_id.ToString(); + + std::move(init_cb).Run(); +} + void MediaDrmStorageBridge::OnSessionDataLoaded( JavaObjectPtr j_callback, const std::string& session_id,
diff --git a/media/base/android/media_drm_storage_bridge.h b/media/base/android/media_drm_storage_bridge.h index e9e9689d..ca136cfe 100644 --- a/media/base/android/media_drm_storage_bridge.h +++ b/media/base/android/media_drm_storage_bridge.h
@@ -32,11 +32,10 @@ MediaDrmStorageBridge(); ~MediaDrmStorageBridge(); - // Bind origin to |this|. Once storage is initialized, |on_init| will be - // called and it will have a random generated origin id for later usage. If - // this function isn't called, all the other functions will fail. - void Initialize(const url::Origin& origin, - const CreateStorageCB& create_storage_cb, + // Once storage is initialized, |init_cb| will be called and it will have a + // random generated origin id for later usage. If this function isn't called, + // all the other functions will fail. + void Initialize(const CreateStorageCB& create_storage_cb, base::OnceClosure init_cb); std::string origin_id() const { return origin_id_; } @@ -76,6 +75,8 @@ private: void RunAndroidBoolCallback(JavaObjectPtr j_callback, bool success); + void OnInitialized(base::OnceClosure init_cb, + const base::UnguessableToken& origin_id); void OnSessionDataLoaded( JavaObjectPtr j_callback, const std::string& session_id,
diff --git a/media/mojo/interfaces/media_drm_storage.mojom b/media/mojo/interfaces/media_drm_storage.mojom index a84dd6b..c6e2b2a 100644 --- a/media/mojo/interfaces/media_drm_storage.mojom +++ b/media/mojo/interfaces/media_drm_storage.mojom
@@ -4,7 +4,7 @@ module media.mojom; -import "url/mojo/origin.mojom"; +import "mojo/common/unguessable_token.mojom"; struct SessionData { array<uint8> key_set_id; @@ -14,11 +14,14 @@ // Allows MediaDrmBridge to store and retrieve persistent data. This is needed // for features like per-origin provisioning and persistent license support. interface MediaDrmStorage { - // Initializes |this| to be bound to the |origin|. This should not modify - // anything in the storage. - Initialize(url.mojom.Origin origin); + // Initializes |this| and return a random orign ID which can identify the + // current origin. The origin ID should be randomly generated if it doesn't + // exist. |origin_id| must be valid. + // This should not modify anything in the storage. + Initialize() => (mojo.common.mojom.UnguessableToken origin_id); - // Saves |origin| in the storage after MediaDrm is provisioned for |origin|. + // Saves origin information (e.g. origin ID, provision time) in the storage + // after MediaDrm is provisioned for current origin. OnProvisioned() => (bool success); // Saves persistent session data for |session_id|.
diff --git a/media/mojo/interfaces/video_frame_struct_traits.cc b/media/mojo/interfaces/video_frame_struct_traits.cc index c68fed42..bd73cde 100644 --- a/media/mojo/interfaces/video_frame_struct_traits.cc +++ b/media/mojo/interfaces/video_frame_struct_traits.cc
@@ -56,26 +56,10 @@ } // namespace // static -void* StructTraits<media::mojom::VideoFrameDataView, - scoped_refptr<media::VideoFrame>>:: - SetUpContext(const scoped_refptr<media::VideoFrame>& input) { - return new media::mojom::VideoFrameDataPtr(MakeVideoFrameData(input)); -} - -// static -void StructTraits<media::mojom::VideoFrameDataView, - scoped_refptr<media::VideoFrame>>:: - TearDownContext(const scoped_refptr<media::VideoFrame>& input, - void* context) { - delete static_cast<media::mojom::VideoFrameDataPtr*>(context); -} - -// static -media::mojom::VideoFrameDataPtr& -StructTraits<media::mojom::VideoFrameDataView, - scoped_refptr<media::VideoFrame>>:: - data(const scoped_refptr<media::VideoFrame>& input, void* context) { - return *static_cast<media::mojom::VideoFrameDataPtr*>(context); +media::mojom::VideoFrameDataPtr StructTraits<media::mojom::VideoFrameDataView, + scoped_refptr<media::VideoFrame>>:: + data(const scoped_refptr<media::VideoFrame>& input) { + return media::mojom::VideoFrameDataPtr(MakeVideoFrameData(input)); } // static
diff --git a/media/mojo/interfaces/video_frame_struct_traits.h b/media/mojo/interfaces/video_frame_struct_traits.h index 3324b09..712a3270 100644 --- a/media/mojo/interfaces/video_frame_struct_traits.h +++ b/media/mojo/interfaces/video_frame_struct_traits.h
@@ -19,11 +19,6 @@ template <> struct StructTraits<media::mojom::VideoFrameDataView, scoped_refptr<media::VideoFrame>> { - static void* SetUpContext(const scoped_refptr<media::VideoFrame>& input); - - static void TearDownContext(const scoped_refptr<media::VideoFrame>&, - void* context); - static bool IsNull(const scoped_refptr<media::VideoFrame>& input) { return !input; } @@ -57,9 +52,8 @@ return input->timestamp(); } - static media::mojom::VideoFrameDataPtr& data( - const scoped_refptr<media::VideoFrame>& input, - void* context); + static media::mojom::VideoFrameDataPtr data( + const scoped_refptr<media::VideoFrame>& input); static bool Read(media::mojom::VideoFrameDataView input, scoped_refptr<media::VideoFrame>* output);
diff --git a/media/mojo/services/mojo_media_drm_storage.cc b/media/mojo/services/mojo_media_drm_storage.cc index 0bf1e99b..f91cc76 100644 --- a/media/mojo/services/mojo_media_drm_storage.cc +++ b/media/mojo/services/mojo_media_drm_storage.cc
@@ -25,9 +25,10 @@ MojoMediaDrmStorage::~MojoMediaDrmStorage() {} -void MojoMediaDrmStorage::Initialize(const url::Origin& origin) { +void MojoMediaDrmStorage::Initialize(InitCB init_cb) { DVLOG(1) << __func__; - media_drm_storage_ptr_->Initialize(origin); + media_drm_storage_ptr_->Initialize( + ScopedCallbackRunner(std::move(init_cb), base::UnguessableToken())); } void MojoMediaDrmStorage::OnProvisioned(ResultCB result_cb) {
diff --git a/media/mojo/services/mojo_media_drm_storage.h b/media/mojo/services/mojo_media_drm_storage.h index b74f9ded..84e53bd 100644 --- a/media/mojo/services/mojo_media_drm_storage.h +++ b/media/mojo/services/mojo_media_drm_storage.h
@@ -24,7 +24,7 @@ ~MojoMediaDrmStorage() final; // MediaDrmStorage implementation: - void Initialize(const url::Origin& origin) final; + void Initialize(InitCB init_cb) final; void OnProvisioned(ResultCB result_cb) final; void SavePersistentSession(const std::string& session_id, const SessionData& session_data,
diff --git a/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.cc b/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.cc index 6b770b1..2586d8d0 100644 --- a/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.cc +++ b/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.cc
@@ -5,39 +5,11 @@ #include "mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.h" namespace mojo { -namespace { - -struct Context { - int32_t value; -}; - -} // namespace - -// static -void* StructTraits<test::NestedStructWithTraitsDataView, - test::NestedStructWithTraitsImpl>:: - SetUpContext(const test::NestedStructWithTraitsImpl& input) { - Context* context = new Context; - context->value = input.value; - return context; -} - -// static -void StructTraits<test::NestedStructWithTraitsDataView, - test::NestedStructWithTraitsImpl>:: - TearDownContext(const test::NestedStructWithTraitsImpl& input, - void* context) { - Context* context_obj = static_cast<Context*>(context); - CHECK_EQ(context_obj->value, input.value); - delete context_obj; -} // static int32_t StructTraits<test::NestedStructWithTraitsDataView, test::NestedStructWithTraitsImpl>:: - value(const test::NestedStructWithTraitsImpl& input, void* context) { - Context* context_obj = static_cast<Context*>(context); - CHECK_EQ(context_obj->value, input.value); + value(const test::NestedStructWithTraitsImpl& input) { return input.value; }
diff --git a/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.h b/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.h index 3590bd55..59a5d1a2 100644 --- a/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.h +++ b/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.h
@@ -20,12 +20,7 @@ template <> struct StructTraits<test::NestedStructWithTraitsDataView, test::NestedStructWithTraitsImpl> { - static void* SetUpContext(const test::NestedStructWithTraitsImpl& input); - static void TearDownContext(const test::NestedStructWithTraitsImpl& input, - void* context); - - static int32_t value(const test::NestedStructWithTraitsImpl& input, - void* context); + static int32_t value(const test::NestedStructWithTraitsImpl& input); static bool Read(test::NestedStructWithTraitsDataView data, test::NestedStructWithTraitsImpl* output);
diff --git a/net/cert/internal/certificate_policies.cc b/net/cert/internal/certificate_policies.cc index 5bd04a0..db7cd19 100644 --- a/net/cert/internal/certificate_policies.cc +++ b/net/cert/internal/certificate_policies.cc
@@ -31,6 +31,10 @@ "PolicyInformation has trailing data"); DEFINE_CERT_ERROR_ID(kFailedParsingPolicyQualifiers, "Failed parsing policy qualifiers"); +DEFINE_CERT_ERROR_ID(kMissingQualifier, + "PolicyQualifierInfo is missing qualifier"); +DEFINE_CERT_ERROR_ID(kPolicyQualifierInfoTrailingData, + "PolicyQualifierInfo has trailing data"); // -- policyQualifierIds for Internet policy qualifiers // @@ -90,11 +94,15 @@ // qualifier ANY DEFINED BY policyQualifierId } der::Tag tag; der::Input value; - if (!policy_information_parser.ReadTagAndValue(&tag, &value)) + if (!policy_information_parser.ReadTagAndValue(&tag, &value)) { + errors->AddError(kMissingQualifier); return false; + } // Should not have trailing data after qualifier. - if (policy_information_parser.HasMore()) + if (policy_information_parser.HasMore()) { + errors->AddError(kPolicyQualifierInfoTrailingData); return false; + } } return true; }
diff --git a/net/cert/internal/parsed_certificate_unittest.cc b/net/cert/internal/parsed_certificate_unittest.cc index 75fa1034..ac4005e 100644 --- a/net/cert/internal/parsed_certificate_unittest.cc +++ b/net/cert/internal/parsed_certificate_unittest.cc
@@ -141,7 +141,8 @@ ASSERT_FALSE(ParseCertificateFromFile("bad_key_usage.pem", {})); } -// TODO(eroman): What is wrong with policy qualifiers? +// Parses a certificate that has a PolicyQualifierInfo that is missing the +// qualifier field. TEST(ParsedCertificateTest, BadPolicyQualifiers) { ASSERT_FALSE(ParseCertificateFromFile("bad_policy_qualifiers.pem", {})); } @@ -151,7 +152,8 @@ ASSERT_FALSE(ParseCertificateFromFile("bad_signature_algorithm_oid.pem", {})); } -// TODO(eroman): What is wrong with the validity? +// The validity encodes time as UTCTime but following the BER rules rather than +// DER rules (i.e. YYMMDDHHMMZ instead of YYMMDDHHMMSSZ). TEST(ParsedCertificateTest, BadValidity) { ASSERT_FALSE(ParseCertificateFromFile("bad_validity.pem", {})); }
diff --git a/net/data/parse_certificate_unittest/bad_policy_qualifiers.pem b/net/data/parse_certificate_unittest/bad_policy_qualifiers.pem index 8a40fb7..ee61eb5 100644 --- a/net/data/parse_certificate_unittest/bad_policy_qualifiers.pem +++ b/net/data/parse_certificate_unittest/bad_policy_qualifiers.pem
@@ -21,9 +21,10 @@ xcGy1rNRBQkfkzAR96isuvSTTV+GpXi/VbYaQFOwhkmyrr0udUT5RuPk7+4ca2ebEJYHZ0= -----END CERTIFICATE----- +ERROR: PolicyQualifierInfo is missing qualifier ERROR: Failed parsing policy qualifiers ERROR: Failed parsing certificate policies -----BEGIN ERRORS----- -RVJST1I6IEZhaWxlZCBwYXJzaW5nIHBvbGljeSBxdWFsaWZpZXJzCkVSUk9SOiBGYWlsZWQgcGFyc2luZyBjZXJ0aWZpY2F0ZSBwb2xpY2llcwo= +RVJST1I6IFBvbGljeVF1YWxpZmllckluZm8gaXMgbWlzc2luZyBxdWFsaWZpZXIKRVJST1I6IEZhaWxlZCBwYXJzaW5nIHBvbGljeSBxdWFsaWZpZXJzCkVSUk9SOiBGYWlsZWQgcGFyc2luZyBjZXJ0aWZpY2F0ZSBwb2xpY2llcwo= -----END ERRORS-----
diff --git a/remoting/ios/app/host_view_controller.mm b/remoting/ios/app/host_view_controller.mm index 0babcdbb..a1ca14f 100644 --- a/remoting/ios/app/host_view_controller.mm +++ b/remoting/ios/app/host_view_controller.mm
@@ -32,6 +32,7 @@ static const CGFloat kFabInset = 15.f; static const CGFloat kKeyboardAnimationTime = 0.3; +static const CGFloat kMoveFABAnimationTime = 0.3; @interface HostViewController ()<ClientKeyboardDelegate, ClientGesturesDelegate, @@ -44,7 +45,9 @@ CGSize _keyboardSize; BOOL _surfaceCreated; HostSettings* _settings; - + BOOL _fabIsRight; + NSArray<NSLayoutConstraint*>* _fabLeftConstraints; + NSArray<NSLayoutConstraint*>* _fabRightConstraints; // When set to true, ClientKeyboard will immediately resign first responder // after it becomes first responder. BOOL _blocksKeyboard; @@ -62,6 +65,14 @@ _blocksKeyboard = NO; _settings = [[RemotingPreferences instance] settingsForHost:client.hostInfo.hostId]; + + if ([UIView userInterfaceLayoutDirectionForSemanticContentAttribute: + self.view.semanticContentAttribute] == + UIUserInterfaceLayoutDirectionRightToLeft) { + _fabIsRight = NO; + } else { + _fabIsRight = YES; + } } return self; } @@ -89,6 +100,7 @@ action:@selector(didTap:) forControlEvents:UIControlEventTouchUpInside]; [_floatingButton sizeToFit]; + _floatingButton.translatesAutoresizingMaskIntoConstraints = NO; _actionImageView = [[MDCActionImageView alloc] initWithFrame:_floatingButton.bounds @@ -102,7 +114,28 @@ _clientKeyboard = [[ClientKeyboard alloc] init]; _clientKeyboard.delegate = self; [self.view addSubview:_clientKeyboard]; - // TODO(nicholss): need to pass some keyboard injection interface here. + + NSDictionary* views = @{@"fab" : _floatingButton}; + NSDictionary* metrics = @{ @"inset" : @(kFabInset) }; + + _fabLeftConstraints = [NSLayoutConstraint + constraintsWithVisualFormat:@"H:|-(inset)-[fab]" + options:NSLayoutFormatDirectionLeftToRight + metrics:metrics + views:views]; + + _fabRightConstraints = [NSLayoutConstraint + constraintsWithVisualFormat:@"H:[fab]-(inset)-|" + options:NSLayoutFormatDirectionLeftToRight + metrics:metrics + views:views]; + + [NSLayoutConstraint + activateConstraints:[NSLayoutConstraint + constraintsWithVisualFormat:@"V:[fab]-(inset)-|" + options:0 + metrics:metrics + views:views]]; } - (void)viewDidUnload { @@ -184,11 +217,7 @@ [self resizeHostToFitIfNeeded]; } - CGSize btnSize = _floatingButton.frame.size; - _floatingButton.frame = - CGRectMake(self.view.frame.size.width - btnSize.width - kFabInset, - self.view.frame.size.height - btnSize.height - kFabInset, - btnSize.width, btnSize.height); + [self updateFABConstraintsAnimated:NO]; } #pragma mark - Keyboard @@ -296,8 +325,32 @@ _client.keyboardInterpreter->HandlePrintScreenEvent(); } +- (void)moveFAB { + _fabIsRight = !_fabIsRight; + [self updateFABConstraintsAnimated:YES]; +} + #pragma mark - Private +- (void)updateFABConstraintsAnimated:(BOOL)animated { + [NSLayoutConstraint deactivateConstraints:_fabRightConstraints]; + [NSLayoutConstraint deactivateConstraints:_fabLeftConstraints]; + if (_fabIsRight) { + [NSLayoutConstraint activateConstraints:_fabRightConstraints]; + } else { + [NSLayoutConstraint activateConstraints:_fabLeftConstraints]; + } + + if (animated) { + [UIView animateWithDuration:kMoveFABAnimationTime + animations:^{ + [self.view layoutIfNeeded]; + }]; + } else { + [self.view layoutIfNeeded]; + } +} + - (void)resizeHostToFitIfNeeded { // Don't adjust the host resolution if the keyboard is active. That would end // up with a very narrow desktop. @@ -414,6 +467,18 @@ restoresKeyboard:NO handler:settingsHandler]; + void (^moveFABHandler)(UIAlertAction*) = ^(UIAlertAction*) { + [weakSelf moveFAB]; + [_actionImageView setActive:NO animated:YES]; + }; + [alert addAction:[UIAlertAction + actionWithTitle:l10n_util::GetNSString( + (_fabIsRight) + ? IDS_MOVE_FAB_LEFT_BUTTON + : IDS_MOVE_FAB_RIGHT_BUTTON) + style:UIAlertActionStyleDefault + handler:moveFABHandler]]; + __weak UIAlertController* weakAlert = alert; void (^cancelHandler)() = ^() { [weakAlert dismissViewControllerAnimated:YES completion:nil];
diff --git a/remoting/resources/remoting_strings.grd b/remoting/resources/remoting_strings.grd index d58dc31..6be5920 100644 --- a/remoting/resources/remoting_strings.grd +++ b/remoting/resources/remoting_strings.grd
@@ -717,6 +717,12 @@ <message desc="Title for the button that brings up a settings menu." name="IDS_SETTINGS_BUTTON"> Settings </message> + <message desc="Title for the button that moves the floating action button to the other left side of the screen." name="IDS_MOVE_FAB_LEFT_BUTTON"> + Dock Left + </message> + <message desc="Title for the button that moves the floating action button to the right side of the screen." name="IDS_MOVE_FAB_RIGHT_BUTTON"> + Dock Right + </message> <message desc="Short placeholder text on a text box to prompt the user to enter the PIN." name="IDS_ENTER_PIN"> Enter PIN </message>
diff --git a/services/device/generic_sensor/README.md b/services/device/generic_sensor/README.md index 7e6bcc8..f294d5f6 100644 --- a/services/device/generic_sensor/README.md +++ b/services/device/generic_sensor/README.md
@@ -59,7 +59,10 @@ Sensors are implemented by passing through values provided by the [Sensor API](https://msdn.microsoft.com/en-us/library/windows/desktop/dd318953(v=vs.85).aspx). The values in the "Windows" column of the table above correspond to the names of -the sensor type GUIDs used to provide data for a SensorType. +the sensor type GUIDs used to provide data for a SensorType. The +LINEAR_ACCELEROMETER sensor type is provided by implementing a low-pass-filter +over the values returned by the ACCELEROMETER in order to remove the +contribution of the gravitational force. ## Testing
diff --git a/services/identity/public/cpp/scope_set_struct_traits.h b/services/identity/public/cpp/scope_set_struct_traits.h index 467b9065..17882b0 100644 --- a/services/identity/public/cpp/scope_set_struct_traits.h +++ b/services/identity/public/cpp/scope_set_struct_traits.h
@@ -11,22 +11,11 @@ template <> struct StructTraits<identity::mojom::ScopeSet::DataView, identity::ScopeSet> { - static void* SetUpContext(const identity::ScopeSet& scope_set) { - std::vector<std::string>* scopes = new std::vector<std::string>(); + static std::vector<std::string> scopes(const identity::ScopeSet& scope_set) { + std::vector<std::string> entries; for (const auto& scope : scope_set) - scopes->push_back(scope); - return scopes; - } - - static void TearDownContext(const identity::ScopeSet& scope_set, - void* context) { - delete static_cast<std::vector<std::string>*>(context); - } - - static const std::vector<std::string>& scopes( - const identity::ScopeSet& scope_set, - void* context) { - return *(static_cast<std::vector<std::string>*>(context)); + entries.push_back(scope); + return entries; } static bool Read(identity::mojom::ScopeSetDataView data,
diff --git a/services/service_manager/public/interfaces/BUILD.gn b/services/service_manager/public/interfaces/BUILD.gn index e91d473..a98a02d 100644 --- a/services/service_manager/public/interfaces/BUILD.gn +++ b/services/service_manager/public/interfaces/BUILD.gn
@@ -22,9 +22,6 @@ ":constants", "//mojo/common:common_custom_types", ] - - # TODO(crbug.com/699569): Convert to use the new JS bindings. - use_new_js_bindings = false } mojom_component("constants") { @@ -33,7 +30,4 @@ sources = [ "constants.mojom", ] - - # TODO(crbug.com/699569): Convert to use the new JS bindings. - use_new_js_bindings = false }
diff --git a/testing/variations/fieldtrial_testing_config.json b/testing/variations/fieldtrial_testing_config.json index 392a2d6..3bbd16a 100644 --- a/testing/variations/fieldtrial_testing_config.json +++ b/testing/variations/fieldtrial_testing_config.json
@@ -1024,6 +1024,24 @@ ] } ], + "GuestViewCrossProcessFrames": [ + { + "platforms": [ + "chromeos", + "linux", + "mac", + "win" + ], + "experiments": [ + { + "name": "Enabled", + "enable_features": [ + "GuestViewCrossProcessFrames" + ] + } + ] + } + ], "Html5ByDefault": [ { "platforms": [
diff --git a/third_party/WebKit/LayoutTests/FlagExpectations/enable-blink-features=LayoutNG b/third_party/WebKit/LayoutTests/FlagExpectations/enable-blink-features=LayoutNG index d83ee9d4..2bb49f3 100644 --- a/third_party/WebKit/LayoutTests/FlagExpectations/enable-blink-features=LayoutNG +++ b/third_party/WebKit/LayoutTests/FlagExpectations/enable-blink-features=LayoutNG
@@ -13221,20 +13221,20 @@ crbug.com/591099 inspector/console/command-line-api-getEventListeners.html [ Crash Failure ] crbug.com/591099 inspector/console/console-Object-overwritten.html [ Failure ] crbug.com/591099 inspector/console/console-api-on-call-frame.html [ Crash Failure ] -crbug.com/591099 inspector/console/console-bind-fake.html [ Failure ] -crbug.com/591099 inspector/console/console-call-getter-on-proto.html [ Failure ] +crbug.com/591099 http/tests/devtools/console/console-bind-fake.js [ Failure ] +crbug.com/591099 http/tests/devtools/console/console-call-getter-on-proto.js [ Failure ] crbug.com/591099 inspector/console/console-clear-function.html [ Failure ] -crbug.com/591099 inspector/console/console-command-clear.html [ Failure ] +crbug.com/591099 http/tests/devtools/console/console-command-clear.js [ Failure ] crbug.com/591099 inspector/console/console-command-copy.html [ Failure ] crbug.com/591099 inspector/console/console-context-selector.html [ Crash Failure ] -crbug.com/591099 inspector/console/console-control-characters.html [ Failure ] +crbug.com/591099 http/tests/devtools/console/console-control-characters.js [ Failure ] crbug.com/591099 inspector/console/console-copy-treeoutline.html [ Failure ] crbug.com/591099 inspector/console/console-copy-truncated-text.html [ Crash Failure ] -crbug.com/591099 inspector/console/console-correct-suggestions.html [ Failure ] -crbug.com/591099 inspector/console/console-dir-deprecated.html [ Failure ] -crbug.com/591099 inspector/console/console-dir-global.html [ Failure ] -crbug.com/591099 inspector/console/console-dir.html [ Failure ] -crbug.com/591099 inspector/console/console-edit-property-value.html [ Crash Failure ] +crbug.com/591099 http/tests/devtools/console/console-correct-suggestions.js [ Failure ] +crbug.com/591099 http/tests/devtools/console/console-dir-deprecated.js [ Failure ] +crbug.com/591099 http/tests/devtools/console/console-dir-global.js [ Failure ] +crbug.com/591099 http/tests/devtools/console/console-dir.js [ Failure ] +crbug.com/591099 http/tests/devtools/console/console-edit-property-value.js [ Crash Failure ] crbug.com/591099 inspector/console/console-error-on-call-frame.html [ Crash Failure ] crbug.com/591099 inspector/console/console-eval-blocked.html [ Failure ] crbug.com/591099 inspector/console/console-eval-exception-report.html [ Failure ]
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations index cca7d3d2..ec16f06 100644 --- a/third_party/WebKit/LayoutTests/TestExpectations +++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -615,6 +615,9 @@ ### virtual/mojo-loading/http/tests/devtools +### Manually fix after migration +crbug.com/667560 virtual/mojo-loading/http/tests/devtools/console/console-dir.js [ NeedsManualRebaseline ] + # ====== DevTools test migration failures until here ====== # Run these tests with under virtual/scalefactor... only. @@ -667,7 +670,7 @@ crbug.com/520611 [ Debug ] fast/filesystem/workers/file-writer-events-shared-worker.html [ Failure Pass ] crbug.com/520194 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-overridesexpires.html [ Failure Pass ] -crbug.com/749251 [ Mac10.9 Mac10.11 ] http/tests/inspector/application-panel/resources-panel-websql.html [ Failure Pass ] +crbug.com/749251 [ Mac ] http/tests/inspector/application-panel/resources-panel-websql.html [ Failure Pass ] crbug.com/233303 [ Win7 Debug ] inspector/sources/debugger-breakpoints/dom-breakpoints.html [ Pass Failure Timeout ] @@ -2933,7 +2936,7 @@ # Sheriff failures 2017-06-23 crbug.com/736548 [ Mac ] css2.1/t040304-c64-uri-00-a-g.html [ Failure Pass ] -crbug.com/v8/6529 inspector/console/console-dir.html [ NeedsManualRebaseline ] +crbug.com/v8/6529 http/tests/devtools/console/console-dir.js [ NeedsManualRebaseline ] crbug.com/v8/6529 inspector/console/console-format.html [ NeedsManualRebaseline ] crbug.com/737959 http/tests/misc/object-image-load-outlives-gc-without-crashing.html [ Failure Pass ]
diff --git a/third_party/WebKit/LayoutTests/harness-tests/mojo-helpers.html b/third_party/WebKit/LayoutTests/harness-tests/mojo-helpers.html index cb27dce..0bba163 100644 --- a/third_party/WebKit/LayoutTests/harness-tests/mojo-helpers.html +++ b/third_party/WebKit/LayoutTests/harness-tests/mojo-helpers.html
@@ -94,17 +94,6 @@ }, 'Test code can receive response messages from mock interfaces.'); mojo_test(() => { - return loadMojoModules( - 'module loading test', - ['services/service_manager/public/interfaces/interface_provider.mojom']).then(mojo => { - let interfaceProvider = mojo.modules[0]; - assert_equals(interfaceProvider.InterfaceProvider.name, - 'service_manager::mojom::InterfaceProvider'); - - }); -}, 'Generated mojo bindings can be loaded in tests'); - -mojo_test(() => { return new Promise(resolve => { let iframe = document.createElement('iframe'); let listener = result => {
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-bind-fake-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-bind-fake-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/inspector/console/console-bind-fake-expected.txt rename to third_party/WebKit/LayoutTests/http/tests/devtools/console/console-bind-fake-expected.txt
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-bind-fake.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-bind-fake.js new file mode 100644 index 0000000..acb0e308 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-bind-fake.js
@@ -0,0 +1,22 @@ +// 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. + +(async function() { + TestRunner.addResult(`Tests that overriding Function.prototype.bind does not break inspector.\n`); + + await TestRunner.loadModule('console_test_runner'); + await TestRunner.showPanel('console'); + + await TestRunner.evaluateInPagePromise(` + var foo = 'fooValue'; + Function.prototype.bind = function () { throw ":P"; }; + `); + + ConsoleTestRunner.evaluateInConsole('foo', step1); + + function step1() { + ConsoleTestRunner.dumpConsoleMessages(); + TestRunner.completeTest(); + } +})();
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-call-getter-on-proto-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-call-getter-on-proto-expected.txt similarity index 66% rename from third_party/WebKit/LayoutTests/inspector/console/console-call-getter-on-proto-expected.txt rename to third_party/WebKit/LayoutTests/http/tests/devtools/console/console-call-getter-on-proto-expected.txt index c7870da..ad4c2dcb 100644 --- a/third_party/WebKit/LayoutTests/inspector/console/console-call-getter-on-proto-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-call-getter-on-proto-expected.txt
@@ -1,7 +1,6 @@ -CONSOLE MESSAGE: line 21: [object Object] Tests that calling getter on prototype will call it on the object. -console-call-getter-on-proto.html:21 B {value: 239} +console-call-getter-on-proto.js:27 B {value: 239} foo: 239 value: 239 __proto__: A
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-call-getter-on-proto.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-call-getter-on-proto.js new file mode 100644 index 0000000..5fba12f --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-call-getter-on-proto.js
@@ -0,0 +1,54 @@ +// 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. + +(async function() { + TestRunner.addResult(`Tests that calling getter on prototype will call it on the object.\n`); + + await TestRunner.loadModule('console_test_runner'); + await TestRunner.showPanel('console'); + + await TestRunner.evaluateInPagePromise(` + function logObject() + { + var A = function() { this.value = 239; } + A.prototype = { + constructor: A, + get foo() + { + return this.value; + } + } + var B = function() { A.call(this); } + B.prototype = { + constructor: B, + __proto__: A.prototype + } + console.log(new B()); + } + `); + + TestRunner.evaluateInPage('logObject()', step2); + + function step2() { + ConsoleTestRunner.expandConsoleMessages(step3); + } + + function expandTreeElementFilter(treeElement) { + var name = treeElement.nameElement && treeElement.nameElement.textContent; + return name === '__proto__'; + } + + function step3() { + ConsoleTestRunner.expandConsoleMessages(step4, expandTreeElementFilter); + } + + function step4() { + ConsoleTestRunner.expandGettersInConsoleMessages(step5); + } + + function step5() { + ConsoleTestRunner.dumpConsoleMessages(false, false, TestRunner.textContentWithLineBreaks); + TestRunner.completeTest(); + } +})();
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-command-clear-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-command-clear-expected.txt new file mode 100644 index 0000000..5636c991 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-command-clear-expected.txt
@@ -0,0 +1,9 @@ +Tests that console is cleared upon clear() eval in console. + +=== Before clear === +console-command-clear.js:14 one +console-command-clear.js:15 two +console-command-clear.js:16 three +=== After clear === +VM:1 Console was cleared +
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-command-clear.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-command-clear.js new file mode 100644 index 0000000..5b704d56 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-command-clear.js
@@ -0,0 +1,31 @@ +// 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. + +(async function() { + TestRunner.addResult(`Tests that console is cleared upon clear() eval in console.\n`); + + await TestRunner.loadModule('console_test_runner'); + await TestRunner.showPanel('console'); + + await TestRunner.evaluateInPagePromise(` + function log() { + // Fill console. + console.log("one"); + console.log("two"); + console.log("three"); + } + log(); + `); + + TestRunner.addResult('=== Before clear ==='); + ConsoleTestRunner.dumpConsoleMessages(); + + function callback() { + TestRunner.addResult('=== After clear ==='); + ConsoleTestRunner.dumpConsoleMessages(); + TestRunner.completeTest(); + } + + ConsoleTestRunner.evaluateInConsole('clear()', callback); +})();
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-control-characters-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-control-characters-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/inspector/console/console-control-characters-expected.txt rename to third_party/WebKit/LayoutTests/http/tests/devtools/console/console-control-characters-expected.txt
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-control-characters.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-control-characters.js new file mode 100644 index 0000000..ce574d1 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-control-characters.js
@@ -0,0 +1,17 @@ +// 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. + +(async function() { + TestRunner.addResult(`Verify that control characters are substituted with printable characters.\n`); + + await TestRunner.loadModule('console_test_runner'); + await TestRunner.showPanel('console'); + + ConsoleTestRunner.evaluateInConsole('var\u001d i = 0;', onEvaluated); + + function onEvaluated() { + ConsoleTestRunner.dumpConsoleMessages(); + TestRunner.completeTest(); + } +})();
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-correct-suggestions-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-correct-suggestions-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/inspector/console/console-correct-suggestions-expected.txt rename to third_party/WebKit/LayoutTests/http/tests/devtools/console/console-correct-suggestions-expected.txt
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-correct-suggestions.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-correct-suggestions.js new file mode 100644 index 0000000..f68a830 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-correct-suggestions.js
@@ -0,0 +1,127 @@ +// 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. + +(async function() { + TestRunner.addResult(`Tests that console correctly finds suggestions in complicated cases.\n`); + + await TestRunner.loadModule('console_test_runner'); + await TestRunner.showPanel('console'); + + await TestRunner.evaluateInPagePromise(` + function templateString() + { + console.log("The template string should not run and you should not see this log"); + return { + shouldNotFindThis:56 + }; + } + function shouldNotFindThisFunction() { } + function shouldFindThisFunction() { } + window["should not find this"] = true; + var myMap = new Map([['first', 1], ['second', 2], ['third', 3], ['shouldNotFindThis', 4]]); + var complicatedObject = { + 'foo-bar': true, + '"double-qouted"': true, + "'single-qouted'": true, + "notDangerous();": true + } + `); + + var consoleEditor; + + function testCompletions(text, expected, force) { + var cursorPosition = text.indexOf('|'); + + if (cursorPosition < 0) + cursorPosition = Infinity; + + consoleEditor.setText(text.replace('|', '')); + consoleEditor.setSelection(TextUtils.TextRange.createFromLocation(0, cursorPosition)); + consoleEditor._autocompleteController.autocomplete(force); + return TestRunner.addSnifferPromise(consoleEditor._autocompleteController, '_onSuggestionsShownForTest').then(checkExpected); + + function checkExpected(suggestions) { + var completions = new Map(suggestions.map(suggestion => [suggestion.text, suggestion])); + var message = 'Checking \'' + text.replace('\n', '\\n').replace('\r', '\\r') + '\''; + + if (force) + message += ' forcefully'; + + TestRunner.addResult(message); + + for (var i = 0; i < expected.length; i++) { + if (completions.has(expected[i])) { + if (completions.get(expected[i]).title) + TestRunner.addResult('Found: ' + expected[i] + ', displayed as ' + completions.get(expected[i]).title); + else + TestRunner.addResult('Found: ' + expected[i]); + } else { + TestRunner.addResult('Not Found: ' + expected[i]); + } + } + + TestRunner.addResult(''); + } + } + + function sequential(tests) { + var promise = Promise.resolve(); + + for (var i = 0; i < tests.length; i++) + promise = promise.then(tests[i]); + + return promise; + } + + sequential([ + () => ConsoleTestRunner.waitUntilConsoleEditorLoaded().then(e => consoleEditor = e), + () => testCompletions('window.do', ['document']), + () => testCompletions('win', ['window']), + () => testCompletions('window["doc', ['"document"]']), + () => testCompletions('window["document"].bo', ['body']), + () => testCompletions('window["document"]["body"].textC', ['textContent']), + () => testCompletions('document.body.inner', ['innerText', 'innerHTML']), + () => testCompletions('document["body"][window.do', ['document']), + () => testCompletions('document["body"][window["document"].body.childNodes[0].text', ['textContent']), + () => testCompletions('templateString`asdf`should', ['shouldNotFindThis']), + () => testCompletions('window.document.BODY', ['body']), + () => testCompletions('window.dOcUmE', ['document']), + () => testCompletions('window.node', ['NodeList', 'AudioNode', 'GainNode']), + () => testCompletions('32', ['Float32Array', 'Int32Array']), + () => testCompletions('window.32', ['Float32Array', 'Int32Array']), + () => testCompletions('', ['window'], false), + () => testCompletions('', ['window'], true), + () => testCompletions('"string g', ['getComputedStyle'], false), + () => testCompletions('`template string docu', ['document'], false), + () => testCompletions('`${do', ['document'], false), + () => testCompletions('// do', ['document'], false), + () => testCompletions('["should', ['shouldNotFindThisFunction']), + () => testCompletions('shou', ['should not find this']), + () => testCompletions('myMap.get(', ['"first")', '"second")', '"third")']), + () => testCompletions('myMap.get(\'', ['\'first\')', '\'second\')', '\'third\')']), + () => testCompletions('myMap.set(\'firs', ['\'first\', ']), + () => testCompletions('myMap.set(should', ['shouldFindThisFunction', 'shouldNotFindThis', '"shouldNotFindThis")']), + () => testCompletions('myMap.delete(\'', ['\'first\')', '\'second\')', '\'third\')']), + () => testCompletions('document. bo', ['body']), + () => testCompletions('document.\tbo', ['body']), + () => testCompletions('document.\nbo', ['body']), + () => testCompletions('document.\r\nbo', ['body']), + () => testCompletions('document [ \'bo', ['\'body\']']), + () => testCompletions('function hey(should', ['shouldNotFindThisFunction']), + () => testCompletions('var should', ['shouldNotFindThisFunction']), + () => testCompletions('document[[win', ['window']), + () => testCompletions('document[ [win', ['window']), + () => testCompletions('document[ [ win', ['window']), + () => testCompletions('I|mag', ['Image', 'Infinity']), + () => testCompletions('var x = (do|);', ['document']), + () => testCompletions('complicatedObject["foo', ['"foo-bar"]']), + () => testCompletions('complicatedObject["foo-', ['"foo-bar"]']), + () => testCompletions('complicatedObject["foo-bar', ['"foo-bar"]']), + () => testCompletions('complicatedObject["\'sing', ['"\'single-qouted\'"]']), + () => testCompletions('complicatedObject[\'\\\'sing', ['\'\\\'single-qouted\\\'\']']), + () => testCompletions('complicatedObject["\'single-qou', ['"\'single-qouted\'"]']), + () => testCompletions('complicatedObject["\\"double-qouted\\"', ['"\\"double-qouted\\""]']), + () => testCompletions('complicatedObject["notDangerous();', ['"notDangerous();"]']) + ]).then(TestRunner.completeTest); +})();
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-dir-deprecated-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-dir-deprecated-expected.txt new file mode 100644 index 0000000..0cb9383 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-dir-deprecated-expected.txt
@@ -0,0 +1,5 @@ +Tests that console does not log deprecated warning messages while dir-dumping objects. + +console-dir-deprecated.js:17 Window +console-dir-deprecated.js:18 #document-fragment +
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-dir-deprecated.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-dir-deprecated.js new file mode 100644 index 0000000..c52ed56 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-dir-deprecated.js
@@ -0,0 +1,28 @@ +// 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. + +(async function() { + TestRunner.addResult(`Tests that console does not log deprecated warning messages while dir-dumping objects.\n`); + + await TestRunner.loadModule('console_test_runner'); + await TestRunner.showPanel('console'); + + await TestRunner.loadHTML(` + <div id="foo"></div> + `); + await TestRunner.evaluateInPagePromise(` + function logObjects() + { + console.dir(window); + console.dir(document.getElementById("foo").createShadowRoot()); + } + `); + + TestRunner.evaluateInPage('logObjects()', step2); + + function step2() { + ConsoleTestRunner.dumpConsoleMessages(); + TestRunner.completeTest(); + } +})();
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-dir-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-dir-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/inspector/console/console-dir-expected.txt rename to third_party/WebKit/LayoutTests/http/tests/devtools/console/console-dir-expected.txt
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-dir-global-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-dir-global-expected.txt similarity index 79% rename from third_party/WebKit/LayoutTests/inspector/console/console-dir-global-expected.txt rename to third_party/WebKit/LayoutTests/http/tests/devtools/console/console-dir-global-expected.txt index e221eb1..4111acf 100644 --- a/third_party/WebKit/LayoutTests/inspector/console/console-dir-global-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-dir-global-expected.txt
@@ -1,4 +1,3 @@ -CONSOLE MESSAGE: line 9: [object Window] Tests that console dumps global object with properties. {
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-dir-global.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-dir-global.js new file mode 100644 index 0000000..9183a1d --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-dir-global.js
@@ -0,0 +1,58 @@ +// 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. + +(async function() { + TestRunner.addResult(`Tests that console dumps global object with properties.\n`); + + await TestRunner.loadModule('console_test_runner'); + await TestRunner.showPanel('console'); + + await TestRunner.evaluateInPagePromise(` + function doit() + { + console.dir(window); + }; + `); + + TestRunner.RuntimeAgent.evaluate('window', 'console', false).then(evalCallback); + + function evalCallback(result) { + if (!result) { + testController.notifyDone('Exception'); + return; + } + + if (result.type === 'error') + testController.notifyDone('Exception:' + result); + + var objectProxy = TestRunner.runtimeModel.createRemoteObject(result); + objectProxy.getOwnProperties(false, getPropertiesCallback); + } + + function getPropertiesCallback(properties) { + properties.sort(ObjectUI.ObjectPropertiesSection.CompareProperties); + + var golden = { + 'window': 1, + 'document': 1, + 'eval': 1, + 'console': 1, + 'frames': 1, + 'Array': 1, + 'doit': 1 + }; + + var result = {}; + + for (var i = 0; i < properties.length; ++i) { + var name = properties[i].name; + + if (golden[name]) + result[name] = 1; + } + + TestRunner.addObject(result); + TestRunner.completeTest(); + } +})();
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-dir.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-dir.js new file mode 100644 index 0000000..6ad6c2a0 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-dir.js
@@ -0,0 +1,71 @@ +// 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. + +(async function() { + TestRunner.addResult(`Tests that console logging dumps proper messages.\n`); + + await TestRunner.loadModule('console_test_runner'); + await TestRunner.showPanel('console'); + + await TestRunner.evaluateInPagePromise(` + function onload() + { + console.dir(["test1", "test2"]); + console.dir(document.childNodes); + console.dir(document.evaluate("//head", document, null, XPathResult.ANY_TYPE, null)); + + // Object with properties containing whitespaces + var obj = { $foo5_: 0 }; + obj[" a b "] = " a b "; + obj["c d"] = "c d"; + obj[""] = ""; + obj[" "] = " "; + obj["a\n\nb\nc"] = "a\n\nb\nc"; + obj["negZero"] = -0; + console.dir(obj); + + // This should correctly display information about the function. + console.dir(function() {}); + + // Test function inferred name in prototype constructor. + var outer = { inner: function() {} }; + console.dir(new outer.inner()); + + // Test "No Properties" placeholder. + console.dir({ __proto__: null }); + console.dir({ foo: { __proto__: null }}); + // Test "No Scopes" placeholder. + console.dir(Object.getOwnPropertyDescriptor(Object.prototype, "__proto__").get); + + // Test big typed array: should be no crash or timeout. + var bigTypedArray = new Uint8Array(new ArrayBuffer(400 * 1000 * 1000)); + bigTypedArray["FAIL"] = "FAIL: Object.getOwnPropertyNames() should not have been run"; + console.dir(bigTypedArray); + + // document.createEvent("Event") has a special property "isTrusted" flagged "Unforgeable". + var event = document.createEvent("Event"); + Object.defineProperty(event, "timeStamp", {value: 0}) + console.dir(event); + + runTest(); + } + //# sourceURL=console-dir.js + `); + + ConsoleTestRunner.expandConsoleMessages(step1, expandTreeElementFilter); + + function expandTreeElementFilter(treeElement) { + var name = treeElement.nameElement && treeElement.nameElement.textContent; + return name === 'foo' || treeElement.title === '<function scope>'; + } + + function step1() { + ConsoleTestRunner.expandConsoleMessages(dumpConsoleMessages, expandTreeElementFilter); + } + + function dumpConsoleMessages() { + ConsoleTestRunner.dumpConsoleMessagesIgnoreErrorStackFrames(); + TestRunner.completeTest(); + } +})();
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-edit-property-value-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-edit-property-value-expected.txt similarity index 75% rename from third_party/WebKit/LayoutTests/inspector/console/console-edit-property-value-expected.txt rename to third_party/WebKit/LayoutTests/http/tests/devtools/console/console-edit-property-value-expected.txt index ffc9ff9..06548df6 100644 --- a/third_party/WebKit/LayoutTests/inspector/console/console-edit-property-value-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-edit-property-value-expected.txt
@@ -1,4 +1,3 @@ -CONSOLE MESSAGE: line 10: [object Object] Tests that property values can be edited inline in the console via double click. Node was hidden after dblclick: true @@ -6,7 +5,7 @@ Node was hidden after dblclick: true Node was hidden after dblclick: true logToConsole() -console-edit-property-value.html:10 {a: 1, b: "foo", c: null, d: 2} +console-edit-property-value.js:15 {a: 1, b: "foo", c: null, d: 2} a: 3 b: "foo" c: (3) [1, 2, 3]
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-edit-property-value.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-edit-property-value.js new file mode 100644 index 0000000..b104647 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-edit-property-value.js
@@ -0,0 +1,69 @@ +// 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. + +(async function() { + TestRunner.addResult(`Tests that property values can be edited inline in the console via double click.\n`); + + await TestRunner.loadModule('console_test_runner'); + await TestRunner.showPanel('console'); + + await TestRunner.evaluateInPagePromise(` + function logToConsole() + { + var obj = {a: 1, b: "foo", c: null, d: 2}; + console.log(obj); + } + `); + + ConsoleTestRunner.evaluateInConsole('logToConsole()', step1); + + function step1() { + ConsoleTestRunner.expandConsoleMessages(step2); + } + + function step2() { + var valueElements = getValueElements(); + doubleClickTypeAndEnter(valueElements[0], '1 + 2'); + ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step3); + } + + function step3() { + var valueElements = getValueElements(); + doubleClickTypeAndEnter(valueElements[1], 'nonExistingValue'); + ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step4); + } + + function step4() { + var valueElements = getValueElements(); + doubleClickTypeAndEnter(valueElements[2], '[1, 2, 3]'); + ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step5); + } + + function step5() { + var valueElements = getValueElements(); + doubleClickTypeAndEnter(valueElements[3], '{x: 2}'); + ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step6); + } + + function step6() { + ConsoleTestRunner.dumpConsoleMessagesIgnoreErrorStackFrames(); + TestRunner.completeTest(); + } + + function getValueElements() { + var messageElement = Console.ConsoleView.instance()._visibleViewMessages[1].element(); + return messageElement.querySelector('.console-message-text *').shadowRoot.querySelectorAll('.value'); + } + + function doubleClickTypeAndEnter(node, text) { + var event = document.createEvent('MouseEvent'); + event.initMouseEvent('dblclick', true, true, null, 2); + node.dispatchEvent(event); + TestRunner.addResult('Node was hidden after dblclick: ' + node.classList.contains('hidden')); + var messageElement = Console.ConsoleView.instance()._visibleViewMessages[1].element(); + var editPrompt = messageElement.querySelector('.console-message-text *').shadowRoot.querySelector('.text-prompt'); + editPrompt.textContent = text; + editPrompt.dispatchEvent(TestRunner.createKeyEvent('Enter')); + } +})();
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/framework.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/framework.js new file mode 100644 index 0000000..cad0a8b --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/framework.js
@@ -0,0 +1,8 @@ +// A framework for testing. + +var Framework = {}; + +Framework.log = function(msg) +{ + console.log(msg); +}
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/importScripts-1.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/importScripts-1.js new file mode 100644 index 0000000..8869a4fb --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/importScripts-1.js
@@ -0,0 +1 @@ +importScripts("importScripts-2.js");
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/importScripts-2.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/importScripts-2.js new file mode 100644 index 0000000..743695a --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/importScripts-2.js
@@ -0,0 +1,5 @@ +function foo() +{ + importScripts("importScripts-3.js"); +} +foo();
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/importScripts-3.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/importScripts-3.js new file mode 100644 index 0000000..2d103a0 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/importScripts-3.js
@@ -0,0 +1 @@ +importScripts("invalidScript.js");
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/invalidScript.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/invalidScript.js new file mode 100644 index 0000000..8655d4d1 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/invalidScript.js
@@ -0,0 +1 @@ +SELECT * FROM TABLE; // an invalid script.
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/log-source.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/log-source.js new file mode 100644 index 0000000..fdab1773 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/log-source.js
@@ -0,0 +1,4 @@ +function log2() +{ + console.log.apply(console, arguments); +} \ No newline at end of file
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/stack-with-sourceMap.coffee b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/stack-with-sourceMap.coffee new file mode 100644 index 0000000..651e08e --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/stack-with-sourceMap.coffee
@@ -0,0 +1,7 @@ +class Failure + letsFailWithStack: -> + console.log((new Error()).stack) + +window.failure = () -> + failure = new Failure + failure.letsFailWithStack()
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/stack-with-sourceMap.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/stack-with-sourceMap.js new file mode 100644 index 0000000..2d4f2f53 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/stack-with-sourceMap.js
@@ -0,0 +1,24 @@ +// Generated by CoffeeScript 1.7.1 +(function() { + var Failure; + + Failure = (function() { + function Failure() {} + + Failure.prototype.letsFailWithStack = function() { + return console.log((new Error()).stack); + }; + + return Failure; + + })(); + + window.failure = function() { + var failure; + failure = new Failure; + return failure.letsFailWithStack(); + }; + +}).call(this); + +//# sourceMappingURL=stack-with-sourceMap.map
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/stack-with-sourceMap.map b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/stack-with-sourceMap.map new file mode 100644 index 0000000..aedb2ab0 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/stack-with-sourceMap.map
@@ -0,0 +1,10 @@ +{ + "version": 3, + "file": "stack-with-sourceMap.js", + "sourceRoot": "", + "sources": [ + "stack-with-sourceMap.coffee" + ], + "names": [], + "mappings": ";AAAA;AAAA,MAAA,OAAA;;AAAA,EAAM;yBACF;;AAAA,sBAAA,iBAAA,GAAmB,SAAA,GAAA;aACf,OAAO,CAAC,GAAR,CAAY,CAAK,IAAA,KAAA,CAAA,CAAL,CAAa,CAAC,KAA1B,EADe;IAAA,CAAnB,CAAA;;mBAAA;;MADJ,CAAA;;AAAA,EAIA,MAAM,CAAC,OAAP,GAAiB,SAAA,GAAA;AACb,QAAA,OAAA;AAAA,IAAA,OAAA,GAAU,GAAA,CAAA,OAAV,CAAA;WACA,OAAO,CAAC,iBAAR,CAAA,EAFa;EAAA,CAJjB,CAAA;AAAA" +} \ No newline at end of file
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/stack-with-sourceUrl.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/stack-with-sourceUrl.js new file mode 100644 index 0000000..5059d24 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/stack-with-sourceUrl.js
@@ -0,0 +1,10 @@ +var c = "Some test" + +function namedFunction() +{ + console.log(new Error(c).stack); +} + +namedFunction(); + +//# sourceURL=foob.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/syntax-error.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/syntax-error.js new file mode 100644 index 0000000..1c126bc --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/syntax-error.js
@@ -0,0 +1,3 @@ + + + )
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/uncaught-in-iframe.html b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/uncaught-in-iframe.html new file mode 100644 index 0000000..44836c1 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/uncaught-in-iframe.html
@@ -0,0 +1,27 @@ +<script> +window.addEventListener("load", function(e) { + function f() { + setTimeout(function() { + function bar() { + throw new Error("Exception in setTimeout callback."); + } + bar(); + }, 0); + + throw new Error("Exception in 'load' event listener.") + } + f(); +}, false); + +function a() +{ + throw new Error("Exception in inline script.") +} + +function b() +{ + a(); +} + +b(); +</script>
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/worker-pause.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/worker-pause.js new file mode 100644 index 0000000..b1f08070 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/worker-pause.js
@@ -0,0 +1 @@ +self.onmessage = function(e) { debugger; }
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/worker-with-defer-handled-promise.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/worker-with-defer-handled-promise.js new file mode 100644 index 0000000..b483f55 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/worker-with-defer-handled-promise.js
@@ -0,0 +1,6 @@ +var p = Promise.reject(new Error("Handled error")); + +onmessage = function(event) +{ + p.catch(function() {}); +}
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/worker-with-unhandled-promises.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/worker-with-unhandled-promises.js new file mode 100644 index 0000000..a5a2038 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/worker-with-unhandled-promises.js
@@ -0,0 +1,32 @@ +function runPromisesInWorker() +{ + Promise.reject(new Error("err1")) + .then() + .then() + .then(); // Last is unhandled. + + var reject + var m0 = new Promise(function(res, rej) { reject = rej; }); + var m1 = m0.then(function() {}); + var m2 = m0.then(function() {}); + var m3 = m0.then(function() {}); + var m4 = 0; + m0.catch(function() { + m2.catch(function() { + m1.catch(function() { + m4 = m3.then(function() {}); // Unhandled. + }); + }); + }); + reject(new Error("err2")); +} + +onmessage = function(event) { + runPromisesInWorker(); + setInterval(doWork, 0); +} +var message_id = 0; +function doWork() +{ + postMessage("Message #" + message_id++); +}
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/worker.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/worker.js new file mode 100644 index 0000000..8fd3923 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/resources/worker.js
@@ -0,0 +1 @@ +postMessage('Done.'); \ No newline at end of file
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-bind-fake.html b/third_party/WebKit/LayoutTests/inspector/console/console-bind-fake.html deleted file mode 100644 index cb3a0046..0000000 --- a/third_party/WebKit/LayoutTests/inspector/console/console-bind-fake.html +++ /dev/null
@@ -1,29 +0,0 @@ -<html> -<head> -<script src="../../http/tests/inspector/inspector-test.js"></script> -<script src="../../http/tests/inspector/console-test.js"></script> -<script> -var foo = 'fooValue'; - -Function.prototype.bind = function () { throw ":P"; }; - -function test() -{ - InspectorTest.evaluateInConsole("foo", step1); - - function step1() - { - InspectorTest.dumpConsoleMessages(); - InspectorTest.completeTest(); - } -} -</script> -</head> - -<body onload="runTest()"> -<p> -Tests that overriding Function.prototype.bind does not break inspector. -</p> - -</body> -</html>
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-call-getter-on-proto.html b/third_party/WebKit/LayoutTests/inspector/console/console-call-getter-on-proto.html deleted file mode 100644 index 327cb864..0000000 --- a/third_party/WebKit/LayoutTests/inspector/console/console-call-getter-on-proto.html +++ /dev/null
@@ -1,58 +0,0 @@ -<html> -<head> -<script src="../../http/tests/inspector/inspector-test.js"></script> -<script src="../../http/tests/inspector/console-test.js"></script> -<script> -function logObject() -{ - var A = function() { this.value = 239; } - A.prototype = { - constructor: A, - get foo() - { - return this.value; - } - } - var B = function() { A.call(this); } - B.prototype = { - constructor: B, - __proto__: A.prototype - } - console.log(new B()); -} - -function test() -{ - InspectorTest.evaluateInPage("logObject()", step2); - function step2() - { - InspectorTest.expandConsoleMessages(step3); - } - function expandTreeElementFilter(treeElement) - { - var name = treeElement.nameElement && treeElement.nameElement.textContent; - return name === "__proto__"; - } - function step3() - { - InspectorTest.expandConsoleMessages(step4, expandTreeElementFilter); - } - function step4() - { - InspectorTest.expandGettersInConsoleMessages(step5); - } - function step5() - { - InspectorTest.dumpConsoleMessages(false, false, InspectorTest.textContentWithLineBreaks); - InspectorTest.completeTest(); - } -} -</script> -</head> - -<body onload="runTest()"> -<p> -Tests that calling getter on prototype will call it on the object. -</p> -</body> -</html>
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-command-clear-expected.txt b/third_party/WebKit/LayoutTests/inspector/console/console-command-clear-expected.txt deleted file mode 100644 index dc9c35e..0000000 --- a/third_party/WebKit/LayoutTests/inspector/console/console-command-clear-expected.txt +++ /dev/null
@@ -1,12 +0,0 @@ -CONSOLE MESSAGE: line 9: one -CONSOLE MESSAGE: line 10: two -CONSOLE MESSAGE: line 11: three -Tests that console is cleared upon clear() eval in console. - -=== Before clear === -console-command-clear.html:9 one -console-command-clear.html:10 two -console-command-clear.html:11 three -=== After clear === -VM:1 Console was cleared -
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-command-clear.html b/third_party/WebKit/LayoutTests/inspector/console/console-command-clear.html deleted file mode 100644 index ed79daa..0000000 --- a/third_party/WebKit/LayoutTests/inspector/console/console-command-clear.html +++ /dev/null
@@ -1,40 +0,0 @@ -<html> -<head> -<script src="../../http/tests/inspector/inspector-test.js"></script> -<script src="../../http/tests/inspector/console-test.js"></script> -<script> - -function log() { - // Fill console. - console.log("one"); - console.log("two"); - console.log("three"); -} - -log(); - -function test() -{ - - InspectorTest.addResult("=== Before clear ==="); - InspectorTest.dumpConsoleMessages(); - - function callback() - { - InspectorTest.addResult("=== After clear ==="); - InspectorTest.dumpConsoleMessages(); - InspectorTest.completeTest(); - } - InspectorTest.evaluateInConsole("clear()", callback); -} - -</script> -</head> - -<body onload="runTest()"> -<p> - Tests that console is cleared upon clear() eval in console. -</p> - -</body> -</html>
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-control-characters.html b/third_party/WebKit/LayoutTests/inspector/console/console-control-characters.html deleted file mode 100644 index afdc95a..0000000 --- a/third_party/WebKit/LayoutTests/inspector/console/console-control-characters.html +++ /dev/null
@@ -1,28 +0,0 @@ -<html> -<head> -<script src="../../http/tests/inspector/inspector-test.js"></script> -<script src="../../http/tests/inspector/console-test.js"></script> -<script> - -function test() -{ - // The following command has control character. - InspectorTest.evaluateInConsole("var\u001D i = 0;", onEvaluated); - - function onEvaluated() - { - InspectorTest.dumpConsoleMessages(); - InspectorTest.completeTest(); - } -} - -</script> -</head> - -<body onload="runTest()"> -<p> - Verify that control characters are substituted with printable characters. -</p> - -</body> -</html>
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-correct-suggestions.html b/third_party/WebKit/LayoutTests/inspector/console/console-correct-suggestions.html deleted file mode 100644 index b13a31f..0000000 --- a/third_party/WebKit/LayoutTests/inspector/console/console-correct-suggestions.html +++ /dev/null
@@ -1,123 +0,0 @@ -<html> -<head> -<script src="../../http/tests/inspector/inspector-test.js"></script> -<script src="../../http/tests/inspector/console-test.js"></script> -<script> -function templateString() -{ - console.log("The template string should not run and you should not see this log"); - return { - shouldNotFindThis:56 - }; -} - -function shouldNotFindThisFunction() { } -function shouldFindThisFunction() { } -window["should not find this"] = true; - -var myMap = new Map([['first', 1], ['second', 2], ['third', 3], ['shouldNotFindThis', 4]]); -var complicatedObject = { - 'foo-bar': true, - '"double-qouted"': true, - "'single-qouted'": true, - "notDangerous();": true -} -function test() -{ - var consoleEditor; - function testCompletions(text, expected, force) - { - var cursorPosition = text.indexOf('|'); - if (cursorPosition < 0) - cursorPosition = Infinity; - consoleEditor.setText(text.replace('|', '')); - consoleEditor.setSelection(TextUtils.TextRange.createFromLocation(0, cursorPosition)); - consoleEditor._autocompleteController.autocomplete(force); - return InspectorTest.addSnifferPromise(consoleEditor._autocompleteController, "_onSuggestionsShownForTest").then(checkExpected); - - function checkExpected(suggestions) - { - var completions = new Map(suggestions.map(suggestion => [suggestion.text, suggestion])); - var message = "Checking '" + text.replace('\n', '\\n').replace('\r', '\\r') + "'"; - if (force) - message += " forcefully"; - InspectorTest.addResult(message); - for (var i = 0; i < expected.length; i++) { - if (completions.has(expected[i])) { - if (completions.get(expected[i]).title) - InspectorTest.addResult("Found: " + expected[i] + ", displayed as " + completions.get(expected[i]).title); - else - InspectorTest.addResult("Found: " + expected[i]); - } else { - InspectorTest.addResult("Not Found: " + expected[i]); - } - } - InspectorTest.addResult(""); - } - } - function sequential(tests) - { - var promise = Promise.resolve(); - for (var i = 0; i < tests.length; i++) - promise = promise.then(tests[i]); - return promise; - } - - sequential([ - InspectorTest.waitUntilConsoleEditorLoaded().then(e => consoleEditor = e), - () => testCompletions("window.do", ["document"]), - () => testCompletions("win", ["window"]), - () => testCompletions('window["doc', ['"document"]']), - () => testCompletions('window["document"].bo', ["body"]), - () => testCompletions('window["document"]["body"].textC', ["textContent"]), - () => testCompletions('document.body.inner', ["innerText", "innerHTML"]), - () => testCompletions('document["body"][window.do', ["document"]), - () => testCompletions('document["body"][window["document"].body.childNodes[0].text', ["textContent"]), - () => testCompletions("templateString`asdf`should", ["shouldNotFindThis"]), - () => testCompletions("window.document.BODY", ["body"]), - () => testCompletions("window.dOcUmE", ["document"]), - () => testCompletions("window.node", ["NodeList", "AudioNode", "GainNode"]), - () => testCompletions("32", ["Float32Array", "Int32Array"]), - () => testCompletions("window.32", ["Float32Array", "Int32Array"]), - () => testCompletions("", ["window"], false), - () => testCompletions("", ["window"], true), - () => testCompletions('"string g', ["getComputedStyle"], false), - () => testCompletions("`template string docu", ["document"], false), - () => testCompletions("`${do", ["document"], false), - () => testCompletions("// do", ["document"], false), - () => testCompletions('["should', ["shouldNotFindThisFunction"]), - () => testCompletions("shou", ["should not find this"]), - () => testCompletions('myMap.get(', ['"first")', '"second")', '"third")']), - () => testCompletions('myMap.get(\'', ['\'first\')', '\'second\')', '\'third\')']), - () => testCompletions('myMap.set(\'firs', ['\'first\', ']), - () => testCompletions('myMap.set(should', ['shouldFindThisFunction', 'shouldNotFindThis', '\"shouldNotFindThis\")']), - () => testCompletions('myMap.delete(\'', ['\'first\')', '\'second\')', '\'third\')']), - () => testCompletions("document. bo", ["body"]), - () => testCompletions("document.\tbo", ["body"]), - () => testCompletions("document.\nbo", ["body"]), - () => testCompletions("document.\r\nbo", ["body"]), - () => testCompletions("document [ 'bo", ["'body']"]), - () => testCompletions("function hey(should", ["shouldNotFindThisFunction"]), - () => testCompletions("var should", ["shouldNotFindThisFunction"]), - () => testCompletions("document[[win", ["window"]), - () => testCompletions("document[ [win", ["window"]), - () => testCompletions("document[ [ win", ["window"]), - () => testCompletions('I|mag', ['Image', 'Infinity']), - () => testCompletions('var x = (do|);', ['document']), - () => testCompletions('complicatedObject["foo', ['"foo-bar"]']), - () => testCompletions('complicatedObject["foo-', ['"foo-bar"]']), - () => testCompletions('complicatedObject["foo-bar', ['"foo-bar"]']), - () => testCompletions('complicatedObject["\'sing', ['"\'single-qouted\'"]']), - () => testCompletions('complicatedObject[\'\\\'sing', ['\'\\\'single-qouted\\\'\']']), - () => testCompletions('complicatedObject["\'single-qou', ['"\'single-qouted\'"]']), - () => testCompletions('complicatedObject["\\"double-qouted\\"', ['"\\"double-qouted\\""]']), - () => testCompletions('complicatedObject["notDangerous();', ['"notDangerous();"]']), - ]).then(InspectorTest.completeTest); - -} -</script> -</head> -<body onload="runTest()"> -<p>Tests that console correctly finds suggestions in complicated cases.</p> -</body> -</html>
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-css-unterminated-comment-expected.txt b/third_party/WebKit/LayoutTests/inspector/console/console-css-unterminated-comment-expected.txt deleted file mode 100644 index 3343832..0000000 --- a/third_party/WebKit/LayoutTests/inspector/console/console-css-unterminated-comment-expected.txt +++ /dev/null
@@ -1 +0,0 @@ -Tests that unterminated comment in CSS generates a warning.
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-css-unterminated-comment.html b/third_party/WebKit/LayoutTests/inspector/console/console-css-unterminated-comment.html deleted file mode 100644 index 28d47c1..0000000 --- a/third_party/WebKit/LayoutTests/inspector/console/console-css-unterminated-comment.html +++ /dev/null
@@ -1,30 +0,0 @@ -<html> -<head> -<script src="../../http/tests/inspector/inspector-test.js"></script> -<script src="../../http/tests/inspector/console-test.js"></script> - -<style>/* unterminated comment </style> -<style>/*</style> - -<style>/* terminated comment */</style> -<style>/* terminated comment *//*</style> - -<script> - -function test() -{ - InspectorTest.consoleModel.messages().forEach(function(message) - { - InspectorTest.addResult(message.message + " (line " + message.line + ")"); - }); - - InspectorTest.completeTest(); -} - -</script> -</head> - -<body onload="runTest()"> -<p id="p">Tests that unterminated comment in CSS generates a warning.</p> -</body> -</html>
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-dir-deprecated-expected.txt b/third_party/WebKit/LayoutTests/inspector/console/console-dir-deprecated-expected.txt deleted file mode 100644 index 159fd40..0000000 --- a/third_party/WebKit/LayoutTests/inspector/console/console-dir-deprecated-expected.txt +++ /dev/null
@@ -1,7 +0,0 @@ -CONSOLE MESSAGE: line 9: [object Window] -CONSOLE MESSAGE: line 10: [object ShadowRoot] -Tests that console does not log deprecated warning messages while dir-dumping objects. - -console-dir-deprecated.html:9 Window -console-dir-deprecated.html:10 #document-fragment -
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-dir-deprecated.html b/third_party/WebKit/LayoutTests/inspector/console/console-dir-deprecated.html deleted file mode 100644 index d672dc0..0000000 --- a/third_party/WebKit/LayoutTests/inspector/console/console-dir-deprecated.html +++ /dev/null
@@ -1,33 +0,0 @@ -<html> -<head> -<script src="../../http/tests/inspector/inspector-test.js"></script> -<script src="../../http/tests/inspector/console-test.js"></script> -<script> - -function logObjects() -{ - console.dir(window); - console.dir(document.getElementById("foo").createShadowRoot()); -} - -function test() -{ - InspectorTest.evaluateInPage("logObjects()", step2); - function step2() - { - InspectorTest.dumpConsoleMessages(); - InspectorTest.completeTest(); - } -} - -</script> -</head> - -<body onload="runTest()"> -<div id="foo"></div> -<p> -Tests that console does not log deprecated warning messages while dir-dumping objects. -</p> - -</body> -</html>
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-dir-global.html b/third_party/WebKit/LayoutTests/inspector/console/console-dir-global.html deleted file mode 100644 index c3ce2fa5..0000000 --- a/third_party/WebKit/LayoutTests/inspector/console/console-dir-global.html +++ /dev/null
@@ -1,53 +0,0 @@ -<html> -<head> -<script src="../../http/tests/inspector/inspector-test.js"></script> -<script src="../../http/tests/inspector/console-test.js"></script> -<script> - -function doit() -{ - console.dir(window); - runTest(); -} - -function test() -{ - InspectorTest.RuntimeAgent.evaluate("window", "console", false).then(evalCallback); - - function evalCallback(result) - { - if (!result) { - testController.notifyDone("Exception"); - return; - } - if (result.type === "error") - testController.notifyDone("Exception:" + result); - var objectProxy = InspectorTest.runtimeModel.createRemoteObject(result); - objectProxy.getOwnProperties(false, getPropertiesCallback); - } - - function getPropertiesCallback(properties) - { - properties.sort(ObjectUI.ObjectPropertiesSection.CompareProperties); - var golden = { "window": 1, "document": 1, "eval": 1, "console": 1, "frames": 1, "Array": 1, "doit": 1 }; - var result = {}; - for (var i = 0; i < properties.length; ++i) { - var name = properties[i].name; - if (golden[name]) - result[name] = 1; - } - InspectorTest.addObject(result); - InspectorTest.completeTest(); - } -} - -</script> -</head> - -<body onload="doit()"> -<p> -Tests that console dumps global object with properties. -</p> - -</body> -</html>
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-dir.html b/third_party/WebKit/LayoutTests/inspector/console/console-dir.html deleted file mode 100644 index 219ae2f..0000000 --- a/third_party/WebKit/LayoutTests/inspector/console/console-dir.html +++ /dev/null
@@ -1,83 +0,0 @@ -<html> -<head> -<script src="../../http/tests/inspector/inspector-test.js"></script> -<script src="../../http/tests/inspector/console-test.js"></script> - -<script> -function onload() -{ - console.dir(["test1", "test2"]); - console.dir(document.childNodes); - console.dir(document.evaluate("//head", document, null, XPathResult.ANY_TYPE, null)); - - // Object with properties containing whitespaces - var obj = { $foo5_: 0 }; - obj[" a b "] = " a b "; - obj["c d"] = "c d"; - obj[""] = ""; - obj[" "] = " "; - obj["a\n\nb\nc"] = "a\n\nb\nc"; - obj["negZero"] = -0; - console.dir(obj); - - // This should correctly display information about the function. - console.dir(function() {}); - - // Test function inferred name in prototype constructor. - var outer = { inner: function() {} }; - console.dir(new outer.inner()); - - // Test "No Properties" placeholder. - console.dir({ __proto__: null }); - console.dir({ foo: { __proto__: null }}); - // Test "No Scopes" placeholder. - console.dir(Object.getOwnPropertyDescriptor(Object.prototype, "__proto__").get); - - // Test big typed array: should be no crash or timeout. - var bigTypedArray = new Uint8Array(new ArrayBuffer(400 * 1000 * 1000)); - bigTypedArray["FAIL"] = "FAIL: Object.getOwnPropertyNames() should not have been run"; - console.dir(bigTypedArray); - - // document.createEvent("Event") has a special property "isTrusted" flagged "Unforgeable". - var event = document.createEvent("Event"); - Object.defineProperty(event, "timeStamp", {value: 0}) - console.dir(event); - - runTest(); -} -//# sourceURL=console-dir.html -</script> - -<script> -function test() -{ - InspectorTest.expandConsoleMessages(step1, expandTreeElementFilter); - - function expandTreeElementFilter(treeElement) - { - var name = treeElement.nameElement && treeElement.nameElement.textContent; - return name === "foo" || treeElement.title === "<function scope>"; - } - - function step1() - { - InspectorTest.expandConsoleMessages(dumpConsoleMessages, expandTreeElementFilter); - } - - function dumpConsoleMessages() - { - InspectorTest.dumpConsoleMessagesIgnoreErrorStackFrames(); - InspectorTest.completeTest(); - } -} - -</script> -</head> - -<body onload="onload()"> -<p> -Tests that console logging dumps proper messages. -</p> - -</body> -</html>
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-edit-property-value.html b/third_party/WebKit/LayoutTests/inspector/console/console-edit-property-value.html deleted file mode 100644 index f4fcc8b..0000000 --- a/third_party/WebKit/LayoutTests/inspector/console/console-edit-property-value.html +++ /dev/null
@@ -1,86 +0,0 @@ -<html> -<head> -<script src="../../http/tests/inspector/inspector-test.js"></script> -<script src="../../http/tests/inspector/console-test.js"></script> -<script> - -function logToConsole() -{ - var obj = {a: 1, b: "foo", c: null, d: 2}; - console.log(obj); -} - -var test = function() -{ - InspectorTest.evaluateInConsole("logToConsole()", step1); - - function step1() - { - InspectorTest.expandConsoleMessages(step2); - } - - function step2() - { - var valueElements = getValueElements(); - doubleClickTypeAndEnter(valueElements[0], "1 + 2"); - InspectorTest.waitForRemoteObjectsConsoleMessages(step3); - } - - function step3() - { - var valueElements = getValueElements(); - doubleClickTypeAndEnter(valueElements[1], "nonExistingValue"); - InspectorTest.waitForRemoteObjectsConsoleMessages(step4); - } - - function step4() - { - var valueElements = getValueElements(); - doubleClickTypeAndEnter(valueElements[2], "[1, 2, 3]"); - InspectorTest.waitForRemoteObjectsConsoleMessages(step5); - } - - function step5() - { - var valueElements = getValueElements(); - doubleClickTypeAndEnter(valueElements[3], "{x: 2}"); - InspectorTest.waitForRemoteObjectsConsoleMessages(step6); - } - - function step6() - { - InspectorTest.dumpConsoleMessagesIgnoreErrorStackFrames(); - InspectorTest.completeTest(); - } - - function getValueElements() - { - var messageElement = Console.ConsoleView.instance()._visibleViewMessages[1].element(); - return messageElement.querySelector(".console-message-text *").shadowRoot.querySelectorAll(".value"); - } - - function doubleClickTypeAndEnter(node, text) - { - var event = document.createEvent("MouseEvent"); - event.initMouseEvent("dblclick", true, true, null, 2); - node.dispatchEvent(event); - - InspectorTest.addResult("Node was hidden after dblclick: " + node.classList.contains("hidden")); - - var messageElement = Console.ConsoleView.instance()._visibleViewMessages[1].element(); - var editPrompt = messageElement.querySelector(".console-message-text *").shadowRoot.querySelector(".text-prompt"); - editPrompt.textContent = text; - editPrompt.dispatchEvent(InspectorTest.createKeyEvent("Enter")); - } -} - -</script> -</head> - -<body onload="runTest()"> -<p> -Tests that property values can be edited inline in the console via double click. -</p> - -</body> -</html>
diff --git a/third_party/WebKit/Source/bindings/bindings.gni b/third_party/WebKit/Source/bindings/bindings.gni index 7b1137f..ac55188 100644 --- a/third_party/WebKit/Source/bindings/bindings.gni +++ b/third_party/WebKit/Source/bindings/bindings.gni
@@ -18,7 +18,6 @@ "core/v8/custom/V8EventTargetCustom.cpp", "core/v8/custom/V8HTMLAllCollectionCustom.cpp", "core/v8/custom/V8HTMLPlugInElementCustom.cpp", - "core/v8/custom/V8MediaQueryListCustom.cpp", "core/v8/custom/V8MessageChannelCustom.cpp", "core/v8/custom/V8MessageEventCustom.cpp", "core/v8/custom/V8PopStateEventCustom.cpp",
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8BindingForCore.cpp b/third_party/WebKit/Source/bindings/core/v8/V8BindingForCore.cpp index 8542ff8..9bfa5187 100644 --- a/third_party/WebKit/Source/bindings/core/v8/V8BindingForCore.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/V8BindingForCore.cpp
@@ -898,28 +898,6 @@ return iterator_getter->IsFunction(); } -void MoveEventListenerToNewWrapper(v8::Isolate* isolate, - v8::Local<v8::Object> object, - EventListener* old_value, - v8::Local<v8::Value> new_value, - int array_index) { - if (old_value) { - V8AbstractEventListener* old_listener = - V8AbstractEventListener::Cast(old_value); - if (old_listener) { - v8::Local<v8::Object> old_listener_object = - old_listener->GetExistingListenerObject(); - if (!old_listener_object.IsEmpty()) { - RemoveHiddenValueFromArray(isolate, object, old_listener_object, - array_index); - } - } - } - // Non-callable input is treated as null and ignored - if (new_value->IsFunction()) - AddHiddenValueToArray(isolate, object, new_value, array_index); -} - v8::Isolate* ToIsolate(ExecutionContext* context) { if (context && context->IsDocument()) return V8PerIsolateData::MainThreadIsolate();
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8BindingForCore.h b/third_party/WebKit/Source/bindings/core/v8/V8BindingForCore.h index 95be8227..c77d5584 100644 --- a/third_party/WebKit/Source/bindings/core/v8/V8BindingForCore.h +++ b/third_party/WebKit/Source/bindings/core/v8/V8BindingForCore.h
@@ -64,7 +64,6 @@ // dependencies to core/. class DOMWindow; -class EventListener; class EventTarget; class ExceptionState; class ExecutionContext; @@ -606,12 +605,6 @@ const String& enum_name, ExceptionState&); -CORE_EXPORT void MoveEventListenerToNewWrapper(v8::Isolate*, - v8::Local<v8::Object>, - EventListener* old_value, - v8::Local<v8::Value> new_value, - int cache_index); - // Result values for platform object 'deleter' methods, // http://www.w3.org/TR/WebIDL/#delete enum DeleteResult { kDeleteSuccess, kDeleteReject, kDeleteUnknownProperty };
diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/V8EventTargetCustom.cpp b/third_party/WebKit/Source/bindings/core/v8/custom/V8EventTargetCustom.cpp index 788a365..418c4d66 100644 --- a/third_party/WebKit/Source/bindings/core/v8/custom/V8EventTargetCustom.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/custom/V8EventTargetCustom.cpp
@@ -49,14 +49,6 @@ } } -void V8EventTarget::addEventListenerMethodEpilogueCustom( - const v8::FunctionCallbackInfo<v8::Value>& info, - EventTarget* impl) { - if (info.Length() >= 2 && info[1]->IsObject() && !impl->ToNode()) - AddHiddenValueToArray(info.GetIsolate(), info.Holder(), info[1], - V8EventTarget::eventListenerCacheIndex); -} - void V8EventTarget::removeEventListenerMethodPrologueCustom( const v8::FunctionCallbackInfo<v8::Value>& info, EventTarget*) { @@ -70,12 +62,4 @@ } } -void V8EventTarget::removeEventListenerMethodEpilogueCustom( - const v8::FunctionCallbackInfo<v8::Value>& info, - EventTarget* impl) { - if (info.Length() >= 2 && info[1]->IsObject() && !impl->ToNode()) - RemoveHiddenValueFromArray(info.GetIsolate(), info.Holder(), info[1], - V8EventTarget::eventListenerCacheIndex); -} - } // namespace blink
diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/V8MediaQueryListCustom.cpp b/third_party/WebKit/Source/bindings/core/v8/custom/V8MediaQueryListCustom.cpp deleted file mode 100644 index 730cdbc..0000000 --- a/third_party/WebKit/Source/bindings/core/v8/custom/V8MediaQueryListCustom.cpp +++ /dev/null
@@ -1,51 +0,0 @@ -/* - * Copyright (C) 2015 Google 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: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT - * OWNER OR 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 "bindings/core/v8/V8MediaQueryList.h" - -namespace blink { - -void V8MediaQueryList::addListenerMethodEpilogueCustom( - const v8::FunctionCallbackInfo<v8::Value>& info, - MediaQueryList* impl) { - if (info.Length() >= 1 && info[0]->IsObject() && !impl->ToNode()) - AddHiddenValueToArray(info.GetIsolate(), info.Holder(), info[0], - V8EventTarget::eventListenerCacheIndex); -} - -void V8MediaQueryList::removeListenerMethodEpilogueCustom( - const v8::FunctionCallbackInfo<v8::Value>& info, - MediaQueryList* impl) { - if (info.Length() >= 1 && info[0]->IsObject() && !impl->ToNode()) - RemoveHiddenValueFromArray(info.GetIsolate(), info.Holder(), info[0], - V8EventTarget::eventListenerCacheIndex); -} - -} // namespace blink
diff --git a/third_party/WebKit/Source/bindings/templates/attributes.cpp.tmpl b/third_party/WebKit/Source/bindings/templates/attributes.cpp.tmpl index b64698a..92c73805 100644 --- a/third_party/WebKit/Source/bindings/templates/attributes.cpp.tmpl +++ b/third_party/WebKit/Source/bindings/templates/attributes.cpp.tmpl
@@ -368,11 +368,7 @@ {% endif %} // Prepare the value to be set. - {% if attribute.idl_type == 'EventHandler' %} - {% if not is_node %} - MoveEventListenerToNewWrapper(isolate, holder, {{attribute.event_handler_getter_expression}}, v8Value, {{v8_class}}::eventListenerCacheIndex); - {% endif %} - {% else %}{# not EventHandler #} + {% if attribute.idl_type != 'EventHandler' %} {{v8_value_to_local_cpp_value(attribute) | indent(2)}} {% endif %}
diff --git a/third_party/WebKit/Source/bindings/templates/interface.h.tmpl b/third_party/WebKit/Source/bindings/templates/interface.h.tmpl index c51d57d2..d561fcd 100644 --- a/third_party/WebKit/Source/bindings/templates/interface.h.tmpl +++ b/third_party/WebKit/Source/bindings/templates/interface.h.tmpl
@@ -111,18 +111,12 @@ static void legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>&); {% endif %} {# Custom internal fields #} - {% set custom_internal_field_counter = 0 %} - {% if is_event_target and not is_node %} - {# Event listeners on DOM nodes are explicitly supported in the GC controller. #} - static const int eventListenerCacheIndex = kV8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}}; - {% set custom_internal_field_counter = custom_internal_field_counter + 1 %} - {% endif %} {# persistentHandleIndex must be the last field, if it is present. Detailed explanation: https://codereview.chromium.org/139173012 FIXME: Remove this internal field, and share one field for either: * a persistent handle (if the object is in oilpan) or * a C++ pointer to the DOM object (if the object is not in oilpan) #} - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}}; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; {# End custom internal fields #} {% if prepare_prototype_and_interface_object_func %} {{exported}}static void preparePrototypeAndInterfaceObject(v8::Local<v8::Context>, const DOMWrapperWorld&, v8::Local<v8::Object> prototypeObject, v8::Local<v8::Function> interfaceObject, v8::Local<v8::FunctionTemplate> interfaceTemplate);
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBuffer.h b/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBuffer.h index 6094f0e..218b412 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBuffer.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBuffer.h
@@ -37,7 +37,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestArrayBuffer>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBufferView.h b/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBufferView.h index f9c8d2aa..9771c1d 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBufferView.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBufferView.h
@@ -37,7 +37,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestArrayBufferView>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8DataView.h b/third_party/WebKit/Source/bindings/tests/results/core/V8DataView.h index 28f220f..b41de67 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8DataView.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8DataView.h
@@ -40,7 +40,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestDataView>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8SVGTestInterface.h b/third_party/WebKit/Source/bindings/tests/results/core/V8SVGTestInterface.h index e2bb5397..727641b 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8SVGTestInterface.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8SVGTestInterface.h
@@ -42,7 +42,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<SVGTestInterface>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackFunctions.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackFunctions.h index 21ea6fb..f5e3cd5 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackFunctions.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackFunctions.h
@@ -42,7 +42,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestCallbackFunctions>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestConstants.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestConstants.h index 250b0d5..92215cc6 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestConstants.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestConstants.h
@@ -43,7 +43,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestConstants>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; static void installFeatureName1(v8::Isolate*, const DOMWrapperWorld&, v8::Local<v8::Object> instance, v8::Local<v8::Object> prototype, v8::Local<v8::Function> interface); static void installFeatureName1(ScriptState*, v8::Local<v8::Object> instance);
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexed.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexed.h index 68b1f8f8..c23d69a 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexed.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexed.h
@@ -50,7 +50,7 @@ static void namedPropertyQueryCustom(const AtomicString&, const v8::PropertyCallbackInfo<v8::Integer>&); static void namedPropertyDeleterCustom(const AtomicString&, const v8::PropertyCallbackInfo<v8::Boolean>&); static void namedPropertyEnumeratorCustom(const v8::PropertyCallbackInfo<v8::Array>&); - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.h index 3a82a7f..df4e4a7 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.h
@@ -51,7 +51,7 @@ static void namedPropertyQueryCustom(const AtomicString&, const v8::PropertyCallbackInfo<v8::Integer>&); static void namedPropertyDeleterCustom(const AtomicString&, const v8::PropertyCallbackInfo<v8::Boolean>&); static void namedPropertyEnumeratorCustom(const v8::PropertyCallbackInfo<v8::Array>&); - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedPrimaryGlobal.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedPrimaryGlobal.h index e93eda5e..403bd6d 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedPrimaryGlobal.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedPrimaryGlobal.h
@@ -51,7 +51,7 @@ static void namedPropertyQueryCustom(const AtomicString&, const v8::PropertyCallbackInfo<v8::Integer>&); static void namedPropertyDeleterCustom(const AtomicString&, const v8::PropertyCallbackInfo<v8::Boolean>&); static void namedPropertyEnumeratorCustom(const v8::PropertyCallbackInfo<v8::Array>&); - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp index ccca509..f9b066e 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp
@@ -822,7 +822,6 @@ TestInterfaceImplementation* impl = V8TestInterface::toImpl(holder); // Prepare the value to be set. - MoveEventListenerToNewWrapper(isolate, holder, impl->implementsEventHandlerAttribute(), v8Value, V8TestInterface::eventListenerCacheIndex); impl->setImplementsEventHandlerAttribute(V8EventListenerHelper::GetEventListener(ScriptState::ForReceiverObject(info), v8Value, true, kListenerFindOrCreate)); }
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.h index 931caecc..0e28b3f 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.h
@@ -46,7 +46,7 @@ } static void implementsCustomVoidMethodMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&); static void legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>&); - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; CORE_EXPORT static void preparePrototypeAndInterfaceObject(v8::Local<v8::Context>, const DOMWrapperWorld&, v8::Local<v8::Object> prototypeObject, v8::Local<v8::Function> interfaceObject, v8::Local<v8::FunctionTemplate> interfaceTemplate); CORE_EXPORT static void UpdateWrapperTypeInfo(
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.h index 0e807b1..8fc17985 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.h
@@ -42,7 +42,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestInterface2>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; CORE_EXPORT static void preparePrototypeAndInterfaceObject(v8::Local<v8::Context>, const DOMWrapperWorld&, v8::Local<v8::Object> prototypeObject, v8::Local<v8::Function> interfaceObject, v8::Local<v8::FunctionTemplate> interfaceTemplate) {} CORE_EXPORT static void UpdateWrapperTypeInfo(
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.h index 8b9e202..8cb8efe 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.h
@@ -50,7 +50,7 @@ static void namedPropertyQueryCustom(const AtomicString&, const v8::PropertyCallbackInfo<v8::Integer>&); static void namedPropertyDeleterCustom(const AtomicString&, const v8::PropertyCallbackInfo<v8::Boolean>&); static void namedPropertyEnumeratorCustom(const v8::PropertyCallbackInfo<v8::Array>&); - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCheckSecurity.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCheckSecurity.h index 026d63ed..c13de37 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCheckSecurity.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCheckSecurity.h
@@ -42,7 +42,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestInterfaceCheckSecurity>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor.h index 17acaab..52ee1115 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor.h
@@ -51,7 +51,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestInterfaceConstructor>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions CORE_EXPORT static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor2.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor2.h index c818f4b..41cfbdf 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor2.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor2.h
@@ -42,7 +42,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestInterfaceConstructor2>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions CORE_EXPORT static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor3.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor3.h index 48b1465..5a9da06 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor3.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor3.h
@@ -42,7 +42,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestInterfaceConstructor3>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions CORE_EXPORT static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor4.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor4.h index 92b90a4..70388a7 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor4.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor4.h
@@ -42,7 +42,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestInterfaceConstructor4>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions CORE_EXPORT static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCustomConstructor.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCustomConstructor.h index 04658967..0fa19458 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCustomConstructor.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCustomConstructor.h
@@ -43,7 +43,7 @@ visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestInterfaceCustomConstructor>()); } static void constructorCustom(const v8::FunctionCallbackInfo<v8::Value>&); - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions CORE_EXPORT static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceDocument.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceDocument.h index 95cabae0..5eb231a 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceDocument.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceDocument.h
@@ -43,7 +43,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestInterfaceDocument>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEmpty.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEmpty.h index 682baa4..6a0b1b3 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEmpty.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEmpty.h
@@ -42,7 +42,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestInterfaceEmpty>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventInitConstructor.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventInitConstructor.h index 48dbf59..cc3518f 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventInitConstructor.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventInitConstructor.h
@@ -43,7 +43,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestInterfaceEventInitConstructor>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions CORE_EXPORT static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventTarget.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventTarget.h index ba129a3b..8736174c 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventTarget.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventTarget.h
@@ -51,8 +51,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestInterfaceEventTarget>()); } - static const int eventListenerCacheIndex = kV8DefaultWrapperInternalFieldCount + 0; - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 1; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceGarbageCollected.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceGarbageCollected.h index 3ec554c..f682acb 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceGarbageCollected.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceGarbageCollected.h
@@ -43,8 +43,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestInterfaceGarbageCollected>()); } - static const int eventListenerCacheIndex = kV8DefaultWrapperInternalFieldCount + 0; - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 1; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions CORE_EXPORT static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor.h index 4efac1b..0b1875d 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor.h
@@ -50,7 +50,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestInterfaceNamedConstructor>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.h index 13bd20d9..5b048e50 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.h
@@ -50,7 +50,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestInterfaceNamedConstructor2>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNode.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNode.h index 4006d8b..946706b 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNode.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNode.h
@@ -43,7 +43,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestInterfaceNode>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceOriginTrialEnabled.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceOriginTrialEnabled.h index c0110b4..3674ee4 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceOriginTrialEnabled.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceOriginTrialEnabled.h
@@ -42,7 +42,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestInterfaceOriginTrialEnabled>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceSecureContext.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceSecureContext.h index 5e4b2eda..bcab084 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceSecureContext.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceSecureContext.h
@@ -42,7 +42,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestInterfaceSecureContext>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; CORE_EXPORT static void preparePrototypeAndInterfaceObject(v8::Local<v8::Context>, const DOMWrapperWorld&, v8::Local<v8::Object> prototypeObject, v8::Local<v8::Function> interfaceObject, v8::Local<v8::FunctionTemplate> interfaceTemplate); // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestNode.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestNode.h index 9088eb8..d5a1b8a 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestNode.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestNode.h
@@ -43,7 +43,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestNode>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions CORE_EXPORT static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp index b44b2fe..db35b36 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp
@@ -1702,7 +1702,6 @@ TestObject* impl = V8TestObject::toImpl(holder); // Prepare the value to be set. - MoveEventListenerToNewWrapper(isolate, holder, impl->eventHandlerAttribute(), v8Value, V8TestObject::eventListenerCacheIndex); impl->setEventHandlerAttribute(V8EventListenerHelper::GetEventListener(ScriptState::ForReceiverObject(info), v8Value, true, kListenerFindOrCreate)); }
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.h index c2d7a0d..0426fe4 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.h
@@ -69,7 +69,7 @@ static void customImplementedAsLongAttributeAttributeSetterCustom(v8::Local<v8::Value>, const v8::FunctionCallbackInfo<v8::Value>&); static void customGetterImplementedAsLongAttributeAttributeGetterCustom(const v8::FunctionCallbackInfo<v8::Value>&); static void customSetterImplementedAsLongAttributeAttributeSetterCustom(v8::Local<v8::Value>, const v8::FunctionCallbackInfo<v8::Value>&); - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; CORE_EXPORT static void preparePrototypeAndInterfaceObject(v8::Local<v8::Context>, const DOMWrapperWorld&, v8::Local<v8::Object> prototypeObject, v8::Local<v8::Function> interfaceObject, v8::Local<v8::FunctionTemplate> interfaceTemplate); static void installFeatureName(v8::Isolate*, const DOMWrapperWorld&, v8::Local<v8::Object> instance, v8::Local<v8::Object> prototype, v8::Local<v8::Function> interface);
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperations.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperations.h index 3c9b745..24a4aa4 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperations.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperations.h
@@ -43,7 +43,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestSpecialOperations>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperationsNotEnumerable.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperationsNotEnumerable.h index 87859030..0217186 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperationsNotEnumerable.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperationsNotEnumerable.h
@@ -42,7 +42,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestSpecialOperationsNotEnumerable>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.h b/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.h index f51472e..ecf571e05 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.h
@@ -47,7 +47,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestTypedefs>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions CORE_EXPORT static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8Uint8ClampedArray.h b/third_party/WebKit/Source/bindings/tests/results/core/V8Uint8ClampedArray.h index 9ad3e51a..9f504a8 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8Uint8ClampedArray.h +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8Uint8ClampedArray.h
@@ -40,7 +40,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestUint8ClampedArray>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions };
diff --git a/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.h b/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.h index 125bbbe..d22e4e7 100644 --- a/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.h +++ b/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.h
@@ -46,7 +46,7 @@ visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestInterface5Implementation>()); } static void legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>&); - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; MODULES_EXPORT static void preparePrototypeAndInterfaceObject(v8::Local<v8::Context>, const DOMWrapperWorld&, v8::Local<v8::Object> prototypeObject, v8::Local<v8::Function> interfaceObject, v8::Local<v8::FunctionTemplate> interfaceTemplate); // Callback functions
diff --git a/third_party/WebKit/Source/bindings/tests/results/modules/V8TestSubObject.h b/third_party/WebKit/Source/bindings/tests/results/modules/V8TestSubObject.h index f9c4d40..633c647 100644 --- a/third_party/WebKit/Source/bindings/tests/results/modules/V8TestSubObject.h +++ b/third_party/WebKit/Source/bindings/tests/results/modules/V8TestSubObject.h
@@ -43,7 +43,7 @@ static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) { visitor->TraceWrappersWithManualWriteBarrier(scriptWrappable->ToImpl<TestSubObject>()); } - static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + 0; + static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions
diff --git a/third_party/WebKit/Source/core/css/BUILD.gn b/third_party/WebKit/Source/core/css/BUILD.gn index 39a86c592..c7aeee5 100644 --- a/third_party/WebKit/Source/core/css/BUILD.gn +++ b/third_party/WebKit/Source/core/css/BUILD.gn
@@ -56,7 +56,6 @@ "CSSFontFeatureValue.h", "CSSFontSelector.cpp", "CSSFontSelector.h", - "CSSFontSelectorClient.h", "CSSFontStyleRangeValue.cpp", "CSSFontStyleRangeValue.h", "CSSFontVariationValue.cpp",
diff --git a/third_party/WebKit/Source/core/css/CSSFontSelector.cpp b/third_party/WebKit/Source/core/css/CSSFontSelector.cpp index 15e891f..012423b 100644 --- a/third_party/WebKit/Source/core/css/CSSFontSelector.cpp +++ b/third_party/WebKit/Source/core/css/CSSFontSelector.cpp
@@ -27,7 +27,6 @@ #include "core/css/CSSFontSelector.h" #include "build/build_config.h" -#include "core/css/CSSFontSelectorClient.h" #include "core/css/CSSSegmentedFontFace.h" #include "core/css/CSSValueList.h" #include "core/css/FontFaceSet.h" @@ -39,6 +38,7 @@ #include "core/loader/FrameLoader.h" #include "platform/RuntimeEnabledFeatures.h" #include "platform/fonts/FontCache.h" +#include "platform/fonts/FontSelectorClient.h" #include "platform/fonts/SimpleFontData.h" #include "platform/wtf/text/AtomicString.h" @@ -60,20 +60,20 @@ CSSFontSelector::~CSSFontSelector() {} void CSSFontSelector::RegisterForInvalidationCallbacks( - CSSFontSelectorClient* client) { + FontSelectorClient* client) { CHECK(client); clients_.insert(client); } void CSSFontSelector::UnregisterForInvalidationCallbacks( - CSSFontSelectorClient* client) { + FontSelectorClient* client) { clients_.erase(client); } void CSSFontSelector::DispatchInvalidationCallbacks() { font_face_cache_.IncrementVersion(); - HeapVector<Member<CSSFontSelectorClient>> clients; + HeapVector<Member<FontSelectorClient>> clients; CopyToVector(clients_, clients); for (auto& client : clients) client->FontsNeedUpdate(this);
diff --git a/third_party/WebKit/Source/core/css/CSSFontSelector.h b/third_party/WebKit/Source/core/css/CSSFontSelector.h index 93df1b8b..07d80de 100644 --- a/third_party/WebKit/Source/core/css/CSSFontSelector.h +++ b/third_party/WebKit/Source/core/css/CSSFontSelector.h
@@ -37,7 +37,6 @@ namespace blink { -class CSSFontSelectorClient; class Document; class FontDescription; @@ -68,8 +67,8 @@ // FontCacheClient implementation void FontCacheInvalidated() override; - void RegisterForInvalidationCallbacks(CSSFontSelectorClient*); - void UnregisterForInvalidationCallbacks(CSSFontSelectorClient*); + void RegisterForInvalidationCallbacks(FontSelectorClient*) override; + void UnregisterForInvalidationCallbacks(FontSelectorClient*) override; Document* GetDocument() const { return document_; } FontFaceCache* GetFontFaceCache() { return &font_face_cache_; } @@ -93,7 +92,7 @@ WeakMember<Document> document_; // FIXME: Move to Document or StyleEngine. FontFaceCache font_face_cache_; - HeapHashSet<WeakMember<CSSFontSelectorClient>> clients_; + HeapHashSet<WeakMember<FontSelectorClient>> clients_; GenericFontFamilySettings generic_font_family_settings_; };
diff --git a/third_party/WebKit/Source/core/css/CSSFontSelectorClient.h b/third_party/WebKit/Source/core/css/CSSFontSelectorClient.h deleted file mode 100644 index 0060eb55..0000000 --- a/third_party/WebKit/Source/core/css/CSSFontSelectorClient.h +++ /dev/null
@@ -1,52 +0,0 @@ -/* - * Copyright (C) 2014 Google 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: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT - * OWNER OR 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 CSSFontSelectorClient_h -#define CSSFontSelectorClient_h - -#include "core/CoreExport.h" -#include "platform/heap/Handle.h" - -namespace blink { - -class CSSFontSelector; - -class CORE_EXPORT CSSFontSelectorClient : public GarbageCollectedMixin { - public: - virtual ~CSSFontSelectorClient() {} - - virtual void FontsNeedUpdate(CSSFontSelector*) = 0; - - DEFINE_INLINE_VIRTUAL_TRACE() {} -}; - -} // namespace blink - -#endif // CSSFontSelectorClient_h
diff --git a/third_party/WebKit/Source/core/css/FontFace.cpp b/third_party/WebKit/Source/core/css/FontFace.cpp index 10a41d49..a26c34c 100644 --- a/third_party/WebKit/Source/core/css/FontFace.cpp +++ b/third_party/WebKit/Source/core/css/FontFace.cpp
@@ -699,7 +699,7 @@ FontResource* fetched = item.Fetch(document); if (fetched) { CSSFontSelector* font_selector = - document->GetStyleEngine().FontSelector(); + document->GetStyleEngine().GetFontSelector(); source = new RemoteFontFaceSource( fetched, font_selector, CSSValueToFontDisplay(display_.Get())); }
diff --git a/third_party/WebKit/Source/core/css/FontFaceSet.cpp b/third_party/WebKit/Source/core/css/FontFaceSet.cpp index 22936e5..47b9f0e 100644 --- a/third_party/WebKit/Source/core/css/FontFaceSet.cpp +++ b/third_party/WebKit/Source/core/css/FontFaceSet.cpp
@@ -265,7 +265,7 @@ if (IsCSSConnectedFontFace(font_face)) return this; CSSFontSelector* font_selector = - GetDocument()->GetStyleEngine().FontSelector(); + GetDocument()->GetStyleEngine().GetFontSelector(); non_css_connected_faces_.insert(font_face); font_selector->GetFontFaceCache()->AddFontFace(font_face, false); if (font_face->LoadStatus() == FontFace::kLoading) @@ -278,7 +278,7 @@ if (!InActiveDocumentContext() || non_css_connected_faces_.IsEmpty()) return; CSSFontSelector* font_selector = - GetDocument()->GetStyleEngine().FontSelector(); + GetDocument()->GetStyleEngine().GetFontSelector(); FontFaceCache* font_face_cache = font_selector->GetFontFaceCache(); for (const auto& font_face : non_css_connected_faces_) { font_face_cache->RemoveFontFace(font_face.Get(), false); @@ -300,7 +300,7 @@ if (it != non_css_connected_faces_.end()) { non_css_connected_faces_.erase(it); CSSFontSelector* font_selector = - GetDocument()->GetStyleEngine().FontSelector(); + GetDocument()->GetStyleEngine().GetFontSelector(); font_selector->GetFontFaceCache()->RemoveFontFace(font_face, false); if (font_face->LoadStatus() == FontFace::kLoading) RemoveFromLoadingFonts(font_face); @@ -325,7 +325,7 @@ Document* document = this->GetDocument(); document->UpdateActiveStyle(); return document->GetStyleEngine() - .FontSelector() + .GetFontSelector() ->GetFontFaceCache() ->CssConnectedFontFaces(); } @@ -393,7 +393,7 @@ } FontFaceCache* font_face_cache = - GetDocument()->GetStyleEngine().FontSelector()->GetFontFaceCache(); + GetDocument()->GetStyleEngine().GetFontSelector()->GetFontFaceCache(); FontFaceArray faces; for (const FontFamily* f = &font.GetFontDescription().Family(); f; f = f->Next()) { @@ -425,7 +425,7 @@ } CSSFontSelector* font_selector = - GetDocument()->GetStyleEngine().FontSelector(); + GetDocument()->GetStyleEngine().GetFontSelector(); FontFaceCache* font_face_cache = font_selector->GetFontFaceCache(); bool has_loaded_faces = false; @@ -484,7 +484,7 @@ GetDocument()->EnsureStyleResolver().ComputeFont(style.Get(), *parsed_style); font = style->GetFont(); - font.Update(GetDocument()->GetStyleEngine().FontSelector()); + font.Update(GetDocument()->GetStyleEngine().GetFontSelector()); return true; }
diff --git a/third_party/WebKit/Source/core/css/MediaQueryList.idl b/third_party/WebKit/Source/core/css/MediaQueryList.idl index 4f1175c..cd276f2 100644 --- a/third_party/WebKit/Source/core/css/MediaQueryList.idl +++ b/third_party/WebKit/Source/core/css/MediaQueryList.idl
@@ -29,7 +29,7 @@ // exist as aliases for addEventListener for backwards compatibility // with older versions of this interface. See the note at // https://dev.w3.org/csswg/cssom-view/#dom-mediaquerylist-removelistener - [ImplementedAs=addDeprecatedListener, Custom=CallEpilogue] void addListener(EventListener? listener); - [ImplementedAs=removeDeprecatedListener, Custom=CallEpilogue]void removeListener(EventListener? listener); + [ImplementedAs=addDeprecatedListener] void addListener(EventListener? listener); + [ImplementedAs=removeDeprecatedListener] void removeListener(EventListener? listener); attribute EventHandler onchange; };
diff --git a/third_party/WebKit/Source/core/css/resolver/FontBuilderTest.cpp b/third_party/WebKit/Source/core/css/resolver/FontBuilderTest.cpp index 3900805..5bb0bfd 100644 --- a/third_party/WebKit/Source/core/css/resolver/FontBuilderTest.cpp +++ b/third_party/WebKit/Source/core/css/resolver/FontBuilderTest.cpp
@@ -49,7 +49,8 @@ FontBuilder builder(&GetDocument()); builder.SetInitial(1.0f); // FIXME: Remove unused param. - builder.CreateFont(GetDocument().GetStyleEngine().FontSelector(), *initial); + builder.CreateFont(GetDocument().GetStyleEngine().GetFontSelector(), + *initial); EXPECT_EQ(16.0f, initial->GetFontDescription().ComputedSize()); } @@ -73,7 +74,7 @@ FontBuilder font_builder(&GetDocument()); funcs.set_value(font_builder); - font_builder.CreateFont(GetDocument().GetStyleEngine().FontSelector(), + font_builder.CreateFont(GetDocument().GetStyleEngine().GetFontSelector(), *style); FontDescription output_description = style->GetFontDescription();
diff --git a/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp b/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp index 326d7d8c..a41fb5ae 100644 --- a/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp +++ b/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp
@@ -71,7 +71,8 @@ return; Document& document = GetTreeScope().GetDocument(); - CSSFontSelector* css_font_selector = document.GetStyleEngine().FontSelector(); + CSSFontSelector* css_font_selector = + document.GetStyleEngine().GetFontSelector(); const HeapVector<Member<StyleRuleFontFace>> font_face_rules = rule_set.FontFaceRules(); for (auto& font_face_rule : font_face_rules) {
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp index 4f70947..4033bdd6 100644 --- a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp +++ b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
@@ -603,7 +603,7 @@ style_not_yet_available_ = ComputedStyle::Create().LeakRef(); style_not_yet_available_->SetDisplay(EDisplay::kNone); style_not_yet_available_->GetFont().Update( - GetDocument().GetStyleEngine().FontSelector()); + GetDocument().GetStyleEngine().GetFontSelector()); } GetDocument().SetHasNodesWithPlaceholderStyle(); @@ -766,7 +766,7 @@ if (value) { StyleBuilder::ApplyProperty(property, state, *value); state.GetFontBuilder().CreateFont( - state.GetDocument().GetStyleEngine().FontSelector(), + state.GetDocument().GetStyleEngine().GetFontSelector(), state.MutableStyleRef()); } return CSSAnimatableValueFactory::Create(property, *state.Style()); @@ -1026,7 +1026,8 @@ void StyleResolver::UpdateFont(StyleResolverState& state) { state.GetFontBuilder().CreateFont( - GetDocument().GetStyleEngine().FontSelector(), state.MutableStyleRef()); + GetDocument().GetStyleEngine().GetFontSelector(), + state.MutableStyleRef()); state.SetConversionFontSizes(CSSToLengthConversionData::FontSizes( state.Style(), state.RootElementStyle())); state.SetConversionZoom(state.Style()->EffectiveZoom());
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp index a705795..7c1ea06 100644 --- a/third_party/WebKit/Source/core/dom/Document.cpp +++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -1835,7 +1835,7 @@ void Document::SetupFontBuilder(ComputedStyle& document_style) { FontBuilder font_builder(this); - CSSFontSelector* selector = GetStyleEngine().FontSelector(); + CSSFontSelector* selector = GetStyleEngine().GetFontSelector(); font_builder.CreateFontForDocument(selector, document_style); } @@ -6550,11 +6550,6 @@ void Document::UpdateHoverState(const HitTestRequest& request, Element* inner_element_in_document) { - // Do not set hover state if event is from touch and on mobile. - bool allow_hover_changes = - !(request.TouchEvent() && GetPage() && - GetPage()->GetVisualViewport().ShouldDisableDesktopWorkarounds()); - Element* old_hover_element = HoverElement(); // The passed in innerElement may not be a result of a hit test for the @@ -6565,10 +6560,9 @@ SkipDisplayNoneAncestors(inner_element_in_document); // Update our current hover element. - if (allow_hover_changes) - SetHoverElement(new_hover_element); + SetHoverElement(new_hover_element); - if (old_hover_element == new_hover_element || !allow_hover_changes) + if (old_hover_element == new_hover_element) return; Node* ancestor_element = nullptr;
diff --git a/third_party/WebKit/Source/core/dom/ScriptLoader.cpp b/third_party/WebKit/Source/core/dom/ScriptLoader.cpp index 0471fb55..62f2834c 100644 --- a/third_party/WebKit/Source/core/dom/ScriptLoader.cpp +++ b/third_party/WebKit/Source/core/dom/ScriptLoader.cpp
@@ -683,8 +683,9 @@ ? element_document.Url() : KURL(); - return ExecuteScriptBlock(ClassicPendingScript::Create(element_, position), - script_url); + ExecuteScriptBlock(ClassicPendingScript::Create(element_, position), + script_url); + return true; } bool ScriptLoader::FetchClassicScript( @@ -795,29 +796,9 @@ return nullptr; } -ScriptLoader::ExecuteScriptResult ScriptLoader::ExecuteScript( - const Script* script) { - double script_exec_start_time = MonotonicallyIncreasingTime(); - ExecuteScriptResult result = DoExecuteScript(script); - - // NOTE: we do not check m_willBeParserExecuted here, since - // m_willBeParserExecuted is false for inline scripts, and we want to - // include inline script execution time as part of parser blocked script - // execution time. - if (async_exec_type_ == ScriptRunner::kNone) - DocumentParserTiming::From(element_->GetDocument()) - .RecordParserBlockedOnScriptExecutionDuration( - MonotonicallyIncreasingTime() - script_exec_start_time, - WasCreatedDuringDocumentWrite()); - return result; -} - -// https://html.spec.whatwg.org/#execute-the-script-block +// Steps 3--7 of https://html.spec.whatwg.org/#execute-the-script-block // with additional support for HTML imports. -// Note that Steps 2 and 8 must be handled by the caller of doExecuteScript(), -// i.e. load/error events are dispatched by the caller. -// Steps 3--7 are implemented here in doExecuteScript(). -// TODO(hiroshige): Move event dispatching code to doExecuteScript(). +// Steps 2 and 8 are handled in ExecuteScriptBlock(). ScriptLoader::ExecuteScriptResult ScriptLoader::DoExecuteScript( const Script* script) { DCHECK(already_started_); @@ -912,7 +893,7 @@ } // https://html.spec.whatwg.org/#execute-the-script-block -bool ScriptLoader::ExecuteScriptBlock(PendingScript* pending_script, +void ScriptLoader::ExecuteScriptBlock(PendingScript* pending_script, const KURL& document_url) { DCHECK(pending_script); DCHECK_EQ(pending_script->IsExternal(), is_external_script_); @@ -929,39 +910,51 @@ Document* context_document = element_document->ContextDocument(); if (original_document_ != context_document && script->GetScriptType() == ScriptType::kModule) - return false; + return; // 2. "If the script's script is null, fire an event named error at the // element, and abort these steps." if (error_occurred) { DispatchErrorEvent(); - return false; + return; } if (was_canceled) - return false; + return; - // Steps 3--7 are in ExecuteScript(). - switch (ExecuteScript(script)) { + double script_exec_start_time = MonotonicallyIncreasingTime(); + + // Steps 3--7 are in DoExecuteScript(). + ExecuteScriptResult result = DoExecuteScript(script); + + // NOTE: we do not check m_willBeParserExecuted here, since + // m_willBeParserExecuted is false for inline scripts, and we want to + // include inline script execution time as part of parser blocked script + // execution time. + if (async_exec_type_ == ScriptRunner::kNone) { + DocumentParserTiming::From(element_->GetDocument()) + .RecordParserBlockedOnScriptExecutionDuration( + MonotonicallyIncreasingTime() - script_exec_start_time, + WasCreatedDuringDocumentWrite()); + } + + switch (result) { case ExecuteScriptResult::kShouldFireLoadEvent: // 8. "If the script is from an external file, then fire an event named // load at the script element." if (is_external) DispatchLoadEvent(); - return true; + break; case ExecuteScriptResult::kShouldFireErrorEvent: // Consider as if "the script's script is null" retrospectively, // due to CSP check failures etc., which are considered as load failure. DispatchErrorEvent(); - return false; + break; case ExecuteScriptResult::kShouldFireNone: - return true; + break; } - - NOTREACHED(); - return false; } void ScriptLoader::PendingScriptFinished(PendingScript* pending_script) {
diff --git a/third_party/WebKit/Source/core/dom/ScriptLoader.h b/third_party/WebKit/Source/core/dom/ScriptLoader.h index 53f18d13..9dbda9dd 100644 --- a/third_party/WebKit/Source/core/dom/ScriptLoader.h +++ b/third_party/WebKit/Source/core/dom/ScriptLoader.h
@@ -84,12 +84,7 @@ // https://html.spec.whatwg.org/#execute-the-script-block // The single entry point of script execution. // PendingScript::Dispose() is called in ExecuteScriptBlock(). - // - // TODO(hiroshige): Replace ExecuteScript() calls with ExecuteScriptBlock(). - // - // TODO(hiroshige): Currently this returns bool (true if success) only to - // preserve existing code structure around PrepareScript(). Clean up this. - bool ExecuteScriptBlock(PendingScript*, const KURL&); + void ExecuteScriptBlock(PendingScript*, const KURL&); // Creates a PendingScript for external script whose fetch is started in // FetchClassicScript()/FetchModuleScriptTree(). @@ -180,7 +175,6 @@ kShouldFireLoadEvent, kShouldFireNone }; - WARN_UNUSED_RESULT ExecuteScriptResult ExecuteScript(const Script*); ExecuteScriptResult DoExecuteScript(const Script*); void DispatchLoadEvent(); void DispatchErrorEvent();
diff --git a/third_party/WebKit/Source/core/dom/StyleEngine.cpp b/third_party/WebKit/Source/core/dom/StyleEngine.cpp index 5da60de3..bed6f6c 100644 --- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp +++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
@@ -56,6 +56,7 @@ #include "core/probe/CoreProbes.h" #include "core/svg/SVGStyleElement.h" #include "platform/fonts/FontCache.h" +#include "platform/fonts/FontSelector.h" #include "platform/instrumentation/tracing/TraceEvent.h" namespace blink { @@ -622,7 +623,7 @@ } } -void StyleEngine::FontsNeedUpdate(CSSFontSelector*) { +void StyleEngine::FontsNeedUpdate(FontSelector*) { if (!GetDocument().IsActive()) return; @@ -1209,7 +1210,7 @@ visitor->Trace(text_to_sheet_cache_); visitor->Trace(sheet_to_text_cache_); visitor->Trace(tracker_); - CSSFontSelectorClient::Trace(visitor); + FontSelectorClient::Trace(visitor); } DEFINE_TRACE_WRAPPERS(StyleEngine) {
diff --git a/third_party/WebKit/Source/core/dom/StyleEngine.h b/third_party/WebKit/Source/core/dom/StyleEngine.h index 7955aea..aaea994 100644 --- a/third_party/WebKit/Source/core/dom/StyleEngine.h +++ b/third_party/WebKit/Source/core/dom/StyleEngine.h
@@ -34,7 +34,6 @@ #include <utility> #include "core/CoreExport.h" #include "core/css/ActiveStyleSheets.h" -#include "core/css/CSSFontSelectorClient.h" #include "core/css/CSSGlobalRuleSet.h" #include "core/css/invalidation/StyleInvalidator.h" #include "core/css/resolver/StyleResolver.h" @@ -45,6 +44,7 @@ #include "core/dom/TreeOrderedList.h" #include "platform/bindings/ScriptWrappable.h" #include "platform/bindings/TraceWrapperMember.h" +#include "platform/fonts/FontSelectorClient.h" #include "platform/heap/Handle.h" #include "platform/wtf/Allocator.h" #include "platform/wtf/AutoReset.h" @@ -57,6 +57,7 @@ class CSSFontSelector; class CSSStyleSheet; +class FontSelector; class MediaQueryEvaluator; class Node; class RuleFeatureSet; @@ -68,7 +69,7 @@ class CORE_EXPORT StyleEngine final : public GarbageCollectedFinalized<StyleEngine>, - public CSSFontSelectorClient, + public FontSelectorClient, public TraceWrapperBase { USING_GARBAGE_COLLECTED_MIXIN(StyleEngine); @@ -211,7 +212,7 @@ .IsEmpty(); } - CSSFontSelector* FontSelector() { return font_selector_; } + CSSFontSelector* GetFontSelector() { return font_selector_; } void SetFontSelector(CSSFontSelector*); void RemoveFontFaceRules(const HeapVector<Member<const StyleRuleFontFace>>&); @@ -274,8 +275,8 @@ DECLARE_TRACE_WRAPPERS(); private: - // CSSFontSelectorClient implementation. - void FontsNeedUpdate(CSSFontSelector*) override; + // FontSelectorClient implementation. + void FontsNeedUpdate(FontSelector*) override; private: StyleEngine(Document&);
diff --git a/third_party/WebKit/Source/core/events/EventTarget.idl b/third_party/WebKit/Source/core/events/EventTarget.idl index 9faf117..7567440b 100644 --- a/third_party/WebKit/Source/core/events/EventTarget.idl +++ b/third_party/WebKit/Source/core/events/EventTarget.idl
@@ -25,7 +25,7 @@ Exposed=(Window,Worker), ImmutablePrototype ] interface EventTarget { - [Custom=(CallPrologue,CallEpilogue)] void addEventListener(DOMString type, EventListener? listener, optional (AddEventListenerOptions or boolean) options); - [Custom=(CallPrologue,CallEpilogue)] void removeEventListener(DOMString type, EventListener? listener, optional (EventListenerOptions or boolean) options); + [Custom=CallPrologue] void addEventListener(DOMString type, EventListener? listener, optional (AddEventListenerOptions or boolean) options); + [Custom=CallPrologue] void removeEventListener(DOMString type, EventListener? listener, optional (EventListenerOptions or boolean) options); [ImplementedAs=dispatchEventForBindings, RaisesException, RuntimeCallStatsCounter=EventTargetDispatchEvent] boolean dispatchEvent(Event event); };
diff --git a/third_party/WebKit/Source/core/exported/WebFrameTest.cpp b/third_party/WebKit/Source/core/exported/WebFrameTest.cpp index aaac743..1a47123e 100644 --- a/third_party/WebKit/Source/core/exported/WebFrameTest.cpp +++ b/third_party/WebKit/Source/core/exported/WebFrameTest.cpp
@@ -11573,76 +11573,6 @@ EXPECT_EQ(scrollbar->HoveredPart(), ScrollbarPart::kNoPart); } -class TapChangeHoverStateTest : public ParameterizedWebFrameTest { - public: - void RunTest(bool viewport_enabled, - bool viewport_meta, - bool should_change_hover_state) { - std::string test_page = - viewport_meta ? "viewport-2-div.html" : "noviewport-2-div.html"; - - FakeCompositingWebViewClient client; - RegisterMockedHttpURLLoad(test_page); - FrameTestHelpers::WebViewHelper web_view_helper; - WebViewBase* web_view; - if (viewport_enabled) { - web_view = web_view_helper.InitializeAndLoad( - base_url_ + test_page, nullptr, &client, nullptr, ConfigureAndroid); - } else { - web_view = web_view_helper.InitializeAndLoad(base_url_ + test_page); - } - web_view_helper.Resize(WebSize(250, 250)); - - Document* document = - ToLocalFrame(web_view->GetPage()->MainFrame())->GetDocument(); - - Element* div1 = document->getElementById("div1"); - Element* div2 = document->getElementById("div2"); - - // Move mouse over div1 should hover div1. - WebMouseEvent mouse_move_over_div1( - WebInputEvent::kMouseMove, WebFloatPoint(10, 10), WebFloatPoint(10, 10), - WebPointerProperties::Button::kNoButton, 0, WebInputEvent::kNoModifiers, - TimeTicks::Now().InSeconds()); - mouse_move_over_div1.SetFrameScale(1); - document->GetFrame()->GetEventHandler().HandleMouseMoveEvent( - mouse_move_over_div1, Vector<WebMouseEvent>()); - - DCHECK(document->HoverElement() == div1); - - // Tap on div2. - WebGestureEvent tap_on_div2(WebInputEvent::kGestureTap, - WebInputEvent::kNoModifiers, - WebInputEvent::kTimeStampForTesting); - tap_on_div2.SetFrameScale(1); - tap_on_div2.x = tap_on_div2.global_x = 10; - tap_on_div2.y = tap_on_div2.global_y = 110; - tap_on_div2.source_device = kWebGestureDeviceTouchscreen; - web_view_helper.WebView() - ->MainFrameImpl() - ->GetFrame() - ->GetEventHandler() - .HandleGestureEvent(tap_on_div2); - - Element* expected_hover_element = should_change_hover_state ? div2 : div1; - EXPECT_EQ(expected_hover_element, document->HoverElement()); - } -}; - -INSTANTIATE_TEST_CASE_P(All, TapChangeHoverStateTest, ::testing::Bool()); - -TEST_P(TapChangeHoverStateTest, TapNotChangeHoverStateOnViewportMetaAndMobile) { - RunTest(true, true, false); -} - -TEST_P(TapChangeHoverStateTest, TapChangeHoverStateOnNoViewportMetaAndMobile) { - RunTest(true, false, true); -} - -TEST_P(TapChangeHoverStateTest, TapChangeHoverStateOnViewportMetaAndDesktop) { - RunTest(false, true, true); -} - TEST_P(ParameterizedWebFrameTest, CustomScrollbarInOverlayScrollbarThemeWillNotCauseDCHECKFails) { RegisterMockedHttpURLLoad(
diff --git a/third_party/WebKit/Source/core/html/forms/InternalPopupMenu.cpp b/third_party/WebKit/Source/core/html/forms/InternalPopupMenu.cpp index 2568a72..a0829a0f 100644 --- a/third_party/WebKit/Source/core/html/forms/InternalPopupMenu.cpp +++ b/third_party/WebKit/Source/core/html/forms/InternalPopupMenu.cpp
@@ -23,6 +23,8 @@ #include "core/layout/LayoutTheme.h" #include "core/page/ChromeClient.h" #include "core/page/PagePopup.h" +#include "platform/fonts/FontSelector.h" +#include "platform/fonts/FontSelectorClient.h" #include "platform/geometry/IntRect.h" #include "platform/text/PlatformLocale.h" #include "public/platform/Platform.h" @@ -59,7 +61,7 @@ } // anonymous namespace class PopupMenuCSSFontSelector : public CSSFontSelector, - private CSSFontSelectorClient { + private FontSelectorClient { USING_GARBAGE_COLLECTED_MIXIN(PopupMenuCSSFontSelector); public: @@ -81,7 +83,7 @@ private: PopupMenuCSSFontSelector(Document*, CSSFontSelector*); - void FontsNeedUpdate(CSSFontSelector*) override; + void FontsNeedUpdate(FontSelector*) override; Member<CSSFontSelector> owner_font_selector_; }; @@ -101,14 +103,14 @@ return owner_font_selector_->GetFontData(description, name); } -void PopupMenuCSSFontSelector::FontsNeedUpdate(CSSFontSelector* font_selector) { +void PopupMenuCSSFontSelector::FontsNeedUpdate(FontSelector* font_selector) { DispatchInvalidationCallbacks(); } DEFINE_TRACE(PopupMenuCSSFontSelector) { visitor->Trace(owner_font_selector_); CSSFontSelector::Trace(visitor); - CSSFontSelectorClient::Trace(visitor); + FontSelectorClient::Trace(visitor); } // ---------------------------------------------------------------- @@ -413,7 +415,7 @@ void InternalPopupMenu::SelectFontsFromOwnerDocument(Document& document) { Document& owner_document = OwnerElement().GetDocument(); document.GetStyleEngine().SetFontSelector(PopupMenuCSSFontSelector::Create( - &document, owner_document.GetStyleEngine().FontSelector())); + &document, owner_document.GetStyleEngine().GetFontSelector())); } void InternalPopupMenu::SetValueAndClosePopup(int num_value,
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp index 9ed17e2f..78de5345 100644 --- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp +++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp
@@ -410,7 +410,7 @@ font_description.SetComputedSize(scaled_font_size); scaled_font = Font(font_description); - scaled_font.Update(document.GetStyleEngine().FontSelector()); + scaled_font.Update(document.GetStyleEngine().GetFontSelector()); } LayoutRect LayoutSVGInlineText::AbsoluteVisualRect() const {
diff --git a/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp b/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp index 9dd5a0c..1eba7d48 100644 --- a/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp +++ b/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp
@@ -779,10 +779,12 @@ layers_with_touch_rects_.clear(); for (const auto& layer_rect : layer_rects) { if (!layer_rect.value.IsEmpty()) { + DCHECK(layer_rect.key->IsRootLayer() || layer_rect.key->Parent()); const PaintLayer* composited_layer = layer_rect.key ->EnclosingLayerForPaintInvalidationCrossingFrameBoundaries(); - DCHECK(composited_layer); + if (!composited_layer) + continue; layers_with_touch_rects_.insert(composited_layer); GraphicsLayer* main_graphics_layer = composited_layer->GraphicsLayerBacking(
diff --git a/third_party/WebKit/Source/core/testing/data/noviewport-2-div.html b/third_party/WebKit/Source/core/testing/data/noviewport-2-div.html deleted file mode 100644 index 9a52639a..0000000 --- a/third_party/WebKit/Source/core/testing/data/noviewport-2-div.html +++ /dev/null
@@ -1,11 +0,0 @@ -<!DOCTYPE html> - -<style> -div { - width: 100px; - height: 100px; -} -</style> - -<div id='div1'></div> -<div id='div2'></div> \ No newline at end of file
diff --git a/third_party/WebKit/Source/core/testing/data/viewport-2-div.html b/third_party/WebKit/Source/core/testing/data/viewport-2-div.html deleted file mode 100644 index eb8658b3..0000000 --- a/third_party/WebKit/Source/core/testing/data/viewport-2-div.html +++ /dev/null
@@ -1,13 +0,0 @@ -<!DOCTYPE html> - -<meta name="viewport" content="width=device-width, initial-scale=1"> - -<style> -div { - width: 100px; - height: 100px; -} -</style> - -<div id='div1'></div> -<div id='div2'></div> \ No newline at end of file
diff --git a/third_party/WebKit/Source/devtools/front_end/console_test_runner/ConsoleTestRunner.js b/third_party/WebKit/Source/devtools/front_end/console_test_runner/ConsoleTestRunner.js index cef7ac9..d00e6e6 100644 --- a/third_party/WebKit/Source/devtools/front_end/console_test_runner/ConsoleTestRunner.js +++ b/third_party/WebKit/Source/devtools/front_end/console_test_runner/ConsoleTestRunner.js
@@ -217,7 +217,7 @@ }; /** - * @param {function(!Element):string} messageFormatter + * @param {function(!Element):string|undefined} messageFormatter * @param {!Element} node * @return {string} */ @@ -261,7 +261,7 @@ printOriginatingCommand, dumpClassNames, messageFormatter) { TestRunner.addResults(ConsoleTestRunner.dumpConsoleMessagesIntoArray( printOriginatingCommand, dumpClassNames, - messageFormatter ? ConsoleTestRunner.formatterIgnoreStackFrameUrls.bind(this, messageFormatter) : undefined)); + ConsoleTestRunner.formatterIgnoreStackFrameUrls.bind(this, messageFormatter))); }; ConsoleTestRunner.dumpConsoleMessagesWithStyles = function() { @@ -410,11 +410,11 @@ ConsoleTestRunner.waitUntilConsoleEditorLoaded = function() { var fulfill; var promise = new Promise(x => (fulfill = x)); - var editor = Console.ConsoleView.instance()._prompt._editor; - if (editor) - fulfill(editor); + var prompt = Console.ConsoleView.instance()._prompt; + if (prompt._editor) + fulfill(prompt._editor); else - TestRunner.addSniffer(Console.ConsolePrompt.prototype, '_editorSetForTest', _ => fulfill(editor)); + TestRunner.addSniffer(Console.ConsolePrompt.prototype, '_editorSetForTest', _ => fulfill(prompt._editor)); return promise; };
diff --git a/third_party/WebKit/Source/devtools/scripts/migrate_test/migrate_test.js b/third_party/WebKit/Source/devtools/scripts/migrate_test/migrate_test.js index e9de174..f9face9 100644 --- a/third_party/WebKit/Source/devtools/scripts/migrate_test/migrate_test.js +++ b/third_party/WebKit/Source/devtools/scripts/migrate_test/migrate_test.js
@@ -13,6 +13,7 @@ const types = recast.types; const b = recast.types.builders; +const migrateUtils = require('./migrate_utils'); const utils = require('../utils'); const DRY_RUN = process.env.DRY_RUN || false; @@ -55,9 +56,13 @@ helperScripts.push(filename); }); - const outPath = getOutPath(inputPath); - const srcResourcePaths = resourceScripts.map(s => path.resolve(path.dirname(inputPath), s)); - const destResourcePaths = resourceScripts.map(s => path.resolve(path.dirname(outPath), s)); + const testsPath = path.resolve(__dirname, 'tests.txt'); + const newToOldTests = new Map(fs.readFileSync(testsPath, 'utf-8').split('\n').map(line => line.split(' ').reverse())); + const originalTestPath = path.resolve( + __dirname, '..', '..', '..', '..', 'LayoutTests', newToOldTests.get(inputPath.slice(inputPath.indexOf('http/')))); + + const srcResourcePaths = resourceScripts.map(s => path.resolve(path.dirname(originalTestPath), s)); + const destResourcePaths = resourceScripts.map(s => path.resolve(path.dirname(inputPath), s)); const relativeResourcePaths = destResourcePaths.map(p => p.slice(p.indexOf('/http/tests') + '/http/tests'.length)); let outputCode; @@ -80,21 +85,14 @@ } catch (err) { console.log('Unable to migrate: ', inputPath); console.log('ERROR: ', err); - return; + process.exit(1); } console.log(outputCode); if (!DRY_RUN) { - mkdirp.sync(path.dirname(outPath)); - - fs.writeFileSync(outPath, outputCode); - const expectationsPath = inputPath.replace('.html', '-expected.txt'); - copyExpectations(expectationsPath, outPath); + fs.writeFileSync(inputPath, outputCode); copyResourceScripts(srcResourcePaths, destResourcePaths); - - fs.unlinkSync(inputPath); - fs.unlinkSync(expectationsPath); - console.log('Migrated to: ', outPath); + console.log('Migrated: ', inputPath); } } @@ -178,12 +176,11 @@ * Create test header based on extracted data */ const headerLines = []; - headerLines.push(createExpressionNode(`TestRunner.addResult('${bodyText}\\n');`)); + headerLines.push(createExpressionNode(`TestRunner.addResult(\`${bodyText}\\n\`);`)); headerLines.push(createNewLineNode()); for (const helper of allTestHelpers) { headerLines.push(createAwaitExpressionNode(`await TestRunner.loadModule('${helper}');`)); } - headerLines.push(createAwaitExpressionNode(`await TestRunner.loadPanel('${panel}');`)); headerLines.push(createAwaitExpressionNode(`await TestRunner.showPanel('${panel}');`)); if (domFixture) { @@ -300,19 +297,6 @@ return copyrightedCode; } - -function getOutPath(inputPath) { - const nonHttpLayoutTestPrefix = 'LayoutTests/inspector'; - const httpLayoutTestPrefix = 'LayoutTests/http/tests/inspector'; - const postfix = inputPath.indexOf(nonHttpLayoutTestPrefix) === -1 ? - inputPath.slice(inputPath.indexOf(httpLayoutTestPrefix) + httpLayoutTestPrefix.length + 1) - .replace('.html', '.js') : - inputPath.slice(inputPath.indexOf(nonHttpLayoutTestPrefix) + nonHttpLayoutTestPrefix.length + 1) - .replace('.html', '.js'); - const out = path.resolve(__dirname, '..', '..', '..', '..', 'LayoutTests', 'http', 'tests', 'devtools', postfix); - return out; -} - function getPanel(inputPath) { const panelByFolder = { 'animation': 'elements',
diff --git a/third_party/WebKit/Source/devtools/scripts/migrate_test/migrate_utils.js b/third_party/WebKit/Source/devtools/scripts/migrate_test/migrate_utils.js new file mode 100644 index 0000000..be774e4 --- /dev/null +++ b/third_party/WebKit/Source/devtools/scripts/migrate_test/migrate_utils.js
@@ -0,0 +1,23 @@ +// 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. + +'use strict'; + +const path = require('path'); + +function getOutPath(inputPath) { + const nonHttpLayoutTestPrefix = 'LayoutTests/inspector'; + const httpLayoutTestPrefix = 'LayoutTests/http/tests/inspector'; + const postfix = inputPath.indexOf(nonHttpLayoutTestPrefix) === -1 ? + inputPath.slice(inputPath.indexOf(httpLayoutTestPrefix) + httpLayoutTestPrefix.length + 1) + .replace('.html', '.js') : + inputPath.slice(inputPath.indexOf(nonHttpLayoutTestPrefix) + nonHttpLayoutTestPrefix.length + 1) + .replace('.html', '.js'); + const out = path.resolve(__dirname, '..', '..', '..', '..', 'LayoutTests', 'http', 'tests', 'devtools', postfix); + return out; +} + +module.exports = { + getOutPath, +};
diff --git a/third_party/WebKit/Source/devtools/scripts/migrate_test/move.js b/third_party/WebKit/Source/devtools/scripts/migrate_test/move.js new file mode 100644 index 0000000..21b6270 --- /dev/null +++ b/third_party/WebKit/Source/devtools/scripts/migrate_test/move.js
@@ -0,0 +1,106 @@ +// 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. + +'use strict'; + +const childProcess = require('child_process'); +const fs = require('fs'); +const path = require('path'); + +const mkdirp = require('mkdirp'); + +const migrateUtils = require('./migrate_utils'); +const utils = require('../utils'); + +const MIGRATE_TEST_PATH = path.resolve(__dirname, 'migrate_test.js'); +const TESTS_PATH = path.resolve(__dirname, 'tests.txt'); +const TEST_EXPECTATIONS_PATH = path.resolve(__dirname, '..', '..', '..', '..', 'LayoutTests', 'TestExpectations'); +const FLAG_EXPECTATIONS_PATH = path.resolve(__dirname, '..', '..', '..', '..', 'LayoutTests', 'FlagExpectations'); + +function main() { + const originalTests = fs.readFileSync(TESTS_PATH, 'utf-8').split('\n').map(line => line.split(' ')[0]); + const oldToNewResourcesPath = new Map(); + const oldToNewTestPath = new Map(originalTests.map(t => [t, ''])); + + for (const inputRelativePath of originalTests) { + if (!inputRelativePath) { + continue; + } + const inputPath = path.resolve(__dirname, '..', '..', '..', '..', 'LayoutTests', inputRelativePath); + const inputResourcesPath = path.resolve(path.dirname(inputPath), 'resources'); + const outPath = migrateUtils.getOutPath(inputPath); + const outResourcesPath = path.resolve(path.dirname(outPath), 'resources'); + + try { + childProcess.execSync(`DRY_RUN=1 node ${MIGRATE_TEST_PATH} ${inputPath}`); + } catch (err) { + console.log('Skipping test', inputPath); + console.log(err.stdout.toString()); + continue; + } + + if (utils.isDir(inputResourcesPath)) + oldToNewResourcesPath.set(inputResourcesPath, outResourcesPath); + mkdirp.sync(path.dirname(outPath)); + + // Move .html -> .js + fs.writeFileSync(outPath, fs.readFileSync(inputPath, 'utf-8')); + fs.unlinkSync(inputPath); + + const outRelativePath = outPath.substring(outPath.indexOf('http/')); + oldToNewTestPath.set(inputRelativePath, outRelativePath); + + // Move expectation file + const inputExpectationsPath = inputPath.replace('.html', '-expected.txt'); + const outExpectationsPath = outPath.replace('.js', '-expected.txt'); + fs.writeFileSync(outExpectationsPath, fs.readFileSync(inputExpectationsPath, 'utf-8')); + fs.unlinkSync(inputExpectationsPath); + } + + fs.writeFileSync(TESTS_PATH, Array.from(oldToNewTestPath.entries()).map(a => a.join(' ')).join('\n')); + + const newTestPaths = Array.from(oldToNewTestPath.values()).filter(x => x); + + // Update TestExpectations + const testExpectations = fs.readFileSync(TEST_EXPECTATIONS_PATH, 'utf-8'); + const updatedTestExpecations = testExpectations.split('\n').map(line => { + for (const [oldTestPath, newTestPath] of oldToNewTestPath) { + if (!newTestPath) + continue; + if (line.indexOf(oldTestPath) !== -1) + return line.replace(oldTestPath, newTestPath); + if (line === '# See crbug.com/667560 for details') { + return line + '\n' + Array.from(newTestPaths).map(x => `crbug.com/667560 ${x} [ Skip ]`).join('\n'); + } + if (line === '### virtual/mojo-loading/http/tests/devtools') { + return line + '\n' + + Array.from(newTestPaths).map(x => `crbug.com/667560 virtual/mojo-loading/${x} [ Skip ]`).join('\n'); + } + } + return line; + }); + fs.writeFileSync(TEST_EXPECTATIONS_PATH, updatedTestExpecations.join('\n')); + + // Update FlagExpectations + for (const folder of fs.readdirSync(FLAG_EXPECTATIONS_PATH)) { + const flagFilePath = path.resolve(FLAG_EXPECTATIONS_PATH, folder); + const expectations = fs.readFileSync(flagFilePath, 'utf-8'); + const updatedExpectations = expectations.split('\n').map(line => { + for (const [oldTestPath, newTestPath] of oldToNewTestPath) { + if (!newTestPath) + continue; + if (line.indexOf(oldTestPath) !== -1) { + return line.replace(oldTestPath, newTestPath); + } + } + return line; + }); + fs.writeFileSync(flagFilePath, updatedExpectations.join('\n')); + } + + for (const [oldResourcesPath, newResourcesPath] of oldToNewResourcesPath) + utils.copyRecursive(oldResourcesPath, path.dirname(newResourcesPath)); +} + +main();
diff --git a/third_party/WebKit/Source/devtools/scripts/migrate_test/notes.txt b/third_party/WebKit/Source/devtools/scripts/migrate_test/notes.txt new file mode 100644 index 0000000..5c5bc70 --- /dev/null +++ b/third_party/WebKit/Source/devtools/scripts/migrate_test/notes.txt
@@ -0,0 +1,4 @@ +inspector/console/command-line-api-getEventListeners.html +- handle <script> extraction +- add output method +- regex in javascript function causing issue
diff --git a/third_party/WebKit/Source/devtools/scripts/migrate_test/tests.txt b/third_party/WebKit/Source/devtools/scripts/migrate_test/tests.txt new file mode 100644 index 0000000..a45b311d --- /dev/null +++ b/third_party/WebKit/Source/devtools/scripts/migrate_test/tests.txt
@@ -0,0 +1,8 @@ +inspector/console/alert-toString-exception.html +inspector/console/console-api-on-call-frame.html +inspector/console/console-clear-function.html +inspector/console/console-command-copy.html +inspector/console/console-context-selector.html +inspector/console/console-copy-treeoutline.html +inspector/console/console-copy-truncated-text.html +inspector/console/console-error-on-call-frame.html \ No newline at end of file
diff --git a/third_party/WebKit/Source/devtools/scripts/migrate_test/transform.js b/third_party/WebKit/Source/devtools/scripts/migrate_test/transform.js new file mode 100644 index 0000000..2cf305b --- /dev/null +++ b/third_party/WebKit/Source/devtools/scripts/migrate_test/transform.js
@@ -0,0 +1,89 @@ +// 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. + +'use strict'; + +const fs = require('fs'); +const path = require('path'); + +const childProcess = require('child_process'); + +const utils = require('../utils'); + +const MIGRATE_SCRIPT_PATH = path.resolve(__dirname, 'migrate_test.js'); +const TESTS_PATH = path.resolve(__dirname, 'tests.txt'); +const TEST_EXPECTATIONS_PATH = path.resolve(__dirname, '..', '..', '..', '..', 'LayoutTests', 'TestExpectations'); +const FLAG_EXPECTATIONS_PATH = path.resolve(__dirname, '..', '..', '..', '..', 'LayoutTests', 'FlagExpectations'); + +function main() { + const tests = fs.readFileSync(TESTS_PATH, 'utf-8').split('\n').map(line => line.split(' ')); + const oldToNewTests = new Map(tests); + const testCount = oldToNewTests.size; + const migratedTests = new Set(); + + for (const [_, testPath] of tests) { + if (!testPath) + continue; + const fullTestPath = path.resolve(__dirname, '..', '..', '..', '..', 'LayoutTests', testPath); + try { + childProcess.execSync(`node ${MIGRATE_SCRIPT_PATH} ${fullTestPath}`) + } catch (err) { + console.log(err.stdout.toString()); + continue; + } + + for (const [oldTest, newTest] of oldToNewTests) { + if (testPath === newTest) + oldToNewTests.delete(oldTest); + } + migratedTests.add(testPath); + } + + console.log(`Successfully migrated: ${migratedTests.size} of ${testCount}`); + + const updatedTests = Array.from(oldToNewTests.entries()).map(line => line.join(' ')).join('\n'); + console.log(updatedTests); + + // Update TestExpectations + const testExpectations = fs.readFileSync(TEST_EXPECTATIONS_PATH, 'utf-8'); + const updatedTestExpecationLines = []; + let seenStartSentinel = false; + let seenEndSentinel = false; + for (const line of testExpectations.split('\n')) { + if (line === '# ====== DevTools test migration failures from here ======') { + seenStartSentinel = true; + updatedTestExpecationLines.push(line); + continue; + } + if (line === '# ====== DevTools test migration failures until here ======') { + seenEndSentinel = true; + updatedTestExpecationLines.push(line); + continue; + } + if (seenEndSentinel) { + updatedTestExpecationLines.push(line); + continue; + } + if (!seenStartSentinel) { + updatedTestExpecationLines.push(line); + continue; + } + let skipLine = false; + for (const test of migratedTests) { + if (line.indexOf(test) !== -1) { + skipLine = true; + break; + } + } + if (!skipLine) + updatedTestExpecationLines.push(line); + } + + fs.writeFileSync(TEST_EXPECTATIONS_PATH, updatedTestExpecationLines.join('\n')); + + // Update tests.txt + fs.writeFileSync(TESTS_PATH, updatedTests); +} + +main();
diff --git a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp index 6c8e9e6..32e02d67 100644 --- a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp +++ b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp
@@ -37,6 +37,7 @@ #include "bindings/core/v8/ExceptionState.h" #include "bindings/modules/v8/RenderingContext.h" #include "core/CSSPropertyNames.h" +#include "core/css/CSSFontSelector.h" #include "core/css/StylePropertySet.h" #include "core/css/resolver/StyleResolver.h" #include "core/dom/AXObjectCache.h" @@ -473,7 +474,7 @@ font_lru_list_.erase(new_font); font_lru_list_.insert(new_font); ModifiableState().SetFont( - i->value, canvas()->GetDocument().GetStyleEngine().FontSelector()); + i->value, canvas()->GetDocument().GetStyleEngine().GetFontSelector()); } else { MutableStylePropertySet* parsed_style = canvas_font_cache->ParseFont(new_font); @@ -508,14 +509,16 @@ PruneLocalFontCache(canvas_font_cache->HardMaxFonts()); // hard limit should_prune_local_font_cache_ = true; // apply soft limit ModifiableState().SetFont( - final_font, canvas()->GetDocument().GetStyleEngine().FontSelector()); + final_font, + canvas()->GetDocument().GetStyleEngine().GetFontSelector()); } } else { Font resolved_font; if (!canvas_font_cache->GetFontUsingDefaultStyle(new_font, resolved_font)) return; ModifiableState().SetFont( - resolved_font, canvas()->GetDocument().GetStyleEngine().FontSelector()); + resolved_font, + canvas()->GetDocument().GetStyleEngine().GetFontSelector()); } // The parse succeeded.
diff --git a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp index 215bde0..131b473 100644 --- a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp +++ b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp
@@ -4,7 +4,7 @@ #include "modules/canvas2d/CanvasRenderingContext2DState.h" -#include "core/css/CSSFontSelector.h" +#include <memory> #include "core/css/resolver/FilterOperationResolver.h" #include "core/css/resolver/StyleBuilder.h" #include "core/css/resolver/StyleResolverState.h" @@ -17,6 +17,7 @@ #include "modules/canvas2d/CanvasPattern.h" #include "modules/canvas2d/CanvasRenderingContext2D.h" #include "modules/canvas2d/CanvasStyle.h" +#include "platform/fonts/FontSelector.h" #include "platform/graphics/DrawLooperBuilder.h" #include "platform/graphics/filters/FilterEffect.h" #include "platform/graphics/filters/SkiaImageFilterBuilder.h" @@ -25,7 +26,6 @@ #include "platform/graphics/skia/SkiaUtils.h" #include "third_party/skia/include/effects/SkDashPathEffect.h" #include "third_party/skia/include/effects/SkDropShadowImageFilter.h" -#include <memory> static const char defaultFont[] = "10px sans-serif"; static const char defaultFilter[] = "none"; @@ -69,8 +69,7 @@ CanvasRenderingContext2DState::CanvasRenderingContext2DState( const CanvasRenderingContext2DState& other, ClipListCopyMode mode) - : CSSFontSelectorClient(), - unrealized_save_count_(other.unrealized_save_count_), + : unrealized_save_count_(other.unrealized_save_count_), unparsed_stroke_color_(other.unparsed_stroke_color_), unparsed_fill_color_(other.unparsed_fill_color_), stroke_style_(other.stroke_style_), @@ -114,14 +113,13 @@ clip_list_ = other.clip_list_; } if (realized_font_) - static_cast<CSSFontSelector*>(font_.GetFontSelector()) - ->RegisterForInvalidationCallbacks(this); + font_.GetFontSelector()->RegisterForInvalidationCallbacks(this); } CanvasRenderingContext2DState::~CanvasRenderingContext2DState() {} void CanvasRenderingContext2DState::FontsNeedUpdate( - CSSFontSelector* font_selector) { + FontSelector* font_selector) { DCHECK_EQ(font_selector, font_.GetFontSelector()); DCHECK(realized_font_); @@ -135,7 +133,7 @@ visitor->Trace(stroke_style_); visitor->Trace(fill_style_); visitor->Trace(filter_value_); - CSSFontSelectorClient::Trace(visitor); + FontSelectorClient::Trace(visitor); } void CanvasRenderingContext2DState::SetLineDashOffset(double offset) { @@ -254,7 +252,7 @@ } void CanvasRenderingContext2DState::SetFont(const Font& font, - CSSFontSelector* selector) { + FontSelector* selector) { font_ = font; font_.Update(selector); realized_font_ = true;
diff --git a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.h b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.h index 0ad9baed..bdb8d14e 100644 --- a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.h +++ b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.h
@@ -5,9 +5,9 @@ #ifndef CanvasRenderingContext2DState_h #define CanvasRenderingContext2DState_h -#include "core/css/CSSFontSelectorClient.h" #include "modules/canvas2d/ClipList.h" #include "platform/fonts/Font.h" +#include "platform/fonts/FontSelectorClient.h" #include "platform/graphics/paint/PaintFlags.h" #include "platform/transforms/AffineTransform.h" #include "platform/wtf/Vector.h" @@ -22,7 +22,7 @@ class CanvasRenderingContext2DState final : public GarbageCollectedFinalized<CanvasRenderingContext2DState>, - public CSSFontSelectorClient { + public FontSelectorClient { WTF_MAKE_NONCOPYABLE(CanvasRenderingContext2DState); USING_GARBAGE_COLLECTED_MIXIN(CanvasRenderingContext2DState); @@ -49,8 +49,8 @@ return new CanvasRenderingContext2DState(other, mode); } - // CSSFontSelectorClient implementation - void FontsNeedUpdate(CSSFontSelector*) override; + // FontSelectorClient implementation + void FontsNeedUpdate(FontSelector*) override; bool HasUnrealizedSaves() const { return unrealized_save_count_; } void Save() { ++unrealized_save_count_; } @@ -80,7 +80,7 @@ return clip_list_.GetCurrentClipPath(); } - void SetFont(const Font&, CSSFontSelector*); + void SetFont(const Font&, FontSelector*); const Font& GetFont() const; bool HasRealizedFont() const { return realized_font_; } void SetUnparsedFont(const String& font) { unparsed_font_ = font; }
diff --git a/third_party/WebKit/Source/platform/BUILD.gn b/third_party/WebKit/Source/platform/BUILD.gn index d5834c6..8667a4e 100644 --- a/third_party/WebKit/Source/platform/BUILD.gn +++ b/third_party/WebKit/Source/platform/BUILD.gn
@@ -706,6 +706,8 @@ "fonts/FontSelectionAlgorithm.h", "fonts/FontSelectionTypes.cpp", "fonts/FontSelectionTypes.h", + "fonts/FontSelector.h", + "fonts/FontSelectorClient.h", "fonts/FontSmoothingMode.h", "fonts/FontVariantNumeric.h", "fonts/FontWidthVariant.h",
diff --git a/third_party/WebKit/Source/platform/bindings/V8Binding.cpp b/third_party/WebKit/Source/platform/bindings/V8Binding.cpp index 783f0cc..43403824 100644 --- a/third_party/WebKit/Source/platform/bindings/V8Binding.cpp +++ b/third_party/WebKit/Source/platform/bindings/V8Binding.cpp
@@ -41,41 +41,6 @@ : function; } -bool AddHiddenValueToArray(v8::Isolate* isolate, - v8::Local<v8::Object> object, - v8::Local<v8::Value> value, - int array_index) { - DCHECK(!value.IsEmpty()); - v8::Local<v8::Value> array_value = object->GetInternalField(array_index); - if (array_value->IsNull() || array_value->IsUndefined()) { - array_value = v8::Array::New(isolate); - object->SetInternalField(array_index, array_value); - } - - v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(array_value); - return V8CallBoolean(array->CreateDataProperty(isolate->GetCurrentContext(), - array->Length(), value)); -} - -void RemoveHiddenValueFromArray(v8::Isolate* isolate, - v8::Local<v8::Object> object, - v8::Local<v8::Value> value, - int array_index) { - v8::Local<v8::Value> array_value = object->GetInternalField(array_index); - if (!array_value->IsArray()) - return; - v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(array_value); - for (int i = array->Length() - 1; i >= 0; --i) { - v8::Local<v8::Value> item; - if (!array->Get(isolate->GetCurrentContext(), i).ToLocal(&item)) - return; - if (item->StrictEquals(value)) { - array->Delete(isolate->GetCurrentContext(), i).ToChecked(); - return; - } - } -} - v8::Local<v8::Value> FreezeV8Object(v8::Local<v8::Value> value, v8::Isolate* isolate) { value.As<v8::Object>()
diff --git a/third_party/WebKit/Source/platform/bindings/V8Binding.h b/third_party/WebKit/Source/platform/bindings/V8Binding.h index 3b350a7..55acc83 100644 --- a/third_party/WebKit/Source/platform/bindings/V8Binding.h +++ b/third_party/WebKit/Source/platform/bindings/V8Binding.h
@@ -363,17 +363,6 @@ V8SetReturnValue(info, properties); } -// These methods store hidden values into an array that is stored in the -// internal field of a DOM wrapper. -PLATFORM_EXPORT bool AddHiddenValueToArray(v8::Isolate*, - v8::Local<v8::Object>, - v8::Local<v8::Value>, - int cache_index); -PLATFORM_EXPORT void RemoveHiddenValueFromArray(v8::Isolate*, - v8::Local<v8::Object>, - v8::Local<v8::Value>, - int cache_index); - // Freeze a V8 object. The type of the first parameter and the return value is // intentionally v8::Value so that this function can wrap ToV8(). // If the argument isn't an object, this will crash.
diff --git a/third_party/WebKit/Source/platform/fonts/FontSelector.h b/third_party/WebKit/Source/platform/fonts/FontSelector.h index 99a3fb8..f37f09d7 100644 --- a/third_party/WebKit/Source/platform/fonts/FontSelector.h +++ b/third_party/WebKit/Source/platform/fonts/FontSelector.h
@@ -37,6 +37,7 @@ class FontData; class FontDescription; +class FontSelectorClient; class PLATFORM_EXPORT FontSelector : public FontCacheClient { public: @@ -56,6 +57,9 @@ virtual unsigned Version() const = 0; virtual void ReportNotDefGlyph() const = 0; + + virtual void RegisterForInvalidationCallbacks(FontSelectorClient*) = 0; + virtual void UnregisterForInvalidationCallbacks(FontSelectorClient*) = 0; }; } // namespace blink
diff --git a/third_party/WebKit/Source/platform/fonts/FontSelectorClient.h b/third_party/WebKit/Source/platform/fonts/FontSelectorClient.h new file mode 100644 index 0000000..e16f7f9 --- /dev/null +++ b/third_party/WebKit/Source/platform/fonts/FontSelectorClient.h
@@ -0,0 +1,25 @@ +// 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 FontSelectorClient_h +#define FontSelectorClient_h + +#include "platform/heap/Handle.h" + +namespace blink { + +class FontSelector; + +class FontSelectorClient : public GarbageCollectedMixin { + public: + virtual ~FontSelectorClient() {} + + virtual void FontsNeedUpdate(FontSelector*) = 0; + + DEFINE_INLINE_VIRTUAL_TRACE() {} +}; + +} // namespace blink + +#endif // FontSelectorClient_h
diff --git a/third_party/WebKit/Source/platform/heap/BUILD.gn b/third_party/WebKit/Source/platform/heap/BUILD.gn index c7e0329e..9a5a37ec 100644 --- a/third_party/WebKit/Source/platform/heap/BUILD.gn +++ b/third_party/WebKit/Source/platform/heap/BUILD.gn
@@ -55,14 +55,13 @@ "WrapperVisitor.h", ] - defines = [ "BLINK_PLATFORM_IMPLEMENTATION=1" ] - configs += [ "//third_party/WebKit/Source:blink_pch", "//third_party/WebKit/Source:config", "//third_party/WebKit/Source:non_test_config", "//third_party/WebKit/Source:inside_blink", "//third_party/WebKit/Source:features", + "//third_party/WebKit/Source/platform:blink_platform_implementation", "//build/config/compiler:no_size_t_to_int_warning", ]
diff --git a/third_party/WebKit/Source/platform/loader/BUILD.gn b/third_party/WebKit/Source/platform/loader/BUILD.gn index 4e29c867..d483734 100644 --- a/third_party/WebKit/Source/platform/loader/BUILD.gn +++ b/third_party/WebKit/Source/platform/loader/BUILD.gn
@@ -84,12 +84,11 @@ sources += get_target_outputs( ":make_platform_loader_generated_fetch_initiator_type_names") - defines = [ "BLINK_PLATFORM_IMPLEMENTATION=1" ] - configs += [ "//third_party/WebKit/Source:config", "//third_party/WebKit/Source:non_test_config", "//third_party/WebKit/Source:inside_blink", + "//third_party/WebKit/Source/platform:blink_platform_implementation", # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. "//build/config/compiler:no_size_t_to_int_warning",
diff --git a/third_party/WebKit/Source/platform/mojo/FetchAPIRequestStructTraits.cpp b/third_party/WebKit/Source/platform/mojo/FetchAPIRequestStructTraits.cpp index aa67d0c..ccb34a29 100644 --- a/third_party/WebKit/Source/platform/mojo/FetchAPIRequestStructTraits.cpp +++ b/third_party/WebKit/Source/platform/mojo/FetchAPIRequestStructTraits.cpp
@@ -14,19 +14,6 @@ namespace mojo { -namespace { - -// Struct traits context for the FetchAPIRequest type. Since getters are invoked -// twice when serializing the type, this reduces the load for heavy members. -struct FetchAPIRequestStructTraitsContext { - FetchAPIRequestStructTraitsContext() = default; - ~FetchAPIRequestStructTraitsContext() = default; - - WTF::HashMap<WTF::String, WTF::String> headers; -}; - -} // namespace - using blink::mojom::FetchCredentialsMode; using blink::mojom::FetchRedirectMode; using blink::mojom::FetchRequestMode; @@ -380,26 +367,6 @@ } // static -void* StructTraits<blink::mojom::FetchAPIRequestDataView, - blink::WebServiceWorkerRequest>:: - SetUpContext(const blink::WebServiceWorkerRequest& request) { - FetchAPIRequestStructTraitsContext* context = - new FetchAPIRequestStructTraitsContext(); - for (const auto& pair : request.Headers()) - context->headers.insert(pair.key, pair.value); - - return context; -} - -// static -void StructTraits<blink::mojom::FetchAPIRequestDataView, - blink::WebServiceWorkerRequest>:: - TearDownContext(const blink::WebServiceWorkerRequest& request, - void* context) { - delete static_cast<FetchAPIRequestStructTraitsContext*>(context); -} - -// static blink::KURL StructTraits<blink::mojom::FetchAPIRequestDataView, blink::WebServiceWorkerRequest>:: url(const blink::WebServiceWorkerRequest& request) { @@ -414,12 +381,14 @@ } // static -const WTF::HashMap<WTF::String, WTF::String>& +WTF::HashMap<WTF::String, WTF::String> StructTraits<blink::mojom::FetchAPIRequestDataView, blink::WebServiceWorkerRequest>:: - headers(const blink::WebServiceWorkerRequest& request, void* context) { - DCHECK(context); - return static_cast<FetchAPIRequestStructTraitsContext*>(context)->headers; + headers(const blink::WebServiceWorkerRequest& request) { + WTF::HashMap<WTF::String, WTF::String> header_map; + for (const auto& pair : request.Headers()) + header_map.insert(pair.key, pair.value); + return header_map; } // static
diff --git a/third_party/WebKit/Source/platform/mojo/FetchAPIRequestStructTraits.h b/third_party/WebKit/Source/platform/mojo/FetchAPIRequestStructTraits.h index a28b1e5c..e054128 100644 --- a/third_party/WebKit/Source/platform/mojo/FetchAPIRequestStructTraits.h +++ b/third_party/WebKit/Source/platform/mojo/FetchAPIRequestStructTraits.h
@@ -68,10 +68,6 @@ template <> struct StructTraits<blink::mojom::FetchAPIRequestDataView, blink::WebServiceWorkerRequest> { - static void* SetUpContext(const blink::WebServiceWorkerRequest&); - static void TearDownContext(const blink::WebServiceWorkerRequest&, - void* context); - static blink::WebURLRequest::FetchRequestMode mode( const blink::WebServiceWorkerRequest& request) { return request.Mode(); @@ -96,9 +92,8 @@ static WTF::String method(const blink::WebServiceWorkerRequest&); - static const WTF::HashMap<WTF::String, WTF::String>& headers( - const blink::WebServiceWorkerRequest&, - void* context); + static WTF::HashMap<WTF::String, WTF::String> headers( + const blink::WebServiceWorkerRequest&); static WTF::String blob_uuid(const blink::WebServiceWorkerRequest&);
diff --git a/third_party/WebKit/Source/platform/testing/FontTestHelpers.cpp b/third_party/WebKit/Source/platform/testing/FontTestHelpers.cpp index ecf98b5..0e8aa36 100644 --- a/third_party/WebKit/Source/platform/testing/FontTestHelpers.cpp +++ b/third_party/WebKit/Source/platform/testing/FontTestHelpers.cpp
@@ -49,6 +49,9 @@ void FontCacheInvalidated() override {} void ReportNotDefGlyph() const override {} + void RegisterForInvalidationCallbacks(FontSelectorClient*) override {} + void UnregisterForInvalidationCallbacks(FontSelectorClient*) override {} + private: TestFontSelector(PassRefPtr<FontCustomPlatformData> custom_platform_data) : custom_platform_data_(std::move(custom_platform_data)) {
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/common/net/web_mock.py b/third_party/WebKit/Tools/Scripts/webkitpy/common/net/web_mock.py index f30205c..7ce129f 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/common/net/web_mock.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/common/net/web_mock.py
@@ -52,6 +52,7 @@ self.status_code = values['status_code'] self.url = '' self.body = values.get('body', '') + self._info = MockInfo(values.get('headers', {})) if int(self.status_code) >= 400: raise urllib2.HTTPError( @@ -66,3 +67,16 @@ def read(self): return self.body + + def info(self): + return self._info + + +class MockInfo(object): + + def __init__(self, headers): + # The name of the headers (keys) are case-insensitive, and values are stripped. + self._headers = {key.lower(): value.strip() for key, value in headers.iteritems()} + + def getheader(self, header): + return self._headers.get(header.lower(), None)
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_github.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_github.py index 506f146e..2f0df3c3 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_github.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_github.py
@@ -5,6 +5,7 @@ import base64 import json import logging +import re import urllib2 from collections import namedtuple @@ -13,6 +14,7 @@ _log = logging.getLogger(__name__) API_BASE = 'https://api.github.com' +MAX_PER_PAGE = 100 class WPTGitHub(object): @@ -21,7 +23,7 @@ This class contains methods for sending requests to the GitHub API. """ - def __init__(self, host, user=None, token=None, pr_history_window=100): + def __init__(self, host, user=None, token=None, pr_history_window=5000): self.host = host self.user = user self.token = token @@ -36,6 +38,16 @@ return base64.b64encode('{}:{}'.format(self.user, self.token)) def request(self, path, method, body=None): + """Sends a request to GitHub API and deserializes the response. + + Args: + path: API endpoint without base URL (starting with '/'). + method: HTTP method to be used for this request. + body: Optional payload in the request body (default=None). + + Returns: + A JSONResponse instance. + """ assert path.startswith('/') if body: @@ -52,12 +64,36 @@ data=body, headers=headers ) + return JSONResponse(response) - status_code = response.getcode() - try: - return json.load(response), status_code - except ValueError: - return None, status_code + def extract_link_next(self, link_header): + """Extracts the URI to the next page of results from a response. + + As per GitHub API specs, the link to the next page of results is + extracted from the Link header -- the link with relation type "next". + Docs: https://developer.github.com/v3/#pagination (and RFC 5988) + + Args: + link_header: The value of the Link header in responses from GitHub. + + Returns: + Path to the next page (without base URL), or None if not found. + """ + # TODO(robertma): Investigate "may require expansion as URI templates" mentioned in docs. + # Example Link header: + # <https://api.github.com/resources?page=3>; rel="next", <https://api.github.com/resources?page=50>; rel="last" + if link_header is None: + return None + link_re = re.compile(r'<(.+?)>; *rel="(.+?)"') + match = link_re.search(link_header) + while match: + link, rel = match.groups() + if rel.lower() == 'next': + # Strip API_BASE so that the return value is useful for request(). + assert link.startswith(API_BASE) + return link[len(API_BASE):] + match = link_re.search(link_header, match.end()) + return None def create_pr(self, remote_branch_name, desc_title, body): """Creates a PR on GitHub. @@ -78,12 +114,12 @@ 'head': remote_branch_name, 'base': 'master', } - data, status_code = self.request(path, method='POST', body=body) + response = self.request(path, method='POST', body=body) - if status_code != 201: + if response.status_code != 201: return None - return data + return response.data def update_pr(self, pr_number, desc_title, body): """Updates a PR on GitHub. @@ -102,12 +138,12 @@ 'title': desc_title, 'body': body, } - data, status_code = self.request(path, method='PATCH', body=body) + response = self.request(path, method='PATCH', body=body) - if status_code != 201: + if response.status_code != 201: return None - return data + return response.data def add_label(self, number, label): path = '/repos/%s/%s/issues/%d/labels' % ( @@ -116,7 +152,8 @@ number ) body = [label] - return self.request(path, method='POST', body=body) + response = self.request(path, method='POST', body=body) + return response.data, response.status_code def remove_label(self, number, label): path = '/repos/%s/%s/issues/%d/labels/%s' % ( @@ -126,12 +163,12 @@ urllib2.quote(label), ) - _, status_code = self.request(path, method='DELETE') + response = self.request(path, method='DELETE') # The GitHub API documentation claims that this endpoint returns a 204 # on success. However in reality it returns a 200. # https://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue - if status_code not in (200, 204): - raise GitHubError('Received non-200 status code attempting to delete label: {}'.format(status_code)) + if response.status_code not in (200, 204): + raise GitHubError('Received non-200 status code attempting to delete label: {}'.format(response.status_code)) def make_pr_from_item(self, item): labels = [label['name'] for label in item['labels']] @@ -144,8 +181,6 @@ @memoized def all_pull_requests(self): - # TODO(jeffcarp): Add pagination to fetch >99 PRs - assert self._pr_history_window <= 100, 'Maximum GitHub page size exceeded.' path = ( '/search/issues' '?q=repo:{}/{}%20type:pr%20label:{}' @@ -155,14 +190,22 @@ WPT_GH_ORG, WPT_GH_REPO_NAME, EXPORT_PR_LABEL, - self._pr_history_window + min(MAX_PER_PAGE, self._pr_history_window) ) - - data, status_code = self.request(path, method='GET') - if status_code == 200: - return [self.make_pr_from_item(item) for item in data['items']] - else: - raise Exception('Non-200 status code (%s): %s' % (status_code, data)) + all_prs = [] + while path is not None and len(all_prs) < self._pr_history_window: + response = self.request(path, method='GET') + if response.status_code == 200: + if response.data['incomplete_results']: + raise GitHubError('Received incomplete results when fetching all pull requests. Data received:\n%s' + % response.data) + prs = [self.make_pr_from_item(item) for item in response.data['items']] + all_prs += prs[:self._pr_history_window - len(all_prs)] + else: + raise GitHubError('Received non-200 status code (%d) when fetching all pull requests: %s' + % (response.status_code, path)) + path = self.extract_link_next(response.getheader('Link')) + return all_prs def get_pr_branch(self, pr_number): path = '/repos/{}/{}/pulls/{}'.format( @@ -170,11 +213,11 @@ WPT_GH_REPO_NAME, pr_number ) - data, status_code = self.request(path, method='GET') - if status_code == 200: - return data['head']['ref'] + response = self.request(path, method='GET') + if response.status_code == 200: + return response.data['head']['ref'] else: - raise Exception('Non-200 status code (%s): %s' % (status_code, data)) + raise Exception('Non-200 status code (%s): %s' % (response.status_code, response.data)) def merge_pull_request(self, pull_request_number): path = '/repos/%s/%s/pulls/%d/merge' % ( @@ -189,17 +232,17 @@ } try: - data, status_code = self.request(path, method='PUT', body=body) + response = self.request(path, method='PUT', body=body) except urllib2.HTTPError as e: if e.code == 405: raise MergeError() else: raise - if status_code != 200: - raise Exception('Received non-200 status code (%d) while merging PR #%d' % (status_code, pull_request_number)) + if response.status_code != 200: + raise Exception('Received non-200 status code (%d) while merging PR #%d' % (response.status_code, pull_request_number)) - return data + return response.data def delete_remote_branch(self, remote_branch_name): # TODO(jeffcarp): Unit test this method @@ -208,12 +251,12 @@ WPT_GH_REPO_NAME, remote_branch_name ) - data, status_code = self.request(path, method='DELETE') + response = self.request(path, method='DELETE') - if status_code != 204: - raise GitHubError('Received non-204 status code attempting to delete remote branch: {}'.format(status_code)) + if response.status_code != 204: + raise GitHubError('Received non-204 status code attempting to delete remote branch: {}'.format(response.status_code)) - return data + return response.data def pr_for_chromium_commit(self, chromium_commit): """Returns a PR corresponding to the given ChromiumCommit, or None.""" @@ -247,6 +290,29 @@ return None +class JSONResponse(object): + """An HTTP response containing JSON data.""" + + def __init__(self, raw_response): + """Initializes a JSONResponse instance. + + Args: + raw_response: a response object returned by open methods in urllib2. + """ + self._raw_response = raw_response + self.status_code = raw_response.getcode() + try: + self.data = json.load(raw_response) + except ValueError: + self.data = None + + def getheader(self, header): + """Gets the value of the header with the given name. + + Delegates to HTTPMessage.getheader(), which is case-insensitive.""" + return self._raw_response.info().getheader(header) + + class MergeError(Exception): """An error specifically for when a PR cannot be merged.
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_github_unittest.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_github_unittest.py index e4ef9d3..1a4af1c 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_github_unittest.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_github_unittest.py
@@ -3,15 +3,26 @@ # found in the LICENSE file. import base64 +import json import unittest from webkitpy.common.host_mock import MockHost from webkitpy.w3c.chromium_commit_mock import MockChromiumCommit +from webkitpy.w3c.common import EXPORT_PR_LABEL from webkitpy.w3c.wpt_github import GitHubError, MergeError, PullRequest, WPTGitHub class WPTGitHubTest(unittest.TestCase): + def generate_pr_item(self, pr_number, state='closed'): + return { + 'title': 'Foobar', + 'number': pr_number, + 'body': 'description', + 'state': state, + 'labels': [{'name': EXPORT_PR_LABEL}] + } + def setUp(self): self.wpt_github = WPTGitHub(MockHost(), user='rutabaga', token='decafbad') @@ -24,6 +35,62 @@ self.wpt_github.auth_token(), base64.encodestring('rutabaga:decafbad').strip()) + def test_extract_link_next(self): + link_header = ('<https://api.github.com/user/repos?page=1&per_page=100>; rel="first", ' + '<https://api.github.com/user/repos?page=2&per_page=100>; rel="prev", ' + '<https://api.github.com/user/repos?page=4&per_page=100>; rel="next", ' + '<https://api.github.com/user/repos?page=50&per_page=100>; rel="last"') + self.assertEqual(self.wpt_github.extract_link_next(link_header), '/user/repos?page=4&per_page=100') + + def test_extract_link_next_not_found(self): + self.assertIsNone(self.wpt_github.extract_link_next('')) + + def test_all_pull_requests_single_page(self): + self.wpt_github.host.web.responses = [ + {'status_code': 200, + 'headers': {'Link': ''}, + 'body': json.dumps({'incomplete_results': False, 'items': [self.generate_pr_item(1)]})}, + ] + self.assertEqual(len(self.wpt_github.all_pull_requests()), 1) + + def test_all_pull_requests_all_pages(self): + self.wpt_github.host.web.responses = [ + {'status_code': 200, + 'headers': {'Link': '<https://api.github.com/resources?page=2>; rel="next"'}, + 'body': json.dumps({'incomplete_results': False, 'items': [self.generate_pr_item(1)]})}, + {'status_code': 200, + 'headers': {'Link': ''}, + 'body': json.dumps({'incomplete_results': False, 'items': [self.generate_pr_item(2)]})}, + ] + self.assertEqual(len(self.wpt_github.all_pull_requests()), 2) + + def test_all_pull_requests_reaches_pr_history_window(self): + self.wpt_github = WPTGitHub(MockHost(), user='rutabaga', token='decafbad', pr_history_window=2) + self.wpt_github.host.web.responses = [ + {'status_code': 200, + 'headers': {'Link': '<https://api.github.com/resources?page=2>; rel="next"'}, + 'body': json.dumps({'incomplete_results': False, 'items': [self.generate_pr_item(1)]})}, + {'status_code': 200, + 'headers': {'Link': ''}, + 'body': json.dumps({'incomplete_results': False, 'items': [self.generate_pr_item(2), self.generate_pr_item(3)]})}, + ] + self.assertEqual(len(self.wpt_github.all_pull_requests()), 2) + + def test_all_pull_requests_throws_github_error_on_non_200(self): + self.wpt_github.host.web.responses = [ + {'status_code': 204}, + ] + with self.assertRaises(GitHubError): + self.wpt_github.all_pull_requests() + + def test_all_pull_requests_throws_github_error_when_incomplete(self): + self.wpt_github.host.web.responses = [ + {'status_code': 200, + 'body': json.dumps({'incomplete_results': True, 'items': [self.generate_pr_item(1)]})}, + ] + with self.assertRaises(GitHubError): + self.wpt_github.all_pull_requests() + def test_merge_pull_request_throws_merge_error_on_405(self): self.wpt_github.host.web.responses = [ {'status_code': 200},
diff --git a/third_party/WebKit/public/README.md b/third_party/WebKit/public/README.md index 13569c5a..2621b7a 100644 --- a/third_party/WebKit/public/README.md +++ b/third_party/WebKit/public/README.md
@@ -49,13 +49,12 @@ The API uses some internal types (e.g., blink::Node). Typically, these types are forward declared and are opaque to consumers of the API. In other cases, -the full definitions are available behind the BLINK_IMPLEMENTATION -preprocessor macro. In both cases, we continue to regard these internal types -as implementation details of Blink, and consumers of the API should not rely -upon these types. +the full definitions are available behind the INSIDE_BLINK preprocessor macro. +In both cases, we continue to regard these internal types as implementation +details of Blink, and consumers of the API should not rely upon these types. -Similarly, the API uses STL types outside of the BLINK_IMPLEMENTATION -preprocessor macro, which is for the convenience of the consumer. +Similarly, the API uses STL types outside of the INSIDE_BLINK preprocessor +macro, which is for the convenience of the consumer. Contact Information -------------------
diff --git a/third_party/WebKit/public/platform/WebCommon.h b/third_party/WebKit/public/platform/WebCommon.h index da2fe734..b41846f 100644 --- a/third_party/WebKit/public/platform/WebCommon.h +++ b/third_party/WebKit/public/platform/WebCommon.h
@@ -41,24 +41,27 @@ #if defined(COMPONENT_BUILD) #if defined(WIN32) + #if BLINK_IMPLEMENTATION #define BLINK_EXPORT __declspec(dllexport) #else // BLINK_IMPLEMENTATION #define BLINK_EXPORT __declspec(dllimport) -#endif +#endif // BLINK_IMPLEMENTATION #if BLINK_PLATFORM_IMPLEMENTATION #define BLINK_PLATFORM_EXPORT __declspec(dllexport) #else // BLINK_PLATFORM_IMPLEMENTATION #define BLINK_PLATFORM_EXPORT __declspec(dllimport) -#endif +#endif // BLINK_PLATFORM_IMPLEMENTATION + #else // defined(WIN32) #define BLINK_EXPORT __attribute__((visibility("default"))) #define BLINK_PLATFORM_EXPORT __attribute__((visibility("default"))) -#endif +#endif // defined(WIN32) + #else // defined(COMPONENT_BUILD) #define BLINK_EXPORT #define BLINK_PLATFORM_EXPORT -#endif +#endif // defined(COMPONENT_BUILD) // ----------------------------------------------------------------------------- // Basic types
diff --git a/third_party/WebKit/public/platform/WebRTCSessionDescription.h b/third_party/WebKit/public/platform/WebRTCSessionDescription.h index 8b60c523..9084692 100644 --- a/third_party/WebKit/public/platform/WebRTCSessionDescription.h +++ b/third_party/WebKit/public/platform/WebRTCSessionDescription.h
@@ -77,7 +77,7 @@ BLINK_PLATFORM_EXPORT WebString Sdp() const; BLINK_PLATFORM_EXPORT void SetSDP(const WebString&); -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebRTCSessionDescription(WebString type, WebString sdp) { this->Initialize(type, sdp); }
diff --git a/third_party/WebKit/public/platform/linux/WebFontRenderStyle.h b/third_party/WebKit/public/platform/linux/WebFontRenderStyle.h index 0179bf1..119b63d6 100644 --- a/third_party/WebKit/public/platform/linux/WebFontRenderStyle.h +++ b/third_party/WebKit/public/platform/linux/WebFontRenderStyle.h
@@ -52,7 +52,7 @@ char use_subpixel_positioning; // use subpixel positioning (fractional X // positions for glyphs) -#if BLINK_IMPLEMENTATION || BLINK_PLATFORM_IMPLEMENTATION +#if INSIDE_BLINK // Translates the members of this struct to a FontRenderStyle void ToFontRenderStyle(FontRenderStyle*); #endif
diff --git a/third_party/WebKit/public/platform/modules/indexeddb/WebIDBKey.h b/third_party/WebKit/public/platform/modules/indexeddb/WebIDBKey.h index 5ed822dec..869e282b 100644 --- a/third_party/WebKit/public/platform/modules/indexeddb/WebIDBKey.h +++ b/third_party/WebKit/public/platform/modules/indexeddb/WebIDBKey.h
@@ -70,13 +70,18 @@ BLINK_EXPORT WebIDBKeyType KeyType() const; BLINK_EXPORT bool IsValid() const; - BLINK_EXPORT WebVector<WebIDBKey> Array() const; // Only valid for ArrayType. - BLINK_EXPORT WebData Binary() const; // Only valid for BinaryType. - BLINK_EXPORT WebString GetString() const; // Only valid for StringType. - BLINK_EXPORT double Date() const; // Only valid for DateType. - BLINK_EXPORT double Number() const; // Only valid for NumberType. + // Only valid for ArrayType. + BLINK_EXPORT WebVector<WebIDBKey> Array() const; + // Only valid for BinaryType. + BLINK_EXPORT WebData Binary() const; + // Only valid for StringType. + BLINK_EXPORT WebString GetString() const; + // Only valid for DateType. + BLINK_EXPORT double Date() const; + // Only valid for NumberType. + BLINK_EXPORT double Number() const; -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebIDBKey(IDBKey* value) : private_(value) {} WebIDBKey& operator=(IDBKey* value) { private_ = value;
diff --git a/third_party/WebKit/public/platform/modules/indexeddb/WebIDBKeyRange.h b/third_party/WebKit/public/platform/modules/indexeddb/WebIDBKeyRange.h index 2b86447a..7943bea 100644 --- a/third_party/WebKit/public/platform/modules/indexeddb/WebIDBKeyRange.h +++ b/third_party/WebKit/public/platform/modules/indexeddb/WebIDBKeyRange.h
@@ -65,7 +65,7 @@ BLINK_EXPORT void Reset(); -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebIDBKeyRange(IDBKeyRange* value) : private_(value) {} WebIDBKeyRange& operator=(IDBKeyRange* value) { private_ = value;
diff --git a/third_party/WebKit/public/web/DEPS b/third_party/WebKit/public/web/DEPS index 1530808a..fc44eb1 100644 --- a/third_party/WebKit/public/web/DEPS +++ b/third_party/WebKit/public/web/DEPS
@@ -3,7 +3,7 @@ "+public/platform", "+public/web", - # Allowed only inside BLINK_IMPLEMENTATION + # Allowed only inside INSIDE_BLINK "+core", "+platform", ]
diff --git a/third_party/WebKit/public/web/WebAXObject.h b/third_party/WebKit/public/web/WebAXObject.h index 95c9148..633973b 100644 --- a/third_party/WebKit/public/web/WebAXObject.h +++ b/third_party/WebKit/public/web/WebAXObject.h
@@ -353,7 +353,7 @@ // window. BLINK_EXPORT void ScrollToGlobalPoint(const WebPoint&) const; -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK BLINK_EXPORT WebAXObject(AXObject*); WebAXObject& operator=(AXObject*); operator AXObject*() const;
diff --git a/third_party/WebKit/public/web/WebArrayBufferView.h b/third_party/WebKit/public/web/WebArrayBufferView.h index 4f9fe3f..71ee0601 100644 --- a/third_party/WebKit/public/web/WebArrayBufferView.h +++ b/third_party/WebKit/public/web/WebArrayBufferView.h
@@ -59,7 +59,7 @@ BLINK_EXPORT static WebArrayBufferView* CreateFromV8Value( v8::Local<v8::Value>); -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebArrayBufferView(DOMArrayBufferView*); WebArrayBufferView& operator=(DOMArrayBufferView*); operator DOMArrayBufferView*() const;
diff --git a/third_party/WebKit/public/web/WebBlob.h b/third_party/WebKit/public/web/WebBlob.h index 093872fe..99568661 100644 --- a/third_party/WebKit/public/web/WebBlob.h +++ b/third_party/WebKit/public/web/WebBlob.h
@@ -77,7 +77,7 @@ v8::Local<v8::Object> creation_context, v8::Isolate*); -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebBlob(Blob*); WebBlob& operator=(Blob*); #endif
diff --git a/third_party/WebKit/public/web/WebColorSuggestion.h b/third_party/WebKit/public/web/WebColorSuggestion.h index 018bad1f..ccc8b57 100644 --- a/third_party/WebKit/public/web/WebColorSuggestion.h +++ b/third_party/WebKit/public/web/WebColorSuggestion.h
@@ -42,7 +42,7 @@ WebColor color; WebString label; -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK BLINK_EXPORT WebColorSuggestion(const ColorSuggestion&); BLINK_EXPORT WebColorSuggestion& operator=(const ColorSuggestion&); #endif
diff --git a/third_party/WebKit/public/web/WebDOMEvent.h b/third_party/WebKit/public/web/WebDOMEvent.h index 94728f15..7062d285 100644 --- a/third_party/WebKit/public/web/WebDOMEvent.h +++ b/third_party/WebKit/public/web/WebDOMEvent.h
@@ -54,7 +54,7 @@ bool IsNull() const { return private_.IsNull(); } -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK BLINK_EXPORT WebDOMEvent(Event*); BLINK_EXPORT operator Event*() const; #endif @@ -74,7 +74,7 @@ } protected: -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK void Assign(Event*); template <typename T>
diff --git a/third_party/WebKit/public/web/WebDOMFileSystem.h b/third_party/WebKit/public/web/WebDOMFileSystem.h index e591579..828e49ec 100644 --- a/third_party/WebKit/public/web/WebDOMFileSystem.h +++ b/third_party/WebKit/public/web/WebDOMFileSystem.h
@@ -100,7 +100,7 @@ bool IsNull() const { return private_.IsNull(); } -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebDOMFileSystem(DOMFileSystem*); WebDOMFileSystem& operator=(DOMFileSystem*); #endif
diff --git a/third_party/WebKit/public/web/WebDOMMediaStreamTrack.h b/third_party/WebKit/public/web/WebDOMMediaStreamTrack.h index bc57dc8..f37f5d6 100644 --- a/third_party/WebKit/public/web/WebDOMMediaStreamTrack.h +++ b/third_party/WebKit/public/web/WebDOMMediaStreamTrack.h
@@ -63,7 +63,7 @@ BLINK_EXPORT WebMediaStreamTrack Component() const; private: -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebDOMMediaStreamTrack(MediaStreamTrack*); #endif
diff --git a/third_party/WebKit/public/web/WebDOMMessageEvent.h b/third_party/WebKit/public/web/WebDOMMessageEvent.h index 4057c1a..32b145d 100644 --- a/third_party/WebKit/public/web/WebDOMMessageEvent.h +++ b/third_party/WebKit/public/web/WebDOMMessageEvent.h
@@ -36,7 +36,7 @@ #include "public/web/WebDocument.h" #include "public/web/WebSerializedScriptValue.h" -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK #include "core/events/MessageEvent.h" #endif @@ -62,7 +62,7 @@ BLINK_EXPORT WebMessagePortChannelArray ReleaseChannels(); -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK explicit WebDOMMessageEvent(MessageEvent* e) : WebDOMEvent(e) {} #endif };
diff --git a/third_party/WebKit/public/web/WebDateTimeSuggestion.h b/third_party/WebKit/public/web/WebDateTimeSuggestion.h index 60997ff..9f7338c9 100644 --- a/third_party/WebKit/public/web/WebDateTimeSuggestion.h +++ b/third_party/WebKit/public/web/WebDateTimeSuggestion.h
@@ -40,7 +40,7 @@ WebDateTimeSuggestion() {} -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK BLINK_EXPORT WebDateTimeSuggestion(const DateTimeSuggestion&); BLINK_EXPORT WebDateTimeSuggestion& operator=(const DateTimeSuggestion&); #endif
diff --git a/third_party/WebKit/public/web/WebDocument.h b/third_party/WebKit/public/web/WebDocument.h index 7534ea0f..fe40942 100644 --- a/third_party/WebKit/public/web/WebDocument.h +++ b/third_party/WebKit/public/web/WebDocument.h
@@ -132,7 +132,7 @@ BLINK_EXPORT bool ManifestUseCredentials() const; BLINK_EXPORT WebDistillabilityFeatures DistillabilityFeatures(); -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK BLINK_EXPORT WebDocument(Document*); BLINK_EXPORT WebDocument& operator=(Document*); BLINK_EXPORT operator Document*() const;
diff --git a/third_party/WebKit/public/web/WebElement.h b/third_party/WebKit/public/web/WebElement.h index 28a7497b..e4a3851 100644 --- a/third_party/WebKit/public/web/WebElement.h +++ b/third_party/WebKit/public/web/WebElement.h
@@ -81,7 +81,7 @@ // if there isn't any. WebImage ImageContents(); -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebElement(Element*); WebElement& operator=(Element*); operator Element*() const;
diff --git a/third_party/WebKit/public/web/WebElementCollection.h b/third_party/WebKit/public/web/WebElementCollection.h index 6addf68..47e12e0e 100644 --- a/third_party/WebKit/public/web/WebElementCollection.h +++ b/third_party/WebKit/public/web/WebElementCollection.h
@@ -35,7 +35,7 @@ #include "public/platform/WebCommon.h" #include "public/platform/WebPrivatePtr.h" -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK #include "platform/heap/Handle.h" #endif @@ -65,7 +65,7 @@ BLINK_EXPORT WebElement NextItem() const; BLINK_EXPORT WebElement FirstItem() const; -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebElementCollection(HTMLCollection*); WebElementCollection& operator=(HTMLCollection*); #endif
diff --git a/third_party/WebKit/public/web/WebFormControlElement.h b/third_party/WebKit/public/web/WebFormControlElement.h index d5dde9a8..d3d2003 100644 --- a/third_party/WebKit/public/web/WebFormControlElement.h +++ b/third_party/WebKit/public/web/WebFormControlElement.h
@@ -115,7 +115,7 @@ WebFormElement Form() const; -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebFormControlElement(HTMLFormControlElement*); WebFormControlElement& operator=(HTMLFormControlElement*); operator HTMLFormControlElement*() const;
diff --git a/third_party/WebKit/public/web/WebFormElement.h b/third_party/WebKit/public/web/WebFormElement.h index a1a9e451..a517636 100644 --- a/third_party/WebKit/public/web/WebFormElement.h +++ b/third_party/WebKit/public/web/WebFormElement.h
@@ -61,7 +61,7 @@ void GetFormControlElements(WebVector<WebFormControlElement>&) const; -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebFormElement(HTMLFormElement*); WebFormElement& operator=(HTMLFormElement*); operator HTMLFormElement*() const;
diff --git a/third_party/WebKit/public/web/WebFrame.h b/third_party/WebKit/public/web/WebFrame.h index c5e99e2b..5da6514 100644 --- a/third_party/WebKit/public/web/WebFrame.h +++ b/third_party/WebKit/public/web/WebFrame.h
@@ -209,7 +209,7 @@ // the given element is not a frame, iframe or if the frame is empty. static WebFrame* FromFrameOwnerElement(const WebElement&); -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK // TODO(mustaq): Should be named FromCoreFrame instead. static WebFrame* FromFrame(Frame*); static Frame* ToCoreFrame(const WebFrame&); @@ -240,7 +240,7 @@ void AppendChild(WebFrame*); private: -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK friend class OpenedFrameTracker; friend class WebFrameTest;
diff --git a/third_party/WebKit/public/web/WebHistoryItem.h b/third_party/WebKit/public/web/WebHistoryItem.h index 0f9a815..b4e0ade 100644 --- a/third_party/WebKit/public/web/WebHistoryItem.h +++ b/third_party/WebKit/public/web/WebHistoryItem.h
@@ -119,7 +119,7 @@ BLINK_EXPORT bool DidSaveScrollOrScaleState() const; -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK BLINK_EXPORT WebHistoryItem(HistoryItem*); BLINK_EXPORT WebHistoryItem& operator=(HistoryItem*); BLINK_EXPORT operator HistoryItem*() const;
diff --git a/third_party/WebKit/public/web/WebHitTestResult.h b/third_party/WebKit/public/web/WebHitTestResult.h index a35d49e..d90a97a 100644 --- a/third_party/WebKit/public/web/WebHitTestResult.h +++ b/third_party/WebKit/public/web/WebHitTestResult.h
@@ -69,7 +69,7 @@ // Return whether an editable input element was hit. BLINK_EXPORT bool IsContentEditable() const; -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK BLINK_EXPORT WebHitTestResult(const HitTestResult&); BLINK_EXPORT WebHitTestResult& operator=(const HitTestResult&); #endif
diff --git a/third_party/WebKit/public/web/WebIconURL.h b/third_party/WebKit/public/web/WebIconURL.h index 990fc6a..0cc3036a 100644 --- a/third_party/WebKit/public/web/WebIconURL.h +++ b/third_party/WebKit/public/web/WebIconURL.h
@@ -31,7 +31,7 @@ #ifndef WebIconURL_h #define WebIconURL_h -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK #include "core/dom/IconURL.h" #endif #include "public/platform/WebSize.h" @@ -59,7 +59,7 @@ const WebVector<WebSize>& Sizes() const { return sizes_; } -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebIconURL(const IconURL& icon_url) : icon_type_(static_cast<Type>(icon_url.icon_type_)), icon_url_(icon_url.icon_url_),
diff --git a/third_party/WebKit/public/web/WebInputElement.h b/third_party/WebKit/public/web/WebInputElement.h index bfd85413..fc1061d0 100644 --- a/third_party/WebKit/public/web/WebInputElement.h +++ b/third_party/WebKit/public/web/WebInputElement.h
@@ -93,7 +93,7 @@ // Returns true if the text of the element should be visible. bool ShouldRevealPassword() const; -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebInputElement(HTMLInputElement*); WebInputElement& operator=(HTMLInputElement*); operator HTMLInputElement*() const;
diff --git a/third_party/WebKit/public/web/WebLabelElement.h b/third_party/WebKit/public/web/WebLabelElement.h index 76ffd8d..72c20dd 100644 --- a/third_party/WebKit/public/web/WebLabelElement.h +++ b/third_party/WebKit/public/web/WebLabelElement.h
@@ -52,7 +52,7 @@ BLINK_EXPORT WebElement CorrespondingControl(); -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebLabelElement(HTMLLabelElement*); WebLabelElement& operator=(HTMLLabelElement*); operator HTMLLabelElement*() const;
diff --git a/third_party/WebKit/public/web/WebMediaDevicesRequest.h b/third_party/WebKit/public/web/WebMediaDevicesRequest.h index 2fee7ea..83e2783 100644 --- a/third_party/WebKit/public/web/WebMediaDevicesRequest.h +++ b/third_party/WebKit/public/web/WebMediaDevicesRequest.h
@@ -62,7 +62,7 @@ BLINK_EXPORT void RequestSucceeded(WebVector<WebMediaDeviceInfo>); -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebMediaDevicesRequest(MediaDevicesRequest*); operator MediaDevicesRequest*() const; #endif
diff --git a/third_party/WebKit/public/web/WebMetaElement.h b/third_party/WebKit/public/web/WebMetaElement.h index 622fd89..7cd82daf 100644 --- a/third_party/WebKit/public/web/WebMetaElement.h +++ b/third_party/WebKit/public/web/WebMetaElement.h
@@ -24,7 +24,7 @@ BLINK_EXPORT WebString ComputeEncoding() const; -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebMetaElement(HTMLMetaElement*); WebMetaElement& operator=(HTMLMetaElement*); operator HTMLMetaElement*() const;
diff --git a/third_party/WebKit/public/web/WebNode.h b/third_party/WebKit/public/web/WebNode.h index a23a47d..ce9fbea 100644 --- a/third_party/WebKit/public/web/WebNode.h +++ b/third_party/WebKit/public/web/WebNode.h
@@ -104,7 +104,7 @@ template <typename T> const T ToConst() const; -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebNode(Node*); WebNode& operator=(Node*); operator Node*() const; @@ -130,7 +130,7 @@ template <> \ BLINK_EXPORT const type WebNode::ToConst<type>() const; -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK #define DEFINE_WEB_NODE_TYPE_CASTS(type, predicate) \ template <> \ BLINK_EXPORT type WebNode::To<type>() { \
diff --git a/third_party/WebKit/public/web/WebOptionElement.h b/third_party/WebKit/public/web/WebOptionElement.h index 1bb74b8..9ecf7b1 100644 --- a/third_party/WebKit/public/web/WebOptionElement.h +++ b/third_party/WebKit/public/web/WebOptionElement.h
@@ -53,7 +53,7 @@ WebString GetText() const; WebString Label() const; -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebOptionElement(HTMLOptionElement*); WebOptionElement& operator=(HTMLOptionElement*); operator HTMLOptionElement*() const;
diff --git a/third_party/WebKit/public/web/WebPageImportanceSignals.h b/third_party/WebKit/public/web/WebPageImportanceSignals.h index f1983b9..4ee44fc 100644 --- a/third_party/WebKit/public/web/WebPageImportanceSignals.h +++ b/third_party/WebKit/public/web/WebPageImportanceSignals.h
@@ -26,7 +26,7 @@ BLINK_EXPORT void SetIssuedNonGetFetchFromScript(); BLINK_EXPORT void Reset(); -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK BLINK_EXPORT void OnCommitLoad(); #endif
diff --git a/third_party/WebKit/public/web/WebPerformance.h b/third_party/WebKit/public/web/WebPerformance.h index 2457029..e7749a9 100644 --- a/third_party/WebKit/public/web/WebPerformance.h +++ b/third_party/WebKit/public/web/WebPerformance.h
@@ -35,7 +35,7 @@ #include "public/platform/WebPrivatePtr.h" #include "WebNavigationType.h" -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK #include "platform/heap/Handle.h" #endif @@ -100,7 +100,7 @@ BLINK_EXPORT double AuthorStyleSheetParseDurationBeforeFCP() const; BLINK_EXPORT double UpdateStyleDurationBeforeFCP() const; -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK BLINK_EXPORT WebPerformance(Performance*); BLINK_EXPORT WebPerformance& operator=(Performance*); #endif
diff --git a/third_party/WebKit/public/web/WebPluginDocument.h b/third_party/WebKit/public/web/WebPluginDocument.h index 5f63ceb0..792be2d 100644 --- a/third_party/WebKit/public/web/WebPluginDocument.h +++ b/third_party/WebKit/public/web/WebPluginDocument.h
@@ -52,7 +52,7 @@ BLINK_EXPORT WebPlugin* Plugin(); -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebPluginDocument(PluginDocument*); WebPluginDocument& operator=(PluginDocument*); operator PluginDocument*() const;
diff --git a/third_party/WebKit/public/web/WebRange.h b/third_party/WebKit/public/web/WebRange.h index 28973f3..82d4c96 100644 --- a/third_party/WebKit/public/web/WebRange.h +++ b/third_party/WebKit/public/web/WebRange.h
@@ -32,7 +32,7 @@ #define WebRange_h #include "public/platform/WebCommon.h" -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK #include "core/editing/EphemeralRange.h" #endif @@ -54,7 +54,7 @@ bool IsNull() const { return start_ == -1 && end_ == -1; } bool IsEmpty() const { return start_ == end_; } -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK BLINK_EXPORT WebRange(const EphemeralRange&); BLINK_EXPORT WebRange(const PlainTextRange&);
diff --git a/third_party/WebKit/public/web/WebScriptSource.h b/third_party/WebKit/public/web/WebScriptSource.h index b9d88e0..a2e0c77 100644 --- a/third_party/WebKit/public/web/WebScriptSource.h +++ b/third_party/WebKit/public/web/WebScriptSource.h
@@ -49,7 +49,7 @@ WebScriptSource(const WebString& code, const WebURL& url, int start_line) : code(code), url(url), start_line(start_line) {} -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK BLINK_EXPORT operator ScriptSourceCode() const; #endif };
diff --git a/third_party/WebKit/public/web/WebSelectElement.h b/third_party/WebKit/public/web/WebSelectElement.h index ebc3ac6..898ab1c 100644 --- a/third_party/WebKit/public/web/WebSelectElement.h +++ b/third_party/WebKit/public/web/WebSelectElement.h
@@ -56,7 +56,7 @@ BLINK_EXPORT WebVector<WebElement> GetListItems() const; -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebSelectElement(HTMLSelectElement*); WebSelectElement& operator=(HTMLSelectElement*); operator HTMLSelectElement*() const;
diff --git a/third_party/WebKit/public/web/WebSerializedScriptValue.h b/third_party/WebKit/public/web/WebSerializedScriptValue.h index 02144d6..ebe8182 100644 --- a/third_party/WebKit/public/web/WebSerializedScriptValue.h +++ b/third_party/WebKit/public/web/WebSerializedScriptValue.h
@@ -78,7 +78,7 @@ // Convert the serialized value to a parsed v8 value. BLINK_EXPORT v8::Local<v8::Value> Deserialize(v8::Isolate*); -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK BLINK_EXPORT WebSerializedScriptValue(WTF::PassRefPtr<SerializedScriptValue>); BLINK_EXPORT WebSerializedScriptValue& operator=( WTF::PassRefPtr<SerializedScriptValue>);
diff --git a/third_party/WebKit/public/web/WebSpeechGrammar.h b/third_party/WebKit/public/web/WebSpeechGrammar.h index 722dc00..a798a756 100644 --- a/third_party/WebKit/public/web/WebSpeechGrammar.h +++ b/third_party/WebKit/public/web/WebSpeechGrammar.h
@@ -46,7 +46,7 @@ BLINK_EXPORT void Reset(); BLINK_EXPORT void Assign(const WebSpeechGrammar&); -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebSpeechGrammar& operator=(SpeechGrammar*); #endif
diff --git a/third_party/WebKit/public/web/WebSpeechRecognitionHandle.h b/third_party/WebKit/public/web/WebSpeechRecognitionHandle.h index e8487b5..bb3b7768 100644 --- a/third_party/WebKit/public/web/WebSpeechRecognitionHandle.h +++ b/third_party/WebKit/public/web/WebSpeechRecognitionHandle.h
@@ -58,7 +58,7 @@ BLINK_EXPORT bool Equals(const WebSpeechRecognitionHandle&) const; BLINK_EXPORT bool LessThan(const WebSpeechRecognitionHandle&) const; -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebSpeechRecognitionHandle(SpeechRecognition*); operator SpeechRecognition*() const; #endif
diff --git a/third_party/WebKit/public/web/WebSpeechRecognitionResult.h b/third_party/WebKit/public/web/WebSpeechRecognitionResult.h index 371a843..c2a0ff4b 100644 --- a/third_party/WebKit/public/web/WebSpeechRecognitionResult.h +++ b/third_party/WebKit/public/web/WebSpeechRecognitionResult.h
@@ -49,7 +49,7 @@ BLINK_EXPORT void Assign(const WebSpeechRecognitionResult&); BLINK_EXPORT void Reset(); -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK operator SpeechRecognitionResult*() const; #endif
diff --git a/third_party/WebKit/public/web/WebTextCheckingResult.h b/third_party/WebKit/public/web/WebTextCheckingResult.h index b63cae74..55998c981 100644 --- a/third_party/WebKit/public/web/WebTextCheckingResult.h +++ b/third_party/WebKit/public/web/WebTextCheckingResult.h
@@ -55,7 +55,7 @@ length(length), replacements(replacements) {} -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK operator TextCheckingResult() const; #endif
diff --git a/third_party/WebKit/public/web/WebTextDirection.h b/third_party/WebKit/public/web/WebTextDirection.h index c3718ec..84fff0f 100644 --- a/third_party/WebKit/public/web/WebTextDirection.h +++ b/third_party/WebKit/public/web/WebTextDirection.h
@@ -31,7 +31,7 @@ #ifndef WebTextDirection_h #define WebTextDirection_h -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK #include "platform/text/TextDirection.h" #endif @@ -45,7 +45,7 @@ kWebTextDirectionLast = kWebTextDirectionRightToLeft }; -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK inline WebTextDirection ToWebTextDirection(TextDirection direction) { switch (direction) { case TextDirection::kLtr:
diff --git a/third_party/WebKit/public/web/WebUserGestureToken.h b/third_party/WebKit/public/web/WebUserGestureToken.h index e020113..baa6321 100644 --- a/third_party/WebKit/public/web/WebUserGestureToken.h +++ b/third_party/WebKit/public/web/WebUserGestureToken.h
@@ -55,7 +55,7 @@ BLINK_EXPORT void SetJavascriptPrompt(); bool IsNull() const { return token_.IsNull(); } -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK explicit WebUserGestureToken(RefPtr<UserGestureToken>); operator PassRefPtr<UserGestureToken>() const; #endif
diff --git a/third_party/WebKit/public/web/WebUserMediaRequest.h b/third_party/WebKit/public/web/WebUserMediaRequest.h index 9b3018fb..93f159f 100644 --- a/third_party/WebKit/public/web/WebUserMediaRequest.h +++ b/third_party/WebKit/public/web/WebUserMediaRequest.h
@@ -85,7 +85,7 @@ static WebUserMediaRequest CreateForTesting(const WebMediaConstraints& audio, const WebMediaConstraints& video); -#if BLINK_IMPLEMENTATION +#if INSIDE_BLINK WebUserMediaRequest(UserMediaRequest*); operator UserMediaRequest*() const; #endif
diff --git a/third_party/closure_compiler/compiled_resources2.gyp b/third_party/closure_compiler/compiled_resources2.gyp index 7b412d98..4fda838 100644 --- a/third_party/closure_compiler/compiled_resources2.gyp +++ b/third_party/closure_compiler/compiled_resources2.gyp
@@ -40,6 +40,7 @@ '<(DEPTH)/chrome/browser/resources/uber/compiled_resources2.gyp:*', '<(DEPTH)/chrome/browser/resources/webapks/compiled_resources2.gyp:*', '<(DEPTH)/ui/file_manager/compiled_resources2.gyp:*', + '<(DEPTH)/ui/webui/resources/chromeos/compiled_resources2.gyp:*', '<(DEPTH)/ui/webui/resources/cr_elements/compiled_resources2.gyp:*', '<(DEPTH)/ui/webui/resources/js/chromeos/compiled_resources2.gyp:*', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:*',
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index 559171073..b9045aa 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -11149,6 +11149,8 @@ <int value="375" label="SafeBrowsingForTrustedSourcesEnabled"/> <int value="376" label="EcryptfsMigrationStrategy"/> <int value="377" label="NoteTakingAppsLockScreenWhitelist"/> + <int value="378" label="CastReceiverEnabled"/> + <int value="379" label="CastReceiverName"/> </enum> <enum name="EnterprisePolicyInvalidations">
diff --git a/ui/android/delegated_frame_host_android.cc b/ui/android/delegated_frame_host_android.cc index cb8333f..14a2a31e 100644 --- a/ui/android/delegated_frame_host_android.cc +++ b/ui/android/delegated_frame_host_android.cc
@@ -210,12 +210,10 @@ void DelegatedFrameHostAndroid::CreateNewCompositorFrameSinkSupport() { constexpr bool is_root = false; - constexpr bool handles_frame_sink_id_invalidation = false; constexpr bool needs_sync_points = true; support_.reset(); support_ = host_frame_sink_manager_->CreateCompositorFrameSinkSupport( - this, frame_sink_id_, is_root, handles_frame_sink_id_invalidation, - needs_sync_points); + this, frame_sink_id_, is_root, needs_sync_points); } viz::SurfaceId DelegatedFrameHostAndroid::SurfaceId() const {
diff --git a/ui/aura/local/layer_tree_frame_sink_local.cc b/ui/aura/local/layer_tree_frame_sink_local.cc index 2583d06..6a036918 100644 --- a/ui/aura/local/layer_tree_frame_sink_local.cc +++ b/ui/aura/local/layer_tree_frame_sink_local.cc
@@ -34,7 +34,6 @@ support_ = host_frame_sink_manager_->CreateCompositorFrameSinkSupport( this, frame_sink_id_, false /* is_root */, - true /* handles_frame_sink_id_invalidation */, true /* needs_sync_points */); begin_frame_source_ = base::MakeUnique<viz::ExternalBeginFrameSource>(this); client->SetBeginFrameSource(begin_frame_source_.get());
diff --git a/ui/events/blink/input_handler_proxy.cc b/ui/events/blink/input_handler_proxy.cc index 1cd0c7f..4e3746b 100644 --- a/ui/events/blink/input_handler_proxy.cc +++ b/ui/events/blink/input_handler_proxy.cc
@@ -1112,8 +1112,6 @@ cc::TouchAction white_listed_touch_action = cc::kTouchActionAuto; EventDisposition result = HitTestTouchEvent( touch_event, &is_touching_scrolling_layer, &white_listed_touch_action); - client_->SetWhiteListedTouchAction(white_listed_touch_action, - touch_event.unique_touch_event_id); // If |result| is still DROP_EVENT look at the touch end handler as // we may not want to discard the entire touch sequence. Note this @@ -1131,6 +1129,9 @@ if (is_flinging_on_impl && is_touching_scrolling_layer) result = DID_NOT_HANDLE_NON_BLOCKING_DUE_TO_FLING; + client_->SetWhiteListedTouchAction(white_listed_touch_action, + touch_event.unique_touch_event_id, result); + return result; } @@ -1144,8 +1145,8 @@ cc::TouchAction white_listed_touch_action = cc::kTouchActionAuto; EventDisposition result = HitTestTouchEvent( touch_event, &is_touching_scrolling_layer, &white_listed_touch_action); - client_->SetWhiteListedTouchAction(white_listed_touch_action, - touch_event.unique_touch_event_id); + client_->SetWhiteListedTouchAction( + white_listed_touch_action, touch_event.unique_touch_event_id, result); return result; } return static_cast<EventDisposition>(touch_result_);
diff --git a/ui/events/blink/input_handler_proxy_client.h b/ui/events/blink/input_handler_proxy_client.h index 602b6f71..b2f4d666 100644 --- a/ui/events/blink/input_handler_proxy_client.h +++ b/ui/events/blink/input_handler_proxy_client.h
@@ -60,8 +60,10 @@ virtual void GenerateScrollBeginAndSendToMainThread( const blink::WebGestureEvent& update_event) = 0; - virtual void SetWhiteListedTouchAction(cc::TouchAction touch_action, - uint32_t unique_touch_event_id) = 0; + virtual void SetWhiteListedTouchAction( + cc::TouchAction touch_action, + uint32_t unique_touch_event_id, + InputHandlerProxy::EventDisposition event_disposition) = 0; protected: virtual ~InputHandlerProxyClient() {}
diff --git a/ui/events/blink/input_handler_proxy_unittest.cc b/ui/events/blink/input_handler_proxy_unittest.cc index e30f228e..1c92b8ec 100644 --- a/ui/events/blink/input_handler_proxy_unittest.cc +++ b/ui/events/blink/input_handler_proxy_unittest.cc
@@ -319,9 +319,10 @@ const gfx::PointF& causal_event_viewport_point)); void DidStopFlinging() override {} void DidAnimateForInput() override {} - MOCK_METHOD2(SetWhiteListedTouchAction, + MOCK_METHOD3(SetWhiteListedTouchAction, void(cc::TouchAction touch_action, - uint32_t unique_touch_event_id)); + uint32_t unique_touch_event_id, + InputHandlerProxy::EventDisposition event_disposition)); private: DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); @@ -2552,7 +2553,9 @@ *touch_action = cc::kTouchActionPanUp; return cc::InputHandler::TouchStartOrMoveEventListenerType::NO_HANDLER; })); - EXPECT_CALL(mock_client_, SetWhiteListedTouchAction(cc::kTouchActionPanUp, 1)) + EXPECT_CALL(mock_client_, + SetWhiteListedTouchAction(cc::kTouchActionPanUp, 1, + InputHandlerProxy::DROP_EVENT)) .WillOnce(testing::Return()); WebTouchEvent touch(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers, @@ -2594,7 +2597,9 @@ return cc::InputHandler::TouchStartOrMoveEventListenerType:: HANDLER_ON_SCROLLING_LAYER; })); - EXPECT_CALL(mock_client_, SetWhiteListedTouchAction(cc::kTouchActionPanY, 1)) + EXPECT_CALL(mock_client_, + SetWhiteListedTouchAction(cc::kTouchActionPanY, 1, + InputHandlerProxy::DID_NOT_HANDLE)) .WillOnce(testing::Return()); // Since the second touch point hits a touch-region, there should be no // hit-testing for the third touch point. @@ -2636,8 +2641,9 @@ *touch_action = cc::kTouchActionPanX; return cc::InputHandler::TouchStartOrMoveEventListenerType::NO_HANDLER; })); - EXPECT_CALL(mock_client_, - SetWhiteListedTouchAction(cc::kTouchActionPanRight, 1)) + EXPECT_CALL(mock_client_, SetWhiteListedTouchAction( + cc::kTouchActionPanRight, 1, + InputHandlerProxy::DID_HANDLE_NON_BLOCKING)) .WillOnce(testing::Return()); WebTouchEvent touch(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers, @@ -2676,7 +2682,9 @@ *touch_action = cc::kTouchActionNone; return cc::InputHandler::TouchStartOrMoveEventListenerType::NO_HANDLER; })); - EXPECT_CALL(mock_client_, SetWhiteListedTouchAction(cc::kTouchActionNone, 1)) + EXPECT_CALL(mock_client_, SetWhiteListedTouchAction( + cc::kTouchActionNone, 1, + InputHandlerProxy::DID_HANDLE_NON_BLOCKING)) .WillOnce(testing::Return()); WebTouchEvent touch(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers, @@ -2710,7 +2718,8 @@ EventListenerTypeForTouchStartOrMoveAt(testing::_, testing::_)) .WillOnce(testing::Return( cc::InputHandler::TouchStartOrMoveEventListenerType::NO_HANDLER)); - EXPECT_CALL(mock_client_, SetWhiteListedTouchAction(testing::_, testing::_)) + EXPECT_CALL(mock_client_, + SetWhiteListedTouchAction(testing::_, testing::_, testing::_)) .WillOnce(testing::Return()); WebTouchEvent touch(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers, @@ -2725,7 +2734,8 @@ EventListenerTypeForTouchStartOrMoveAt(testing::_, testing::_)) .WillOnce(testing::Return( cc::InputHandler::TouchStartOrMoveEventListenerType::HANDLER)); - EXPECT_CALL(mock_client_, SetWhiteListedTouchAction(testing::_, testing::_)) + EXPECT_CALL(mock_client_, + SetWhiteListedTouchAction(testing::_, testing::_, testing::_)) .WillOnce(testing::Return()); touch.SetType(WebInputEvent::kTouchMove); @@ -3525,7 +3535,8 @@ mock_input_handler_, GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove)) .WillOnce(testing::Return(cc::EventListenerProperties::kPassive)); - EXPECT_CALL(mock_client_, SetWhiteListedTouchAction(testing::_, testing::_)) + EXPECT_CALL(mock_client_, + SetWhiteListedTouchAction(testing::_, testing::_, testing::_)) .WillOnce(testing::Return()); expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING; @@ -3557,7 +3568,8 @@ .WillOnce( testing::Return(cc::InputHandler::TouchStartOrMoveEventListenerType:: HANDLER_ON_SCROLLING_LAYER)); - EXPECT_CALL(mock_client_, SetWhiteListedTouchAction(testing::_, testing::_)) + EXPECT_CALL(mock_client_, + SetWhiteListedTouchAction(testing::_, testing::_, testing::_)) .WillOnce(testing::Return()); expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
diff --git a/ui/events/keycodes/keyboard_code_conversion_mac.mm b/ui/events/keycodes/keyboard_code_conversion_mac.mm index 143f9b1..d6427700 100644 --- a/ui/events/keycodes/keyboard_code_conversion_mac.mm +++ b/ui/events/keycodes/keyboard_code_conversion_mac.mm
@@ -18,6 +18,12 @@ namespace { +bool IsUnicodeControl(unichar c) { + // C0 control characters: http://unicode.org/charts/PDF/U0000.pdf + // C1 control characters: http://unicode.org/charts/PDF/U0080.pdf + return c <= 0x1F || (c >= 0x7F && c <= 0x9F); +} + // This value is not defined but shows up as 0x36. const int kVK_RightCommand = 0x36; // Context menu is not defined but shows up as 0x6E. @@ -850,18 +856,10 @@ // e.g. On French keyboard [+a will produce "^q", DomKey should be 'q'. unichar dom_key_char = [characters characterAtIndex:[characters length] - 1]; - const bool is_ctrl_down = ([event modifierFlags] & NSControlKeyMask) && - !([event modifierFlags] & NSAlternateKeyMask); - const bool is_command_down = [event modifierFlags] & NSCommandKeyMask; - // On Mac Blink won't insert ASCII character if either Ctrl or Command, or - // both, are down. - // See EditingBehavior::shouldInsertCharacter() - if (std::iscntrl(dom_key_char) || - (dom_key_char < 0x80 && (is_ctrl_down || is_command_down))) { - // According to spec if the key combination produces a non-printable - // character, the key value should be the character without modifiers - // except Shift and AltGr. - // See https://w3c.github.io/uievents/#keys-guidelines + if (IsUnicodeControl(dom_key_char)) { + // Filter non-glyph modifiers if the generated characters are part of + // Unicode 'Other, Control' General Category. + // https://w3c.github.io/uievents-key/#selecting-key-attribute-values bool unused_is_dead_key; const int kAllowedModifiersMask = NSShiftKeyMask | NSAlphaShiftKeyMask | NSAlternateKeyMask; @@ -870,7 +868,10 @@ [event keyCode], [event modifierFlags] & kAllowedModifiersMask, &unused_is_dead_key); } - if (!std::iscntrl(dom_key_char)) + + // We need to check again because keys like ESC will produce control + // characters even without any modifiers. + if (!IsUnicodeControl(dom_key_char)) return DomKeyFromCharCode(dom_key_char); } }
diff --git a/ui/gfx/image/mojo/image_skia_struct_traits.cc b/ui/gfx/image/mojo/image_skia_struct_traits.cc index 98ef823..cb9487f 100644 --- a/ui/gfx/image/mojo/image_skia_struct_traits.cc +++ b/ui/gfx/image/mojo/image_skia_struct_traits.cc
@@ -107,32 +107,12 @@ } // static -void* StructTraits<gfx::mojom::ImageSkiaDataView, gfx::ImageSkia>::SetUpContext( +std::vector<gfx::ImageSkiaRep> +StructTraits<gfx::mojom::ImageSkiaDataView, gfx::ImageSkia>::image_reps( const gfx::ImageSkia& input) { // Trigger the image to load everything. input.EnsureRepsForSupportedScales(); - - // Use a context to return a stable list of ImageSkiaRep objects. That is, - // multiple calls of image_reps() should return exactly the same list of - // ImageSkiaRep objects. So that ImageSkiaRep with the same backing pixel - // buffer is properly serialized and only once. - return new std::vector<gfx::ImageSkiaRep>(input.image_reps()); -} - -// static -void StructTraits<gfx::mojom::ImageSkiaDataView, - gfx::ImageSkia>::TearDownContext(const gfx::ImageSkia& input, - void* context) { - delete static_cast<std::vector<gfx::ImageSkiaRep>*>(context); -} - -// static -const std::vector<gfx::ImageSkiaRep>& -StructTraits<gfx::mojom::ImageSkiaDataView, gfx::ImageSkia>::image_reps( - const gfx::ImageSkia& input, - void* context) { - // See the comment in SetUpContext regarding context usage. - return *(static_cast<std::vector<gfx::ImageSkiaRep>*>(context)); + return input.image_reps(); } // static
diff --git a/ui/gfx/image/mojo/image_skia_struct_traits.h b/ui/gfx/image/mojo/image_skia_struct_traits.h index 974ec9c..0b9cfecf 100644 --- a/ui/gfx/image/mojo/image_skia_struct_traits.h +++ b/ui/gfx/image/mojo/image_skia_struct_traits.h
@@ -56,11 +56,7 @@ template <> struct StructTraits<gfx::mojom::ImageSkiaDataView, gfx::ImageSkia> { - static void* SetUpContext(const gfx::ImageSkia& input); - static void TearDownContext(const gfx::ImageSkia& input, void* context); - static const std::vector<gfx::ImageSkiaRep>& image_reps( - const gfx::ImageSkia& input, - void* context); + static std::vector<gfx::ImageSkiaRep> image_reps(const gfx::ImageSkia& input); static bool IsNull(const gfx::ImageSkia& input) { return input.image_reps().empty();
diff --git a/ui/gfx/mojo/buffer_types_struct_traits.cc b/ui/gfx/mojo/buffer_types_struct_traits.cc index 186e2eb5..e9aea16 100644 --- a/ui/gfx/mojo/buffer_types_struct_traits.cc +++ b/ui/gfx/mojo/buffer_types_struct_traits.cc
@@ -8,30 +8,17 @@ namespace mojo { -void* StructTraits<gfx::mojom::NativePixmapHandleDataView, - gfx::NativePixmapHandle>:: - SetUpContext(const gfx::NativePixmapHandle& pixmap_handle) { - auto* handles = new std::vector<mojo::ScopedHandle>(); +std::vector<mojo::ScopedHandle> +StructTraits<gfx::mojom::NativePixmapHandleDataView, gfx::NativePixmapHandle>:: + fds(const gfx::NativePixmapHandle& pixmap_handle) { + std::vector<mojo::ScopedHandle> handles; #if defined(OS_LINUX) for (const base::FileDescriptor& fd : pixmap_handle.fds) - handles->emplace_back(mojo::WrapPlatformFile(fd.fd)); + handles.emplace_back(mojo::WrapPlatformFile(fd.fd)); #endif // defined(OS_LINUX) return handles; } -void StructTraits<gfx::mojom::NativePixmapHandleDataView, - gfx::NativePixmapHandle>:: - TearDownContext(const gfx::NativePixmapHandle& handle, void* context) { - delete static_cast<std::vector<mojo::ScopedHandle>*>(context); -} - -std::vector<mojo::ScopedHandle>& StructTraits< - gfx::mojom::NativePixmapHandleDataView, - gfx::NativePixmapHandle>::fds(const gfx::NativePixmapHandle& pixmap_handle, - void* context) { - return *static_cast<std::vector<mojo::ScopedHandle>*>(context); -} - bool StructTraits< gfx::mojom::NativePixmapHandleDataView, gfx::NativePixmapHandle>::Read(gfx::mojom::NativePixmapHandleDataView data,
diff --git a/ui/gfx/mojo/buffer_types_struct_traits.h b/ui/gfx/mojo/buffer_types_struct_traits.h index 0fdf909..fadb17a8 100644 --- a/ui/gfx/mojo/buffer_types_struct_traits.h +++ b/ui/gfx/mojo/buffer_types_struct_traits.h
@@ -239,10 +239,6 @@ template <> struct StructTraits<gfx::mojom::NativePixmapHandleDataView, gfx::NativePixmapHandle> { - static void* SetUpContext(const gfx::NativePixmapHandle& handle); - static void TearDownContext(const gfx::NativePixmapHandle& handle, - void* context); - static bool IsNull(const gfx::NativePixmapHandle& handle) { #if defined(OS_LINUX) return false; @@ -251,9 +247,8 @@ return true; #endif } - static std::vector<mojo::ScopedHandle>& fds( - const gfx::NativePixmapHandle& pixmap_handle, - void* context); + static std::vector<mojo::ScopedHandle> fds( + const gfx::NativePixmapHandle& pixmap_handle); static const std::vector<gfx::NativePixmapPlane>& planes( const gfx::NativePixmapHandle& pixmap_handle) {
diff --git a/ui/native_theme/overlay_scrollbar_constants_aura.h b/ui/native_theme/overlay_scrollbar_constants_aura.h index dec0491..9ecba8aa 100644 --- a/ui/native_theme/overlay_scrollbar_constants_aura.h +++ b/ui/native_theme/overlay_scrollbar_constants_aura.h
@@ -19,7 +19,7 @@ constexpr float kOverlayScrollbarStrokeHoverAlpha = 0.5f; constexpr base::TimeDelta kOverlayScrollbarFadeDelay = - base::TimeDelta::FromMilliseconds(1000); + base::TimeDelta::FromMilliseconds(500); constexpr base::TimeDelta kOverlayScrollbarFadeDuration = base::TimeDelta::FromMilliseconds(200); // TODO(bokan): This is still undetermined. crbug.com/652520.
diff --git a/ui/views/cocoa/views_nswindow_delegate.mm b/ui/views/cocoa/views_nswindow_delegate.mm index d0d50a0e..96acf216 100644 --- a/ui/views/cocoa/views_nswindow_delegate.mm +++ b/ui/views/cocoa/views_nswindow_delegate.mm
@@ -92,6 +92,12 @@ parent_->OnWindowKeyStatusChangedTo(false); } +- (BOOL)windowShouldClose:(id)sender { + views::NonClientView* nonClientView = + [self nativeWidgetMac]->GetWidget()->non_client_view(); + return !nonClientView || nonClientView->CanClose(); +} + - (void)windowWillClose:(NSNotification*)notification { // Retain |self|. |parent_| should be cleared. OnWindowWillClose() may delete // |parent_|, but it may also dealloc |self| before returning. However, the
diff --git a/ui/views/widget/native_widget_mac_unittest.mm b/ui/views/widget/native_widget_mac_unittest.mm index edd51fb..bae7382 100644 --- a/ui/views/widget/native_widget_mac_unittest.mm +++ b/ui/views/widget/native_widget_mac_unittest.mm
@@ -915,11 +915,17 @@ explicit ModalDialogDelegate(ui::ModalType modal_type) : modal_type_(modal_type) {} + void set_can_close(bool value) { can_close_ = value; } + // WidgetDelegate: ui::ModalType GetModalType() const override { return modal_type_; } + // DialogDelegate: + bool Close() override { return can_close_; } + private: const ui::ModalType modal_type_; + bool can_close_ = true; DISALLOW_COPY_AND_ASSIGN(ModalDialogDelegate); }; @@ -1877,6 +1883,19 @@ ]])); } +// Test -[NSWindowDelegate windowShouldClose:]. +TEST_F(NativeWidgetMacTest, CanClose) { + ModalDialogDelegate* delegate = new ModalDialogDelegate(ui::MODAL_TYPE_NONE); + Widget* widget = + views::DialogDelegate::CreateDialogWidget(delegate, nullptr, nullptr); + NSWindow* window = widget->GetNativeWindow(); + delegate->set_can_close(false); + EXPECT_FALSE([[window delegate] windowShouldClose:window]); + delegate->set_can_close(true); + EXPECT_TRUE([[window delegate] windowShouldClose:window]); + widget->CloseNow(); +} + } // namespace test } // namespace views
diff --git a/ui/webui/resources/PRESUBMIT.py b/ui/webui/resources/PRESUBMIT.py index 2b24710..31d3e2bab 100644 --- a/ui/webui/resources/PRESUBMIT.py +++ b/ui/webui/resources/PRESUBMIT.py
@@ -28,9 +28,11 @@ for f in input_api.AffectedFiles(): local_path = f.LocalPath() + # Allow translation in i18n_behavior.js and the chromeos/ directory. if local_path.endswith('i18n_behavior.js'): continue - + if 'chromeos' in local_path: + continue keywords = None if local_path.endswith('.js'): keywords = js_keywords
diff --git a/ui/webui/resources/chromeos/OWNERS b/ui/webui/resources/chromeos/OWNERS new file mode 100644 index 0000000..aa215c7 --- /dev/null +++ b/ui/webui/resources/chromeos/OWNERS
@@ -0,0 +1 @@ +stevenjb@chromium.org
diff --git a/ui/webui/resources/chromeos/README.md b/ui/webui/resources/chromeos/README.md new file mode 100644 index 0000000..682c983 --- /dev/null +++ b/ui/webui/resources/chromeos/README.md
@@ -0,0 +1,7 @@ +This directory contains shared chromeos elements for Web UI +(e.g. between Settings and a stand alone dialog). + +These components are allowed to use I18nBehavior. The Web UI hosting +these elements is expected to provide loadTimeData with the necessary +strings. TODO(stevenjb/dschuyler): Add support for i18n{} substitution. +
diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.html b/ui/webui/resources/chromeos/bluetooth_dialog.html similarity index 71% rename from chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.html rename to ui/webui/resources/chromeos/bluetooth_dialog.html index fc05b83..a89ba4d5 100644 --- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.html +++ b/ui/webui/resources/chromeos/bluetooth_dialog.html
@@ -1,17 +1,17 @@ <link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> +<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html"> <link rel="import" href="chrome://resources/html/cr.html"> +<link rel="import" href="chrome://resources/html/i18n_behavior.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-list/iron-list.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-input/paper-input.html"> -<link rel="import" href="../bluetooth_page/bluetooth_device_list_item.html"> -<link rel="import" href="../settings_shared_css.html"> -<dom-module id="bluetooth-device-dialog"> +<dom-module id="bluetooth-dialog"> <template> - <style include="settings-shared iron-flex"> + <style include="cr-hidden-style iron-flex"> #pairing { margin-bottom: 10px; } @@ -68,73 +68,70 @@ margin: 0 20px; } </style> + <!-- TODO(stevenjb/dschuyler): Find a solution to support i18n{} here --> <dialog is="cr-dialog" id="dialog" on-cancel="onDialogCanceled_" - close-text="$i18n{close}" on-closed="onDialogCanceled_"> - <div slot="title">$i18n{bluetoothPairDevicePageTitle}</div> + close-text="[[i18n('close')]]" on-closed="onDialogCanceled_"> + <div slot="title">[[title]]</div> <div slot="body"> <div class="contents layout vertical center center-justified"> - <template is="dom-if" if="[[isDialogType_(dialogId, 'pairDevice')]]"> - <div id="pairing" class="settings-box first layout vertical center - center-justified"> + <template is="dom-if" if="[[!errorMessage_]]"> + <div id="pairing" class="layout vertical center center-justified"> <div class="dialog-message"> [[getMessage_(pairingDevice, pairingEvent_)]] </div> <div hidden$="[[!showEnterPincode_(pairingEvent_)]]"> <paper-input id="pincode" minlength="1" maxlength="16" - type="text" auto-validate value="{{pinOrPass}}"> + type="text" auto-validate value="{{pinOrPass_}}"> </paper-input> </div> <div hidden$="[[!showEnterPasskey_(pairingEvent_)]]"> <paper-input id="passkey" minlength="6" maxlength="6" - type="text" auto-validate value="{{pinOrPass}}"> + type="text" auto-validate value="{{pinOrPass_}}"> </paper-input> </div> <div id="pinDiv" class="layout horizontal center center-justified" hidden="[[!showDisplayPassOrPin_(pairingEvent_)]]"> - <template is="dom-repeat" items="[[digits]]"> + <template is="dom-repeat" items="[[digits_]]"> <span class$="[[getPinClass_(index, pairingEvent_)]]"> [[getPinDigit_(index, pairingEvent_)]] </span> </template> <span class$="[[getPinClass_(-1, pairingEvent_)]]" hidden="[[showAcceptReject_(pairingEvent_)]]"> - $i18n{bluetoothEnterKey} + [[i18n('bluetoothEnterKey')]] </span> </div> </div> </template> - <template is="dom-if" - if="[[isDialogType_('connectError', dialogId)]]"> - <div class="settings-box first layout vertical center - center-justified"> - <div class="dialog-message">[[errorMessage]]</div> + <template is="dom-if" if="[[errorMessage_]]"> + <div class="layout vertical center center-justified"> + <div class="dialog-message">[[errorMessage_]]</div> </div> </template> </div> </div> <div slot="button-container"> - <template is="dom-if" if="[[isDialogType_('pairDevice', dialogId)]]"> + <template is="dom-if" if="[[!errorMessage_]]"> <paper-button hidden$="[[!showAcceptReject_(pairingEvent_)]]" - on-tap="onAcceptTap_">$i18n{bluetoothAccept}</paper-button> + on-tap="onAcceptTap_">[[i18n('bluetoothAccept')]]</paper-button> <paper-button hidden$="[[!showAcceptReject_(pairingEvent_)]]" - on-tap="onRejectTap_">$i18n{bluetoothReject}</paper-button> + on-tap="onRejectTap_">[[i18n('bluetoothReject')]]</paper-button> <paper-button hidden$="[[!showConnect_(pairingEvent_)]]" - disabled="[[!enableConnect_(pairingEvent_, pinOrPass)]]" - on-tap="onConnectTap_">$i18n{bluetoothPair}</paper-button> + disabled="[[!enableConnect_(pairingEvent_, pinOrPass_)]]" + on-tap="onConnectTap_">[[i18n('bluetoothPair')]]</paper-button> <paper-button hidden$="[[!showDismiss_(pairingDevice, pairingEvent_)]]" - on-tap="close">$i18n{bluetoothDismiss}</paper-button> + on-tap="close">[[i18n('ok')]]</paper-button> <paper-button hidden$="[[showDismiss_(pairingDevice, pairingEvent_)]]" on-tap="onCancelTap_"> - $i18n{cancel} + [[i18n('cancel')]] </paper-button> </template> - <template is="dom-if" if="[[isDialogType_('connectError', dialogId)]]"> - <paper-button on-tap="close">$i18n{bluetoothDismiss} - </paper-button> + <template is="dom-if" if="[[errorMessage_]]"> + <paper-button on-tap="close">[[i18n('ok')]]</paper-button> </template> </div> </dialog> </template> - <script src="bluetooth_device_dialog.js"></script> + <script src="bluetooth_dialog.js"></script> </dom-module>
diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js b/ui/webui/resources/chromeos/bluetooth_dialog.js similarity index 72% rename from chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js rename to ui/webui/resources/chromeos/bluetooth_dialog.js index 7cc05849..b061349 100644 --- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js +++ b/ui/webui/resources/chromeos/bluetooth_dialog.js
@@ -2,17 +2,44 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.exportPath('settings'); +/** + * @fileoverview + * Dialog used for pairing a provided |pairing-device|. Set |show-error| to + * show the error results from a pairing event instead of the pairing UI. + * NOTE: This module depends on I18nBehavior which depends on loadTimeData. + */ var PairingEventType = chrome.bluetoothPrivate.PairingEventType; -// NOTE(dbeam): even though this behavior is only used privately, it must -// be globally accessible for Closure's --polymer_pass to compile happily. +Polymer({ + is: 'bluetooth-dialog', -/** @polymerBehavior */ -settings.BluetoothPairDeviceBehavior = { + behaviors: [I18nBehavior], + properties: { /** + * Interface for bluetooth calls. Set in bluetooth-page. + * @type {Bluetooth} + * @private + */ + bluetooth: { + type: Object, + value: chrome.bluetooth, + }, + + /** + * Interface for bluetoothPrivate calls. + * @type {BluetoothPrivate} + */ + bluetoothPrivate: { + type: Object, + value: chrome.bluetoothPrivate, + }, + + /** Dialog title */ + title: String, + + /** * Current Pairing device. * @type {!chrome.bluetooth.Device|undefined} */ @@ -20,31 +47,31 @@ /** * Current Pairing event. - * @type {?chrome.bluetoothPrivate.PairingEvent} + * @private {?chrome.bluetoothPrivate.PairingEvent} */ pairingEvent_: { type: Object, value: null, }, - /** Pincode or passkey value, used to trigger connect enabled changes. */ - pinOrPass: String, - /** - * Interface for bluetoothPrivate calls. Set in bluetooth-page. - * @type {BluetoothPrivate} + * May be set by the host to show a pairing error result, or may be + * set by the dialog if a pairing or connect error occured. * @private */ - bluetoothPrivate: { - type: Object, - value: chrome.bluetoothPrivate, - }, + errorMessage_: String, /** - * @const - * @type {!Array<number>} + * Pincode or passkey value, used to trigger connect enabled changes. + * @private */ - digits: { + pinOrPass_: String, + + /** + * @const {!Array<number>} + * @private + */ + digits_: { type: Array, readOnly: true, value: [0, 1, 2, 3, 4, 5], @@ -52,16 +79,100 @@ }, observers: [ + 'dialogUpdated_(errorMessage_, pairingEvent_)', 'pairingChanged_(pairingDevice, pairingEvent_)', ], /** * Listener for chrome.bluetoothPrivate.onPairing events. - * @type {?function(!chrome.bluetoothPrivate.PairingEvent)} - * @private + * @private {?function(!chrome.bluetoothPrivate.PairingEvent)} */ bluetoothPrivateOnPairingListener_: null, + /** + * Listener for chrome.bluetooth.onBluetoothDeviceChanged events. + * @private {?function(!chrome.bluetooth.Device)} + */ + bluetoothDeviceChangedListener_: null, + + open: function() { + this.startPairing(); + this.pinOrPass_ = ''; + this.getDialog_().showModal(); + this.itemWasFocused_ = false; + }, + + close: function() { + this.endPairing(); + var dialog = this.getDialog_(); + if (dialog.open) + dialog.close(); + }, + + /** + * Updates the dialog after a connect attempt. + * @param {!chrome.bluetooth.Device} device The device connected to + * @param {!{message: string}} lastError chrome.runtime.lastError + * @param {chrome.bluetoothPrivate.ConnectResultType} result The connect + * result + * @return {boolean} + */ + handleError: function(device, lastError, result) { + var error; + if (lastError) { + error = lastError.message; + } else { + switch (result) { + case chrome.bluetoothPrivate.ConnectResultType.IN_PROGRESS: + case chrome.bluetoothPrivate.ConnectResultType.ALREADY_CONNECTED: + case chrome.bluetoothPrivate.ConnectResultType.AUTH_CANCELED: + case chrome.bluetoothPrivate.ConnectResultType.SUCCESS: + this.errorMessage_ = ''; + return false; + default: + error = result; + } + } + + var name = device.name || device.address; + var id = 'bluetooth_connect_' + error; + if (this.i18nExists(id)) { + this.errorMessage_ = this.i18n(id, name); + } else { + this.errorMessage_ = error; + console.error('Unexpected error connecting to: ' + name + ': ' + error); + } + return true; + }, + + /** @private */ + dialogUpdated_: function() { + if (this.showEnterPincode_()) + this.$$('#pincode').focus(); + else if (this.showEnterPasskey_()) + this.$$('#passkey').focus(); + }, + + /** + * @return {!CrDialogElement} + * @private + */ + getDialog_: function() { + return /** @type {!CrDialogElement} */ (this.$.dialog); + }, + + /** @private */ + onCancelTap_: function() { + this.getDialog_().cancel(); + }, + + /** @private */ + onDialogCanceled_: function() { + if (!this.errorMessage_) + this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CANCEL); + this.endPairing(); + }, + /** Called when the dialog is opened. Starts listening for pairing events. */ startPairing: function() { if (!this.bluetoothPrivateOnPairingListener_) { @@ -70,6 +181,12 @@ this.bluetoothPrivate.onPairing.addListener( this.bluetoothPrivateOnPairingListener_); } + if (!this.bluetoothDeviceChangedListener_) { + this.bluetoothDeviceChangedListener_ = + this.onBluetoothDeviceChanged_.bind(this); + this.bluetooth.onDeviceChanged.addListener( + this.bluetoothDeviceChangedListener_); + } }, /** Called when the dialog is closed. */ @@ -79,6 +196,11 @@ this.bluetoothPrivateOnPairingListener_); this.bluetoothPrivateOnPairingListener_ = null; } + if (this.bluetoothDeviceChangedListener_) { + this.bluetooth.onDeviceChanged.removeListener( + this.bluetoothDeviceChangedListener_); + this.bluetoothDeviceChangedListener_ = null; + } this.pairingEvent_ = null; }, @@ -101,6 +223,18 @@ this.pairingEvent_ = event; }, + /** + * Process bluetooth.onDeviceChanged events. This ensures that the dialog + * updates when the connection state changes. + * @param {!chrome.bluetooth.Device} device + * @private + */ + onBluetoothDeviceChanged_: function(device) { + if (!this.pairingDevice || device.address != this.pairingDevice.address) + return; + this.pairingDevice = device; + }, + /** @private */ pairingChanged_: function() { // Auto-close the dialog when pairing completes. @@ -109,7 +243,8 @@ this.close(); return; } - this.pinOrPass = ''; + this.errorMessage_ = ''; + this.pinOrPass_ = ''; }, /** @@ -313,7 +448,7 @@ this.pairingEvent_.pairing == PairingEventType.KEYS_ENTERED && this.pairingEvent_.enteredKey) { var enteredKey = this.pairingEvent_.enteredKey; // 1-7 - var lastKey = this.digits.length; // 6 + var lastKey = this.digits_.length; // 6 if ((index == -1 && enteredKey > lastKey) || (index + 1 == enteredKey)) cssClass += ' next'; else if (index > enteredKey) @@ -321,73 +456,4 @@ } return cssClass; }, -}; - -Polymer({ - is: 'bluetooth-device-dialog', - - behaviors: [I18nBehavior, settings.BluetoothPairDeviceBehavior], - - properties: { - /** - * The version of this dialog to show: 'pairDevice', or 'connectError'. - * Must be set before the dialog is opened. - */ - dialogId: String, - }, - - observers: [ - 'dialogUpdated_(dialogId, pairingEvent_)', - ], - - open: function() { - this.startPairing(); - this.pinOrPass = ''; - this.getDialog_().showModal(); - this.itemWasFocused_ = false; - }, - - close: function() { - this.endPairing(); - var dialog = this.getDialog_(); - if (dialog.open) - dialog.close(); - }, - - /** @private */ - dialogUpdated_: function() { - if (this.showEnterPincode_()) - this.$$('#pincode').focus(); - else if (this.showEnterPasskey_()) - this.$$('#passkey').focus(); - }, - - /** - * @return {!CrDialogElement} - * @private - */ - getDialog_: function() { - return /** @type {!CrDialogElement} */ (this.$.dialog); - }, - - /** - * @param {string} desiredDialogType - * @return {boolean} - * @private - */ - isDialogType_: function(desiredDialogType, currentDialogType) { - return currentDialogType == desiredDialogType; - }, - - /** @private */ - onCancelTap_: function() { - this.getDialog_().cancel(); - }, - - /** @private */ - onDialogCanceled_: function() { - if (this.dialogId == 'pairDevice') - this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CANCEL); - this.endPairing(); - }, });
diff --git a/ui/webui/resources/chromeos/compiled_resources2.gyp b/ui/webui/resources/chromeos/compiled_resources2.gyp new file mode 100644 index 0000000..aa53f37 --- /dev/null +++ b/ui/webui/resources/chromeos/compiled_resources2.gyp
@@ -0,0 +1,23 @@ +# 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. +{ + 'targets': [ + { + 'target_name': 'bluetooth_dialog', + 'dependencies': [ + '<(DEPTH)/ui/webui/resources/cr_elements/cr_dialog/compiled_resources2.gyp:cr_dialog', + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert', + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior', + '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-resizable-behavior/compiled_resources2.gyp:iron-resizable-behavior-extracted', + '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-input/compiled_resources2.gyp:paper-input-extracted', + '<(EXTERNS_GYP):bluetooth', + '<(EXTERNS_GYP):bluetooth_private', + '<(INTERFACES_GYP):bluetooth_interface', + '<(INTERFACES_GYP):bluetooth_private_interface', + ], + 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'], + }, + ], +}
diff --git a/ui/webui/resources/chromeos_elements_resources.grdp b/ui/webui/resources/chromeos_elements_resources.grdp new file mode 100644 index 0000000..a80f926 --- /dev/null +++ b/ui/webui/resources/chromeos_elements_resources.grdp
@@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<grit-part> + <!-- Chrome OS Custom Elements --> + <structure name="IDR_WEBUI_CHROMEOS_BLUETOOTH_DIALOG_HTML" + file="chromeos/bluetooth_dialog.html" + type="chrome_html" /> + <structure name="IDR_WEBUI_CHROMEOS_BLUETOOTH_DIALOG_JS" + file="chromeos/bluetooth_dialog.js" + type="chrome_html" /> +</grit-part>
diff --git a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_list.js b/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_list.js index c3e1236c7..c840537 100644 --- a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_list.js +++ b/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_list.js
@@ -48,7 +48,7 @@ */ profileImageUrl_: { type: String, - value: 'chrome://theme/IDR_LOGIN_DEFAULT_USER', + value: CrPicture.kDefaultImageUrl, }, /** @@ -128,6 +128,12 @@ * @param {number=} imageIndex */ setOldImageUrl(imageUrl, imageIndex) { + if (imageUrl == CrPicture.kDefaultImageUrl || imageIndex === 0) { + // Treat the default image as empty so it does not show in the list. + this.oldImageUrl_ = ''; + this.setSelectedImageUrl(CrPicture.kDefaultImageUrl); + return; + } this.oldImageUrl_ = imageUrl; this.oldImageIndex_ = imageIndex === undefined ? -1 : imageIndex; if (imageUrl) {
diff --git a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_types.js b/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_types.js index 71b0252..b8603989 100644 --- a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_types.js +++ b/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_types.js
@@ -29,3 +29,5 @@ * }} */ CrPicture.ImageElement; + +CrPicture.kDefaultImageUrl = 'chrome://theme/IDR_LOGIN_DEFAULT_USER';
diff --git a/ui/webui/resources/webui_resources.grd b/ui/webui/resources/webui_resources.grd index 24f7ea9c..efa995e 100644 --- a/ui/webui/resources/webui_resources.grd +++ b/ui/webui/resources/webui_resources.grd
@@ -511,6 +511,9 @@ <part file="cr_elements_resources.grdp" /> <part file="polymer_resources.grdp" /> </if> + <if expr="chromeos"> + <part file="chromeos_elements_resources.grdp" /> + </if> </structures> </release> </grit>