diff --git a/DEPS b/DEPS index eadf524..e77d011 100644 --- a/DEPS +++ b/DEPS
@@ -121,7 +121,7 @@ # 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': '5e710e13a55bfd42389427c29e65dfd078e5d4e8', + 'skia_revision': 'faa73875d2c05c27e6b9863381060befdf5b7ea7', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other. @@ -133,11 +133,11 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ANGLE # and whatever else without interference from each other. - 'angle_revision': '9db8df4c3e6e8ae7ec5af3515dbeb3969a3461aa', + 'angle_revision': '5df1d281a992fb221f243d532c70ad0398c9410a', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling build tools # and whatever else without interference from each other. - 'buildtools_revision': '0e1cbc4eab6861b0c84bf2ed9a3c4b7aa2063819', + 'buildtools_revision': '7d88270de197ebe8b439ab5eb57a4a2a0bb810e0', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling SwiftShader # and whatever else without interference from each other. @@ -679,7 +679,7 @@ # Build tools for Chrome OS. Note: This depends on third_party/pyelftools. 'src/third_party/chromite': { - 'url': Var('chromium_git') + '/chromiumos/chromite.git' + '@' + '1457e48474e72375f9fed300a1a826d0b5f02614', + 'url': Var('chromium_git') + '/chromiumos/chromite.git' + '@' + 'ed43a650f0c063e682bab0019ff786498c2347b6', 'condition': 'checkout_linux', }, @@ -1230,7 +1230,7 @@ Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'), 'src-internal': { - 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@fccd9e7db52d5e771aaa6cd97da79264dbee622c', + 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@987044114d9be5160763ecd27d4f0bf69b2ab8be', 'condition': 'checkout_src_internal', },
diff --git a/android_webview/browser/icon_helper.h b/android_webview/browser/icon_helper.h index 194692bb..8bb464d 100644 --- a/android_webview/browser/icon_helper.h +++ b/android_webview/browser/icon_helper.h
@@ -8,6 +8,7 @@ #include <stdint.h> #include <string> +#include <unordered_set> #include "base/containers/hash_tables.h" #include "base/macros.h" @@ -68,7 +69,7 @@ Listener* listener_; typedef uint32_t MissingFaviconURLHash; - base::hash_set<MissingFaviconURLHash> missing_favicon_urls_; + std::unordered_set<MissingFaviconURLHash> missing_favicon_urls_; DISALLOW_COPY_AND_ASSIGN(IconHelper); };
diff --git a/build/config/c++/c++.gni b/build/config/c++/c++.gni index ed179a2..1b94aaa8 100644 --- a/build/config/c++/c++.gni +++ b/build/config/c++/c++.gni
@@ -11,7 +11,7 @@ # Don't check in changes that set this to false for more platforms; doing so # is not supported. use_custom_libcxx = - is_msan || is_fuchsia || is_android || + is_msan || is_fuchsia || (is_linux && (!is_chromeos || default_toolchain != "//build/toolchain/cros:target"))
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc index 16bee16..def5a7c 100644 --- a/cc/trees/layer_tree_host_common.cc +++ b/cc/trees/layer_tree_host_common.cc
@@ -572,9 +572,12 @@ gfx::RectF(gfx::SizeF(inputs->device_viewport_size))); float page_scale_factor_for_root = combine_dsf_and_psf ? inputs->page_scale_factor : 1.f; + // SetRootTransformsAndScales will be incorrect if the root layer has + // non-zero position, so ensure it is zero. + DCHECK(inputs->root_layer->position().IsOrigin()); property_trees->transform_tree.SetRootTransformsAndScales( inputs->device_scale_factor, page_scale_factor_for_root, - inputs->device_transform, inputs->root_layer->position()); + inputs->device_transform); draw_property_utils::UpdatePropertyTreesAndRenderSurfaces( inputs->root_layer, inputs->property_trees, inputs->can_adjust_raster_scales);
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index e23d8e9..b2a7a579 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -2019,7 +2019,6 @@ layer_transform.Translate(1.0, 1.0); root->test_properties()->transform = layer_transform; - root->SetPosition(gfx::PointF(2.5f, 0.f)); root->SetBounds(gfx::Size(10, 10)); root->test_properties()->transform_origin = gfx::Point3F(0.25f, 0.f, 0.f); render_surface1->test_properties()->transform = layer_transform; @@ -2548,23 +2547,6 @@ drawing_layer->drawable_content_rect()); } -TEST_F(LayerTreeHostCommonTest, - VisibleRectsForPositionedRootLayerClippedByViewport) { - LayerImpl* root = root_layer_for_testing(); - - root->SetPosition(gfx::PointF(60, 70)); - root->SetBounds(gfx::Size(100, 100)); - root->SetDrawsContent(true); - ExecuteCalculateDrawProperties(root); - - EXPECT_EQ(gfx::RectF(100.f, 100.f), - GetRenderSurface(root)->DrawableContentRect()); - // In target space, not clipped. - EXPECT_EQ(gfx::Rect(60, 70, 100, 100), root->drawable_content_rect()); - // In layer space, clipped. - EXPECT_EQ(gfx::Rect(40, 30), root->visible_layer_rect()); -} - TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) { LayerImpl* root = root_layer_for_testing(); LayerImpl* child1_layer = AddChildToRoot<LayerImpl>();
diff --git a/cc/trees/layer_tree_impl_unittest.cc b/cc/trees/layer_tree_impl_unittest.cc index 1c35945..2cea29e7 100644 --- a/cc/trees/layer_tree_impl_unittest.cc +++ b/cc/trees/layer_tree_impl_unittest.cc
@@ -288,17 +288,22 @@ TEST_F(LayerTreeImplTest, HitTestingForSinglePositionedLayer) { // This layer is positioned, and hit testing should correctly know where the // layer is located. - LayerImpl* root = root_layer(); - root->SetPosition(gfx::PointF(50.f, 50.f)); - root->SetBounds(gfx::Size(100, 100)); - root->SetDrawsContent(true); + { + std::unique_ptr<LayerImpl> test_layer = + LayerImpl::Create(host_impl().active_tree(), 12345); + test_layer->SetPosition(gfx::PointF(50.f, 50.f)); + test_layer->SetBounds(gfx::Size(100, 100)); + test_layer->SetDrawsContent(true); + root_layer()->test_properties()->AddChild(std::move(test_layer)); + } - host_impl().active_tree()->SetDeviceViewportSize(root->bounds()); + LayerImpl* test_layer = root_layer()->test_properties()->children[0]; + host_impl().active_tree()->SetDeviceViewportSize(test_layer->bounds()); host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_EQ(1u, GetRenderSurfaceList().size()); - ASSERT_EQ(1, GetRenderSurface(root_layer())->num_contributors()); + ASSERT_EQ(1, GetRenderSurface(test_layer)->num_contributors()); // Hit testing for a point outside the layer should return a null pointer. gfx::PointF test_point(49.f, 49.f); @@ -318,13 +323,13 @@ result_layer = host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); ASSERT_TRUE(result_layer); - EXPECT_EQ(root->id(), result_layer->id()); + EXPECT_EQ(test_layer->id(), result_layer->id()); test_point = gfx::PointF(99.f, 99.f); result_layer = host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); ASSERT_TRUE(result_layer); - EXPECT_EQ(root->id(), result_layer->id()); + EXPECT_EQ(test_layer->id(), result_layer->id()); } TEST_F(LayerTreeImplTest, HitTestingForSingleRotatedLayer) { @@ -1352,18 +1357,23 @@ // This layer is positioned, and hit testing should correctly know where the // layer is located. - LayerImpl* root = root_layer(); - root->SetPosition(gfx::PointF(50.f, 50.f)); - root->SetBounds(gfx::Size(100, 100)); - root->SetDrawsContent(true); - root->SetTouchActionRegion(touch_action_region); + { + std::unique_ptr<LayerImpl> test_layer = + LayerImpl::Create(host_impl().active_tree(), 12345); + test_layer->SetPosition(gfx::PointF(50.f, 50.f)); + test_layer->SetBounds(gfx::Size(100, 100)); + test_layer->SetDrawsContent(true); + test_layer->SetTouchActionRegion(touch_action_region); + root_layer()->test_properties()->AddChild(std::move(test_layer)); + } - host_impl().active_tree()->SetDeviceViewportSize(root->bounds()); + LayerImpl* test_layer = root_layer()->test_properties()->children[0]; + host_impl().active_tree()->SetDeviceViewportSize(test_layer->bounds()); host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_EQ(1u, GetRenderSurfaceList().size()); - ASSERT_EQ(1, GetRenderSurface(root)->num_contributors()); + ASSERT_EQ(1, GetRenderSurface(test_layer)->num_contributors()); // Hit checking for a point outside the layer should return a null pointer. gfx::PointF test_point(49.f, 49.f); @@ -1389,20 +1399,20 @@ EXPECT_FALSE(result_layer); // Hit checking for a point inside the touch event handler region should - // return the root layer. + // return the test layer. test_point = gfx::PointF(61.f, 61.f); result_layer = host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( test_point); ASSERT_TRUE(result_layer); - EXPECT_EQ(root->id(), result_layer->id()); + EXPECT_EQ(test_layer->id(), result_layer->id()); test_point = gfx::PointF(99.f, 99.f); result_layer = host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( test_point); ASSERT_TRUE(result_layer); - EXPECT_EQ(root->id(), result_layer->id()); + EXPECT_EQ(test_layer->id(), result_layer->id()); } TEST_F(LayerTreeImplTest,
diff --git a/cc/trees/property_tree.cc b/cc/trees/property_tree.cc index efcce44..1e74c89 100644 --- a/cc/trees/property_tree.cc +++ b/cc/trees/property_tree.cc
@@ -635,8 +635,7 @@ void TransformTree::SetRootTransformsAndScales( float device_scale_factor, float page_scale_factor_for_root, - const gfx::Transform& device_transform, - gfx::PointF root_position) { + const gfx::Transform& device_transform) { gfx::Vector2dF device_transform_scale_components = MathUtil::ComputeTransform2dScaleComponents(device_transform, 1.f); @@ -645,17 +644,14 @@ std::max(device_transform_scale_components.x(), device_transform_scale_components.y()); - // If DT is the device transform, DSF is the matrix scaled by (device scale - // factor * page scale factor for root), RP is the matrix translated by root's - // position, - // Let Screen Space Scale(SSS) = scale component of DT*DSF*RP, - // then the screen space transform of the root transform node is set to SSS - // and the post local transform of the contents root node is set to - // SSS^-1*DT*DSF*RP. + // Let DT be the device transform and DSF be the matrix scaled by (device + // scale factor * page scale factor for root). Let Screen Space Scale(SSS) = + // scale component of DT*DSF. The screen space transform of the root + // transform node is set to SSS and the post local transform of the contents + // root node is set to SSS^-1*DT*DSF. gfx::Transform transform = device_transform; transform.Scale(device_scale_factor * page_scale_factor_for_root, device_scale_factor * page_scale_factor_for_root); - transform.Translate(root_position.x(), root_position.y()); float fallback_value = device_scale_factor * page_scale_factor_for_root; gfx::Vector2dF screen_space_scale = MathUtil::ComputeTransform2dScaleComponents(transform, fallback_value);
diff --git a/cc/trees/property_tree.h b/cc/trees/property_tree.h index d5ae6e7..dcf8cb9 100644 --- a/cc/trees/property_tree.h +++ b/cc/trees/property_tree.h
@@ -189,8 +189,7 @@ void SetRootTransformsAndScales(float device_scale_factor, float page_scale_factor_for_root, - const gfx::Transform& device_transform, - gfx::PointF root_position); + const gfx::Transform& device_transform); float device_transform_scale_factor() const { return device_transform_scale_factor_; }
diff --git a/cc/trees/property_tree_builder.cc b/cc/trees/property_tree_builder.cc index 0bc2da5..674f77f 100644 --- a/cc/trees/property_tree_builder.cc +++ b/cc/trees/property_tree_builder.cc
@@ -537,9 +537,12 @@ if (is_root) { float page_scale_factor_for_root = is_page_scale_layer ? page_scale_factor_ : 1.f; + // SetRootTransformsAndScales will be incorrect if the root layer has + // non-zero position, so ensure it is zero. + DCHECK(layer->position().IsOrigin()); transform_tree_.SetRootTransformsAndScales( transform_tree_.device_scale_factor(), page_scale_factor_for_root, - device_transform_, layer->position()); + device_transform_); } else { node->source_offset = source_offset; node->update_post_local_transform(layer->position(), @@ -1363,9 +1366,11 @@ clip_tree_.SetViewportClip(gfx::RectF(viewport)); float page_scale_factor_for_root = page_scale_is_root_layer ? page_scale_factor_ : 1.f; + // SetRootTransformsAndScales will be incorrect if the root layer has + // non-zero position, so ensure it is zero. + DCHECK(root_layer_->position().IsOrigin()); transform_tree_.SetRootTransformsAndScales( - device_scale_factor, page_scale_factor_for_root, device_transform_, - root_layer_->position()); + device_scale_factor, page_scale_factor_for_root, device_transform_); return; }
diff --git a/cc/trees/property_tree_unittest.cc b/cc/trees/property_tree_unittest.cc index 7935b59..1e0a02a 100644 --- a/cc/trees/property_tree_unittest.cc +++ b/cc/trees/property_tree_unittest.cc
@@ -48,10 +48,10 @@ contents_root.id = tree.Insert(contents_root, 0); EXPECT_FALSE(tree.needs_update()); - tree.SetRootTransformsAndScales(0.6f, 1.f, gfx::Transform(), gfx::PointF()); + tree.SetRootTransformsAndScales(0.6f, 1.f, gfx::Transform()); EXPECT_TRUE(tree.needs_update()); tree.set_needs_update(false); - tree.SetRootTransformsAndScales(0.6f, 1.f, gfx::Transform(), gfx::PointF()); + tree.SetRootTransformsAndScales(0.6f, 1.f, gfx::Transform()); EXPECT_FALSE(tree.needs_update()); }
diff --git a/cc/trees/tree_synchronizer_unittest.cc b/cc/trees/tree_synchronizer_unittest.cc index 547dccae..99b8819c 100644 --- a/cc/trees/tree_synchronizer_unittest.cc +++ b/cc/trees/tree_synchronizer_unittest.cc
@@ -380,8 +380,8 @@ // Pick some random properties to set. The values are not important, we're // just testing that at least some properties are making it through. - gfx::PointF root_position = gfx::PointF(2.3f, 7.4f); - layer_tree_root->SetPosition(root_position); + gfx::Size root_bounds = gfx::Size(10, 12); + layer_tree_root->SetBounds(root_bounds); gfx::Size second_child_bounds = gfx::Size(25, 53); layer_tree_root->children()[1]->SetBounds(second_child_bounds); @@ -400,9 +400,7 @@ // Check that the property values we set on the Layer tree are reflected in // the LayerImpl tree. - gfx::PointF root_layer_impl_position = layer_impl_tree_root->position(); - EXPECT_EQ(root_position.x(), root_layer_impl_position.x()); - EXPECT_EQ(root_position.y(), root_layer_impl_position.y()); + EXPECT_EQ(root_bounds, layer_impl_tree_root->bounds()); gfx::Size second_layer_impl_child_bounds = layer_impl_tree_root->layer_tree_impl()
diff --git a/chrome/VERSION b/chrome/VERSION index 0215fc7..40c71e3 100644 --- a/chrome/VERSION +++ b/chrome/VERSION
@@ -1,4 +1,4 @@ MAJOR=73 MINOR=0 -BUILD=3662 +BUILD=3665 PATCH=0
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java index bfead93..17c8bba 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java
@@ -444,7 +444,8 @@ @Override public OverlayPanelContent createNewOverlayPanelContent() { return new OverlayPanelContent(new OverlayContentDelegate(), - new OverlayContentProgressObserver(), mActivity, getBarHeight()); + new OverlayContentProgressObserver(), mActivity, /* isIncognito= */ false, + getBarHeight()); } /**
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelContent.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelContent.java index cd50879..d3c722d 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelContent.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelContent.java
@@ -95,6 +95,9 @@ // java layer. Otherwise, the instance could be garbage-collected unexpectedly. private InterceptNavigationDelegate mInterceptNavigationDelegate; + /** Set to {@code True} if opened for an incognito tab. */ + private boolean mIsIncognito; + /** The desired size of the {@link ContentView} associated with this panel content. */ private int mContentViewWidth; private int mContentViewHeight; @@ -160,15 +163,17 @@ * for this parameter, the default one will be used. * @param progressObserver An observer for progress related events. * @param activity The ChromeActivity that contains this object. + * @param isIncognito {@True} if opened for an incognito tab * @param barHeight The height of the bar at the top of the OverlayPanel in dp. */ public OverlayPanelContent(OverlayContentDelegate contentDelegate, OverlayContentProgressObserver progressObserver, ChromeActivity activity, - float barHeight) { + boolean isIncognito, float barHeight) { mNativeOverlayPanelContentPtr = nativeInit(); mContentDelegate = contentDelegate; mProgressObserver = progressObserver; mActivity = activity; + mIsIncognito = isIncognito; mBarHeightPx = (int) (barHeight * mActivity.getResources().getDisplayMetrics().density); mWebContentsDelegate = new WebContentsDelegateAndroid() { @@ -296,7 +301,7 @@ } // Creates an initially hidden WebContents which gets shown when the panel is opened. - mWebContents = WebContentsFactory.createWebContents(false, true); + mWebContents = WebContentsFactory.createWebContents(mIsIncognito, true); ContentView cv = ContentView.createContentView(mActivity, mWebContents); if (mContentViewWidth != 0 || mContentViewHeight != 0) {
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java index 53a9dff..ce16837 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java
@@ -115,7 +115,7 @@ @Override public OverlayPanelContent createNewOverlayPanelContent() { return new OverlayPanelContent(mManagementDelegate.getOverlayContentDelegate(), - new PanelProgressObserver(), mActivity, getBarHeight()); + new PanelProgressObserver(), mActivity, /* isIncognito= */ false, getBarHeight()); } // ============================================================================================
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/ephemeraltab/EphemeralTabPanel.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/ephemeraltab/EphemeralTabPanel.java index 28d51f15..e40e1c3 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/ephemeraltab/EphemeralTabPanel.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/ephemeraltab/EphemeralTabPanel.java
@@ -39,6 +39,9 @@ /** Remembers whether the panel was opened beyond the peeking state. */ private boolean mWasPanelOpened; + /** True if the Tab from which the panel is opened is in incognito mode. */ + private boolean mIsIncognito; + /** * Checks if this feature (a.k.a. "Sneak peek") for html and image is supported. * @return {@code true} if the feature is enabled. @@ -76,7 +79,7 @@ @Override public OverlayPanelContent createNewOverlayPanelContent() { return new OverlayPanelContent(new OverlayContentDelegate(), new PanelProgressObserver(), - mActivity, getBarHeight()); + mActivity, mIsIncognito, getBarHeight()); } @Override @@ -169,8 +172,10 @@ * Request opening the ephemeral tab panel when triggered from context menu. * @param url URL of the content to open in the panel * @param text Link text which will appear on the tab bar. + * @param isIncognito {@link True} if the panel is opened from an incognito tab. */ - public void requestOpenPanel(String url, String text) { + public void requestOpenPanel(String url, String text, boolean isIncognito) { + mIsIncognito = isIncognito; loadUrlInPanel(url); WebContents panelWebContents = getWebContents(); if (panelWebContents != null) panelWebContents.onShow();
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/snackbar/smartlockautosignin/AutoSigninSnackbarController.java b/chrome/android/java/src/org/chromium/chrome/browser/snackbar/smartlockautosignin/AutoSigninSnackbarController.java index ee9eb1c..7213ea8a 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/snackbar/smartlockautosignin/AutoSigninSnackbarController.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/snackbar/smartlockautosignin/AutoSigninSnackbarController.java
@@ -35,8 +35,8 @@ */ @CalledByNative private static void showSnackbar(Tab tab, String text) { - SnackbarManager snackbarManager = tab.getSnackbarManager(); - if (snackbarManager == null) return; + if (tab.getActivity() == null) return; + SnackbarManager snackbarManager = tab.getActivity().getSnackbarManager(); AutoSigninSnackbarController snackbarController = new AutoSigninSnackbarController(snackbarManager, tab); Snackbar snackbar = Snackbar.make(text, snackbarController, Snackbar.TYPE_NOTIFICATION,
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java index f2fb0d5..35812eb 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
@@ -76,7 +76,6 @@ import org.chromium.chrome.browser.printing.TabPrinter; import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.rlz.RevenueStats; -import org.chromium.chrome.browser.snackbar.SnackbarManager; import org.chromium.chrome.browser.ssl.SecurityStateModel; import org.chromium.chrome.browser.tab.TabState.WebContentsState; import org.chromium.chrome.browser.tab.TabUma.TabCreationState; @@ -2137,15 +2136,6 @@ } /** - * Returns the SnackbarManager for the activity that owns this Tab, if any. May - * return null. - */ - public SnackbarManager getSnackbarManager() { - if (getActivity() == null) return null; - return getActivity().getSnackbarManager(); - } - - /** * @return The native pointer representing the native side of this {@link Tab} object. */ @CalledByNative @@ -2227,21 +2217,6 @@ } /** - * @return Whether the Tab should be preserved in Android's Recents list when users hit "back". - */ - public boolean shouldPreserve() { - return mShouldPreserve; - } - - /** - * Sets whether the Tab should be preserved in Android's Recents list when users hit "back". - * @param preserve Whether the tab should be preserved. - */ - public void setShouldPreserve(boolean preserve) { - mShouldPreserve = preserve; - } - - /** * @return Whether there are pending {@link LoadUrlParams} associated with the tab. This * indicates the tab was created for lazy load. */
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java index 4497f513..28565f7 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java
@@ -223,7 +223,7 @@ @Override public void onOpenInEphemeralTab(String url, String title) { - mTab.getActivity().getEphemeralTabPanel().requestOpenPanel(url, title); + mTab.getActivity().getEphemeralTabPanel().requestOpenPanel(url, title, mTab.isIncognito()); } @Override
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelEventFilterTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelEventFilterTest.java index 2a1560ec..901137a7 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelEventFilterTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelEventFilterTest.java
@@ -123,7 +123,7 @@ */ private class MockOverlayPanelContent extends OverlayPanelContent { public MockOverlayPanelContent() { - super(null, null, null, 0); + super(null, null, null, false, 0); } @Override
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelManagerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelManagerTest.java index 6bd37a8a..28cf1938 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelManagerTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelManagerTest.java
@@ -109,7 +109,7 @@ */ private static class MockOverlayPanelContent extends OverlayPanelContent { public MockOverlayPanelContent() { - super(null, null, null, 0); + super(null, null, null, false, 0); } @Override
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchFakeServer.java b/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchFakeServer.java index e993be95..35131fb 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchFakeServer.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchFakeServer.java
@@ -386,7 +386,7 @@ OverlayPanelContentWrapper(OverlayContentDelegate contentDelegate, OverlayContentProgressObserver progressObserver, ChromeActivity activity, float barHeight) { - super(contentDelegate, progressObserver, activity, barHeight); + super(contentDelegate, progressObserver, activity, false, barHeight); } @Override
diff --git a/chrome/android/profiles/newest.txt b/chrome/android/profiles/newest.txt index b1d0bed2..b7b9047 100644 --- a/chrome/android/profiles/newest.txt +++ b/chrome/android/profiles/newest.txt
@@ -1 +1 @@ -chromeos-chrome-amd64-73.0.3661.0_rc-r1.afdo.bz2 \ No newline at end of file +chromeos-chrome-amd64-73.0.3663.0_rc-r1.afdo.bz2 \ No newline at end of file
diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp index 574cf98..4f22917d 100644 --- a/chrome/app/settings_strings.grdp +++ b/chrome/app/settings_strings.grdp
@@ -3183,6 +3183,12 @@ <message name="IDS_SETTINGS_SITE_SETTINGS_BLOCK_AUTOPLAY" desc="A label for a toggle in site settings to block autoplay. If the toggle is on then Chrome will block autoplay by default and use an algorithm to determine which sites should still be able to autoplay. If the toggle is off then autoplay will be enabled for all sites."> Let Chrome choose when sites can play sound (recommended) </message> + <message name="IDS_SETTINGS_SITE_SETTINGS_EMPTY_ALL_SITES_PAGE" desc="Explanation shown when there are no sites that have appeared yet on the All Sites page."> + Sites you visit will appear here + </message> + <message name="IDS_SETTINGS_SITE_SETTINGS_NO_SITES_FOUND" desc="Explanation shown when there are no matching search results on All Sites page."> + No sites found + </message> <message name="IDS_SETTINGS_NO_USB_DEVICES_FOUND" desc="Explanation for not showing USB devices in site settings."> No USB devices found
diff --git a/chrome/browser/browsing_data/canonical_cookie_hash.h b/chrome/browser/browsing_data/canonical_cookie_hash.h index 066c388c..e7b9026 100644 --- a/chrome/browser/browsing_data/canonical_cookie_hash.h +++ b/chrome/browser/browsing_data/canonical_cookie_hash.h
@@ -34,9 +34,10 @@ } }; -typedef base::hash_set<net::CanonicalCookie, - CanonicalCookieHasher, - CanonicalCookieComparer> CookieHashSet; +typedef std::unordered_set<net::CanonicalCookie, + CanonicalCookieHasher, + CanonicalCookieComparer> + CookieHashSet; } // namespace canonical_cookie
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 49fb338..9784be9 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc
@@ -4437,6 +4437,40 @@ return logging::GetLogFileName(command_line); } +namespace { +// TODO(jam): move this to a separate file. +class ProtocolHandlerThrottle : public content::URLLoaderThrottle { + public: + explicit ProtocolHandlerThrottle( + const scoped_refptr<ProtocolHandlerRegistry::IOThreadDelegate>& + protocol_handler_registry) + : protocol_handler_registry_(protocol_handler_registry) {} + ~ProtocolHandlerThrottle() override = default; + + void WillStartRequest(network::ResourceRequest* request, + bool* defer) override { + GURL translated_url = protocol_handler_registry_->Translate(request->url); + if (!translated_url.is_empty()) + request->url = translated_url; + } + + void WillRedirectRequest(net::RedirectInfo* redirect_info, + const network::ResourceResponseHead& response_head, + bool* defer, + std::vector<std::string>* to_be_removed_headers, + net::HttpRequestHeaders* modified_headers) override { + GURL translated_url = + protocol_handler_registry_->Translate(redirect_info->new_url); + if (!translated_url.is_empty()) + redirect_info->new_url = translated_url; + } + + private: + scoped_refptr<ProtocolHandlerRegistry::IOThreadDelegate> + protocol_handler_registry_; +}; +} // namespace + std::vector<std::unique_ptr<content::URLLoaderThrottle>> ChromeContentBrowserClient::CreateURLLoaderThrottles( const network::ResourceRequest& request, @@ -4522,6 +4556,11 @@ ->GetClientDataHeader(is_signed_in)}; result.push_back(std::make_unique<GoogleURLLoaderThrottle>( is_off_the_record, std::move(dynamic_params))); + + if (network_service_enabled) { + result.push_back(std::make_unique<ProtocolHandlerThrottle>( + io_data->protocol_handler_registry_io_thread_delegate())); + } } #if BUILDFLAG(ENABLE_PLUGINS)
diff --git a/chrome/browser/chromeos/BUILD.gn b/chrome/browser/chromeos/BUILD.gn index bf38efd..abce227 100644 --- a/chrome/browser/chromeos/BUILD.gn +++ b/chrome/browser/chromeos/BUILD.gn
@@ -1631,6 +1631,8 @@ "power/auto_screen_brightness/als_reader.h", "power/auto_screen_brightness/als_reader_impl.cc", "power/auto_screen_brightness/als_reader_impl.h", + "power/auto_screen_brightness/als_samples.cc", + "power/auto_screen_brightness/als_samples.h", "power/auto_screen_brightness/brightness_monitor.h", "power/auto_screen_brightness/brightness_monitor_impl.cc", "power/auto_screen_brightness/brightness_monitor_impl.h", @@ -2344,6 +2346,7 @@ "policy/user_cloud_policy_token_forwarder_unittest.cc", "power/auto_screen_brightness/adapter_unittest.cc", "power/auto_screen_brightness/als_reader_impl_unittest.cc", + "power/auto_screen_brightness/als_samples_unittest.cc", "power/auto_screen_brightness/brightness_monitor_impl_unittest.cc", "power/auto_screen_brightness/gaussian_trainer_unittest.cc", "power/auto_screen_brightness/metrics_reporter_unittest.cc",
diff --git a/chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge.cc b/chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge.cc index e33b851..e121bd4 100644 --- a/chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge.cc +++ b/chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge.cc
@@ -253,10 +253,12 @@ void ArcAccessibilityHelperBridge::OnAccessibilityEvent( mojom::AccessibilityEventDataPtr event_data) { - // TODO(yawano): Handle AccessibilityFilterType::OFF. arc::mojom::AccessibilityFilterType filter_type = GetFilterTypeForProfile(profile_); + if (filter_type == arc::mojom::AccessibilityFilterType::OFF) + return; + if (filter_type == arc::mojom::AccessibilityFilterType::ALL || filter_type == arc::mojom::AccessibilityFilterType::WHITELISTED_PACKAGE_NAME) { @@ -354,7 +356,7 @@ CHECK_EQ(1U, event_data.get()->node_data.size()); DispatchFocusChange(event_data.get()->node_data[0].get(), profile_); -} // namespace arc +} void ArcAccessibilityHelperBridge::OnNotificationStateChanged( const std::string& notification_key,
diff --git a/chrome/browser/chromeos/file_manager/volume_manager.cc b/chrome/browser/chromeos/file_manager/volume_manager.cc index 710db30..22d20ff 100644 --- a/chrome/browser/chromeos/file_manager/volume_manager.cc +++ b/chrome/browser/chromeos/file_manager/volume_manager.cc
@@ -362,13 +362,15 @@ const base::FilePath& path, VolumeType volume_type, chromeos::DeviceType device_type, - bool read_only) { + bool read_only, + const base::FilePath& device_path) { std::unique_ptr<Volume> volume(new Volume()); volume->type_ = volume_type; volume->device_type_ = device_type; // Keep source_path empty. volume->source_ = SOURCE_DEVICE; volume->mount_path_ = path; + volume->system_path_prefix_ = device_path; volume->mount_condition_ = chromeos::disks::MOUNT_CONDITION_NONE; volume->is_read_only_ = read_only; volume->volume_id_ = GenerateVolumeId(*volume); @@ -638,11 +640,12 @@ void VolumeManager::AddVolumeForTesting(const base::FilePath& path, VolumeType volume_type, chromeos::DeviceType device_type, - bool read_only) { + bool read_only, + const base::FilePath& device_path) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - DoMountEvent( - chromeos::MOUNT_ERROR_NONE, - Volume::CreateForTesting(path, volume_type, device_type, read_only)); + DoMountEvent(chromeos::MOUNT_ERROR_NONE, + Volume::CreateForTesting(path, volume_type, device_type, + read_only, device_path)); } void VolumeManager::AddVolumeForTesting(std::unique_ptr<Volume> volume) {
diff --git a/chrome/browser/chromeos/file_manager/volume_manager.h b/chrome/browser/chromeos/file_manager/volume_manager.h index ae9b8ff..3ec6104 100644 --- a/chrome/browser/chromeos/file_manager/volume_manager.h +++ b/chrome/browser/chromeos/file_manager/volume_manager.h
@@ -112,7 +112,8 @@ const base::FilePath& path, VolumeType volume_type, chromeos::DeviceType device_type, - bool read_only); + bool read_only, + const base::FilePath& device_path); static std::unique_ptr<Volume> CreateForTesting( const base::FilePath& device_path, const base::FilePath& mount_path); @@ -318,10 +319,12 @@ // For testing purpose, adds a volume info pointing to |path|, with TESTING // type. Assumes that the mount point is already registered. - void AddVolumeForTesting(const base::FilePath& path, - VolumeType volume_type, - chromeos::DeviceType device_type, - bool read_only); + void AddVolumeForTesting( + const base::FilePath& path, + VolumeType volume_type, + chromeos::DeviceType device_type, + bool read_only, + const base::FilePath& device_path = base::FilePath()); // For testing purpose, adds the volume info to the volume manager. void AddVolumeForTesting(std::unique_ptr<Volume> volume);
diff --git a/chrome/browser/chromeos/power/auto_screen_brightness/als_samples.cc b/chrome/browser/chromeos/power/auto_screen_brightness/als_samples.cc new file mode 100644 index 0000000..e2c14f5b --- /dev/null +++ b/chrome/browser/chromeos/power/auto_screen_brightness/als_samples.cc
@@ -0,0 +1,64 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/chromeos/power/auto_screen_brightness/als_samples.h" + +#include <numeric> + +#include "base/logging.h" + +namespace chromeos { +namespace power { +namespace auto_screen_brightness { + +AmbientLightSampleBuffer::AmbientLightSampleBuffer(base::TimeDelta horizon) + : horizon_(horizon) { + DCHECK(!horizon_.is_zero()); +} + +AmbientLightSampleBuffer::~AmbientLightSampleBuffer() = default; + +void AmbientLightSampleBuffer::SaveToBuffer( + const AmbientLightSampleBuffer::Sample& sample) { + samples_.push_back(sample); + Prune(sample.sample_time); +} + +base::Optional<double> AmbientLightSampleBuffer::AverageAmbient( + base::TimeTicks now) { + const auto add_lux = [](double lux, const Sample& sample) { + return lux + sample.lux; + }; + + Prune(now); + + if (samples_.empty()) { + return base::nullopt; + } else { + return std::accumulate(samples_.begin(), samples_.end(), 0.0, add_lux) / + samples_.size(); + } +} + +size_t AmbientLightSampleBuffer::NumberOfSamples(base::TimeTicks now) { + Prune(now); + return samples_.size(); +} + +size_t AmbientLightSampleBuffer::NumberOfSamplesForTesting() const { + return samples_.size(); +} + +void AmbientLightSampleBuffer::Prune(base::TimeTicks now) { + while (!samples_.empty()) { + if (now - samples_.front().sample_time < horizon_) + return; + + samples_.pop_front(); + } +} + +} // namespace auto_screen_brightness +} // namespace power +} // namespace chromeos
diff --git a/chrome/browser/chromeos/power/auto_screen_brightness/als_samples.h b/chrome/browser/chromeos/power/auto_screen_brightness/als_samples.h new file mode 100644 index 0000000..ee98d85 --- /dev/null +++ b/chrome/browser/chromeos/power/auto_screen_brightness/als_samples.h
@@ -0,0 +1,61 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_POWER_AUTO_SCREEN_BRIGHTNESS_ALS_SAMPLES_H_ +#define CHROME_BROWSER_CHROMEOS_POWER_AUTO_SCREEN_BRIGHTNESS_ALS_SAMPLES_H_ + +#include <deque> + +#include "base/optional.h" +#include "base/time/time.h" + +namespace chromeos { +namespace power { +namespace auto_screen_brightness { + +// AmbientLightSampleBuffer stores most recent ambient light samples, with +// horizon defined in its ctor. +class AmbientLightSampleBuffer { + public: + struct Sample { + double lux; + base::TimeTicks sample_time; + }; + + // Constructs a buffer that keeps samples younger than |horizon|. |horizon| + // should be greater than 0. + explicit AmbientLightSampleBuffer(base::TimeDelta horizon); + ~AmbientLightSampleBuffer(); + + // Adds |sample| to the buffer and discards samples that are now too old. + // |sample| must be later than any previously added sample. + void SaveToBuffer(const Sample& sample); + + // Returns average ambient lux from the buffer (discarding samples that are + // now too old). |now| must be no earlier than any previously added sample. If + // there are no valid samples, returns nullopt. + base::Optional<double> AverageAmbient(base::TimeTicks now); + + // Returns the number of recorded samples within |horizon| of the last + // observed time point. |now| must be no earlier than any previously added + // sample, and this function will discard old examples. + size_t NumberOfSamples(base::TimeTicks now); + + // Same as |NumberOfSamples| but without pruning. + size_t NumberOfSamplesForTesting() const; + + private: + const base::TimeDelta horizon_; + std::deque<Sample> samples_; + + // Removes samples from |samples_| that have time <= |now| - |horizon_|. + void Prune(base::TimeTicks now); + DISALLOW_COPY_AND_ASSIGN(AmbientLightSampleBuffer); +}; + +} // namespace auto_screen_brightness +} // namespace power +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_POWER_AUTO_SCREEN_BRIGHTNESS_ALS_SAMPLES_H_
diff --git a/chrome/browser/chromeos/power/auto_screen_brightness/als_samples_unittest.cc b/chrome/browser/chromeos/power/auto_screen_brightness/als_samples_unittest.cc new file mode 100644 index 0000000..1ecce941 --- /dev/null +++ b/chrome/browser/chromeos/power/auto_screen_brightness/als_samples_unittest.cc
@@ -0,0 +1,98 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/chromeos/power/auto_screen_brightness/als_samples.h" + +#include <cmath> + +#include "base/logging.h" +#include "base/test/simple_test_tick_clock.h" +#include "base/time/time.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace chromeos { +namespace power { +namespace auto_screen_brightness { + +TEST(AmbientLightSampleBufferTest, Basic) { + base::SimpleTestTickClock tick_clock; + AmbientLightSampleBuffer buffer(base::TimeDelta::FromSeconds(5)); + double sum = 0; + for (int i = 1; i < 6; ++i) { + tick_clock.Advance(base::TimeDelta::FromSeconds(1)); + const AmbientLightSampleBuffer::Sample sample = {i, tick_clock.NowTicks()}; + sum += i; + buffer.SaveToBuffer(sample); + EXPECT_EQ(buffer.NumberOfSamplesForTesting(), static_cast<size_t>(i)); + EXPECT_DOUBLE_EQ(buffer.AverageAmbient(tick_clock.NowTicks()).value(), + sum / i); + EXPECT_EQ(buffer.NumberOfSamplesForTesting(), static_cast<size_t>(i)); + } + + // Add another two items that will push out the oldest. + tick_clock.Advance(base::TimeDelta::FromSeconds(1)); + buffer.SaveToBuffer({10, tick_clock.NowTicks()}); + sum = sum - 1 + 10; + EXPECT_EQ(buffer.NumberOfSamplesForTesting(), 5u); + EXPECT_DOUBLE_EQ(buffer.AverageAmbient(tick_clock.NowTicks()).value(), + sum / 5); + EXPECT_EQ(buffer.NumberOfSamplesForTesting(), 5u); + + tick_clock.Advance(base::TimeDelta::FromSeconds(1)); + buffer.SaveToBuffer({20, tick_clock.NowTicks()}); + sum = sum - 2 + 20; + EXPECT_EQ(buffer.NumberOfSamplesForTesting(), 5u); + EXPECT_DOUBLE_EQ(buffer.AverageAmbient(tick_clock.NowTicks()).value(), + sum / 5); + EXPECT_EQ(buffer.NumberOfSamplesForTesting(), 5u); + + // Add another item but it doesn't push out the oldest. + tick_clock.Advance(base::TimeDelta::FromMilliseconds(1)); + buffer.SaveToBuffer({100, tick_clock.NowTicks()}); + sum += 100; + EXPECT_EQ(buffer.NumberOfSamplesForTesting(), 6u); + EXPECT_DOUBLE_EQ(buffer.AverageAmbient(tick_clock.NowTicks()).value(), + sum / 6); + EXPECT_EQ(buffer.NumberOfSamplesForTesting(), 6u); +} + +TEST(AmbientLightSampleBufferTest, LargeSampleTimeGap) { + base::SimpleTestTickClock tick_clock; + AmbientLightSampleBuffer buffer(base::TimeDelta::FromSeconds(5)); + tick_clock.Advance(base::TimeDelta::FromSeconds(1)); + const AmbientLightSampleBuffer::Sample sample = {10, tick_clock.NowTicks()}; + buffer.SaveToBuffer(sample); + EXPECT_EQ(buffer.NumberOfSamplesForTesting(), 1u); + EXPECT_DOUBLE_EQ(buffer.AverageAmbient(tick_clock.NowTicks()).value(), 10.0); + EXPECT_EQ(buffer.NumberOfSamplesForTesting(), 1u); + + // Another samples arrives sufficiently late so the 1st sample is pushed out. + tick_clock.Advance(base::TimeDelta::FromSeconds(5)); + buffer.SaveToBuffer({20, tick_clock.NowTicks()}); + EXPECT_EQ(buffer.NumberOfSamplesForTesting(), 1u); + EXPECT_DOUBLE_EQ(buffer.AverageAmbient(tick_clock.NowTicks()).value(), 20); + EXPECT_EQ(buffer.NumberOfSamplesForTesting(), 1u); +} + +TEST(AmbientLightSampleBufferTest, AverageTimeTooLate) { + base::SimpleTestTickClock tick_clock; + AmbientLightSampleBuffer buffer(base::TimeDelta::FromSeconds(5)); + tick_clock.Advance(base::TimeDelta::FromSeconds(1)); + const AmbientLightSampleBuffer::Sample sample = {10, tick_clock.NowTicks()}; + buffer.SaveToBuffer(sample); + EXPECT_EQ(buffer.NumberOfSamplesForTesting(), 1u); + EXPECT_DOUBLE_EQ(buffer.AverageAmbient(tick_clock.NowTicks()).value(), 10.0); + EXPECT_EQ(buffer.NumberOfSamplesForTesting(), 1u); + + // When average is calculated, all samples are too old, hence average is + // nullopt. + tick_clock.Advance(base::TimeDelta::FromSeconds(5)); + EXPECT_EQ(buffer.NumberOfSamplesForTesting(), 1u); + EXPECT_FALSE(buffer.AverageAmbient(tick_clock.NowTicks()).has_value()); + EXPECT_EQ(buffer.NumberOfSamplesForTesting(), 0u); +} + +} // namespace auto_screen_brightness +} // namespace power +} // namespace chromeos
diff --git a/chrome/browser/chromeos/power/ml/user_activity_manager.cc b/chrome/browser/chromeos/power/ml/user_activity_manager.cc index f721496..45a02a8 100644 --- a/chrome/browser/chromeos/power/ml/user_activity_manager.cc +++ b/chrome/browser/chromeos/power/ml/user_activity_manager.cc
@@ -607,8 +607,6 @@ } void UserActivityManager::CancelDimDecisionRequest() { - // TODO(crbug.com/893425): Add a unit-test to verify UMA logging of - // cancellation time. LOG(WARNING) << "Cancelling pending Smart Dim decision request."; smart_dim_model_->CancelPreviousRequest(); waiting_for_model_decision_ = false;
diff --git a/chrome/browser/chromeos/power/ml/user_activity_manager_unittest.cc b/chrome/browser/chromeos/power/ml/user_activity_manager_unittest.cc index c91457b2..4db38e47 100644 --- a/chrome/browser/chromeos/power/ml/user_activity_manager_unittest.cc +++ b/chrome/browser/chromeos/power/ml/user_activity_manager_unittest.cc
@@ -955,6 +955,83 @@ EXPECT_TRUE(events.empty()); } +// Tests the cancellation of a Smart Dim decision request, immediately after it +// has been requested. +TEST_F(UserActivityManagerTest, ScreenDimRequestCanceled) { + base::HistogramTester histogram_tester; + const std::map<std::string, std::string> params = { + {"dim_threshold", "0.651"}}; + base::test::ScopedFeatureList scoped_feature_list; + scoped_feature_list.InitAndEnableFeatureWithParameters( + features::kUserActivityPrediction, params); + + model_.set_inactivity_score(60); + model_.set_decision_threshold(65); + + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + // Report user activity immediately after the idle event, so that + // the SmartDimModel doesn't get a chance to run. + ReportUserActivity(nullptr); + thread_bundle()->RunUntilIdle(); + EXPECT_EQ(0, GetNumberOfDeferredDims()); + + std::string hist_complete("PowerML.SmartDimModel.RequestCompleteDuration"); + histogram_tester.ExpectTotalCount(hist_complete, 0); + std::string hist_cancel("PowerML.SmartDimModel.RequestCanceledDuration"); + histogram_tester.ExpectTotalCount(hist_cancel, 1); + + // Since the pending SmartDim decision request was canceled, we shouldn't + // have any UserActivityEvent generated. + const std::vector<UserActivityEvent>& events = delegate_.events(); + ASSERT_EQ(0U, events.size()); +} + +// Tests the cancellation of a Smart Dim decision request, when two idle events +// occur in quick succession. This verifies that only one request is serviced. +TEST_F(UserActivityManagerTest, ScreenDimConsecutiveRequests) { + base::HistogramTester histogram_tester; + const std::map<std::string, std::string> params = { + {"dim_threshold", "0.651"}}; + base::test::ScopedFeatureList scoped_feature_list; + scoped_feature_list.InitAndEnableFeatureWithParameters( + features::kUserActivityPrediction, params); + + model_.set_inactivity_score(60); + model_.set_decision_threshold(65); + + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + ReportIdleEvent(data); + thread_bundle()->RunUntilIdle(); + ReportUserActivity(nullptr); + EXPECT_EQ(1, GetNumberOfDeferredDims()); + + std::string hist_complete("PowerML.SmartDimModel.RequestCompleteDuration"); + histogram_tester.ExpectTotalCount(hist_complete, 1); + std::string hist_cancel("PowerML.SmartDimModel.RequestCanceledDuration"); + histogram_tester.ExpectTotalCount(hist_cancel, 1); + + const std::vector<UserActivityEvent>& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + UserActivityEvent::Event expected_event; + expected_event.set_type(UserActivityEvent::Event::REACTIVATE); + expected_event.set_reason(UserActivityEvent::Event::USER_ACTIVITY); + expected_event.set_log_duration_sec(0); + expected_event.set_screen_dim_occurred(false); + expected_event.set_screen_off_occurred(false); + expected_event.set_screen_lock_occurred(false); + EqualEvent(expected_event, events[0].event()); + + UserActivityEvent::ModelPrediction expected_prediction; + expected_prediction.set_decision_threshold(65); + expected_prediction.set_inactivity_score(60); + expected_prediction.set_model_applied(true); + expected_prediction.set_response(UserActivityEvent::ModelPrediction::NO_DIM); + EqualModelPrediction(expected_prediction, events[0].model_prediction()); +} + TEST_F(UserActivityManagerTest, ScreenDimNotDeferred) { base::HistogramTester histogram_tester; const std::map<std::string, std::string> params = {
diff --git a/chrome/browser/custom_handlers/protocol_handler_registry.cc b/chrome/browser/custom_handlers/protocol_handler_registry.cc index 96aba56..624a440 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry.cc +++ b/chrome/browser/custom_handlers/protocol_handler_registry.cc
@@ -66,55 +66,6 @@ // IOThreadDelegate ------------------------------------------------------------ -// IOThreadDelegate is an IO thread specific object. Access to the class should -// all be done via the IO thread. The registry living on the UI thread makes -// a best effort to update the IO object after local updates are completed. -class ProtocolHandlerRegistry::IOThreadDelegate - : public base::RefCountedThreadSafe< - ProtocolHandlerRegistry::IOThreadDelegate> { - public: - // Creates a new instance. If |enabled| is true the registry is considered - // enabled on the IO thread. - explicit IOThreadDelegate(bool enabled); - - // Returns true if the protocol has a default protocol handler. - // Should be called only from the IO thread. - bool IsHandledProtocol(const std::string& scheme) const; - - // Clears the default for the provided protocol. - // Should be called only from the IO thread. - void ClearDefault(const std::string& scheme); - - // Makes this ProtocolHandler the default handler for its protocol. - // Should be called only from the IO thread. - void SetDefault(const ProtocolHandler& handler); - - // Creates a URL request job for the given request if there is a matching - // protocol handler, returns NULL otherwise. - net::URLRequestJob* MaybeCreateJob( - net::URLRequest* request, net::NetworkDelegate* network_delegate) const; - - // Indicate that the registry has been enabled in the IO thread's - // copy of the data. - void Enable() { enabled_ = true; } - - // Indicate that the registry has been disabled in the IO thread's copy of - // the data. - void Disable() { enabled_ = false; } - - private: - friend class base::RefCountedThreadSafe<IOThreadDelegate>; - virtual ~IOThreadDelegate(); - - // Copy of protocol handlers use only on the IO thread. - ProtocolHandlerRegistry::ProtocolHandlerMap default_handlers_; - - // Is the registry enabled on the IO thread. - bool enabled_; - - DISALLOW_COPY_AND_ASSIGN(IOThreadDelegate); -}; - ProtocolHandlerRegistry::IOThreadDelegate::IOThreadDelegate(bool) : enabled_(true) {} ProtocolHandlerRegistry::IOThreadDelegate::~IOThreadDelegate() {} @@ -138,6 +89,21 @@ default_handlers_.insert(std::make_pair(handler.protocol(), handler)); } +GURL ProtocolHandlerRegistry::IOThreadDelegate::Translate( + const GURL& url) const { + DCHECK_CURRENTLY_ON(BrowserThread::IO); + + ProtocolHandler handler = LookupHandler(default_handlers_, url.scheme()); + if (handler.IsEmpty()) + return GURL(); + + GURL translated_url(handler.TranslateUrl(url)); + if (!translated_url.is_valid()) + return GURL(); + + return translated_url; +} + // Create a new job for the supplied |URLRequest| if a default handler // is registered and the associated handler is able to interpret // the url from |request|. @@ -145,14 +111,9 @@ net::URLRequest* request, net::NetworkDelegate* network_delegate) const { DCHECK_CURRENTLY_ON(BrowserThread::IO); - ProtocolHandler handler = LookupHandler(default_handlers_, - request->url().scheme()); - if (handler.IsEmpty()) - return NULL; - - GURL translated_url(handler.TranslateUrl(request->url())); - if (!translated_url.is_valid()) - return NULL; + GURL translated_url(Translate(request->url())); + if (translated_url.is_empty()) + return nullptr; return new net::URLRequestRedirectJob( request, network_delegate, translated_url, @@ -160,6 +121,16 @@ "Protocol Handler Registry"); } +void ProtocolHandlerRegistry::IOThreadDelegate::Enable() { + DCHECK_CURRENTLY_ON(BrowserThread::IO); + enabled_ = true; +} + +void ProtocolHandlerRegistry::IOThreadDelegate::Disable() { + DCHECK_CURRENTLY_ON(BrowserThread::IO); + enabled_ = false; +} + // JobInterceptorFactory ------------------------------------------------------- // Instances of JobInterceptorFactory are produced for ownership by the IO
diff --git a/chrome/browser/custom_handlers/protocol_handler_registry.h b/chrome/browser/custom_handlers/protocol_handler_registry.h index 378f092..8c9dce7 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry.h +++ b/chrome/browser/custom_handlers/protocol_handler_registry.h
@@ -40,6 +40,10 @@ POLICY, // The handler was installed by policy }; + typedef std::map<std::string, ProtocolHandler> ProtocolHandlerMap; + typedef std::vector<ProtocolHandler> ProtocolHandlerList; + typedef std::map<std::string, ProtocolHandlerList> ProtocolHandlerMultiMap; + // |Delegate| provides an interface for interacting asynchronously // with the underlying OS for the purposes of registering Chrome // as the default handler for specific protocols. @@ -56,8 +60,58 @@ ProtocolHandlerRegistry* registry); }; - // Forward declaration of the internal implementation class. - class IOThreadDelegate; + // IOThreadDelegate is an IO thread specific object. Access to the class + // should all be done via the IO thread. The registry living on the UI thread + // makes a best effort to update the IO object after local updates are + // completed. + class IOThreadDelegate : public base::RefCountedThreadSafe<IOThreadDelegate> { + public: + // Creates a new instance. If |enabled| is true the registry is considered + // enabled on the IO thread. + explicit IOThreadDelegate(bool enabled); + + // Returns true if the protocol has a default protocol handler. + // Should be called only from the IO thread. + bool IsHandledProtocol(const std::string& scheme) const; + + // Clears the default for the provided protocol. + // Should be called only from the IO thread. + void ClearDefault(const std::string& scheme); + + // Makes this ProtocolHandler the default handler for its protocol. + // Should be called only from the IO thread. + void SetDefault(const ProtocolHandler& handler); + + // Returns a translated url if |url| is handled by a protocol handler, + // otherwise it returns an empty URL. + GURL Translate(const GURL& url) const; + + // Creates a URL request job for the given request if there is a matching + // protocol handler, returns NULL otherwise. + net::URLRequestJob* MaybeCreateJob( + net::URLRequest* request, + net::NetworkDelegate* network_delegate) const; + + // Indicate that the registry has been enabled in the IO thread's + // copy of the data. + void Enable(); + + // Indicate that the registry has been disabled in the IO thread's copy of + // the data. + void Disable(); + + private: + friend class base::RefCountedThreadSafe<IOThreadDelegate>; + virtual ~IOThreadDelegate(); + + // Copy of protocol handlers use only on the IO thread. + ProtocolHandlerRegistry::ProtocolHandlerMap default_handlers_; + + // Is the registry enabled on the IO thread. + bool enabled_; + + DISALLOW_COPY_AND_ASSIGN(IOThreadDelegate); + }; // JobInterceptorFactory intercepts URLRequestJob creation for URLRequests the // ProtocolHandlerRegistry is registered to handle. When no handler is @@ -104,10 +158,6 @@ DISALLOW_COPY_AND_ASSIGN(JobInterceptorFactory); }; - typedef std::map<std::string, ProtocolHandler> ProtocolHandlerMap; - typedef std::vector<ProtocolHandler> ProtocolHandlerList; - typedef std::map<std::string, ProtocolHandlerList> ProtocolHandlerMultiMap; - // Creates a new instance. Assumes ownership of |delegate|. ProtocolHandlerRegistry(content::BrowserContext* context, Delegate* delegate); ~ProtocolHandlerRegistry() override; @@ -232,6 +282,10 @@ bool enabled() const { return enabled_; } + scoped_refptr<IOThreadDelegate> io_thread_delegate() { + return io_thread_delegate_; + } + // Add a predefined protocol handler. This has to be called before the first // load command was issued, otherwise the command will be ignored. void AddPredefinedHandler(const ProtocolHandler& handler);
diff --git a/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc b/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc index 8becd7c..3725feac 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc +++ b/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc
@@ -123,4 +123,12 @@ ASSERT_EQ(handler_url, browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); + + // Also check redirects. + GURL redirect_url = + embedded_test_server()->GetURL("/server-redirect?foo:test"); + ui_test_utils::NavigateToURL(browser(), redirect_url); + + ASSERT_EQ(handler_url, + browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); }
diff --git a/chrome/browser/engagement/important_sites_util.cc b/chrome/browser/engagement/important_sites_util.cc index 8dcbecbd..42c046f6 100644 --- a/chrome/browser/engagement/important_sites_util.cc +++ b/chrome/browser/engagement/important_sites_util.cc
@@ -8,6 +8,7 @@ #include <map> #include <memory> #include <set> +#include <unordered_set> #include <utility> #include "base/containers/hash_tables.h" @@ -196,14 +197,15 @@ return a.second.engagement_score > b.second.engagement_score; } -base::hash_set<std::string> GetBlacklistedImportantDomains(Profile* profile) { +std::unordered_set<std::string> GetBlacklistedImportantDomains( + Profile* profile) { ContentSettingsForOneType content_settings_list; HostContentSettingsMap* map = HostContentSettingsMapFactory::GetForProfile(profile); map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_IMPORTANT_SITE_INFO, content_settings::ResourceIdentifier(), &content_settings_list); - base::hash_set<std::string> ignoring_domains; + std::unordered_set<std::string> ignoring_domains; for (const ContentSettingPatternSource& site : content_settings_list) { GURL origin(site.primary_pattern.ToString()); if (!origin.is_valid() || @@ -378,7 +380,7 @@ PopulateInfoMapWithBookmarks(profile, engagement_map, &important_info); - base::hash_set<std::string> blacklisted_domains = + std::unordered_set<std::string> blacklisted_domains = GetBlacklistedImportantDomains(profile); std::vector<std::pair<std::string, ImportantDomainInfo>> items(
diff --git a/chrome/browser/extensions/api/declarative_content/declarative_content_css_condition_tracker.cc b/chrome/browser/extensions/api/declarative_content/declarative_content_css_condition_tracker.cc index a5fb36a..b881b12 100644 --- a/chrome/browser/extensions/api/declarative_content/declarative_content_css_condition_tracker.cc +++ b/chrome/browser/extensions/api/declarative_content/declarative_content_css_condition_tracker.cc
@@ -243,7 +243,7 @@ static_cast<const DeclarativeContentCssPredicate*>(predicate); auto loc = per_web_contents_tracker_.find(tab); DCHECK(loc != per_web_contents_tracker_.end()); - const base::hash_set<std::string>& matching_css_selectors = + const std::unordered_set<std::string>& matching_css_selectors = loc->second->matching_css_selectors(); for (const std::string& predicate_css_selector : typed_predicate->css_selectors()) {
diff --git a/chrome/browser/extensions/api/declarative_content/declarative_content_css_condition_tracker.h b/chrome/browser/extensions/api/declarative_content/declarative_content_css_condition_tracker.h index 028c569f..ad4ef21 100644 --- a/chrome/browser/extensions/api/declarative_content/declarative_content_css_condition_tracker.h +++ b/chrome/browser/extensions/api/declarative_content/declarative_content_css_condition_tracker.h
@@ -9,6 +9,7 @@ #include <memory> #include <set> #include <string> +#include <unordered_set> #include <vector> #include "base/callback.h" @@ -99,7 +100,7 @@ void OnWebContentsNavigation(content::NavigationHandle* navigation_handle); - const base::hash_set<std::string>& matching_css_selectors() const { + const std::unordered_set<std::string>& matching_css_selectors() const { return matching_css_selectors_; } @@ -114,7 +115,7 @@ const WebContentsDestroyedCallback web_contents_destroyed_; // We use a hash_set for maximally efficient lookup. - base::hash_set<std::string> matching_css_selectors_; + std::unordered_set<std::string> matching_css_selectors_; DISALLOW_COPY_AND_ASSIGN(PerWebContentsTracker); };
diff --git a/chrome/browser/extensions/extension_garbage_collector.cc b/chrome/browser/extensions/extension_garbage_collector.cc index 10f1ce42..e3af0c2 100644 --- a/chrome/browser/extensions/extension_garbage_collector.cc +++ b/chrome/browser/extensions/extension_garbage_collector.cc
@@ -7,6 +7,7 @@ #include <stddef.h> #include <memory> +#include <unordered_set> #include <utility> #include "base/bind.h" @@ -221,8 +222,8 @@ return; extension_prefs->SetNeedsStorageGarbageCollection(false); - std::unique_ptr<base::hash_set<base::FilePath>> active_paths( - new base::hash_set<base::FilePath>()); + std::unique_ptr<std::unordered_set<base::FilePath>> active_paths( + new std::unordered_set<base::FilePath>()); std::unique_ptr<ExtensionSet> extensions = ExtensionRegistry::Get(context_)->GenerateInstalledExtensionsSet(); for (ExtensionSet::const_iterator iter = extensions->begin();
diff --git a/chrome/browser/extensions/extension_messages_apitest.cc b/chrome/browser/extensions/extension_messages_apitest.cc index 58ffc47..b307bc1d 100644 --- a/chrome/browser/extensions/extension_messages_apitest.cc +++ b/chrome/browser/extensions/extension_messages_apitest.cc
@@ -66,6 +66,7 @@ #include "extensions/test/test_extension_dir.h" #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/embedded_test_server.h" +#include "services/network/public/cpp/features.h" #include "url/gurl.h" namespace extensions { @@ -1096,6 +1097,9 @@ // that can connect to it, with a TLS channel ID having been generated. IN_PROC_BROWSER_TEST_P(ExternallyConnectableMessagingTest, WebConnectableWithNonEmptyTlsChannelId) { + if (base::FeatureList::IsEnabled(network::features::kNetworkService)) + return; // Channel ID doesn't work with network service. + std::string expected_tls_channel_id_value; bool expect_empty_id = true; @@ -1366,6 +1370,9 @@ // storage partitions. IN_PROC_BROWSER_TEST_P(MessagingApiTest, DifferentStoragePartitionTLSChannelID) { + if (base::FeatureList::IsEnabled(network::features::kNetworkService)) + return; // Channel ID doesn't work with network service. + // Create a platform app (which will have a different storage partition). TestExtensionDir platform_app_dir; platform_app_dir.WriteManifest(
diff --git a/chrome/browser/net/variations_http_headers_browsertest.cc b/chrome/browser/net/variations_http_headers_browsertest.cc index cac1650..66f16b3 100644 --- a/chrome/browser/net/variations_http_headers_browsertest.cc +++ b/chrome/browser/net/variations_http_headers_browsertest.cc
@@ -32,6 +32,7 @@ #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "net/url_request/url_fetcher.h" #include "net/url_request/url_fetcher_delegate.h" +#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/simple_url_loader.h" #include "testing/gtest/include/gtest/gtest.h" @@ -241,6 +242,9 @@ // https://crbug.com/773295 IN_PROC_BROWSER_TEST_F(VariationsHttpHeadersBrowserTest, TestStrippingHeadersFromInternalRequest) { + if (base::FeatureList::IsEnabled(network::features::kNetworkService)) + return; // URLFetcher doesn't work with network service. + BlockingURLFetcherDelegate delegate; GURL url = GetGoogleRedirectUrl1();
diff --git a/chrome/browser/predictors/loading_data_collector.cc b/chrome/browser/predictors/loading_data_collector.cc index dde78ae..3e08a3ad 100644 --- a/chrome/browser/predictors/loading_data_collector.cc +++ b/chrome/browser/predictors/loading_data_collector.cc
@@ -109,7 +109,6 @@ const GURL& url, const content::mojom::CommonNetworkInfoPtr& network_info) { GURL origin = url.GetOrigin(); - DCHECK(origin.is_valid()); if (!origin.is_valid()) return;
diff --git a/chrome/browser/profiles/profile_browsertest.cc b/chrome/browser/profiles/profile_browsertest.cc index ee641bc2..616854e 100644 --- a/chrome/browser/profiles/profile_browsertest.cc +++ b/chrome/browser/profiles/profile_browsertest.cc
@@ -719,6 +719,9 @@ // Verifies that, by default, there's a separate disk cache for media files. // TODO(crbug.com/789657): remove once there is no separate on-disk media cache. IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, SeparateMediaCache) { + if (base::FeatureList::IsEnabled(network::features::kNetworkService)) + return; // Network service doesn't use a separate media cache. + ASSERT_TRUE(embedded_test_server()->Start()); // Do a normal load using the media URLRequestContext, populating the cache.
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index 17cb756a..dedc927d 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc
@@ -368,6 +368,9 @@ ProtocolHandlerRegistryFactory::GetForBrowserContext(profile); DCHECK(protocol_handler_registry); + protocol_handler_registry_io_thread_delegate_ = + protocol_handler_registry->io_thread_delegate(); + // The profile instance is only available here in the InitializeOnUIThread // method, so we create the url job factory here, then save it for // later delivery to the job factory in Init().
diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h index 9114011..33a1d95 100644 --- a/chrome/browser/profiles/profile_io_data.h +++ b/chrome/browser/profiles/profile_io_data.h
@@ -223,6 +223,11 @@ return data_reduction_proxy_io_data_.get(); } + ProtocolHandlerRegistry::IOThreadDelegate* + protocol_handler_registry_io_thread_delegate() const { + return protocol_handler_registry_io_thread_delegate_.get(); + } + // Returns the predictor service for this Profile. Returns nullptr if there is // no Predictor, as is the case with OffTheRecord profiles. virtual chrome_browser_net::Predictor* GetPredictor(); @@ -523,6 +528,9 @@ mutable std::unique_ptr<data_reduction_proxy::DataReductionProxyIOData> data_reduction_proxy_io_data_; + mutable scoped_refptr<ProtocolHandlerRegistry::IOThreadDelegate> + protocol_handler_registry_io_thread_delegate_; + #if defined(OS_CHROMEOS) mutable std::string username_hash_; mutable SystemKeySlotUseType system_key_slot_use_type_;
diff --git a/chrome/browser/resources/app_management/BUILD.gn b/chrome/browser/resources/app_management/BUILD.gn index 639f0d1..f3aaf7f 100644 --- a/chrome/browser/resources/app_management/BUILD.gn +++ b/chrome/browser/resources/app_management/BUILD.gn
@@ -54,7 +54,9 @@ ":router", ":store", ":store_client", + ":types", ":util", + "//chrome/browser/ui/webui/app_management:mojo_bindings_js_externs", ] } @@ -71,6 +73,7 @@ ":fake_page_handler", ":metadata_view", ":permission_view_header", + ":store_client", ] } @@ -110,6 +113,10 @@ } js_library("permission_view_header") { + deps = [ + ":browser_proxy", + ":store_client", + ] } js_library("permission_item") {
diff --git a/chrome/browser/resources/app_management/app.html b/chrome/browser/resources/app_management/app.html index ead7ce65..ffb3901 100644 --- a/chrome/browser/resources/app_management/app.html +++ b/chrome/browser/resources/app_management/app.html
@@ -32,8 +32,10 @@ <template is="dom-if" if="[[pwaPermissionViewSelected_]]"> <app-management-pwa-permission-view></app-management-pwa-permission-view> </template> - <app-management-chrome-app-permission-view> - </app-management-chrome-app-permission-view> + <template is="dom-if" if="[[chromeAppPermissionViewSelected_]]"> + <app-management-chrome-app-permission-view> + </app-management-chrome-app-permission-view> + </template> <app-management-router></app-management-router> </template> <script src="chrome://apps/app.js"></script>
diff --git a/chrome/browser/resources/app_management/app.js b/chrome/browser/resources/app_management/app.js index 19d05a3..74344aa 100644 --- a/chrome/browser/resources/app_management/app.js +++ b/chrome/browser/resources/app_management/app.js
@@ -19,6 +19,11 @@ * @private {boolean} */ pwaPermissionViewSelected_: Boolean, + + /** + * @private {boolean} + */ + chromeAppPermissionViewSelected_: Boolean, }, /** @override */ @@ -27,8 +32,31 @@ return state.currentPage.pageType == PageType.MAIN; }); - this.watch('pwaPermissionViewSelected_', function(state) { - return state.currentPage.pageType == PageType.DETAIL; + this.watch('pwaPermissionViewSelected_', (state) => { + return this.appTypeSelected(state, apps.mojom.AppType.kWeb); }); + + this.watch('chromeAppPermissionViewSelected_', (state) => { + return this.appTypeSelected(state, apps.mojom.AppType.kExtension); + }); + + this.updateFromStore(); }, + + /** + * Returns true if the current page is the detail page of an app of the + * given type. + * @param {AppManagementPageState} state + * @param {apps.mojom.AppType} type + * @return {boolean} + */ + appTypeSelected: function(state, type) { + if (!state.currentPage.selectedAppId) { + return false; + } + + const selectedApp = state.apps[state.currentPage.selectedAppId]; + return state.currentPage.pageType == PageType.DETAIL && + selectedApp.type == type; + } });
diff --git a/chrome/browser/resources/app_management/browser_proxy.js b/chrome/browser/resources/app_management/browser_proxy.js index 0e887df..4e24225 100644 --- a/chrome/browser/resources/app_management/browser_proxy.js +++ b/chrome/browser/resources/app_management/browser_proxy.js
@@ -22,7 +22,7 @@ 'ahfgeienlihckogmohjhadlkjgocpleb'), app_management.FakePageHandler.createApp( 'aohghmighlieiainnegkcijnfilokake', - {type: apps.mojom.AppType.kArc}), + {type: apps.mojom.AppType.kExtension}), app_management.FakePageHandler.createApp( 'blpcfgokakmgnkcojhhkbfbldkacnbeo'), app_management.FakePageHandler.createApp(
diff --git a/chrome/browser/resources/app_management/chrome_app_permission_view.html b/chrome/browser/resources/app_management/chrome_app_permission_view.html index ea78140..140ff527 100644 --- a/chrome/browser/resources/app_management/chrome_app_permission_view.html +++ b/chrome/browser/resources/app_management/chrome_app_permission_view.html
@@ -1,13 +1,13 @@ <link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="shared_style.html"> -<link rel="import" href="shared_style.html"> +<link rel="import" href="store_client.html"> +<link rel="import" href="util.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html"> <dom-module id="app-management-chrome-app-permission-view"> <template> <style include="app-management-shared-css"> - </style> <app-management-permission-view-header app="[[app_]]"> </app-management-permission-view-header>
diff --git a/chrome/browser/resources/app_management/chrome_app_permission_view.js b/chrome/browser/resources/app_management/chrome_app_permission_view.js index 896d1d7..70b8678 100644 --- a/chrome/browser/resources/app_management/chrome_app_permission_view.js +++ b/chrome/browser/resources/app_management/chrome_app_permission_view.js
@@ -4,17 +4,34 @@ Polymer({ is: 'app-management-chrome-app-permission-view', + behaviors: [ + app_management.StoreClient, + ], + properties: { /** - * @type {appManagement.mojom.App} - * @private + * @private {App} */ - app_: { - type: Object, - value: function() { - return app_management.FakePageHandler.createApp( - 'ahfgeienlihckogmohjhadlkjgocpleb'); - }, - }, + app_: Object, + }, + + attached: function() { + this.watch('app_', function(state) { + const selectedAppId = state.currentPage.selectedAppId; + if (selectedAppId) { + return state.apps[selectedAppId]; + } + }); + + this.updateFromStore(); + }, + + /** + * @param {App} app + * @return {string} + * @private + */ + iconUrlFromId_: function(app) { + return app_management.util.getAppIcon(app); }, });
diff --git a/chrome/browser/resources/app_management/fake_page_handler.js b/chrome/browser/resources/app_management/fake_page_handler.js index a86724c..63795be 100644 --- a/chrome/browser/resources/app_management/fake_page_handler.js +++ b/chrome/browser/resources/app_management/fake_page_handler.js
@@ -25,7 +25,7 @@ const app = { id: id, - type: apps.mojom.AppType.kUnknown, + type: apps.mojom.AppType.kWeb, title: 'App Title', version: '5.1', size: '9.0MB',
diff --git a/chrome/browser/resources/app_management/permission_view_header.html b/chrome/browser/resources/app_management/permission_view_header.html index f502bbf1..e5073f23 100644 --- a/chrome/browser/resources/app_management/permission_view_header.html +++ b/chrome/browser/resources/app_management/permission_view_header.html
@@ -29,14 +29,16 @@ text-overflow: ellipsis; } </style> - <paper-icon-button-light class="icon-arrow-back"> - <button><paper-ripple class="circle"></paper-ripple></button> + <button id="closeButton" on-click="onClickBackButton_" + aria-label="$i18n{back}"> + <paper-ripple class="circle"></paper-ripple> + </button> </paper-icon-button-light> <img id="permission-view-header-icon" src="[[iconUrlFromId_(app)]]"> <div id="app-title">[[app.title]]</div> <slot name="extra-right-buttons"></slot> - <paper-button> + <paper-button on-click="onClickUninstallButton_"> $i18n{uninstall} </paper-button> </template>
diff --git a/chrome/browser/resources/app_management/permission_view_header.js b/chrome/browser/resources/app_management/permission_view_header.js index b60b8f0d..823f146 100644 --- a/chrome/browser/resources/app_management/permission_view_header.js +++ b/chrome/browser/resources/app_management/permission_view_header.js
@@ -4,6 +4,10 @@ Polymer({ is: 'app-management-permission-view-header', + behaviors: [ + app_management.StoreClient, + ], + properties: { /** @type {App} */ app: { @@ -12,6 +16,20 @@ }, /** + * @private + */ + onClickBackButton_: function() { + this.dispatch(app_management.actions.changePage(PageType.MAIN)); + }, + + /** + * @private + */ + onClickUninstallButton_: function() { + app_management.BrowserProxy.getInstance().handler.uninstall(this.app.id); + }, + + /** * @param {App} app * @return {string} * @private
diff --git a/chrome/browser/resources/app_management/pwa_permission_view.js b/chrome/browser/resources/app_management/pwa_permission_view.js index 48bd4cb..587beb8 100644 --- a/chrome/browser/resources/app_management/pwa_permission_view.js +++ b/chrome/browser/resources/app_management/pwa_permission_view.js
@@ -37,21 +37,6 @@ /** * @private */ - onClickBackButton_: function() { - this.listExpanded_ = false; - this.dispatch(app_management.actions.changePage(PageType.MAIN)); - }, - - /** - * @private - */ - onClickUninstallButton_: function() { - app_management.BrowserProxy.getInstance().handler.uninstall(this.app_.id); - }, - - /** - * @private - */ toggleListExpanded_: function() { this.listExpanded_ = !this.listExpanded_; },
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs index 970d4cc..ecbaa8f 100644 --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs
@@ -1369,11 +1369,11 @@ }); }); -// Failing consistently, please see https://crbug.com/857382 -TEST_F('ChromeVoxBackgroundTest', 'DISABLED_TextSelectionAndLiveRegion', function() { +TEST_F('ChromeVoxBackgroundTest', 'TextSelectionAndLiveRegion', function() { DesktopAutomationHandler.announceActions = true; var mockFeedback = this.createMockFeedback(); this.runWithLoadedTree(function(root) {/*! + <p>start</p> <div><input value="test" type="text"></input></div> <div id="live" aria-live="assertive"></div> <script> @@ -1383,11 +1383,13 @@ div.addEventListener('click', function() { clicks++; if (clicks == 1) { + live.textContent = 'go'; + } else if (clicks == 2) { input.selectionStart = 1; live.textContent = 'queued'; } else { - live.textContent = 'interrupted'; input.selectionStart = 2; + live.textContent = 'interrupted'; } }); </script> @@ -1397,12 +1399,15 @@ mockFeedback.call(textField.focus.bind(textField)) .expectSpeech('Edit text') .call(div.doDefault.bind(div)) - .expectSpeechWithQueueMode('e', cvox.QueueMode.FLUSH) - .expectSpeechWithQueueMode('queued', cvox.QueueMode.CATEGORY_FLUSH) + .expectSpeechWithQueueMode('go', cvox.QueueMode.CATEGORY_FLUSH) .call(div.doDefault.bind(div)) - .expectSpeechWithQueueMode('interrupted', cvox.QueueMode.QUEUE) + .expectSpeechWithQueueMode('e', cvox.QueueMode.FLUSH) + .expectSpeechWithQueueMode('queued', cvox.QueueMode.QUEUE) + + .call(div.doDefault.bind(div)) .expectSpeechWithQueueMode('s', cvox.QueueMode.FLUSH) + .expectSpeechWithQueueMode('interrupted', cvox.QueueMode.QUEUE) .replay(); });
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js index eeeb708..9bfe601 100644 --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js
@@ -702,6 +702,13 @@ return this.value.length; }, + /** @override */ + changed: function(evt) { + // This path does not use the Output module to synthesize speech. + Output.forceModeForNextSpeechUtterance(undefined); + cvox.ChromeVoxEditableTextBase.prototype.changed.call(this, evt); + }, + /** * @private * @param {editing.EditableLine} cur Current line.
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/live_regions.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/live_regions.js index 09b67ba..5e283ddc 100644 --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/live_regions.js +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/live_regions.js
@@ -87,8 +87,10 @@ onTreeChange: function(treeChange) { var type = treeChange.type; var node = treeChange.target; - if (!node.containerLiveStatus && type != TreeChangeType.SUBTREE_UPDATE_END) + if ((!node.containerLiveStatus || node.containerLiveStatus == 'off') && + type != TreeChangeType.SUBTREE_UPDATE_END) { return; + } var currentRange = this.chromeVoxState_.currentRange; @@ -140,11 +142,15 @@ * @private */ processQueuedTreeChanges_: function() { + // Schedule all live regions after all events in the native C++ EventBundle. this.liveRegionNodeSet_ = new WeakSet(); - this.changedNodes_.forEach(function(node) { - this.outputLiveRegionChange_(node, null); - }.bind(this)); - this.changedNodes_ = []; + setTimeout(function() { + for (var i = 0; i < this.changedNodes_.length; i++) { + var node = this.changedNodes_[i]; + this.outputLiveRegionChange_(node, null); + } + this.changedNodes_ = []; + }.bind(this), 0); }, /**
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/live_regions_test.extjs b/chrome/browser/resources/chromeos/chromevox/cvox2/background/live_regions_test.extjs index fd26ae0..592fbe8 100644 --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/live_regions_test.extjs +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/live_regions_test.extjs
@@ -167,8 +167,7 @@ function(rootNode) { var go = rootNode.find({ role: RoleType.BUTTON }); mockFeedback.call(go.doDefault.bind(go)) - .expectCategoryFlushSpeech('After') - .expectQueuedSpeech('Image'); + .expectCategoryFlushSpeech('After'); mockFeedback.replay(); }); }); @@ -295,7 +294,9 @@ var live = new LiveRegions(ChromeVoxState.instance); var t1, t2; [t1, t2] = root.findAll({role: RoleType.STATIC_TEXT}); - mockFeedback.call(function() { + mockFeedback.expectSpeech('hello there') + .clearPendingOutput() + .call(function() { live.onTreeChange({type: TreeChangeType.TEXT_CHANGED, target: t2}); live.onTreeChange({type: TreeChangeType.SUBTREE_UPDATE_END, target: t2}); }) @@ -312,3 +313,39 @@ mockFeedback.replay(); }); }); + +TEST_F('ChromeVoxLiveRegionsTest', 'LiveStatusOff', function() { + var mockFeedback = this.createMockFeedback(); + this.runWithLoadedTree(function() {/*! + <div><input aria-live="off" type="text"></input></div> + <script> + var input = document.querySelector('input'); + var div = document.querySelector('div'); + var clicks = 0; + div.addEventListener('click', () => { + clicks++; + if (clicks == 1) { + input.value = 'bb'; + input.selectionStart = 2; + input.selectionEnd = 2; + } else if (clicks == 2) { + input.value = 'bba'; + input.selectionStart = 3; + input.selectionEnd = 3; + } + }); + </script> + */}, + function(root) { + var input = root.find({role: RoleType.TEXT_FIELD}); + var clickInput = input.parent.doDefault.bind(input.parent); + mockFeedback.call(input.focus.bind(input)) + .call(clickInput) + .expectSpeech('bb') + .clearPendingOutput() + .call(clickInput) + .expectNextSpeechUtteranceIsNot('bba') + .expectSpeech('a') + .replay(); + }); +});
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js index 331455c..1b1de4f 100644 --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js
@@ -708,7 +708,7 @@ * Calling this will make the next speech utterance use |mode| even if it would * normally queue or do a category flush. This differs from the |withQueueMode| * instance method as it can apply to future output. - * @param {cvox.QueueMode} mode + * @param {cvox.QueueMode|undefined} mode */ Output.forceModeForNextSpeechUtterance = function(mode) { Output.forceModeForNextSpeechUtterance_ = mode;
diff --git a/chrome/browser/resources/settings/printing_page/printing_page.html b/chrome/browser/resources/settings/printing_page/printing_page.html index 10e4104d..df8f0b3 100644 --- a/chrome/browser/resources/settings/printing_page/printing_page.html +++ b/chrome/browser/resources/settings/printing_page/printing_page.html
@@ -20,30 +20,26 @@ focus-config="[[focusConfig_]]"> <div route-path="default"> <if expr="chromeos"> - <div id="cupsPrinters" class="settings-box first" - on-click="onTapCupsPrinters_" actionable> - <div class="start">$i18n{cupsPrintersTitle}</div> - <paper-icon-button-light class="subpage-arrow"> - <button aria-label="$i18n{cupsPrintersTitle}"></button> - </paper-icon-button-light> - </div> + <cr-link-row + icon-class="subpage-arrow" + id="cupsPrinters" + label="$i18n{cupsPrintersTitle}" + on-click="onTapCupsPrinters_"> + </cr-link-row> </if> <if expr="not chromeos"> - <div class="settings-box first" - on-click="onTapLocalPrinters_" actionable> - <div class="start">$i18n{localPrintersTitle}</div> - <paper-icon-button-light class="subpage-arrow"> - <button aria-label="$i18n{localPrintersTitle}"></button> - </paper-icon-button-light> - </div> + <cr-link-row + icon-class="subpage-arrow" + label="$i18n{localPrintersTitle}" + on-click="onTapLocalPrinters_"> + </cr-link-row> </if> - <div id="cloudPrinters" class="settings-box" - on-click="onTapCloudPrinters_" actionable> - <div class="start">$i18n{cloudPrintersTitle}</div> - <paper-icon-button-light class="subpage-arrow"> - <button aria-label="$i18n{cloudPrintersTitle}"></button> - </paper-icon-button-light> - </div> + <cr-link-row + icon-class="subpage-arrow" + id="cloudPrinters" + label="$i18n{cloudPrintersTitle}" + on-click="onTapCloudPrinters_"> + </cr-link-row> </div> <if expr="chromeos"> <template is="dom-if" route-path="/cupsPrinters">
diff --git a/chrome/browser/resources/settings/printing_page/printing_page.js b/chrome/browser/resources/settings/printing_page/printing_page.js index 652eb30..8bdd69e 100644 --- a/chrome/browser/resources/settings/printing_page/printing_page.js +++ b/chrome/browser/resources/settings/printing_page/printing_page.js
@@ -22,15 +22,11 @@ value: function() { const map = new Map(); if (settings.routes.CLOUD_PRINTERS) { - map.set( - settings.routes.CLOUD_PRINTERS.path, - '#cloudPrinters .subpage-arrow button'); + map.set(settings.routes.CLOUD_PRINTERS.path, '#cloudPrinters'); } // <if expr="chromeos"> if (settings.routes.CUPS_PRINTERS) { - map.set( - settings.routes.CUPS_PRINTERS.path, - '#cupsPrinters .subpage-arrow button'); + map.set(settings.routes.CUPS_PRINTERS.path, '#cupsPrinters'); } // </if> return map;
diff --git a/chrome/browser/resources/settings/reset_page/reset_page.html b/chrome/browser/resources/settings/reset_page/reset_page.html index 5b28d42..2910641 100644 --- a/chrome/browser/resources/settings/reset_page/reset_page.html +++ b/chrome/browser/resources/settings/reset_page/reset_page.html
@@ -24,14 +24,12 @@ <style include="settings-shared"></style> <settings-animated-pages id="reset-pages" section="reset"> <div route-path="default"> - <div class="settings-box first" id="resetProfile" - on-click="onShowResetProfileDialog_" actionable> - <div id="resetProfileTrigger" class="start">$i18n{resetTrigger}</div> - <paper-icon-button-light class="subpage-arrow"> - <button id="resetProfileArrow" aria-label="$i18n{resetTrigger}" - aria-describedby="resetProfileTrigger"></button> - </paper-icon-button-light> - </div> + <cr-link-row + icon-class="subpage-arrow" + id="resetProfile" + label="$i18n{resetTrigger}" + on-click="onShowResetProfileDialog_"> + </cr-link-row> <!-- Keep a single instance of reset-profile-dialog on purpose, to preserve state across show/hide operations. --> <cr-lazy-render id="resetProfileDialog"> @@ -42,46 +40,36 @@ </template> </cr-lazy-render> <if expr="chromeos"> - <div class="settings-box two-line" id="powerwash" actionable - on-click="onShowPowerwashDialog_" hidden="[[!allowPowerwash_]]"> - <div class="start"> - $i18n{powerwashTitle} - <div class="secondary" id="powerwashSecondary"> - $i18n{powerwashDescription} - </div> - </div> - <paper-icon-button-light class="subpage-arrow"> - <button id="powerwashArrow" aria-label="$i18n{powerwashTitle}" - aria-describedby="powerwashSecondary"></button> - </paper-icon-button-light> - </div> + <cr-link-row + class="hr" + hidden="[[!allowPowerwash_]]" + icon-class="subpage-arrow" + id="powerwash" + label="$i18n{powerwashTitle}" + on-click="onShowPowerwashDialog_" + sub-label="$i18n{powerwashDescription}"> + </cr-link-row> <template is="dom-if" if="[[showPowerwashDialog_]]" restamp> <settings-powerwash-dialog on-close="onPowerwashDialogClose_"> </settings-powerwash-dialog> </template> </if> <if expr="_google_chrome and is_win"> - <div class="settings-box" id="chromeCleanupSubpageTrigger" - on-click="onChromeCleanupTap_" actionable> - <div class="start">$i18n{resetCleanupComputerTrigger}</div> - <paper-icon-button-light class="subpage-arrow"> - <button id="chromeCleanupArrow" - aria-label="$i18n{resetCleanupComputerTrigger}"></button> - </paper-icon-button-light> - </div> + <cr-link-row + class="hr" + icon-class="subpage-arrow" + id="chromeCleanupSubpageTrigger" + label="$i18n{resetCleanupComputerTrigger}" + on-click="onChromeCleanupTap_"> + </cr-link-row> <template is="dom-if" if="[[showIncompatibleApplications_]]" restamp> - <div class="settings-box" + <cr-link-row + class="hr" + icon-class="subpage-arrow" id="incompatibleApplicationsSubpageTrigger" - on-click="onIncompatibleApplicationsTap_" actionable> - <div class="start"> - $i18n{incompatibleApplicationsResetCardTitle} - </div> - <paper-icon-button-light class="subpage-arrow"> - <button - aria-label="$i18n{incompatibleApplicationsResetCardTitle}" - aria-describedby="incompatibleApplicationsSecondary"></button> - </paper-icon-button-light> - </div> + label="$i18n{incompatibleApplicationsResetCardTitle}" + on-click="onIncompatibleApplicationsTap_"> + </cr-link-row> </template> </if> </div>
diff --git a/chrome/browser/resources/settings/reset_page/reset_page.js b/chrome/browser/resources/settings/reset_page/reset_page.js index 62f8f87..22cf6ae 100644 --- a/chrome/browser/resources/settings/reset_page/reset_page.js +++ b/chrome/browser/resources/settings/reset_page/reset_page.js
@@ -77,7 +77,7 @@ /** @private */ onResetProfileDialogClose_: function() { settings.navigateToPreviousRoute(); - cr.ui.focusWithoutInk(assert(this.$.resetProfileArrow)); + cr.ui.focusWithoutInk(assert(this.$.resetProfile)); }, // <if expr="chromeos"> @@ -93,7 +93,7 @@ /** @private */ onPowerwashDialogClose_: function() { this.showPowerwashDialog_ = false; - cr.ui.focusWithoutInk(assert(this.$.powerwashArrow)); + cr.ui.focusWithoutInk(assert(this.$.powerwash)); }, // </if>
diff --git a/chrome/browser/resources/settings/site_settings/all_sites.html b/chrome/browser/resources/settings/site_settings/all_sites.html index 9f07761..f6ec471 100644 --- a/chrome/browser/resources/settings/site_settings/all_sites.html +++ b/chrome/browser/resources/settings/site_settings/all_sites.html
@@ -52,12 +52,15 @@ </select> </div> </div> - <div class="list-frame" hidden$="[[siteGroupMap.size]]"> - <div class="list-item secondary">$i18n{noSitesAdded}</div> + <div class="list-frame" hidden$="[[!siteGroupMapEmpty_(siteGroupMap)]]"> + <div class="list-item secondary">$i18n{emptyAllSitesPage}</div> + </div> + <div class="list-frame" hidden$="[[!noSearchResultFound_(filteredList_)]]"> + <div class="list-item secondary">$i18n{noSitesFound}</div> </div> <div class="list-frame without-heading" id="listContainer"> <iron-list id="allSitesList" - items="[[filterPopulatedList_(siteGroupMap, searchQuery_)]]" + items="[[filteredList_]]" scroll-target="[[subpageScrollTarget]]"> <template> <site-entry site-group="[[item]]" list-index="[[index]]"
diff --git a/chrome/browser/resources/settings/site_settings/all_sites.js b/chrome/browser/resources/settings/site_settings/all_sites.js index d4e8003..8d73343 100644 --- a/chrome/browser/resources/settings/site_settings/all_sites.js +++ b/chrome/browser/resources/settings/site_settings/all_sites.js
@@ -28,6 +28,16 @@ value: function() { return new Map(); }, + observer: 'forceListUpdate_', + }, + + /** + * Filtered site group list. + * @type {!Array<SiteGroup>} + * @private + */ + filteredList_: { + type: Array, }, /** @@ -48,6 +58,7 @@ searchQuery_: { type: String, value: '', + observer: 'forceListUpdate_', }, /** @@ -136,10 +147,13 @@ } this.browserProxy.getAllSites(contentTypes).then((response) => { + // Create a new map to make an observable change. + const newMap = /** @type {!Map<string, !SiteGroup>} */ + (new Map(this.siteGroupMap)); response.forEach(siteGroup => { - this.siteGroupMap.set(siteGroup.etldPlus1, siteGroup); + newMap.set(siteGroup.etldPlus1, siteGroup); }); - this.forceListUpdate_(); + this.siteGroupMap = newMap; }); }, @@ -149,9 +163,12 @@ * @param {!Array<!SiteGroup>} list The list of sites using local storage. */ onLocalStorageListFetched: function(list) { + // Create a new map to make an observable change. + const newMap = /** @type {!Map<string, !SiteGroup>} */ + (new Map(this.siteGroupMap)); list.forEach(storageSiteGroup => { - if (this.siteGroupMap.has(storageSiteGroup.etldPlus1)) { - const siteGroup = this.siteGroupMap.get(storageSiteGroup.etldPlus1); + if (newMap.has(storageSiteGroup.etldPlus1)) { + const siteGroup = newMap.get(storageSiteGroup.etldPlus1); const storageOriginInfoMap = new Map(); storageSiteGroup.origins.forEach( originInfo => @@ -170,10 +187,10 @@ storageOriginInfoMap.forEach( originInfo => siteGroup.origins.push(originInfo)); } else { - this.siteGroupMap.set(storageSiteGroup.etldPlus1, storageSiteGroup); + newMap.set(storageSiteGroup.etldPlus1, storageSiteGroup); } }); - this.forceListUpdate_(); + this.siteGroupMap = newMap; }, /** @@ -305,8 +322,8 @@ * @private */ onSortMethodChanged_: function() { - this.$.allSitesList.items = - this.sortSiteGroupList_(this.$.allSitesList.items); + this.filteredList_ = + this.sortSiteGroupList_(this.filteredList_); // Force the iron-list to rerender its items, as the order has changed. this.$.allSitesList.fire('iron-resize'); }, @@ -317,7 +334,7 @@ * @private */ forceListUpdate_: function() { - this.$.allSitesList.items = + this.filteredList_ = this.filterPopulatedList_(this.siteGroupMap, this.searchQuery_); this.$.allSitesList.fire('iron-resize'); }, @@ -355,4 +372,23 @@ this.focusConfig.set( settings.routes.SITE_SETTINGS_SITE_DETAILS.path, onNavigatedTo); }, + + /** + * Whether the |siteGroupMap| is empty. + * @return {boolean} + * @private + */ + siteGroupMapEmpty_: function() { + return !this.siteGroupMap.size; + }, + + /** + * Whether the |filteredList_| is empty due to searching. + * @return {boolean} + * @private + */ + noSearchResultFound_: function() { + return !this.filteredList_.length && !this.siteGroupMapEmpty_(); + } + });
diff --git a/chrome/browser/resources/welcome/OWNERS b/chrome/browser/resources/welcome/onboarding_welcome/OWNERS similarity index 100% rename from chrome/browser/resources/welcome/OWNERS rename to chrome/browser/resources/welcome/onboarding_welcome/OWNERS
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/shared/BUILD.gn b/chrome/browser/resources/welcome/onboarding_welcome/shared/BUILD.gn index 31e4036..f78a437 100644 --- a/chrome/browser/resources/welcome/onboarding_welcome/shared/BUILD.gn +++ b/chrome/browser/resources/welcome/onboarding_welcome/shared/BUILD.gn
@@ -20,6 +20,7 @@ "//third_party/polymer/v1_0/components-chromium/iron-a11y-announcer:iron-a11y-announcer-extracted", "//ui/webui/resources/js:cr", "//ui/webui/resources/js:i18n_behavior", + "//ui/webui/resources/js:util", ] }
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/shared/app_chooser.html b/chrome/browser/resources/welcome/onboarding_welcome/shared/app_chooser.html index a3359d4..fda46964 100644 --- a/chrome/browser/resources/welcome/onboarding_welcome/shared/app_chooser.html +++ b/chrome/browser/resources/welcome/onboarding_welcome/shared/app_chooser.html
@@ -5,6 +5,7 @@ <link rel="import" href="chrome://resources/cr_elements/shared_vars_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/html/util.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-a11y-announcer/iron-a11y-announcer.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/shared/app_chooser.js b/chrome/browser/resources/welcome/onboarding_welcome/shared/app_chooser.js index 01e2f053..8d5f377b 100644 --- a/chrome/browser/resources/welcome/onboarding_welcome/shared/app_chooser.js +++ b/chrome/browser/resources/welcome/onboarding_welcome/shared/app_chooser.js
@@ -24,6 +24,8 @@ */ nux.AppItemModel; +const KEYBOARD_FOCUSED = 'keyboard-focused'; + Polymer({ is: 'app-chooser', @@ -111,6 +113,36 @@ }, /** + * @param {EventTarget} element + * @param {number} direction + * @private + */ + changeFocus_: function(element, direction) { + if (isRTL()) { + direction *= -1; // Reverse direction if RTL. + } + + const buttons = this.root.querySelectorAll('button'); + const targetIndex = Array.prototype.indexOf.call(buttons, element); + + const oldFocus = buttons[targetIndex]; + if (!oldFocus) { + return; + } + + const newFocus = buttons[targetIndex + direction]; + + // New target and we're changing direction. + if (newFocus && direction) { + newFocus.classList.add(KEYBOARD_FOCUSED); + oldFocus.classList.remove(KEYBOARD_FOCUSED); + newFocus.focus(); + } else { + oldFocus.classList.add(KEYBOARD_FOCUSED); + } + }, + + /** * Called when bookmarks should be removed for all selected apps. * @private */ @@ -181,7 +213,13 @@ * @private */ onAppKeyUp_: function(e) { - e.currentTarget.classList.add('keyboard-focused'); + if (e.key == 'ArrowRight') { + this.changeFocus_(e.currentTarget, 1); + } else if (e.key == 'ArrowLeft') { + this.changeFocus_(e.currentTarget, -1); + } else { + this.changeFocus_(e.currentTarget, 0); + } }, /** @@ -189,7 +227,7 @@ * @private */ onAppPointerDown_: function(e) { - e.currentTarget.classList.remove('keyboard-focused'); + e.currentTarget.classList.remove(KEYBOARD_FOCUSED); }, /** @private */
diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database.cc b/chrome/browser/sync_file_system/drive_backend/metadata_database.cc index a83bcce..d31d9cd 100644 --- a/chrome/browser/sync_file_system/drive_backend/metadata_database.cc +++ b/chrome/browser/sync_file_system/drive_backend/metadata_database.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h" #include <algorithm> +#include <unordered_set> #include <utility> #include "base/bind.h" @@ -336,7 +337,7 @@ } // Remove trackers in the reversed order. - base::hash_set<std::string> affected_file_ids; + std::unordered_set<std::string> affected_file_ids; for (auto itr = to_be_removed.rbegin(); itr != to_be_removed.rend(); ++itr) { FileTracker tracker; index->GetFileTracker(*itr, &tracker); @@ -989,8 +990,8 @@ return SYNC_STATUS_FAILED; } - base::hash_set<std::string> children(child_file_ids.begin(), - child_file_ids.end()); + std::unordered_set<std::string> children(child_file_ids.begin(), + child_file_ids.end()); std::vector<int64_t> known_children = index_->GetFileTrackerIDsByParent(folder_tracker->tracker_id());
diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_index.cc b/chrome/browser/sync_file_system/drive_backend/metadata_database_index.cc index 30adec6c..ca536cf 100644 --- a/chrome/browser/sync_file_system/drive_backend/metadata_database_index.cc +++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_index.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index.h" #include <tuple> +#include <unordered_set> #include <utility> #include "base/memory/ptr_util.h" @@ -180,7 +181,7 @@ contents->file_trackers = std::move(reachable_trackers); // List all |file_id| referred by a tracker. - base::hash_set<std::string> referred_file_ids; + std::unordered_set<std::string> referred_file_ids; for (size_t i = 0; i < contents->file_trackers.size(); ++i) referred_file_ids.insert(contents->file_trackers[i]->file_id());
diff --git a/chrome/browser/ui/libgtkui/x11_input_method_context_impl_gtk.h b/chrome/browser/ui/libgtkui/x11_input_method_context_impl_gtk.h index 5431b643..81d5df8 100644 --- a/chrome/browser/ui/libgtkui/x11_input_method_context_impl_gtk.h +++ b/chrome/browser/ui/libgtkui/x11_input_method_context_impl_gtk.h
@@ -5,6 +5,7 @@ #ifndef CHROME_BROWSER_UI_LIBGTKUI_X11_INPUT_METHOD_CONTEXT_IMPL_GTK_H_ #define CHROME_BROWSER_UI_LIBGTKUI_X11_INPUT_METHOD_CONTEXT_IMPL_GTK_H_ +#include <unordered_set> #include <vector> #include "base/containers/hash_tables.h" @@ -98,7 +99,7 @@ gfx::Rect last_caret_bounds_; // A set of hardware keycodes of modifier keys. - base::hash_set<unsigned int> modifier_keycodes_; + std::unordered_set<unsigned int> modifier_keycodes_; // A list of keycodes of each modifier key. std::vector<int> meta_keycodes_;
diff --git a/chrome/browser/ui/media_router/query_result_manager.cc b/chrome/browser/ui/media_router/query_result_manager.cc index f8bb0ed..1240e051 100644 --- a/chrome/browser/ui/media_router/query_result_manager.cc +++ b/chrome/browser/ui/media_router/query_result_manager.cc
@@ -4,6 +4,7 @@ #include "chrome/browser/ui/media_router/query_result_manager.h" +#include <unordered_set> #include <utility> #include "base/containers/hash_tables.h" @@ -169,7 +170,7 @@ MediaCastMode cast_mode, const MediaSource& source, const std::vector<MediaSink>& new_sinks) { - base::hash_set<MediaSink::Id> new_sink_ids; + std::unordered_set<MediaSink::Id> new_sink_ids; for (const MediaSink& sink : new_sinks) new_sink_ids.insert(sink.id());
diff --git a/chrome/browser/ui/omnibox/omnibox_theme.cc b/chrome/browser/ui/omnibox/omnibox_theme.cc index ce80ecc1..e36270e 100644 --- a/chrome/browser/ui/omnibox/omnibox_theme.cc +++ b/chrome/browser/ui/omnibox/omnibox_theme.cc
@@ -78,17 +78,20 @@ return dark ? gfx::kGoogleGrey100 : gfx::kGoogleBlue600; case OmniboxPart::LOCATION_BAR_FOCUS_RING: return dark ? gfx::kGoogleBlueDark600 : gfx::kGoogleBlue600; - case OmniboxPart::RESULTS_BACKGROUND: - // The spec calls for transparent black (or white) overlays for hover (8%) - // and select (6%), which can overlap (for 14%). Pre-blend these with the - // background for the best text AA result. + case OmniboxPart::RESULTS_BACKGROUND: { // High contrast mode needs a darker base - Grey 800 with 14% white // overlaid on it (see below) is hard to produce good contrast ratios // against with colors other than white. + const SkColor dark_base_color = + high_contrast ? gfx::kGoogleGrey900 : gfx::kGoogleGrey800; + const SkColor base_color = dark ? dark_base_color : SK_ColorWHITE; + // The spec calls for transparent black (or white) overlays for hover (8%) + // and select (6%), which can overlap (for 14%). Pre-blend these with the + // background for the best text AA result. return color_utils::BlendTowardOppositeLuma( - dark ? (high_contrast ? gfx::kGoogleGrey900 : gfx::kGoogleGrey800) - : SK_ColorWHITE, - gfx::ToRoundedInt(GetOmniboxStateAlpha(state) * 0xff)); + base_color, + gfx::ToRoundedInt(GetOmniboxStateOpacity(state) * SK_AlphaOPAQUE)); + } case OmniboxPart::LOCATION_BAR_CLEAR_ALL: case OmniboxPart::LOCATION_BAR_TEXT_DEFAULT: case OmniboxPart::RESULTS_TEXT_DEFAULT: @@ -147,7 +150,7 @@ return GetOmniboxColor(OmniboxPart::LOCATION_BAR_SECURITY_CHIP, tint, state); } -float GetOmniboxStateAlpha(OmniboxPartState state) { +float GetOmniboxStateOpacity(OmniboxPartState state) { switch (state) { case OmniboxPartState::NORMAL: return 0; @@ -156,8 +159,8 @@ case OmniboxPartState::SELECTED: return 0.06f; case OmniboxPartState::HOVERED_AND_SELECTED: - return GetOmniboxStateAlpha(OmniboxPartState::HOVERED) + - GetOmniboxStateAlpha(OmniboxPartState::SELECTED); + return GetOmniboxStateOpacity(OmniboxPartState::HOVERED) + + GetOmniboxStateOpacity(OmniboxPartState::SELECTED); default: NOTREACHED(); return 0;
diff --git a/chrome/browser/ui/omnibox/omnibox_theme.h b/chrome/browser/ui/omnibox/omnibox_theme.h index 5c8625b..3790fa4 100644 --- a/chrome/browser/ui/omnibox/omnibox_theme.h +++ b/chrome/browser/ui/omnibox/omnibox_theme.h
@@ -59,6 +59,6 @@ OmniboxTint tint, security_state::SecurityLevel security_level); -float GetOmniboxStateAlpha(OmniboxPartState state); +float GetOmniboxStateOpacity(OmniboxPartState state); #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_THEME_H_
diff --git a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc index 308cd34..b9c65fd 100644 --- a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc +++ b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc
@@ -139,7 +139,7 @@ AddChildView(ink_drop_container_); ink_drop_container_->SetVisible(false); set_ink_drop_visible_opacity( - GetOmniboxStateAlpha(OmniboxPartState::SELECTED)); + GetOmniboxStateOpacity(OmniboxPartState::SELECTED)); UpdateBorder(); @@ -333,7 +333,7 @@ gfx::RectF(ink_drop_container_->bounds()).CenterPoint(), ink_drop_container_->size()); highlight->set_visible_opacity( - GetOmniboxStateAlpha(OmniboxPartState::HOVERED)); + GetOmniboxStateOpacity(OmniboxPartState::HOVERED)); return highlight; }
diff --git a/chrome/browser/ui/views/page_action/page_action_icon_view.cc b/chrome/browser/ui/views/page_action/page_action_icon_view.cc index b03d190..c2bb86c 100644 --- a/chrome/browser/ui/views/page_action/page_action_icon_view.cc +++ b/chrome/browser/ui/views/page_action/page_action_icon_view.cc
@@ -51,7 +51,7 @@ active_(false), suppress_mouse_released_action_(false) { set_ink_drop_visible_opacity( - GetOmniboxStateAlpha(OmniboxPartState::SELECTED)); + GetOmniboxStateOpacity(OmniboxPartState::SELECTED)); } PageActionIconView::~PageActionIconView() {} @@ -193,7 +193,7 @@ gfx::RectF(GetMirroredRect(GetContentsBounds())).CenterPoint(), size()); highlight->set_visible_opacity( - GetOmniboxStateAlpha(OmniboxPartState::HOVERED)); + GetOmniboxStateOpacity(OmniboxPartState::HOVERED)); return highlight; }
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc index 26542e8..a7d7d3c 100644 --- a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc +++ b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
@@ -356,7 +356,6 @@ ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(tab_1_center) && ui_test_utils::SendMouseEventsSync( ui_controls::LEFT, ui_controls::DOWN)); - gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); TestDesktopBrowserFrameAura* frame = static_cast<TestDesktopBrowserFrameAura*>( BrowserView::GetBrowserViewForBrowser(browser())->GetWidget()-> @@ -364,7 +363,8 @@ // Invoke ReleaseCaptureOnDrag() so that when the drag happens and focus // changes capture is released and the drag cancels. frame->ReleaseCaptureOnNextClear(); - ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(tab_0_center)); + ASSERT_TRUE(ui_test_utils::SendMouseMoveSync( + GetCenterInScreenCoordinates(tab_strip->tab_at(0)))); EXPECT_FALSE(tab_strip->IsDragSessionActive()); } @@ -592,9 +592,9 @@ const gfx::Point tab_0_center = GetCenterInScreenCoordinates(tab_strip->tab_at(tab)); ASSERT_TRUE(PressInput(tab_0_center)); - const gfx::Point target = - tab_0_center + gfx::Vector2d(drag_x_offset, GetDetachY(tab_strip)); - ASSERT_TRUE(DragInputToNotifyWhenDone(target, std::move(task))); + ASSERT_TRUE(DragInputToNotifyWhenDone( + tab_0_center + gfx::Vector2d(drag_x_offset, GetDetachY(tab_strip)), + std::move(task))); QuitWhenNotDragging(); } @@ -622,10 +622,8 @@ TabStrip* tab_strip = GetTabStripForBrowser(browser()); TabStripModel* model = browser()->tab_strip_model(); - gfx::Point tab_1_center(GetCenterInScreenCoordinates(tab_strip->tab_at(1))); - ASSERT_TRUE(PressInput(tab_1_center)); - gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); - ASSERT_TRUE(DragInputTo(tab_0_center)); + ASSERT_TRUE(PressInput(GetCenterInScreenCoordinates(tab_strip->tab_at(1)))); + ASSERT_TRUE(DragInputTo(GetCenterInScreenCoordinates(tab_strip->tab_at(0)))); // Test that the dragging info is correctly set on |tab_strip|. EXPECT_TRUE(IsTabDraggingInfoSet(tab_strip, tab_strip)); ASSERT_TRUE(ReleaseInput()); @@ -679,10 +677,8 @@ TabStrip* tab_strip = GetTabStripForBrowser(browser()); TabStripModel* model = browser()->tab_strip_model(); - gfx::Point tab_1_center(GetCenterInScreenCoordinates(tab_strip->tab_at(1))); - ASSERT_TRUE(PressInput(tab_1_center)); - gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); - ASSERT_TRUE(DragInputTo(tab_0_center)); + ASSERT_TRUE(PressInput(GetCenterInScreenCoordinates(tab_strip->tab_at(1)))); + ASSERT_TRUE(DragInputTo(GetCenterInScreenCoordinates(tab_strip->tab_at(0)))); ASSERT_TRUE(ReleaseInput()); EXPECT_EQ("1 0", IDString(model)); EXPECT_FALSE(TabDragController::IsActive()); @@ -1220,10 +1216,10 @@ EXPECT_EQ("0 1 2 3", IDString(browser()->tab_strip_model())); // Click the first tab and select two middle tabs. - gfx::Point tab_1_center(GetCenterInScreenCoordinates(tab_strip->tab_at(1))); - ASSERT_TRUE(PressInput(tab_1_center)); + ASSERT_TRUE(PressInput(GetCenterInScreenCoordinates(tab_strip->tab_at(1)))); ASSERT_TRUE(ReleaseInput()); browser()->tab_strip_model()->ToggleSelectionAt(2); + // Press mouse button in the second tab and drag it enough to detach. DragTabAndNotify( tab_strip, base::BindOnce(&CloseTabsWhileDetachedStep2, browser_list), 2); @@ -1332,19 +1328,16 @@ // Invoked from the nested run loop. void DragAllToSeparateWindowStep2(DetachToBrowserTabDragControllerTest* test, TabStrip* attached_tab_strip, - TabStrip* target_tab_strip, - const BrowserList* browser_list) { + TabStrip* target_tab_strip) { ASSERT_TRUE(attached_tab_strip->IsDragSessionActive()); ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); ASSERT_TRUE(TabDragController::IsActive()); - ASSERT_EQ(2u, browser_list->size()); + ASSERT_EQ(2u, test->browser_list->size()); // Drag to target_tab_strip. This should stop the nested loop from dragging // the window. - gfx::Point target_point(target_tab_strip->width() / 2, - target_tab_strip->height() / 2); - views::View::ConvertPointToScreen(target_tab_strip, &target_point); - ASSERT_TRUE(test->DragInputToAsync(target_point)); + ASSERT_TRUE( + test->DragInputToAsync(GetCenterInScreenCoordinates(target_tab_strip))); } } // namespace @@ -1365,9 +1358,8 @@ // Move to the first tab and drag it enough so that it detaches, but not // enough that it attaches to browser2. - DragTabAndNotify( - tab_strip, base::BindOnce(&DragAllToSeparateWindowStep2, this, tab_strip, - tab_strip2, browser_list)); + DragTabAndNotify(tab_strip, base::BindOnce(&DragAllToSeparateWindowStep2, + this, tab_strip, tab_strip2)); // Should now be attached to tab_strip2. ASSERT_TRUE(tab_strip2->IsDragSessionActive()); @@ -1401,10 +1393,8 @@ // Drag to target_tab_strip. This should stop the nested loop from dragging // the window. - gfx::Point target_point(target_tab_strip->width() / 2, - target_tab_strip->height() / 2); - views::View::ConvertPointToScreen(target_tab_strip, &target_point); - ASSERT_TRUE(test->DragInputToAsync(target_point)); + ASSERT_TRUE( + test->DragInputToAsync(GetCenterInScreenCoordinates(target_tab_strip))); } } // namespace @@ -1532,9 +1522,8 @@ // Move to the first tab and drag it enough so that it detaches, but not // enough that it attaches to browser2. - DragTabAndNotify( - tab_strip, base::BindOnce(&DragAllToSeparateWindowStep2, this, tab_strip, - tab_strip2, browser_list)); + DragTabAndNotify(tab_strip, base::BindOnce(&DragAllToSeparateWindowStep2, + this, tab_strip, tab_strip2)); // Should now be attached to tab_strip2. ASSERT_TRUE(tab_strip2->IsDragSessionActive()); @@ -1586,8 +1575,8 @@ AddTabAndResetBrowser(browser()); // Move to the first tab and drag it enough so that it detaches. - gfx::Point tab_0_center( - GetCenterInScreenCoordinates(tab_strip->tab_at(0))); + const gfx::Point tab_0_center = + GetCenterInScreenCoordinates(tab_strip->tab_at(0)); ASSERT_TRUE(PressInput(tab_0_center)); // Add another tab. This should trigger exiting the nested loop. Add at the @@ -1598,7 +1587,7 @@ content::NotificationService::AllSources()); ASSERT_TRUE(DragInputToNotifyWhenDone( tab_0_center + gfx::Vector2d(0, GetDetachY(tab_strip)), - base::Bind(&CancelOnNewTabWhenDraggingStep2, this, browser_list))); + base::BindOnce(&CancelOnNewTabWhenDraggingStep2, this, browser_list))); observer.Wait(); // Should be two windows and not dragging. @@ -1680,7 +1669,7 @@ ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); ASSERT_TRUE(TabDragController::IsActive()); - // And there should be three browser windows, incluing the newly created one + // And there should be three browser windows, including the newly created one // for the dragged tab. EXPECT_EQ(3u, test->browser_list->size()); @@ -1689,10 +1678,8 @@ ->SetProperty(ash::kIsShowingInOverviewKey, true); // Drag to target_tab_strip. - gfx::Point target_point(target_tab_strip->width() / 2, - target_tab_strip->height() / 2); - views::View::ConvertPointToScreen(target_tab_strip, &target_point); - ASSERT_TRUE(test->DragInputTo(target_point)); + ASSERT_TRUE( + test->DragInputTo(GetCenterInScreenCoordinates(target_tab_strip))); // Test that the dragged tab did not attach to the overview window. EXPECT_EQ(3u, test->browser_list->size()); @@ -1820,7 +1807,7 @@ // another browser's tabstrip. test_->MoveInputTo(end_point_); - // Change window's bounds to simulate what might happend in ash. If + // Change window's bounds to simulate what might happened in ash. If // TabDragController is still an observer of the dragged tabstrip's // widget, OnWidgetBoundsChanged() will calls into ContinueDragging() // to attach the dragged tabstrip into another browser, which might @@ -1870,11 +1857,10 @@ EXPECT_EQ(2u, browser_list->size()); // Create an window observer to observe the dragged window. - gfx::Point target_point(tab_strip2->bounds().CenterPoint()); - views::View::ConvertPointToScreen(tab_strip2, &target_point); std::unique_ptr<DraggedWindowObserver> observer(new DraggedWindowObserver( this, test::GetWindowForTabStrip(tab_strip), - tab_strip2->GetWidget()->GetNativeWindow()->bounds(), target_point)); + tab_strip2->GetWidget()->GetNativeWindow()->bounds(), + GetCenterInScreenCoordinates(tab_strip2))); // Drag the tab long enough so that it moves. DragTabAndNotify(tab_strip, @@ -1896,7 +1882,7 @@ TabStrip* target_tab_strip) { ASSERT_TRUE(TabDragController::IsActive()); - // There should be three browser windows, incluing the newly created one for + // There should be three browser windows, including the newly created one for // the dragged tab. EXPECT_EQ(3u, test->browser_list->size()); // Get this new created window and set it to non-attachable. @@ -1905,10 +1891,8 @@ ->SetProperty(ash::kCanAttachToAnotherWindowKey, false); // Now drag to target_tab_strip. - gfx::Point target_point(target_tab_strip->width() / 2, - target_tab_strip->height() / 2); - views::View::ConvertPointToScreen(target_tab_strip, &target_point); - ASSERT_TRUE(test->DragInputTo(target_point)); + ASSERT_TRUE( + test->DragInputTo(GetCenterInScreenCoordinates(target_tab_strip))); ASSERT_TRUE(test->ReleaseInput()); } @@ -1948,7 +1932,7 @@ ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); ASSERT_TRUE(TabDragController::IsActive()); - // And there should be three browser windows, incluing the newly created one + // And there should be three browser windows, including the newly created one // for the dragged tab. EXPECT_EQ(3u, test->browser_list->size()); @@ -1957,10 +1941,8 @@ ->SetProperty(ash::kIsShowingInOverviewKey, true); // Drag to target_tab_strip. - gfx::Point target_point(target_tab_strip->width() / 2, - target_tab_strip->height() / 2); - views::View::ConvertPointToScreen(target_tab_strip, &target_point); - ASSERT_TRUE(test->DragInputTo(target_point)); + ASSERT_TRUE( + test->DragInputTo(GetCenterInScreenCoordinates(target_tab_strip))); // At this point, |target_tab_strip| should be the deferred target tabstip. // Theoratically the dragged tabstrip will merge into |target_tab_strip| after @@ -2016,7 +1998,7 @@ void FastResizeDuringDraggingStep2(DetachToBrowserTabDragControllerTest* test, TabStrip* not_attached_tab_strip, TabStrip* target_tab_strip) { - // There should be three browser windows, incluing the newly created one for + // There should be three browser windows, including the newly created one for // the dragged tab. EXPECT_EQ(3u, test->browser_list->size()); @@ -2027,10 +2009,8 @@ EXPECT_TRUE(WebContentsIsFastResized(test->browser())); // Now drag to target_tab_strip. - gfx::Point target_point(target_tab_strip->width() / 2, - target_tab_strip->height() / 2); - views::View::ConvertPointToScreen(target_tab_strip, &target_point); - ASSERT_TRUE(test->DragInputTo(target_point)); + ASSERT_TRUE( + test->DragInputTo(GetCenterInScreenCoordinates(target_tab_strip))); ASSERT_TRUE(test->ReleaseInput()); } @@ -2155,7 +2135,8 @@ const gfx::Point& target_point) { ASSERT_TRUE(test->DragInputToNotifyWhenDone( target_point, - base::Bind(&DragSingleTabToSeparateWindowInSecondDisplayStep3, test))); + base::BindOnce(&DragSingleTabToSeparateWindowInSecondDisplayStep3, + test))); } } // namespace @@ -2324,9 +2305,8 @@ // warp. ASSERT_TRUE(DragInputToNotifyWhenDone( gfx::Point(first_display_warp_edge_x, detach_y), - base::BindRepeating( - &DragSingleTabToSeparateWindowInSecondDisplayStep2, this, - warped_point))); + base::BindOnce(&DragSingleTabToSeparateWindowInSecondDisplayStep2, + this, warped_point))); })); // Should no longer be dragging. @@ -2365,7 +2345,7 @@ browser()->window()->SetBounds(work_area); work_area.set_x(work_area.right()); browser2->window()->SetBounds(work_area); - // Wait for the display changes. See the ealier comments for the details. + // Wait for the display changes. See the earlier comments for the details. aura::test::WaitForAllChangesToComplete(); EXPECT_EQ( second_display.id(), @@ -2482,7 +2462,7 @@ display::Screen* screen = display::Screen::GetScreen(); const std::pair<Display, Display> displays = GetDisplays(screen); browser2->window()->SetBounds(displays.second.work_area()); - // Wait for the display changes. See the ealier comments for the details. + // Wait for the display changes. See the earlier comments for the details. aura::test::WaitForAllChangesToComplete(); EXPECT_EQ( displays.second.id(), @@ -2578,12 +2558,8 @@ // The expected device scale factors after the cursor is moved to the // corresponding kDragPoints in CursorDeviceScaleFactorStep. -const float kDeviceScaleFactorExpectations[] = { - 1.0f, - 1.0f, - 2.0f, - 2.0f, - 1.0f, +constexpr float kDeviceScaleFactorExpectations[] = { + 1.0f, 1.0f, 2.0f, 2.0f, 1.0f, }; static_assert( @@ -2609,12 +2585,12 @@ if (index < base::size(kDragPoints)) { ASSERT_TRUE(test->DragInputToNotifyWhenDone( - kDragPoints[index], base::Bind(&CursorDeviceScaleFactorStep, test, - not_attached_tab_strip, index + 1))); + kDragPoints[index], base::BindOnce(&CursorDeviceScaleFactorStep, test, + not_attached_tab_strip, index + 1))); } else { // Finishes a series of CursorDeviceScaleFactorStep calls and ends drag. - ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( - ui_controls::LEFT, ui_controls::UP)); + ASSERT_TRUE( + ui_test_utils::SendMouseEventsSync(ui_controls::LEFT, ui_controls::UP)); } } @@ -2642,8 +2618,6 @@ tab_strip, 0)); } -namespace { - class DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest : public DetachToBrowserTabDragControllerTest { public: @@ -2652,7 +2626,7 @@ void SetUpCommandLine(base::CommandLine* command_line) override { DetachToBrowserTabDragControllerTest::SetUpCommandLine(command_line); command_line->AppendSwitchASCII("ash-host-window-bounds", - "0+0-250x250,251+0-250x250"); + "0+0-250x250,250+0-250x250"); } private: @@ -2660,6 +2634,8 @@ DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest); }; +namespace { + // Invoked from the nested run loop. void CancelDragTabToWindowInSeparateDisplayStep3( TabStrip* tab_strip, @@ -2728,8 +2704,8 @@ EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); // Release the mouse - ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( - ui_controls::LEFT, ui_controls::UP)); + ASSERT_TRUE( + ui_test_utils::SendMouseEventsSync(ui_controls::LEFT, ui_controls::UP)); } // Drags from browser from a second display to primary and releases input. @@ -2750,7 +2726,7 @@ .id()); browser()->window()->SetBounds(displays.second.work_area()); - // Wait for the display changes. See the ealier comments for the details. + // Wait for the display changes. See the earlier comments for the details. aura::test::WaitForAllChangesToComplete(); EXPECT_EQ( displays.second.id(), @@ -2773,8 +2749,8 @@ EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); // Release the mouse - ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( - ui_controls::LEFT, ui_controls::UP)); + ASSERT_TRUE( + ui_test_utils::SendMouseEventsSync(ui_controls::LEFT, ui_controls::UP)); } // Subclass of DetachToBrowserTabDragControllerTest that runs tests only with @@ -2811,7 +2787,7 @@ ASSERT_TRUE(test->PressInput(gfx::Point(), 1)); ASSERT_TRUE(test->DragInputToNotifyWhenDone( target_point, - base::Bind(&PressSecondFingerWhileDetachedStep3, test))); + base::BindOnce(&PressSecondFingerWhileDetachedStep3, test))); } } // namespace @@ -2870,9 +2846,8 @@ ->SetProperty(ash::kIsShowingInOverviewKey, true); // Drag to |target_tab_strip|. - gfx::Point target_point(target_tab_strip->width() / 2, - target_tab_strip->height() / 2); - views::View::ConvertPointToScreen(target_tab_strip, &target_point); + const gfx::Point target_point = + GetCenterInScreenCoordinates(target_tab_strip); ASSERT_TRUE(test->DragInputTo(target_point)); // Now add a second finger to tap on it. @@ -2928,7 +2903,7 @@ // Drag the tab 1 to left-snapping. DragTabAndNotify( tab_strip, base::BindLambdaForTesting([&]() { - gfx::Rect display_bounds = + const gfx::Rect display_bounds = display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); const gfx::Point target(display_bounds.x(), display_bounds.CenterPoint().y()); @@ -2951,7 +2926,8 @@ ui::GestureConfiguration::GetInstance()->set_min_fling_velocity(1); TabStrip* tab_strip = GetTabStripForBrowser(browser()); - gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); + const gfx::Point tab_0_center = + GetCenterInScreenCoordinates(tab_strip->tab_at(0)); const gfx::Vector2d detach(0, GetDetachY(tab_strip)); base::SimpleTestTickClock clock; clock.SetNowTicks(base::TimeTicks::Now());
diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc index 54ea15c..68acd643 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.cc +++ b/chrome/browser/ui/views/tabs/tab_strip.cc
@@ -1336,10 +1336,9 @@ // Returns the accessible tab name for the tab. base::string16 TabStrip::GetAccessibleTabName(const Tab* tab) const { - int model_index = GetModelIndexOfTab(tab); - if (IsValidModelIndex(model_index)) - return controller_->GetAccessibleTabName(tab); - return base::string16(); + const int model_index = GetModelIndexOfTab(tab); + return IsValidModelIndex(model_index) ? controller_->GetAccessibleTabName(tab) + : base::string16(); } int TabStrip::GetBackgroundResourceId( @@ -2298,47 +2297,40 @@ if (!controller_) return; - const SkColor active_tab_bg_color = GetTabBackgroundColor(TAB_ACTIVE); - const SkColor inactive_tab_bg_color = GetTabBackgroundColor(TAB_INACTIVE); + const SkColor inactive_bg = GetTabBackgroundColor(TAB_INACTIVE); + const auto get_alpha = [inactive_bg](SkColor target, float contrast) { + return color_utils::GetBlendValueWithMinimumContrast(inactive_bg, target, + inactive_bg, contrast); + }; + + const SkColor active_bg = GetTabBackgroundColor(TAB_ACTIVE); + const auto get_hover_opacity = [active_bg, &get_alpha](float contrast) { + return get_alpha(active_bg, contrast) / 255.0f; + }; // The contrast ratio for the hover effect on standard-width tabs. // In the default color scheme, this corresponds to a hover opacity of 0.4. - constexpr float kDesiredContrastHoveredStandardWidthTab = 1.11f; - const SkAlpha hover_base_alpha_wide = - color_utils::GetBlendValueWithMinimumContrast( - inactive_tab_bg_color, active_tab_bg_color, inactive_tab_bg_color, - kDesiredContrastHoveredStandardWidthTab); - hover_opacity_min_ = hover_base_alpha_wide / 255.0f; + constexpr float kStandardWidthContrast = 1.11f; + hover_opacity_min_ = get_hover_opacity(kStandardWidthContrast); // The contrast ratio for the hover effect on min-width tabs. // In the default color scheme, this corresponds to a hover opacity of 0.65. - constexpr float kDesiredContrastHoveredMinWidthTab = 1.19f; - const SkAlpha hover_base_alpha_narrow = - color_utils::GetBlendValueWithMinimumContrast( - inactive_tab_bg_color, active_tab_bg_color, inactive_tab_bg_color, - kDesiredContrastHoveredMinWidthTab); - hover_opacity_max_ = hover_base_alpha_narrow / 255.0f; + constexpr float kMinWidthContrast = 1.19f; + hover_opacity_max_ = get_hover_opacity(kMinWidthContrast); // The contrast ratio for the radial gradient effect on hovered tabs. // In the default color scheme, this corresponds to a hover opacity of 0.45. - constexpr float kDesiredContrastRadialGradient = 1.13728f; - const SkAlpha radial_highlight_alpha = - color_utils::GetBlendValueWithMinimumContrast( - inactive_tab_bg_color, active_tab_bg_color, inactive_tab_bg_color, - kDesiredContrastRadialGradient); - radial_highlight_opacity_ = radial_highlight_alpha / 255.0f; + constexpr float kRadialGradientContrast = 1.13728f; + radial_highlight_opacity_ = get_hover_opacity(kRadialGradientContrast); + const SkColor inactive_fg = GetTabForegroundColor(TAB_INACTIVE, inactive_bg); // The contrast ratio for the separator between inactive tabs. // In the default color scheme, this corresponds to a separator opacity of // 0.46. - const SkColor text_color = - GetTabForegroundColor(TAB_INACTIVE, inactive_tab_bg_color); - constexpr float kTabSeparatorRatio = 1.84f; - const SkAlpha separator_alpha = color_utils::GetBlendValueWithMinimumContrast( - inactive_tab_bg_color, text_color, inactive_tab_bg_color, - kTabSeparatorRatio); - separator_color_ = color_utils::AlphaBlend(text_color, inactive_tab_bg_color, - separator_alpha); + constexpr float kTabSeparatorContrast = 1.84f; + const SkAlpha separator_alpha = get_alpha(inactive_fg, kTabSeparatorContrast); + separator_color_ = + color_utils::AlphaBlend(inactive_fg, inactive_bg, separator_alpha); } void TabStrip::ResizeLayoutTabs() {
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 2ebbdd42..0eadddc 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
@@ -2530,6 +2530,8 @@ IDS_SETTINGS_SITE_SETTINGS_PAYMENT_HANDLER_BLOCK}, {"siteSettingsBlockAutoplaySetting", IDS_SETTINGS_SITE_SETTINGS_BLOCK_AUTOPLAY}, + {"emptyAllSitesPage", IDS_SETTINGS_SITE_SETTINGS_EMPTY_ALL_SITES_PAGE}, + {"noSitesFound", IDS_SETTINGS_SITE_SETTINGS_NO_SITES_FOUND}, }; AddLocalizedStringsBulk(html_source, kLocalizedStrings, base::size(kLocalizedStrings));
diff --git a/chrome/browser/ui/webui/welcome/OWNERS b/chrome/browser/ui/webui/welcome/nux/OWNERS similarity index 81% rename from chrome/browser/ui/webui/welcome/OWNERS rename to chrome/browser/ui/webui/welcome/nux/OWNERS index c497ef2..589a5fa6 100644 --- a/chrome/browser/ui/webui/welcome/OWNERS +++ b/chrome/browser/ui/webui/welcome/nux/OWNERS
@@ -2,3 +2,4 @@ scottchen@chromium.org # COMPONENT: UI>Browser>FirstRun +# LABEL: Proj-Navi \ No newline at end of file
diff --git a/chrome/renderer/safe_browsing/phishing_dom_feature_extractor.cc b/chrome/renderer/safe_browsing/phishing_dom_feature_extractor.cc index 61a1b52..92ee1a54 100644 --- a/chrome/renderer/safe_browsing/phishing_dom_feature_extractor.cc +++ b/chrome/renderer/safe_browsing/phishing_dom_feature_extractor.cc
@@ -44,7 +44,7 @@ struct PhishingDOMFeatureExtractor::PageFeatureState { // Link related features int external_links; - base::hash_set<std::string> external_domains; + std::unordered_set<std::string> external_domains; int secure_links; int total_links; @@ -56,7 +56,7 @@ int num_check_inputs; int action_other_domain; int total_actions; - base::hash_set<std::string> page_action_urls; + std::unordered_set<std::string> page_action_urls; // Image related features int img_other_domain;
diff --git a/chrome/renderer/safe_browsing/phishing_term_feature_extractor.cc b/chrome/renderer/safe_browsing/phishing_term_feature_extractor.cc index c570c33..cb663d1d 100644 --- a/chrome/renderer/safe_browsing/phishing_term_feature_extractor.cc +++ b/chrome/renderer/safe_browsing/phishing_term_feature_extractor.cc
@@ -7,6 +7,7 @@ #include <list> #include <map> #include <memory> +#include <unordered_set> #include <utility> #include "base/bind.h" @@ -82,8 +83,8 @@ }; PhishingTermFeatureExtractor::PhishingTermFeatureExtractor( - const base::hash_set<std::string>* page_term_hashes, - const base::hash_set<uint32_t>* page_word_hashes, + const std::unordered_set<std::string>* page_term_hashes, + const std::unordered_set<uint32_t>* page_word_hashes, size_t max_words_per_term, uint32_t murmurhash3_seed, size_t max_shingles_per_page,
diff --git a/chrome/renderer/safe_browsing/phishing_term_feature_extractor.h b/chrome/renderer/safe_browsing/phishing_term_feature_extractor.h index 68608b9..076ea50 100644 --- a/chrome/renderer/safe_browsing/phishing_term_feature_extractor.h +++ b/chrome/renderer/safe_browsing/phishing_term_feature_extractor.h
@@ -22,6 +22,7 @@ #include <memory> #include <set> #include <string> +#include <unordered_set> #include "base/callback.h" #include "base/containers/hash_tables.h" @@ -58,8 +59,8 @@ // |clock| is used for timing feature extractor operations, and may be mocked // for testing. The caller keeps ownership of the clock. PhishingTermFeatureExtractor( - const base::hash_set<std::string>* page_term_hashes, - const base::hash_set<uint32_t>* page_word_hashes, + const std::unordered_set<std::string>* page_term_hashes, + const std::unordered_set<uint32_t>* page_word_hashes, size_t max_words_per_term, uint32_t murmurhash3_seed, size_t max_shingles_per_page, @@ -127,14 +128,14 @@ void Clear(); // All of the term hashes that we are looking for in the page. - const base::hash_set<std::string>* page_term_hashes_; + const std::unordered_set<std::string>* page_term_hashes_; // Murmur3 hashes of all the individual words in page_term_hashes_. If // page_term_hashes_ included (hashed) "one" and "one two", page_word_hashes_ // would contain (hashed) "one" and "two". We do this so that we can have a // quick out in the common case that the current word we are processing // doesn't contain any part of one of our terms. - const base::hash_set<uint32_t>* page_word_hashes_; + const std::unordered_set<uint32_t>* page_word_hashes_; // The maximum number of words in an n-gram. const size_t max_words_per_term_;
diff --git a/chrome/renderer/safe_browsing/phishing_term_feature_extractor_unittest.cc b/chrome/renderer/safe_browsing/phishing_term_feature_extractor_unittest.cc index 9ced887..967b795 100644 --- a/chrome/renderer/safe_browsing/phishing_term_feature_extractor_unittest.cc +++ b/chrome/renderer/safe_browsing/phishing_term_feature_extractor_unittest.cc
@@ -9,6 +9,7 @@ #include <memory> #include <string> +#include <unordered_set> #include "base/bind.h" #include "base/callback.h" @@ -40,7 +41,7 @@ class PhishingTermFeatureExtractorTest : public ::testing::Test { protected: void SetUp() override { - base::hash_set<std::string> terms; + std::unordered_set<std::string> terms; terms.insert("one"); terms.insert("one one"); terms.insert("two"); @@ -58,7 +59,7 @@ term_hashes_.insert(crypto::SHA256HashString(*it)); } - base::hash_set<std::string> words; + std::unordered_set<std::string> words; words.insert("one"); words.insert("two"); words.insert("multi"); @@ -138,8 +139,8 @@ std::unique_ptr<base::RunLoop> active_run_loop_; MockFeatureExtractorClock clock_; std::unique_ptr<PhishingTermFeatureExtractor> extractor_; - base::hash_set<std::string> term_hashes_; - base::hash_set<uint32_t> word_hashes_; + std::unordered_set<std::string> term_hashes_; + std::unordered_set<uint32_t> word_hashes_; bool success_; // holds the success value from ExtractFeatures };
diff --git a/chrome/renderer/safe_browsing/scorer.cc b/chrome/renderer/safe_browsing/scorer.cc index 7c25f3b..23ceefb 100644 --- a/chrome/renderer/safe_browsing/scorer.cc +++ b/chrome/renderer/safe_browsing/scorer.cc
@@ -8,6 +8,7 @@ #include <memory> #include <unordered_map> +#include <unordered_set> #include "base/logging.h" #include "base/metrics/histogram_macros.h" @@ -89,11 +90,11 @@ return model_.version(); } -const base::hash_set<std::string>& Scorer::page_terms() const { +const std::unordered_set<std::string>& Scorer::page_terms() const { return page_terms_; } -const base::hash_set<uint32_t>& Scorer::page_words() const { +const std::unordered_set<uint32_t>& Scorer::page_words() const { return page_words_; }
diff --git a/chrome/renderer/safe_browsing/scorer.h b/chrome/renderer/safe_browsing/scorer.h index 6a37c4f..abf0671b 100644 --- a/chrome/renderer/safe_browsing/scorer.h +++ b/chrome/renderer/safe_browsing/scorer.h
@@ -18,6 +18,7 @@ #include <stdint.h> #include <string> +#include <unordered_set> #include "base/containers/hash_tables.h" #include "base/macros.h" @@ -48,11 +49,11 @@ // Returns a set of hashed page terms that appear in the model in binary // format. - const base::hash_set<std::string>& page_terms() const; + const std::unordered_set<std::string>& page_terms() const; // Returns a set of hashed page words that appear in the model in binary // format. - const base::hash_set<uint32_t>& page_words() const; + const std::unordered_set<uint32_t>& page_words() const; // Return the maximum number of words per term for the loaded model. size_t max_words_per_term() const; @@ -83,8 +84,8 @@ const FeatureMap& features) const; ClientSideModel model_; - base::hash_set<std::string> page_terms_; - base::hash_set<uint32_t> page_words_; + std::unordered_set<std::string> page_terms_; + std::unordered_set<uint32_t> page_words_; DISALLOW_COPY_AND_ASSIGN(Scorer); };
diff --git a/chrome/renderer/safe_browsing/scorer_unittest.cc b/chrome/renderer/safe_browsing/scorer_unittest.cc index bc710ba..4244ac6 100644 --- a/chrome/renderer/safe_browsing/scorer_unittest.cc +++ b/chrome/renderer/safe_browsing/scorer_unittest.cc
@@ -7,6 +7,7 @@ #include <stdint.h> #include <memory> +#include <unordered_set> #include "base/containers/hash_tables.h" #include "base/files/file_path.h" @@ -83,7 +84,7 @@ std::unique_ptr<Scorer> scorer(Scorer::Create(model_.SerializeAsString())); ASSERT_TRUE(scorer.get()); - // Use std::vector instead of base::hash_set for comparison. + // Use std::vector instead of std::unordered_set for comparison. // On Android, EXPECT_THAT(..., ContainerEq(...)) doesn't support // std::hash_set, but std::vector works fine. std::vector<std::string> expected_page_terms; @@ -91,7 +92,7 @@ expected_page_terms.push_back("token two"); std::sort(expected_page_terms.begin(), expected_page_terms.end()); - base::hash_set<std::string> page_terms = scorer->page_terms(); + std::unordered_set<std::string> page_terms = scorer->page_terms(); std::vector<std::string> page_terms_v(page_terms.begin(), page_terms.end()); std::sort(page_terms_v.begin(), page_terms_v.end()); @@ -107,7 +108,7 @@ expected_page_words.push_back(3000U); std::sort(expected_page_words.begin(), expected_page_words.end()); - base::hash_set<uint32_t> page_words = scorer->page_words(); + std::unordered_set<uint32_t> page_words = scorer->page_words(); std::vector<uint32_t> page_words_v(page_words.begin(), page_words.end()); std::sort(page_words_v.begin(), page_words_v.end());
diff --git a/chromeos/cryptohome/cryptohome_parameters.cc b/chromeos/cryptohome/cryptohome_parameters.cc index 39273f8..f6f4672 100644 --- a/chromeos/cryptohome/cryptohome_parameters.cc +++ b/chromeos/cryptohome/cryptohome_parameters.cc
@@ -7,6 +7,7 @@ #include <stddef.h> #include <stdint.h> +#include "base/logging.h" #include "chromeos/dbus/cryptohome/key.pb.h" #include "components/account_id/account_id.h" #include "components/user_manager/known_user.h"
diff --git a/components/bookmarks/browser/bookmark_model_unittest.cc b/components/bookmarks/browser/bookmark_model_unittest.cc index ae5f04c..90cdf678 100644 --- a/components/bookmarks/browser/bookmark_model_unittest.cc +++ b/components/bookmarks/browser/bookmark_model_unittest.cc
@@ -8,9 +8,11 @@ #include <stdint.h> #include <set> #include <string> +#include <unordered_set> #include <utility> #include <memory> +#include <unordered_set> #include "base/base_paths.h" #include "base/command_line.h" @@ -222,7 +224,7 @@ void VerifyNoDuplicateIDs(BookmarkModel* model) { ui::TreeNodeIterator<const BookmarkNode> it(model->root_node()); - base::hash_set<int64_t> ids; + std::unordered_set<int64_t> ids; while (it.has_next()) ASSERT_TRUE(ids.insert(it.Next()->id()).second); }
diff --git a/components/bookmarks/browser/bookmark_utils.cc b/components/bookmarks/browser/bookmark_utils.cc index f0653f3..7798a25 100644 --- a/components/bookmarks/browser/bookmark_utils.cc +++ b/components/bookmarks/browser/bookmark_utils.cc
@@ -6,6 +6,7 @@ #include <stdint.h> #include <memory> +#include <unordered_set> #include <utility> #include "base/bind.h" @@ -274,7 +275,7 @@ const BookmarkNode* parent, const GURL& url, base::string16* title) { - base::hash_set<base::string16> titles; + std::unordered_set<base::string16> titles; base::string16 original_title_lower = base::i18n::ToLower(*title); for (int i = 0; i < parent->child_count(); i++) { const BookmarkNode* node = parent->GetChild(i);
diff --git a/components/dom_distiller/core/distiller.h b/components/dom_distiller/core/distiller.h index 7801c01..bc7f1d9 100644 --- a/components/dom_distiller/core/distiller.h +++ b/components/dom_distiller/core/distiller.h
@@ -11,6 +11,7 @@ #include <memory> #include <string> #include <unordered_map> +#include <unordered_set> #include <vector> #include "base/callback.h" @@ -182,7 +183,7 @@ // Set to keep track of which urls are already seen by the distiller. Used to // prevent distiller from distilling the same url twice. - base::hash_set<std::string> seen_urls_; + std::unordered_set<std::string> seen_urls_; size_t max_pages_in_article_;
diff --git a/components/dom_distiller/core/dom_distiller_model.cc b/components/dom_distiller/core/dom_distiller_model.cc index 2bdd539..1fdc9aa 100644 --- a/components/dom_distiller/core/dom_distiller_model.cc +++ b/components/dom_distiller/core/dom_distiller_model.cc
@@ -4,6 +4,7 @@ #include "components/dom_distiller/core/dom_distiller_model.h" +#include <unordered_set> #include <utility> using syncer::SyncChange; @@ -101,7 +102,7 @@ const SyncDataList& data, SyncChangeList* changes_to_apply, SyncChangeList* changes_missing) { - typedef base::hash_set<std::string> StringSet; + typedef std::unordered_set<std::string> StringSet; StringSet entries_to_change; for (auto it = data.begin(); it != data.end(); ++it) { std::string entry_id = GetEntryIdFromSyncData(*it);
diff --git a/components/favicon/core/favicon_service_impl.h b/components/favicon/core/favicon_service_impl.h index 8e49d4f6..355968a 100644 --- a/components/favicon/core/favicon_service_impl.h +++ b/components/favicon/core/favicon_service_impl.h
@@ -8,6 +8,7 @@ #include <stdint.h> #include <memory> +#include <unordered_set> #include <vector> #include "base/callback.h" @@ -159,7 +160,7 @@ const std::vector<favicon_base::FaviconRawBitmapResult>& favicon_bitmap_results); - base::hash_set<MissingFaviconURLHash> missing_favicon_urls_; + std::unordered_set<MissingFaviconURLHash> missing_favicon_urls_; std::unique_ptr<FaviconClient> favicon_client_; history::HistoryService* history_service_;
diff --git a/components/spellcheck/browser/spellcheck_host_metrics.h b/components/spellcheck/browser/spellcheck_host_metrics.h index d2f0db7..b488c512 100644 --- a/components/spellcheck/browser/spellcheck_host_metrics.h +++ b/components/spellcheck/browser/spellcheck_host_metrics.h
@@ -8,6 +8,7 @@ #include <stddef.h> #include <string> +#include <unordered_set> #include <vector> #include "base/containers/hash_tables.h" @@ -90,7 +91,7 @@ // Time when first spellcheck happened. base::TimeTicks start_time_; // Set of checked words in the hashed form. - base::hash_set<std::string> checked_word_hashes_; + std::unordered_set<std::string> checked_word_hashes_; base::RepeatingTimer recording_timer_; };
diff --git a/components/sync_bookmarks/bookmark_model_associator.h b/components/sync_bookmarks/bookmark_model_associator.h index a0226320..055db522 100644 --- a/components/sync_bookmarks/bookmark_model_associator.h +++ b/components/sync_bookmarks/bookmark_model_associator.h
@@ -12,6 +12,7 @@ #include <memory> #include <set> #include <string> +#include <unordered_set> #include <vector> #include "base/compiler_specific.h" @@ -204,7 +205,7 @@ // for the purpose of detecting duplicates. A small number of // false positives due to hash collisions is OK because this // data is used for reporting purposes only. - base::hash_set<size_t> hashes_; + std::unordered_set<size_t> hashes_; // Overall number of bookmark collisions from RecordDuplicates call. int duplicate_count_; // Result of the most recent BookmarkModelAssociator::CheckModelSyncState.
diff --git a/components/tracing/common/graphics_memory_dump_provider_android.h b/components/tracing/common/graphics_memory_dump_provider_android.h index 520a91c..16f378c 100644 --- a/components/tracing/common/graphics_memory_dump_provider_android.h +++ b/components/tracing/common/graphics_memory_dump_provider_android.h
@@ -8,6 +8,7 @@ #include <stddef.h> #include <string> +#include <unordered_set> #include "base/containers/hash_tables.h" #include "base/gtest_prod_util.h" @@ -47,7 +48,7 @@ // Stores key names coming from the memtrack helper in long-lived storage. // This is to allow using cheap char* strings in tracing without copies. - base::hash_set<std::string> key_names_; + std::unordered_set<std::string> key_names_; DISALLOW_COPY_AND_ASSIGN(GraphicsMemoryDumpProvider); };
diff --git a/content/browser/accessibility/cross_platform_accessibility_browsertest.cc b/content/browser/accessibility/cross_platform_accessibility_browsertest.cc index b1942ea..6218a44 100644 --- a/content/browser/accessibility/cross_platform_accessibility_browsertest.cc +++ b/content/browser/accessibility/cross_platform_accessibility_browsertest.cc
@@ -6,6 +6,7 @@ #include <stdint.h> #include <string> +#include <unordered_set> #include <vector> #include "base/macros.h" @@ -53,8 +54,8 @@ } // Make sure each node in the tree has a unique id. - void RecursiveAssertUniqueIds( - const ui::AXNode* node, base::hash_set<int>* ids) { + void RecursiveAssertUniqueIds(const ui::AXNode* node, + std::unordered_set<int>* ids) { ASSERT_TRUE(ids->find(node->id()) == ids->end()); ids->insert(node->id()); for (int i = 0; i < node->child_count(); i++) @@ -271,7 +272,7 @@ const ui::AXTree& tree = GetAXTree(); const ui::AXNode* root = tree.root(); - base::hash_set<int> ids; + std::unordered_set<int> ids; RecursiveAssertUniqueIds(root, &ids); } @@ -339,7 +340,7 @@ const ui::AXTree& tree = GetAXTree(); const ui::AXNode* root = tree.root(); - base::hash_set<int> ids; + std::unordered_set<int> ids; RecursiveAssertUniqueIds(root, &ids); }
diff --git a/content/browser/appcache/appcache_manifest_parser.h b/content/browser/appcache/appcache_manifest_parser.h index 6312d4f..362ecea 100644 --- a/content/browser/appcache/appcache_manifest_parser.h +++ b/content/browser/appcache/appcache_manifest_parser.h
@@ -33,6 +33,7 @@ #define CONTENT_BROWSER_APPCACHE_APPCACHE_MANIFEST_PARSER_H_ #include <string> +#include <unordered_set> #include <vector> #include "base/containers/hash_tables.h" @@ -47,7 +48,7 @@ AppCacheManifest(); ~AppCacheManifest(); - base::hash_set<std::string> explicit_urls; + std::unordered_set<std::string> explicit_urls; std::vector<AppCacheNamespace> intercept_namespaces; std::vector<AppCacheNamespace> fallback_namespaces; std::vector<AppCacheNamespace> online_whitelist_namespaces;
diff --git a/content/browser/appcache/appcache_manifest_parser_unittest.cc b/content/browser/appcache/appcache_manifest_parser_unittest.cc index dba03d1..15b4387e 100644 --- a/content/browser/appcache/appcache_manifest_parser_unittest.cc +++ b/content/browser/appcache/appcache_manifest_parser_unittest.cc
@@ -5,6 +5,7 @@ #include <stddef.h> #include <string> +#include <unordered_set> #include <vector> #include "base/stl_util.h" @@ -113,7 +114,7 @@ EXPECT_FALSE(manifest.did_ignore_intercept_namespaces); EXPECT_FALSE(manifest.did_ignore_fallback_namespaces); - base::hash_set<std::string> urls = manifest.explicit_urls; + std::unordered_set<std::string> urls = manifest.explicit_urls; const size_t kExpected = 5; ASSERT_EQ(kExpected, urls.size()); EXPECT_TRUE(urls.find("http://www.foo.com/relative/one") != urls.end()); @@ -398,7 +399,7 @@ manifest)); EXPECT_TRUE(manifest.online_whitelist_all); - base::hash_set<std::string> urls = manifest.explicit_urls; + std::unordered_set<std::string> urls = manifest.explicit_urls; size_t expected = 3; ASSERT_EQ(expected, urls.size()); EXPECT_TRUE(urls.find("http://combo.com:42/relative/explicit-1") != @@ -446,7 +447,7 @@ EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), PARSE_MANIFEST_ALLOWING_DANGEROUS_FEATURES, manifest)); - base::hash_set<std::string> urls = manifest.explicit_urls; + std::unordered_set<std::string> urls = manifest.explicit_urls; EXPECT_TRUE(urls.find("http://bad.com/%EF%BF%BDinvalidutf8") != urls.end()) << "manifest byte stream was passed through, not UTF-8-decoded"; EXPECT_TRUE(urls.find("http://bad.com/nonbmp%F1%84%AB%BC") != urls.end()); @@ -462,7 +463,7 @@ PARSE_MANIFEST_ALLOWING_DANGEROUS_FEATURES, manifest)); - base::hash_set<std::string> urls = manifest.explicit_urls; + std::unordered_set<std::string> urls = manifest.explicit_urls; EXPECT_TRUE(urls.find("http://smorg.borg/resource.txt") != urls.end()); } @@ -482,7 +483,7 @@ EXPECT_TRUE(manifest.fallback_namespaces.empty()); EXPECT_TRUE(manifest.online_whitelist_namespaces.empty()); - base::hash_set<std::string> urls = manifest.explicit_urls; + std::unordered_set<std::string> urls = manifest.explicit_urls; const size_t kExpected = 3; ASSERT_EQ(kExpected, urls.size()); EXPECT_TRUE(urls.find("https://www.foo.com/relative/secureschemesameorigin")
diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc index e054e1f..617683c9 100644 --- a/content/browser/browser_context.cc +++ b/content/browser/browser_context.cc
@@ -10,6 +10,7 @@ #include <algorithm> #include <limits> #include <memory> +#include <unordered_set> #include <utility> #include <vector> @@ -389,7 +390,7 @@ // static void BrowserContext::GarbageCollectStoragePartitions( BrowserContext* browser_context, - std::unique_ptr<base::hash_set<base::FilePath>> active_paths, + std::unique_ptr<std::unordered_set<base::FilePath>> active_paths, const base::Closure& done) { GetStoragePartitionMap(browser_context) ->GarbageCollect(std::move(active_paths), done);
diff --git a/content/browser/frame_host/render_frame_host_manager.cc b/content/browser/frame_host/render_frame_host_manager.cc index 5d6a0ecf..5a0b3cf3 100644 --- a/content/browser/frame_host/render_frame_host_manager.cc +++ b/content/browser/frame_host/render_frame_host_manager.cc
@@ -8,6 +8,7 @@ #include <algorithm> #include <string> +#include <unordered_set> #include <utility> #include <vector> @@ -2433,7 +2434,7 @@ void RenderFrameHostManager::CollectOpenerFrameTrees( std::vector<FrameTree*>* opener_frame_trees, - base::hash_set<FrameTreeNode*>* nodes_with_back_links) { + std::unordered_set<FrameTreeNode*>* nodes_with_back_links) { CHECK(opener_frame_trees); opener_frame_trees->push_back(frame_tree_node_->frame_tree()); @@ -2477,7 +2478,7 @@ SiteInstance* instance, FrameTreeNode* skip_this_node) { std::vector<FrameTree*> opener_frame_trees; - base::hash_set<FrameTreeNode*> nodes_with_back_links; + std::unordered_set<FrameTreeNode*> nodes_with_back_links; CollectOpenerFrameTrees(&opener_frame_trees, &nodes_with_back_links);
diff --git a/content/browser/frame_host/render_frame_host_manager.h b/content/browser/frame_host/render_frame_host_manager.h index b42002f3..99da756 100644 --- a/content/browser/frame_host/render_frame_host_manager.h +++ b/content/browser/frame_host/render_frame_host_manager.h
@@ -11,6 +11,7 @@ #include <map> #include <memory> #include <unordered_map> +#include <unordered_set> #include "base/containers/hash_tables.h" #include "base/logging.h" @@ -661,7 +662,7 @@ // the node is added to |nodes_with_back_links|. void CollectOpenerFrameTrees( std::vector<FrameTree*>* opener_frame_trees, - base::hash_set<FrameTreeNode*>* nodes_with_back_links); + std::unordered_set<FrameTreeNode*>* nodes_with_back_links); // Create swapped out RenderViews and RenderFrameProxies in the given // SiteInstance for the current node's FrameTree. Used as a helper function
diff --git a/content/browser/frame_host/render_frame_host_manager_unittest.cc b/content/browser/frame_host/render_frame_host_manager_unittest.cc index 679bae80..ef31b4a 100644 --- a/content/browser/frame_host/render_frame_host_manager_unittest.cc +++ b/content/browser/frame_host/render_frame_host_manager_unittest.cc
@@ -8,6 +8,7 @@ #include <string> #include <tuple> +#include <unordered_set> #include <utility> #include <vector> @@ -500,7 +501,7 @@ void CollectOpenerFrameTrees( FrameTreeNode* node, std::vector<FrameTree*>* opener_frame_trees, - base::hash_set<FrameTreeNode*>* nodes_with_back_links) { + std::unordered_set<FrameTreeNode*>* nodes_with_back_links) { node->render_manager()->CollectOpenerFrameTrees(opener_frame_trees, nodes_with_back_links); } @@ -2325,7 +2326,7 @@ root4->child_at(0)->SetOpener(root3); std::vector<FrameTree*> opener_frame_trees; - base::hash_set<FrameTreeNode*> nodes_with_back_links; + std::unordered_set<FrameTreeNode*> nodes_with_back_links; CollectOpenerFrameTrees(root1, &opener_frame_trees, &nodes_with_back_links);
diff --git a/content/browser/loader/navigation_url_loader_impl.cc b/content/browser/loader/navigation_url_loader_impl.cc index e27b972..70c543ba 100644 --- a/content/browser/loader/navigation_url_loader_impl.cc +++ b/content/browser/loader/navigation_url_loader_impl.cc
@@ -795,13 +795,14 @@ // the restarted request to use a new loader, instead of, e.g., reusing the // AppCache or service worker loader. For an optimization, we keep and reuse // the default url loader if the all |interceptors_| doesn't handle the - // redirected request. If the network service is enabled, only certain - // schemes are handled by the default URL loader. We need to make sure the - // redirected URL is a handled scheme, otherwise reset the loader so the - // correct non-network service loader can be used. + // redirected request. If the network service is enabled, reset the loader + // if the redirected URL's scheme and the previous URL scheme don't match in + // their use or disuse of the network service loader. if (!default_loader_used_ || (base::FeatureList::IsEnabled(network::features::kNetworkService) && - !IsURLHandledByDefaultLoader(resource_request_->url))) { + url_chain_.size() > 1 && + IsURLHandledByDefaultLoader(url_chain_[url_chain_.size() - 1]) != + IsURLHandledByDefaultLoader(url_chain_[url_chain_.size() - 2]))) { url_loader_.reset(); } interceptor_index_ = 0;
diff --git a/content/browser/media/session/media_session_impl.h b/content/browser/media/session/media_session_impl.h index 561dacd..0fa48a29 100644 --- a/content/browser/media/session/media_session_impl.h +++ b/content/browser/media/session/media_session_impl.h
@@ -10,6 +10,7 @@ #include <map> #include <set> #include <unordered_map> +#include <unordered_set> #include "base/callback_list.h" #include "base/containers/id_map.h" @@ -278,7 +279,8 @@ MediaSessionPlayerObserver* observer; int player_id; }; - using PlayersMap = base::hash_set<PlayerIdentifier, PlayerIdentifier::Hash>; + using PlayersMap = + std::unordered_set<PlayerIdentifier, PlayerIdentifier::Hash>; using StateChangedCallback = base::Callback<void(State)>; CONTENT_EXPORT explicit MediaSessionImpl(WebContents* web_contents);
diff --git a/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper.h b/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper.h index 99b6751..3ab5eb9 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper.h +++ b/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper.h
@@ -66,7 +66,7 @@ NSArray* GetEditSelectorNames(); private: - base::hash_set<std::string> edit_command_set_; + std::unordered_set<std::string> edit_command_set_; DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMacEditCommandHelper); };
diff --git a/content/browser/storage_partition_impl_map.cc b/content/browser/storage_partition_impl_map.cc index 5025231..a37a5c2 100644 --- a/content/browser/storage_partition_impl_map.cc +++ b/content/browser/storage_partition_impl_map.cc
@@ -4,6 +4,7 @@ #include "content/browser/storage_partition_impl_map.h" +#include <unordered_set> #include <utility> #include "base/bind.h" @@ -271,8 +272,8 @@ // Ensures each path in |active_paths| is a direct child of storage_root. void NormalizeActivePaths(const base::FilePath& storage_root, - base::hash_set<base::FilePath>* active_paths) { - base::hash_set<base::FilePath> normalized_active_paths; + std::unordered_set<base::FilePath>* active_paths) { + std::unordered_set<base::FilePath> normalized_active_paths; for (auto iter = active_paths->begin(); iter != active_paths->end(); ++iter) { base::FilePath relative_path; @@ -309,7 +310,7 @@ void BlockingGarbageCollect( const base::FilePath& storage_root, const scoped_refptr<base::TaskRunner>& file_access_runner, - std::unique_ptr<base::hash_set<base::FilePath>> active_paths) { + std::unique_ptr<std::unordered_set<base::FilePath>> active_paths) { CHECK(storage_root.IsAbsolute()); NormalizeActivePaths(storage_root, active_paths.get()); @@ -524,7 +525,7 @@ } void StoragePartitionImplMap::GarbageCollect( - std::unique_ptr<base::hash_set<base::FilePath>> active_paths, + std::unique_ptr<std::unordered_set<base::FilePath>> active_paths, const base::Closure& done) { // Include all paths for current StoragePartitions in the active_paths since // they cannot be deleted safely.
diff --git a/content/browser/storage_partition_impl_map.h b/content/browser/storage_partition_impl_map.h index ce0951b..c68c9de 100644 --- a/content/browser/storage_partition_impl_map.h +++ b/content/browser/storage_partition_impl_map.h
@@ -8,6 +8,7 @@ #include <map> #include <memory> #include <string> +#include <unordered_set> #include "base/callback_forward.h" #include "base/containers/hash_tables.h" @@ -55,7 +56,7 @@ // The |done| closure is executed on the calling thread when garbage // collection is complete. void GarbageCollect( - std::unique_ptr<base::hash_set<base::FilePath>> active_paths, + std::unique_ptr<std::unordered_set<base::FilePath>> active_paths, const base::Closure& done); void ForEach(const BrowserContext::StoragePartitionCallback& callback);
diff --git a/content/browser/storage_partition_impl_map_unittest.cc b/content/browser/storage_partition_impl_map_unittest.cc index 89fc1685..efffbc89 100644 --- a/content/browser/storage_partition_impl_map_unittest.cc +++ b/content/browser/storage_partition_impl_map_unittest.cc
@@ -4,6 +4,7 @@ #include "content/browser/storage_partition_impl_map.h" +#include <unordered_set> #include <utility> #include "base/files/file_util.h" @@ -71,8 +72,8 @@ TestBrowserContext browser_context; StoragePartitionImplMap storage_partition_impl_map(&browser_context); - std::unique_ptr<base::hash_set<base::FilePath>> active_paths( - new base::hash_set<base::FilePath>); + std::unique_ptr<std::unordered_set<base::FilePath>> active_paths( + new std::unordered_set<base::FilePath>); base::FilePath active_path = browser_context.GetPath().Append( StoragePartitionImplMap::GetStoragePartitionPath(
diff --git a/content/browser/web_contents/web_contents_android.cc b/content/browser/web_contents/web_contents_android.cc index 60996ac..4076bab 100644 --- a/content/browser/web_contents/web_contents_android.cc +++ b/content/browser/web_contents/web_contents_android.cc
@@ -6,6 +6,7 @@ #include <stdint.h> #include <string> +#include <unordered_set> #include <utility> #include <vector> @@ -69,7 +70,7 @@ // Track all WebContentsAndroid objects here so that we don't deserialize a // destroyed WebContents object. -base::LazyInstance<base::hash_set<WebContentsAndroid*>>::Leaky +base::LazyInstance<std::unordered_set<WebContentsAndroid*>>::Leaky g_allocated_web_contents_androids = LAZY_INSTANCE_INITIALIZER; void JavaScriptResultCallback(const ScopedJavaGlobalRef<jobject>& callback,
diff --git a/content/browser/web_contents/web_contents_view_cocoa.mm b/content/browser/web_contents/web_contents_view_cocoa.mm index 53bd394..5cb0953 100644 --- a/content/browser/web_contents/web_contents_view_cocoa.mm +++ b/content/browser/web_contents/web_contents_view_cocoa.mm
@@ -14,8 +14,10 @@ #include "content/public/browser/web_contents_view_delegate.h" #import "third_party/mozilla/NSPasteboard+Utils.h" #include "ui/base/clipboard/custom_data_helper.h" +#include "ui/base/cocoa/cocoa_base_utils.h" #include "ui/base/dragdrop/cocoa_dnd_util.h" +using content::DraggingInfo; using content::DropData; using content::WebContentsImpl; using content::WebContentsViewMac; @@ -59,6 +61,33 @@ [super dealloc]; } +- (void)populateDraggingInfo:(DraggingInfo*)info + fromNSDraggingInfo:(id<NSDraggingInfo>)nsInfo { + NSPoint windowPoint = [nsInfo draggingLocation]; + + NSPoint viewPoint = [self convertPoint:windowPoint fromView:nil]; + NSRect viewFrame = [self frame]; + info->location_in_view = + gfx::PointF(viewPoint.x, viewFrame.size.height - viewPoint.y); + + NSPoint screenPoint = + ui::ConvertPointFromWindowToScreen([self window], windowPoint); + NSScreen* screen = [[self window] screen]; + NSRect screenFrame = [screen frame]; + info->location_in_screen = + gfx::PointF(screenPoint.x, screenFrame.size.height - screenPoint.y); + + info->location_in_view = gfx::PointF(viewPoint.x, viewPoint.y); + info->location_in_screen = gfx::PointF(screenPoint.x, screenPoint.y); + NSPasteboard* pboard = [nsInfo draggingPasteboard]; + if ([pboard containsURLDataConvertingTextToURL:YES]) { + GURL url; + ui::PopulateURLAndTitleFromPasteboard(&url, NULL, pboard, YES); + info->url.emplace(url); + } + info->operation_mask = [nsInfo draggingSourceOperationMask]; +} + - (BOOL)allowsVibrancy { // Returning YES will allow rendering this view with vibrancy effect if it is // incorporated into a view hierarchy that uses vibrancy, it will have no @@ -185,7 +214,10 @@ content::PopulateDropDataFromPasteboard(&dropData, [sender draggingPasteboard]); [dragDest_ setDropData:dropData]; - return [dragDest_ draggingEntered:sender view:self]; + + DraggingInfo draggingInfo; + [self populateDraggingInfo:&draggingInfo fromNSDraggingInfo:sender]; + return [dragDest_ draggingEntered:draggingInfo]; } - (void)draggingExited:(id<NSDraggingInfo>)sender { @@ -193,11 +225,15 @@ } - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender { - return [dragDest_ draggingUpdated:sender view:self]; + DraggingInfo draggingInfo; + [self populateDraggingInfo:&draggingInfo fromNSDraggingInfo:sender]; + return [dragDest_ draggingUpdated:draggingInfo]; } - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { - return [dragDest_ performDragOperation:sender view:self]; + DraggingInfo draggingInfo; + [self populateDraggingInfo:&draggingInfo fromNSDraggingInfo:sender]; + return [dragDest_ performDragOperation:draggingInfo]; } - (void)cancelDeferredClose {
diff --git a/content/browser/web_contents/web_drag_dest_mac.h b/content/browser/web_contents/web_drag_dest_mac.h index 990cd2cd5..0f51b9f 100644 --- a/content/browser/web_contents/web_drag_dest_mac.h +++ b/content/browser/web_contents/web_drag_dest_mac.h
@@ -33,6 +33,27 @@ void CONTENT_EXPORT PopulateDropDataFromPasteboard(content::DropData* data, NSPasteboard* pboard); +// The data extracted from an NSDraggingInfo needed by draggingEntered, +// draggingUpdated, and performDragOperation. +// TODO(https://crbug.com/898608): Change this to be a mojo structure. +struct CONTENT_EXPORT DraggingInfo { + DraggingInfo(); + ~DraggingInfo(); + + // The dragging location in the NSView, with the origin in the upper-left. + gfx::PointF location_in_view; + + // The dragging location in the NSScreen, with the origin in the upper-left. + gfx::PointF location_in_screen; + + // The URL data from the drag, if any. Note that this is redundant in that it + // is already present in DropData. It is here because it is used by methods + // that don't use DropData. + base::Optional<GURL> url; + + // The operation mask. + uint32_t operation_mask; +}; } // A class that handles tracking and event processing for a drag and drop @@ -95,17 +116,15 @@ // Messages to send during the tracking of a drag, ususally upon receiving // calls from the view system. Communicates the drag messages to WebCore. - (void)setDropData:(const content::DropData&)dropData; -- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)info - view:(NSView*)view; +- (NSDragOperation)draggingEntered:(const content::DraggingInfo&)info; - (void)draggingExited; -- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)info - view:(NSView*)view; -- (BOOL)performDragOperation:(id<NSDraggingInfo>)info view:(NSView*)view; +- (NSDragOperation)draggingUpdated:(const content::DraggingInfo&)info; +- (BOOL)performDragOperation:(const content::DraggingInfo&)info; // Helper to call WebWidgetHostInputEventRouter::GetRenderWidgetHostAtPoint(). - (content::RenderWidgetHostImpl*) -GetRenderWidgetHostAtPoint:(const NSPoint&)viewPoint - transformedPt:(gfx::PointF*)transformedPt; + GetRenderWidgetHostAtPoint:(const gfx::PointF&)viewPoint + transformedPt:(gfx::PointF*)transformedPt; // Sets |dragStartProcessID_| and |dragStartViewID_|. - (void)setDragStartTrackersForProcess:(int)processID;
diff --git a/content/browser/web_contents/web_drag_dest_mac.mm b/content/browser/web_contents/web_drag_dest_mac.mm index e9d6a913..e8ae8e1f 100644 --- a/content/browser/web_contents/web_drag_dest_mac.mm +++ b/content/browser/web_contents/web_drag_dest_mac.mm
@@ -26,6 +26,7 @@ #include "ui/gfx/geometry/point.h" using blink::WebDragOperationsMask; +using content::DraggingInfo; using content::DropData; using content::OpenURLParams; using content::Referrer; @@ -137,17 +138,11 @@ dropDataUnfiltered_ = std::make_unique<DropData>(dropData); } -- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)info - view:(NSView*)view { +- (NSDragOperation)draggingEntered:(const DraggingInfo&)info { // Save off the RVH so we can tell if it changes during a drag. If it does, // we need to send a new enter message in draggingUpdated:. currentRVH_ = webContents_->GetRenderViewHost(); - // Create the appropriate mouse locations for WebCore. The draggingLocation - // is in window coordinates. Both need to be flipped. - NSPoint windowPoint = [info draggingLocation]; - NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; - NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; gfx::PointF transformedPt; if (!webContents_->GetRenderWidgetHostView()) { // TODO(ekaramad, paulmeyer): Find a better way than toggling |canceled_|. @@ -158,7 +153,8 @@ } content::RenderWidgetHostImpl* targetRWH = - [self GetRenderWidgetHostAtPoint:viewPoint transformedPt:&transformedPt]; + [self GetRenderWidgetHostAtPoint:info.location_in_view + transformedPt:&transformedPt]; if (![self isValidDragTarget:targetRWH]) return NSDragOperationNone; @@ -170,7 +166,7 @@ currentRWHForDrag_ = targetRWH->GetWeakPtr(); currentRWHForDrag_->FilterDropData(dropData.get()); - NSDragOperation mask = [info draggingSourceOperationMask]; + NSDragOperation mask = info.operation_mask; // Give the delegate an opportunity to cancel the drag. canceled_ = !webContents_->GetDelegate()->CanDragEnter( @@ -181,7 +177,7 @@ return NSDragOperationNone; if ([self onlyAllowsNavigation]) { - if ([[info draggingPasteboard] containsURLDataConvertingTextToURL:YES]) + if (info.url) return NSDragOperationCopy; return NSDragOperationNone; } @@ -194,8 +190,7 @@ dropDataFiltered_.swap(dropData); currentRWHForDrag_->DragTargetDragEnter( - *dropDataFiltered_, transformedPt, - gfx::PointF(screenPoint.x, screenPoint.y), + *dropDataFiltered_, transformedPt, info.location_in_screen, static_cast<WebDragOperationsMask>(mask), GetModifierFlags()); // We won't know the true operation (whether the drag is allowed) until we @@ -226,21 +221,17 @@ dropDataFiltered_.reset(); } -- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)info view:(NSView*)view { +- (NSDragOperation)draggingUpdated:(const DraggingInfo&)info { if (canceled_) { // TODO(ekaramad,paulmeyer): We probably shouldn't be checking for // |canceled_| twice in this method. return NSDragOperationNone; } - // Create the appropriate mouse locations for WebCore. The draggingLocation - // is in window coordinates. Both need to be flipped. - NSPoint windowPoint = [info draggingLocation]; - NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; - NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; gfx::PointF transformedPt; content::RenderWidgetHostImpl* targetRWH = - [self GetRenderWidgetHostAtPoint:viewPoint transformedPt:&transformedPt]; + [self GetRenderWidgetHostAtPoint:info.location_in_view + transformedPt:&transformedPt]; if (![self isValidDragTarget:targetRWH]) return NSDragOperationNone; @@ -249,9 +240,8 @@ // per drag, even without the drag ever leaving the window. if (targetRWH != currentRWHForDrag_.get()) { if (currentRWHForDrag_) { - gfx::PointF transformedLeavePoint = gfx::PointF(viewPoint.x, viewPoint.y); - gfx::PointF transformedScreenPoint = - gfx::PointF(screenPoint.x, screenPoint.y); + gfx::PointF transformedLeavePoint = info.location_in_view; + gfx::PointF transformedScreenPoint = info.location_in_screen; content::RenderWidgetHostViewBase* rootView = static_cast<content::RenderWidgetHostViewBase*>( webContents_->GetRenderWidgetHostView()); @@ -265,22 +255,22 @@ currentRWHForDrag_->DragTargetDragLeave(transformedLeavePoint, transformedScreenPoint); } - [self draggingEntered:info view:view]; + [self draggingEntered:info]; } if (canceled_) return NSDragOperationNone; if ([self onlyAllowsNavigation]) { - if ([[info draggingPasteboard] containsURLDataConvertingTextToURL:YES]) + if (info.url) return NSDragOperationCopy; return NSDragOperationNone; } - NSDragOperation mask = [info draggingSourceOperationMask]; - targetRWH->DragTargetDragOver( - transformedPt, gfx::PointF(screenPoint.x, screenPoint.y), - static_cast<WebDragOperationsMask>(mask), GetModifierFlags()); + NSDragOperation mask = info.operation_mask; + targetRWH->DragTargetDragOver(transformedPt, info.location_in_screen, + static_cast<WebDragOperationsMask>(mask), + GetModifierFlags()); if (delegate_) delegate_->OnDragOver(); @@ -288,36 +278,28 @@ return currentOperation_; } -- (BOOL)performDragOperation:(id<NSDraggingInfo>)info - view:(NSView*)view { - // Create the appropriate mouse locations for WebCore. The draggingLocation - // is in window coordinates. Both need to be flipped. - NSPoint windowPoint = [info draggingLocation]; - NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; - NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; +- (BOOL)performDragOperation:(const DraggingInfo&)info { gfx::PointF transformedPt; content::RenderWidgetHostImpl* targetRWH = - [self GetRenderWidgetHostAtPoint:viewPoint transformedPt:&transformedPt]; + [self GetRenderWidgetHostAtPoint:info.location_in_view + transformedPt:&transformedPt]; if (![self isValidDragTarget:targetRWH]) return NO; if (targetRWH != currentRWHForDrag_.get()) { if (currentRWHForDrag_) - currentRWHForDrag_->DragTargetDragLeave( - transformedPt, gfx::PointF(screenPoint.x, screenPoint.y)); - [self draggingEntered:info view:view]; + currentRWHForDrag_->DragTargetDragLeave(transformedPt, + info.location_in_screen); + [self draggingEntered:info]; } // Check if we only allow navigation and navigate to a url on the pasteboard. if ([self onlyAllowsNavigation]) { - NSPasteboard* pboard = [info draggingPasteboard]; - if ([pboard containsURLDataConvertingTextToURL:YES]) { - GURL url; - ui::PopulateURLAndTitleFromPasteboard(&url, NULL, pboard, YES); - webContents_->OpenURL( - OpenURLParams(url, Referrer(), WindowOpenDisposition::CURRENT_TAB, - ui::PAGE_TRANSITION_AUTO_BOOKMARK, false)); + if (info.url) { + webContents_->OpenURL(OpenURLParams( + *info.url, Referrer(), WindowOpenDisposition::CURRENT_TAB, + ui::PAGE_TRANSITION_AUTO_BOOKMARK, false)); return YES; } else { return NO; @@ -330,8 +312,7 @@ currentRVH_ = NULL; targetRWH->DragTargetDrop(*dropDataFiltered_, transformedPt, - gfx::PointF(screenPoint.x, screenPoint.y), - GetModifierFlags()); + info.location_in_screen, GetModifierFlags()); dropDataUnfiltered_.reset(); dropDataFiltered_.reset(); @@ -340,11 +321,11 @@ } - (content::RenderWidgetHostImpl*) -GetRenderWidgetHostAtPoint:(const NSPoint&)viewPoint - transformedPt:(gfx::PointF*)transformedPt { + GetRenderWidgetHostAtPoint:(const gfx::PointF&)viewPoint + transformedPt:(gfx::PointF*)transformedPt { return webContents_->GetInputEventRouter()->GetRenderWidgetHostAtPoint( - webContents_->GetRenderViewHost()->GetWidget()->GetView(), - gfx::PointF(viewPoint.x, viewPoint.y), transformedPt); + webContents_->GetRenderViewHost()->GetWidget()->GetView(), viewPoint, + transformedPt); } - (void)setDragStartTrackersForProcess:(int)processID { @@ -425,4 +406,7 @@ } } +DraggingInfo::DraggingInfo() = default; +DraggingInfo::~DraggingInfo() = default; + } // namespace content
diff --git a/content/browser/web_contents/web_drag_dest_mac_unittest.mm b/content/browser/web_contents/web_drag_dest_mac_unittest.mm index 3ecdcc8..b837cbd 100644 --- a/content/browser/web_contents/web_drag_dest_mac_unittest.mm +++ b/content/browser/web_contents/web_drag_dest_mac_unittest.mm
@@ -66,24 +66,6 @@ EXPECT_TRUE(drag_dest_); } -// Test flipping of coordinates given a point in window coordinates. -TEST_F(WebDragDestTest, Flip) { - NSPoint windowPoint = NSZeroPoint; - base::scoped_nsobject<NSWindow> window([[CocoaTestHelperWindow alloc] init]); - NSPoint viewPoint = - [drag_dest_ flipWindowPointToView:windowPoint - view:[window contentView]]; - NSPoint screenPoint = - [drag_dest_ flipWindowPointToScreen:windowPoint - view:[window contentView]]; - EXPECT_EQ(0, viewPoint.x); - EXPECT_EQ(600, viewPoint.y); - EXPECT_EQ(0, screenPoint.x); - // We can't put a value on the screen size since everyone will have a - // different one. - EXPECT_NE(0, screenPoint.y); -} - TEST_F(WebDragDestTest, URL) { NSString* url = nil; NSString* title = nil;
diff --git a/content/browser/webrtc/webrtc_internals.h b/content/browser/webrtc/webrtc_internals.h index ad8acfc1..f77c7936 100644 --- a/content/browser/webrtc/webrtc_internals.h +++ b/content/browser/webrtc/webrtc_internals.h
@@ -7,6 +7,7 @@ #include <memory> #include <string> +#include <unordered_set> #include "base/containers/hash_tables.h" #include "base/containers/queue.h" @@ -245,7 +246,7 @@ const bool should_block_power_saving_; // Set of render process hosts that |this| is registered as an observer on. - base::hash_set<int> render_process_id_set_; + std::unordered_set<int> render_process_id_set_; // Used to bulk up updates that we send to javascript. // The class owns the value/dictionary and command name of an update.
diff --git a/content/common/mime_sniffing_throttle_unittest.cc b/content/common/mime_sniffing_throttle_unittest.cc index ea5bfe6..23fed7f 100644 --- a/content/common/mime_sniffing_throttle_unittest.cc +++ b/content/common/mime_sniffing_throttle_unittest.cc
@@ -433,6 +433,14 @@ delegate->LoadResponseBody(long_body); scoped_task_environment_.RunUntilIdle(); + // Send OnComplete() to the MimeSniffingURLLoader. + delegate->CompleteResponse(); + scoped_task_environment_.RunUntilIdle(); + // MimeSniffingURLLoader should not send OnComplete() to the destination + // client until it finished writing all the data. + EXPECT_FALSE( + delegate->destination_loader_client()->has_received_completion()); + // Read the half of the body. This unblocks MimeSniffingURLLoader to push the // rest of the body to the data pipe. uint32_t read_bytes = delegate->ReadResponseBody(long_body.size() / 2); @@ -441,7 +449,6 @@ // Read the rest of the body. read_bytes += delegate->ReadResponseBody(long_body.size() / 2); scoped_task_environment_.RunUntilIdle(); - delegate->CompleteResponse(); delegate->destination_loader_client()->RunUntilComplete(); // Check if all data has been read.
diff --git a/content/common/mime_sniffing_url_loader.cc b/content/common/mime_sniffing_url_loader.cc index 38cf1e1..06ebccc 100644 --- a/content/common/mime_sniffing_url_loader.cc +++ b/content/common/mime_sniffing_url_loader.cc
@@ -121,11 +121,11 @@ destination_url_loader_client_->OnComplete(status); return; case State::kSniffing: - // Defer calling OnComplete() since we defer calling - // OnStartLoadingResponseBody() until mime sniffing has been finished. + case State::kSending: + // Defer calling OnComplete() until mime sniffing has finished and all + // data is sent. complete_status_ = status; return; - case State::kSending: case State::kCompleted: destination_url_loader_client_->OnComplete(status); return; @@ -231,7 +231,7 @@ DCHECK_EQ(State::kSniffing, state_); if (buffered_body_.empty()) { // The URLLoader ended before sending any data. There is not enough - // informations to determine the MIME type. + // information to determine the MIME type. response_head_.mime_type = kDefaultMimeType; } @@ -255,12 +255,10 @@ MOJO_HANDLE_SIGNAL_WRITABLE | MOJO_HANDLE_SIGNAL_PEER_CLOSED, base::BindRepeating(&MimeSniffingURLLoader::OnBodyWritable, base::Unretained(this))); - // Send deferred messages. + + // Send deferred message. destination_url_loader_client_->OnStartLoadingResponseBody( std::move(body_to_send)); - // Call OnComplete() if OnComplete() has already been called. - if (complete_status_.has_value()) - destination_url_loader_client_->OnComplete(complete_status_.value()); if (bytes_remaining_in_buffer_) { SendReceivedBodyToClient(); @@ -273,6 +271,11 @@ void MimeSniffingURLLoader::CompleteSending() { DCHECK_EQ(State::kSending, state_); state_ = State::kCompleted; + // Call client's OnComplete() if |this|'s OnComplete() has already been + // called. + if (complete_status_.has_value()) + destination_url_loader_client_->OnComplete(complete_status_.value()); + body_consumer_watcher_.Cancel(); body_producer_watcher_.Cancel(); body_consumer_handle_.reset();
diff --git a/content/common/mime_sniffing_url_loader.h b/content/common/mime_sniffing_url_loader.h index d830131..9c10ba56 100644 --- a/content/common/mime_sniffing_url_loader.h +++ b/content/common/mime_sniffing_url_loader.h
@@ -41,10 +41,10 @@ // type. The received body is kept in this loader until the mime type // is decided. When the mime type is decided or all body has been // received, this loader will dispatch queued messages like -// OnStartLoadingResponseBody() and OnComplete() to the destination +// OnStartLoadingResponseBody() to the destination // loader client, and then the state is changed to kSending. -// kSending: Receives the body and send it to the destination loader client. All -// data has been read by this loader, the state goes to kCompleted. +// kSending: Receives the body and sends it to the destination loader client. +// The state changes to kCompleted after all data is sent. // kCompleted: All data has been sent to the destination loader. // kAborted: Unexpected behavior happens. Watchers, pipes and the binding from // the source loader to |this| are stopped. All incoming messages from
diff --git a/content/common/throttling_url_loader.cc b/content/common/throttling_url_loader.cc index ce10c13..3adb75e 100644 --- a/content/common/throttling_url_loader.cc +++ b/content/common/throttling_url_loader.cc
@@ -342,9 +342,16 @@ DCHECK(throttle_will_start_redirect_url_.is_empty()) << "ThrottlingURLLoader doesn't support multiple throttles " "changing the URL."; - CHECK_EQ(original_url.GetOrigin(), url_request->url.GetOrigin()) - << "ThrottlingURLLoader doesn't support a throttle making a " - << "cross-origin redirect."; + // Only do this sanity check if the schemes are both http[s], as this + // generated-redirect functionality is also used by + // registerProtocolHandler to map non-web to web schemes and that is + // safe. + if (original_url.SchemeIsHTTPOrHTTPS() && + url_request->url.SchemeIsHTTPOrHTTPS()) { + CHECK_EQ(original_url.GetOrigin(), url_request->url.GetOrigin()) + << "ThrottlingURLLoader doesn't support a throttle making a " + << "cross-origin redirect."; + } throttle_will_start_redirect_url_ = url_request->url; // Restore the original URL so that all throttles see the same original // URL. @@ -536,10 +543,17 @@ DCHECK(throttle_will_redirect_redirect_url_.is_empty()) << "ThrottlingURLLoader doesn't support multiple throttles " "changing the URL."; - CHECK_EQ(redirect_info_copy.new_url.GetOrigin(), - redirect_info.new_url.GetOrigin()) - << "ThrottlingURLLoader doesn't support a throttle making a " - << "cross-origin redirect."; + // Only do this sanity check if the schemes are both http[s], as this + // generated-redirect functionality is also used by + // registerProtocolHandler to map non-web to web schemes and that is + // safe. + if (redirect_info_copy.new_url.SchemeIsHTTPOrHTTPS() && + redirect_info.new_url.SchemeIsHTTPOrHTTPS()) { + CHECK_EQ(redirect_info_copy.new_url.GetOrigin(), + redirect_info.new_url.GetOrigin()) + << "ThrottlingURLLoader doesn't support a throttle making a " + << "cross-origin redirect."; + } throttle_will_redirect_redirect_url_ = redirect_info_copy.new_url; } else { CHECK_EQ(redirect_info_copy.new_url, redirect_info.new_url)
diff --git a/content/public/browser/browser_context.h b/content/public/browser/browser_context.h index 15c5d11..9f562fd9 100644 --- a/content/public/browser/browser_context.h +++ b/content/public/browser/browser_context.h
@@ -11,6 +11,7 @@ #include <map> #include <memory> #include <string> +#include <unordered_set> #include <vector> #include "base/callback_forward.h" @@ -142,7 +143,7 @@ // ownership of the pointer. static void GarbageCollectStoragePartitions( BrowserContext* browser_context, - std::unique_ptr<base::hash_set<base::FilePath>> active_paths, + std::unique_ptr<std::unordered_set<base::FilePath>> active_paths, const base::Closure& done); static StoragePartition* GetDefaultStoragePartition(
diff --git a/content/renderer/BUILD.gn b/content/renderer/BUILD.gn index 5a874a7..f1c517af 100644 --- a/content/renderer/BUILD.gn +++ b/content/renderer/BUILD.gn
@@ -46,8 +46,6 @@ "android/synchronous_compositor_registry.h", "android/synchronous_layer_tree_frame_sink.cc", "android/synchronous_layer_tree_frame_sink.h", - "appcache/appcache_backend_proxy.cc", - "appcache/appcache_backend_proxy.h", "appcache/appcache_frontend_impl.cc", "appcache/appcache_frontend_impl.h", "appcache/web_application_cache_host_impl.cc",
diff --git a/content/renderer/appcache/appcache_backend_proxy.cc b/content/renderer/appcache/appcache_backend_proxy.cc deleted file mode 100644 index 19b509b..0000000 --- a/content/renderer/appcache/appcache_backend_proxy.cc +++ /dev/null
@@ -1,86 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/renderer/appcache/appcache_backend_proxy.h" -#include "content/common/appcache.mojom.h" -#include "content/public/common/service_names.mojom.h" -#include "content/public/renderer/render_thread.h" -#include "services/service_manager/public/cpp/connector.h" - -namespace content { - -AppCacheBackendProxy::AppCacheBackendProxy() = default; -AppCacheBackendProxy::~AppCacheBackendProxy() = default; - -mojom::AppCacheBackend* AppCacheBackendProxy::GetAppCacheBackendPtr() { - if (!app_cache_backend_ptr_) { - RenderThread::Get()->GetConnector()->BindInterface( - mojom::kBrowserServiceName, mojo::MakeRequest(&app_cache_backend_ptr_)); - } - return app_cache_backend_ptr_.get(); -} - -void AppCacheBackendProxy::RegisterHost(int host_id) { - GetAppCacheBackendPtr()->RegisterHost(host_id); -} - -void AppCacheBackendProxy::UnregisterHost(int host_id) { - GetAppCacheBackendPtr()->UnregisterHost(host_id); -} - -void AppCacheBackendProxy::SetSpawningHostId(int host_id, - int spawning_host_id) { - GetAppCacheBackendPtr()->SetSpawningHostId(host_id, spawning_host_id); -} - -void AppCacheBackendProxy::SelectCache( - int host_id, - const GURL& document_url, - const int64_t cache_document_was_loaded_from, - const GURL& manifest_url) { - GetAppCacheBackendPtr()->SelectCache( - host_id, document_url, cache_document_was_loaded_from, manifest_url); -} - -void AppCacheBackendProxy::SelectCacheForSharedWorker(int host_id, - int64_t appcache_id) { - GetAppCacheBackendPtr()->SelectCacheForSharedWorker(host_id, appcache_id); -} - -void AppCacheBackendProxy::MarkAsForeignEntry( - int host_id, - const GURL& document_url, - int64_t cache_document_was_loaded_from) { - GetAppCacheBackendPtr()->MarkAsForeignEntry(host_id, document_url, - cache_document_was_loaded_from); -} - -AppCacheStatus AppCacheBackendProxy::GetStatus(int host_id) { - AppCacheStatus status = AppCacheStatus::APPCACHE_STATUS_UNCACHED; - GetAppCacheBackendPtr()->GetStatus(host_id, &status); - return status; -} - -bool AppCacheBackendProxy::StartUpdate(int host_id) { - bool result = false; - GetAppCacheBackendPtr()->StartUpdate(host_id, &result); - return result; -} - -bool AppCacheBackendProxy::SwapCache(int host_id) { - bool result = false; - GetAppCacheBackendPtr()->SwapCache(host_id, &result); - return result; -} - -void AppCacheBackendProxy::GetResourceList( - int host_id, std::vector<AppCacheResourceInfo>* resource_infos) { - std::vector<mojom::AppCacheResourceInfoPtr> boxed_infos; - GetAppCacheBackendPtr()->GetResourceList(host_id, &boxed_infos); - for (auto& b : boxed_infos) { - resource_infos->emplace_back(std::move(*b)); - } -} - -} // namespace content
diff --git a/content/renderer/appcache/appcache_backend_proxy.h b/content/renderer/appcache/appcache_backend_proxy.h deleted file mode 100644 index 3a3c732..0000000 --- a/content/renderer/appcache/appcache_backend_proxy.h +++ /dev/null
@@ -1,51 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_RENDERER_APPCACHE_APPCACHE_BACKEND_PROXY_H_ -#define CONTENT_RENDERER_APPCACHE_APPCACHE_BACKEND_PROXY_H_ - -#include <stdint.h> - -#include <vector> - -#include "content/common/appcache.mojom.h" -#include "content/common/appcache_interfaces.h" -#include "ipc/ipc_sender.h" -#include "url/gurl.h" - -namespace content { - -// Sends appcache related messages to the main process. -class AppCacheBackendProxy { - public: - AppCacheBackendProxy(); - ~AppCacheBackendProxy(); - - // AppCacheBackend methods - void RegisterHost(int host_id); - void UnregisterHost(int host_id); - void SetSpawningHostId(int host_id, int spawning_host_id); - void SelectCache(int host_id, - const GURL& document_url, - const int64_t cache_document_was_loaded_from, - const GURL& manifest_url); - void SelectCacheForSharedWorker(int host_id, int64_t appcache_id); - void MarkAsForeignEntry(int host_id, - const GURL& document_url, - int64_t cache_document_was_loaded_from); - AppCacheStatus GetStatus(int host_id); - bool StartUpdate(int host_id); - bool SwapCache(int host_id); - void GetResourceList(int host_id, - std::vector<AppCacheResourceInfo>* resource_infos); - - private: - mojom::AppCacheBackend* GetAppCacheBackendPtr(); - - mojom::AppCacheBackendPtr app_cache_backend_ptr_; -}; - -} // namespace content - -#endif // CONTENT_RENDERER_APPCACHE_APPCACHE_BACKEND_PROXY_H_
diff --git a/content/renderer/appcache/appcache_frontend_impl.cc b/content/renderer/appcache/appcache_frontend_impl.cc index 810893e..89aeb93 100644 --- a/content/renderer/appcache/appcache_frontend_impl.cc +++ b/content/renderer/appcache/appcache_frontend_impl.cc
@@ -4,7 +4,12 @@ #include "content/renderer/appcache/appcache_frontend_impl.h" +#include "content/common/appcache.mojom.h" +#include "content/public/common/service_names.mojom.h" +#include "content/public/renderer/render_thread.h" #include "content/renderer/appcache/web_application_cache_host_impl.h" +#include "mojo/public/cpp/bindings/interface_request.h" +#include "services/service_manager/public/cpp/connector.h" #include "third_party/blink/public/web/web_console_message.h" using blink::WebApplicationCacheHost; @@ -24,6 +29,14 @@ binding_.Bind(std::move(request)); } +mojom::AppCacheBackend* AppCacheFrontendImpl::backend_proxy() { + if (!backend_ptr_) { + RenderThread::Get()->GetConnector()->BindInterface( + mojom::kBrowserServiceName, mojo::MakeRequest(&backend_ptr_)); + } + return backend_ptr_.get(); +} + void AppCacheFrontendImpl::CacheSelected(int32_t host_id, mojom::AppCacheInfoPtr info) { WebApplicationCacheHostImpl* host = GetHost(host_id);
diff --git a/content/renderer/appcache/appcache_frontend_impl.h b/content/renderer/appcache/appcache_frontend_impl.h index 5d465a16..18bcee3e3 100644 --- a/content/renderer/appcache/appcache_frontend_impl.h +++ b/content/renderer/appcache/appcache_frontend_impl.h
@@ -11,7 +11,6 @@ #include "content/common/appcache.mojom.h" #include "content/common/appcache_interfaces.h" -#include "content/renderer/appcache/appcache_backend_proxy.h" #include "mojo/public/cpp/bindings/binding.h" namespace content { @@ -25,7 +24,7 @@ void Bind(mojom::AppCacheFrontendRequest request); - AppCacheBackendProxy* backend_proxy() { return &backend_proxy_; } + mojom::AppCacheBackend* backend_proxy(); private: // mojom::AppCacheFrontend @@ -48,7 +47,7 @@ int32_t host_id, network::mojom::URLLoaderFactoryPtr url_loader_factory) override; - AppCacheBackendProxy backend_proxy_; + mojom::AppCacheBackendPtr backend_ptr_; mojo::Binding<mojom::AppCacheFrontend> binding_; };
diff --git a/content/renderer/appcache/web_application_cache_host_impl.cc b/content/renderer/appcache/web_application_cache_host_impl.cc index aa3cd86..a297f9c 100644 --- a/content/renderer/appcache/web_application_cache_host_impl.cc +++ b/content/renderer/appcache/web_application_cache_host_impl.cc
@@ -11,7 +11,7 @@ #include "base/containers/id_map.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" -#include "content/renderer/appcache/appcache_backend_proxy.h" +#include "content/common/appcache.mojom.h" #include "third_party/blink/public/platform/web_string.h" #include "third_party/blink/public/platform/web_url.h" #include "third_party/blink/public/platform/web_url_response.h" @@ -57,7 +57,7 @@ WebApplicationCacheHostImpl::WebApplicationCacheHostImpl( WebApplicationCacheHostClient* client, - AppCacheBackendProxy* backend, + mojom::AppCacheBackend* backend, int appcache_host_id) : client_(client), backend_(backend), @@ -261,39 +261,31 @@ is_new_master_entry_ = OLD_ENTRY; } -void WebApplicationCacheHostImpl::DidReceiveDataForMainResource( - const char* data, - size_t len) { - if (is_new_master_entry_ == OLD_ENTRY) - return; - // TODO(michaeln): write me -} - -void WebApplicationCacheHostImpl::DidFinishLoadingMainResource(bool success) { - if (is_new_master_entry_ == OLD_ENTRY) - return; - // TODO(michaeln): write me -} - WebApplicationCacheHost::Status WebApplicationCacheHostImpl::GetStatus() { return static_cast<WebApplicationCacheHost::Status>(status_); } bool WebApplicationCacheHostImpl::StartUpdate() { - if (!backend_->StartUpdate(host_id_)) + bool result = false; + backend_->StartUpdate(host_id_, &result); + if (!result) return false; if (status_ == AppCacheStatus::APPCACHE_STATUS_IDLE || - status_ == AppCacheStatus::APPCACHE_STATUS_UPDATE_READY) + status_ == AppCacheStatus::APPCACHE_STATUS_UPDATE_READY) { status_ = AppCacheStatus::APPCACHE_STATUS_CHECKING; - else - status_ = backend_->GetStatus(host_id_); + } else { + status_ = AppCacheStatus::APPCACHE_STATUS_UNCACHED; + backend_->GetStatus(host_id_, &status_); + } return true; } bool WebApplicationCacheHostImpl::SwapCache() { - if (!backend_->SwapCache(host_id_)) + bool result = false; + backend_->SwapCache(host_id_, &result); + if (!result) return false; - status_ = backend_->GetStatus(host_id_); + backend_->GetStatus(host_id_, &status_); return true; } @@ -315,8 +307,12 @@ WebVector<ResourceInfo>* resources) { if (!cache_info_.is_complete) return; + std::vector<mojom::AppCacheResourceInfoPtr> boxed_infos; + backend_->GetResourceList(host_id_, &boxed_infos); std::vector<AppCacheResourceInfo> resource_infos; - backend_->GetResourceList(host_id_, &resource_infos); + for (auto& b : boxed_infos) { + resource_infos.emplace_back(std::move(*b)); + } WebVector<ResourceInfo> web_resources(resource_infos.size()); for (size_t i = 0; i < resource_infos.size(); ++i) {
diff --git a/content/renderer/appcache/web_application_cache_host_impl.h b/content/renderer/appcache/web_application_cache_host_impl.h index 35a680e..c39e0f0f 100644 --- a/content/renderer/appcache/web_application_cache_host_impl.h +++ b/content/renderer/appcache/web_application_cache_host_impl.h
@@ -7,6 +7,7 @@ #include <string> +#include "content/common/appcache.mojom.h" #include "content/common/appcache_interfaces.h" #include "mojo/public/cpp/system/message_pipe.h" #include "third_party/blink/public/platform/web_application_cache_host.h" @@ -17,20 +18,18 @@ namespace content { -class AppCacheBackendProxy; - class WebApplicationCacheHostImpl : public blink::WebApplicationCacheHost { public: // Returns the host having given id or NULL if there is no such host. static WebApplicationCacheHostImpl* FromId(int id); WebApplicationCacheHostImpl(blink::WebApplicationCacheHostClient* client, - AppCacheBackendProxy* backend, + mojom::AppCacheBackend* backend, int appcache_host_id); ~WebApplicationCacheHostImpl() override; int host_id() const { return host_id_; } - AppCacheBackendProxy* backend() const { return backend_; } + mojom::AppCacheBackend* backend() const { return backend_; } blink::WebApplicationCacheHostClient* client() const { return client_; } virtual void OnCacheSelected(const AppCacheInfo& info); @@ -50,8 +49,6 @@ void SelectCacheWithoutManifest() override; bool SelectCacheWithManifest(const blink::WebURL& manifestURL) override; void DidReceiveResponseForMainResource(const blink::WebURLResponse&) override; - void DidReceiveDataForMainResource(const char* data, size_t len) override; - void DidFinishLoadingMainResource(bool success) override; blink::WebApplicationCacheHost::Status GetStatus() override; bool StartUpdate() override; bool SwapCache() override; @@ -67,7 +64,7 @@ enum IsNewMasterEntry { MAYBE_NEW_ENTRY, NEW_ENTRY, OLD_ENTRY }; blink::WebApplicationCacheHostClient* client_; - AppCacheBackendProxy* backend_; + mojom::AppCacheBackend* backend_; int host_id_; AppCacheStatus status_; blink::WebURLResponse document_response_;
diff --git a/content/renderer/pepper/v8_var_converter.cc b/content/renderer/pepper/v8_var_converter.cc index 580c2a4..d38aa4e 100644 --- a/content/renderer/pepper/v8_var_converter.cc +++ b/content/renderer/pepper/v8_var_converter.cc
@@ -11,6 +11,7 @@ #include <memory> #include <string> #include <unordered_map> +#include <unordered_set> #include "base/bind.h" #include "base/containers/circular_deque.h" @@ -69,12 +70,13 @@ namespace { // Maps PP_Var IDs to the V8 value handle they correspond to. + typedef std::unordered_map<int64_t, v8::Local<v8::Value>> VarHandleMap; -typedef base::hash_set<int64_t> ParentVarSet; +typedef std::unordered_set<int64_t> ParentVarSet; // Maps V8 value handles to the PP_Var they correspond to. typedef std::unordered_map<HashedHandle, ScopedPPVar> HandleVarMap; -typedef base::hash_set<HashedHandle> ParentHandleSet; +typedef std::unordered_set<HashedHandle> ParentHandleSet; // Returns a V8 value which corresponds to a given PP_Var. If |var| is a // reference counted PP_Var type, and it exists in |visited_ids|, the V8 value
diff --git a/content/renderer/pepper/video_decoder_shim.h b/content/renderer/pepper/video_decoder_shim.h index e5f640d..94740e2 100644 --- a/content/renderer/pepper/video_decoder_shim.h +++ b/content/renderer/pepper/video_decoder_shim.h
@@ -9,6 +9,7 @@ #include <memory> #include <unordered_map> +#include <unordered_set> #include <vector> #include "base/containers/hash_tables.h" @@ -88,7 +89,7 @@ using TextureIdMap = std::unordered_map<uint32_t, uint32_t>; TextureIdMap texture_id_map_; // Available textures (these are plugin ids.) - using TextureIdSet = base::hash_set<uint32_t>; + using TextureIdSet = std::unordered_set<uint32_t>; TextureIdSet available_textures_; // Track textures that are no longer needed (these are plugin ids.) TextureIdSet textures_to_dismiss_;
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index 518f8b8..9d61ea3 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc
@@ -6502,8 +6502,6 @@ request.SetHasUserGesture(common_params.has_user_gesture); #endif - request.SetNavigationStartTime(common_params.navigation_start); - return request; }
diff --git a/content/renderer/renderer_webapplicationcachehost_impl.cc b/content/renderer/renderer_webapplicationcachehost_impl.cc index 39ec671..48ef67b 100644 --- a/content/renderer/renderer_webapplicationcachehost_impl.cc +++ b/content/renderer/renderer_webapplicationcachehost_impl.cc
@@ -4,8 +4,8 @@ #include "content/renderer/renderer_webapplicationcachehost_impl.h" +#include "content/common/appcache.mojom.h" #include "content/common/view_messages.h" -#include "content/renderer/appcache/appcache_backend_proxy.h" #include "content/renderer/render_frame_impl.h" #include "content/renderer/render_thread_impl.h" #include "content/renderer/render_view_impl.h" @@ -21,7 +21,7 @@ RendererWebApplicationCacheHostImpl::RendererWebApplicationCacheHostImpl( RenderViewImpl* render_view, WebApplicationCacheHostClient* client, - AppCacheBackendProxy* backend, + mojom::AppCacheBackend* backend, int appcache_host_id, int frame_routing_id) : WebApplicationCacheHostImpl(client, backend, appcache_host_id),
diff --git a/content/renderer/renderer_webapplicationcachehost_impl.h b/content/renderer/renderer_webapplicationcachehost_impl.h index a369480..cd52f69 100644 --- a/content/renderer/renderer_webapplicationcachehost_impl.h +++ b/content/renderer/renderer_webapplicationcachehost_impl.h
@@ -7,16 +7,17 @@ #include "content/renderer/appcache/web_application_cache_host_impl.h" +#include "content/common/appcache.mojom.h" + namespace content { class RenderViewImpl; -class AppCacheBackendProxy; class RendererWebApplicationCacheHostImpl : public WebApplicationCacheHostImpl { public: RendererWebApplicationCacheHostImpl( RenderViewImpl* render_view, blink::WebApplicationCacheHostClient* client, - AppCacheBackendProxy* backend, + mojom::AppCacheBackend* backend, int appcache_host_id, int frame_routing_id);
diff --git a/content/renderer/shared_worker/embedded_shared_worker_stub.cc b/content/renderer/shared_worker/embedded_shared_worker_stub.cc index 6e7bd1fd..d6dfe0a 100644 --- a/content/renderer/shared_worker/embedded_shared_worker_stub.cc +++ b/content/renderer/shared_worker/embedded_shared_worker_stub.cc
@@ -72,8 +72,6 @@ const WebApplicationCacheHost* spawning_host) override {} void DidReceiveResponseForMainResource( const blink::WebURLResponse&) override {} - void DidReceiveDataForMainResource(const char* data, size_t len) override {} - void DidFinishLoadingMainResource(bool success) override {} // Cache selection is also different for workers. We know at construction // time what cache to select and do so then.
diff --git a/courgette/difference_estimator.cc b/courgette/difference_estimator.cc index 099900c..82d456df 100644 --- a/courgette/difference_estimator.cc +++ b/courgette/difference_estimator.cc
@@ -60,7 +60,7 @@ private: Region region_; - base::hash_set<size_t> hashes_; + std::unordered_set<size_t> hashes_; friend class DifferenceEstimator; DISALLOW_COPY_AND_ASSIGN(Base);
diff --git a/device/bluetooth/bluetooth_adapter_win.h b/device/bluetooth/bluetooth_adapter_win.h index c391eca..7287b682 100644 --- a/device/bluetooth/bluetooth_adapter_win.h +++ b/device/bluetooth/bluetooth_adapter_win.h
@@ -10,6 +10,7 @@ #include <memory> #include <set> #include <string> +#include <unordered_set> #include <utility> #include <vector> @@ -146,7 +147,7 @@ bool initialized_; bool powered_; DiscoveryStatus discovery_status_; - base::hash_set<std::string> discovered_devices_; + std::unordered_set<std::string> discovered_devices_; std::vector<std::pair<base::Closure, DiscoverySessionErrorCallback>> on_start_discovery_callbacks_;
diff --git a/extensions/browser/api/api_resource_manager.h b/extensions/browser/api/api_resource_manager.h index 129d2040..b5ea217 100644 --- a/extensions/browser/api/api_resource_manager.h +++ b/extensions/browser/api/api_resource_manager.h
@@ -7,6 +7,7 @@ #include <map> #include <memory> +#include <unordered_set> #include "base/containers/hash_tables.h" #include "base/memory/ptr_util.h" @@ -131,7 +132,7 @@ return data_->Get(extension_id, api_resource_id); } - base::hash_set<int>* GetResourceIds(const std::string& extension_id) { + std::unordered_set<int>* GetResourceIds(const std::string& extension_id) { return data_->GetResourceIds(extension_id); } @@ -193,7 +194,8 @@ public: typedef std::map<int, std::unique_ptr<T>> ApiResourceMap; // Lookup map from extension id's to allocated resource id's. - typedef std::map<std::string, base::hash_set<int>> ExtensionToResourceMap; + typedef std::map<std::string, std::unordered_set<int>> + ExtensionToResourceMap; ApiResourceData() : next_id_(1) { sequence_checker_.DetachFromSequence(); } @@ -209,7 +211,8 @@ extension_resource_map_.find(extension_id); if (it == extension_resource_map_.end()) { it = extension_resource_map_ - .insert(std::make_pair(extension_id, base::hash_set<int>())) + .insert( + std::make_pair(extension_id, std::unordered_set<int>())) .first; } it->second.insert(id); @@ -249,7 +252,7 @@ return false; } - base::hash_set<int>* GetResourceIds(const std::string& extension_id) { + std::unordered_set<int>* GetResourceIds(const std::string& extension_id) { DCHECK(sequence_checker_.CalledOnValidSequence()); return GetOwnedResourceIds(extension_id); } @@ -286,7 +289,8 @@ return NULL; } - base::hash_set<int>* GetOwnedResourceIds(const std::string& extension_id) { + std::unordered_set<int>* GetOwnedResourceIds( + const std::string& extension_id) { DCHECK(sequence_checker_.CalledOnValidSequence()); ExtensionToResourceMap::iterator it = extension_resource_map_.find(extension_id); @@ -316,8 +320,8 @@ // Remove all resources, or the non persistent ones only if |remove_all| // is false. - base::hash_set<int>& resource_ids = it->second; - for (base::hash_set<int>::iterator it = resource_ids.begin(); + std::unordered_set<int>& resource_ids = it->second; + for (std::unordered_set<int>::iterator it = resource_ids.begin(); it != resource_ids.end();) { bool erase = false; if (remove_all) {
diff --git a/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.cc b/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.cc index f201275..bb988e19 100644 --- a/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.cc +++ b/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
@@ -7,6 +7,7 @@ #include <stdint.h> #include <algorithm> #include <iterator> +#include <unordered_set> #include <utility> #include <vector> @@ -1048,7 +1049,7 @@ advertisements_manager_->Remove(extension_id(), advertisement_id); } -const base::hash_set<int>* +const std::unordered_set<int>* BluetoothLowEnergyAdvertisementFunction::GetAdvertisementIds() { return advertisements_manager_->GetResourceIds(extension_id()); } @@ -1226,7 +1227,7 @@ return; } - const base::hash_set<int>* advertisement_ids = GetAdvertisementIds(); + const std::unordered_set<int>* advertisement_ids = GetAdvertisementIds(); if (!advertisement_ids || advertisement_ids->empty()) { Respond(NoArguments()); return; @@ -1234,7 +1235,7 @@ // Copy the hash set, as RemoveAdvertisement can change advertisement_ids // while we are iterating over it. - base::hash_set<int> advertisement_ids_tmp = *advertisement_ids; + std::unordered_set<int> advertisement_ids_tmp = *advertisement_ids; for (int advertisement_id : advertisement_ids_tmp) { RemoveAdvertisement(advertisement_id); }
diff --git a/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.h b/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.h index 69d72ca..638f6a94 100644 --- a/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.h +++ b/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.h
@@ -7,6 +7,7 @@ #include <memory> #include <string> +#include <unordered_set> #include "base/macros.h" #include "base/memory/ref_counted.h" @@ -488,7 +489,7 @@ int AddAdvertisement(BluetoothApiAdvertisement* advertisement); BluetoothApiAdvertisement* GetAdvertisement(int advertisement_id); void RemoveAdvertisement(int advertisement_id); - const base::hash_set<int>* GetAdvertisementIds(); + const std::unordered_set<int>* GetAdvertisementIds(); // ExtensionFunction override. ResponseAction Run() override;
diff --git a/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc b/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc index 2d5a46d..4c0005a 100644 --- a/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc +++ b/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc
@@ -6,6 +6,7 @@ #include <algorithm> #include <iterator> +#include <unordered_set> #include <utility> #include "base/bind.h" @@ -1781,7 +1782,8 @@ ConnectionResourceManager* manager = GetConnectionResourceManager(browser_context_); - base::hash_set<int>* connection_ids = manager->GetResourceIds(extension_id); + std::unordered_set<int>* connection_ids = + manager->GetResourceIds(extension_id); if (!connection_ids) return NULL; @@ -1805,7 +1807,8 @@ ConnectionResourceManager* manager = GetConnectionResourceManager(browser_context_); - base::hash_set<int>* connection_ids = manager->GetResourceIds(extension_id); + std::unordered_set<int>* connection_ids = + manager->GetResourceIds(extension_id); if (!connection_ids) return false; @@ -1830,7 +1833,7 @@ NotifySessionResourceManager* manager = GetNotifySessionResourceManager(browser_context_); - base::hash_set<int>* ids = manager->GetResourceIds(extension_id); + std::unordered_set<int>* ids = manager->GetResourceIds(extension_id); if (!ids) return NULL; @@ -1854,7 +1857,7 @@ NotifySessionResourceManager* manager = GetNotifySessionResourceManager(browser_context_); - base::hash_set<int>* ids = manager->GetResourceIds(extension_id); + std::unordered_set<int>* ids = manager->GetResourceIds(extension_id); if (!ids) return false;
diff --git a/extensions/browser/api/bluetooth_socket/bluetooth_socket_api.cc b/extensions/browser/api/bluetooth_socket/bluetooth_socket_api.cc index daa772db..fec95c8 100644 --- a/extensions/browser/api/bluetooth_socket/bluetooth_socket_api.cc +++ b/extensions/browser/api/bluetooth_socket/bluetooth_socket_api.cc
@@ -5,6 +5,7 @@ #include "extensions/browser/api/bluetooth_socket/bluetooth_socket_api.h" #include <stdint.h> +#include <unordered_set> #include <utility> #include "base/hash.h" @@ -162,7 +163,7 @@ manager_->Remove(extension_id(), api_resource_id); } -base::hash_set<int>* BluetoothSocketAsyncApiFunction::GetSocketIds() { +std::unordered_set<int>* BluetoothSocketAsyncApiFunction::GetSocketIds() { return manager_->GetResourceIds(extension_id()); } @@ -599,7 +600,7 @@ ExtensionFunction::ResponseAction BluetoothSocketGetSocketsFunction::Run() { std::vector<bluetooth_socket::SocketInfo> socket_infos; - base::hash_set<int>* resource_ids = GetSocketIds(); + std::unordered_set<int>* resource_ids = GetSocketIds(); if (resource_ids) { for (int socket_id : *resource_ids) { BluetoothApiSocket* socket = GetSocket(socket_id);
diff --git a/extensions/browser/api/bluetooth_socket/bluetooth_socket_api.h b/extensions/browser/api/bluetooth_socket/bluetooth_socket_api.h index bbab919..87ab2e4d 100644 --- a/extensions/browser/api/bluetooth_socket/bluetooth_socket_api.h +++ b/extensions/browser/api/bluetooth_socket/bluetooth_socket_api.h
@@ -9,6 +9,7 @@ #include <memory> #include <string> +#include <unordered_set> #include "base/containers/hash_tables.h" #include "base/memory/ref_counted.h" @@ -54,7 +55,7 @@ int AddSocket(BluetoothApiSocket* socket); BluetoothApiSocket* GetSocket(int api_resource_id); void RemoveSocket(int api_resource_id); - base::hash_set<int>* GetSocketIds(); + std::unordered_set<int>* GetSocketIds(); private: ApiResourceManager<BluetoothApiSocket>* manager_;
diff --git a/extensions/browser/api/declarative/deduping_factory.h b/extensions/browser/api/declarative/deduping_factory.h index b3d9658..6b563cb25 100644 --- a/extensions/browser/api/declarative/deduping_factory.h +++ b/extensions/browser/api/declarative/deduping_factory.h
@@ -10,6 +10,7 @@ #include <list> #include <string> #include <unordered_map> +#include <unordered_set> #include "base/compiler_specific.h" #include "base/containers/hash_tables.h" @@ -85,7 +86,7 @@ typedef std::list<scoped_refptr<const BaseClassT> > PrototypeList; typedef std::unordered_map<InstanceType, PrototypeList> ExistingPrototypes; typedef std::unordered_map<InstanceType, FactoryMethod> FactoryMethods; - typedef base::hash_set<InstanceType> ParameterizedTypes; + typedef std::unordered_set<InstanceType> ParameterizedTypes; const size_t max_number_prototypes_; ExistingPrototypes prototypes_;
diff --git a/extensions/browser/api/serial/serial_api.cc b/extensions/browser/api/serial/serial_api.cc index a801ad6..9d246c4 100644 --- a/extensions/browser/api/serial/serial_api.cc +++ b/extensions/browser/api/serial/serial_api.cc
@@ -5,6 +5,7 @@ #include "extensions/browser/api/serial/serial_api.h" #include <algorithm> +#include <unordered_set> #include <vector> #include "base/task/post_task.h" @@ -384,7 +385,7 @@ void SerialGetConnectionsFunction::AsyncWorkStart() { DCHECK_CURRENTLY_ON(BrowserThread::IO); - const base::hash_set<int>* connection_ids = + const std::unordered_set<int>* connection_ids = manager_->GetResourceIds(extension_->id()); if (connection_ids) { for (auto it = connection_ids->cbegin(); it != connection_ids->cend();
diff --git a/extensions/browser/api/socket/socket_api.cc b/extensions/browser/api/socket/socket_api.cc index 5b61a08a..29f1901 100644 --- a/extensions/browser/api/socket/socket_api.cc +++ b/extensions/browser/api/socket/socket_api.cc
@@ -4,6 +4,7 @@ #include "extensions/browser/api/socket/socket_api.h" +#include <unordered_set> #include <utility> #include <vector> @@ -98,7 +99,7 @@ manager_->Replace(extension_->id(), api_resource_id, socket); } -base::hash_set<int>* SocketAsyncApiFunction::GetSocketIds() { +std::unordered_set<int>* SocketAsyncApiFunction::GetSocketIds() { return manager_->GetResourceIds(extension_->id()); }
diff --git a/extensions/browser/api/socket/socket_api.h b/extensions/browser/api/socket/socket_api.h index 28ea96b7..5a89a6e 100644 --- a/extensions/browser/api/socket/socket_api.h +++ b/extensions/browser/api/socket/socket_api.h
@@ -10,6 +10,7 @@ #include <memory> #include <string> +#include <unordered_set> #include "base/gtest_prod_util.h" #include "base/macros.h" @@ -58,7 +59,7 @@ virtual void Replace(const std::string& extension_id, int api_resource_id, Socket* socket) = 0; - virtual base::hash_set<int>* GetResourceIds( + virtual std::unordered_set<int>* GetResourceIds( const std::string& extension_id) = 0; }; @@ -98,7 +99,7 @@ manager_->Remove(extension_id, api_resource_id); } - base::hash_set<int>* GetResourceIds( + std::unordered_set<int>* GetResourceIds( const std::string& extension_id) override { return manager_->GetResourceIds(extension_id); } @@ -125,7 +126,7 @@ Socket* GetSocket(int api_resource_id); void ReplaceSocket(int api_resource_id, Socket* socket); void RemoveSocket(int api_resource_id); - base::hash_set<int>* GetSocketIds(); + std::unordered_set<int>* GetSocketIds(); // A no-op outside of Chrome OS. void OpenFirewallHole(const std::string& address,
diff --git a/extensions/browser/api/sockets_tcp/sockets_tcp_api.cc b/extensions/browser/api/sockets_tcp/sockets_tcp_api.cc index 86c4d754..a2e05c4 100644 --- a/extensions/browser/api/sockets_tcp/sockets_tcp_api.cc +++ b/extensions/browser/api/sockets_tcp/sockets_tcp_api.cc
@@ -5,6 +5,7 @@ #include "extensions/browser/api/sockets_tcp/sockets_tcp_api.h" #include <string> +#include <unordered_set> #include <utility> #include <vector> @@ -456,7 +457,7 @@ void SocketsTcpGetSocketsFunction::Work() { std::vector<sockets_tcp::SocketInfo> socket_infos; - base::hash_set<int>* resource_ids = GetSocketIds(); + std::unordered_set<int>* resource_ids = GetSocketIds(); if (resource_ids != NULL) { for (int socket_id : *resource_ids) { ResumableTCPSocket* socket = GetTcpSocket(socket_id);
diff --git a/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.cc b/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.cc index 45b8a780..a8356627 100644 --- a/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.cc +++ b/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.cc
@@ -4,6 +4,7 @@ #include "extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.h" +#include <unordered_set> #include <vector> #include "content/public/common/socket_permission_request.h" @@ -294,7 +295,7 @@ void SocketsTcpServerGetSocketsFunction::Work() { std::vector<sockets_tcp_server::SocketInfo> socket_infos; - base::hash_set<int>* resource_ids = GetSocketIds(); + std::unordered_set<int>* resource_ids = GetSocketIds(); if (resource_ids != NULL) { for (int socket_id : *resource_ids) { ResumableTCPServerSocket* socket = GetTcpSocket(socket_id);
diff --git a/extensions/browser/api/sockets_udp/sockets_udp_api.cc b/extensions/browser/api/sockets_udp/sockets_udp_api.cc index 70121fe..f67d183 100644 --- a/extensions/browser/api/sockets_udp/sockets_udp_api.cc +++ b/extensions/browser/api/sockets_udp/sockets_udp_api.cc
@@ -361,7 +361,7 @@ void SocketsUdpGetSocketsFunction::Work() { std::vector<sockets_udp::SocketInfo> socket_infos; - base::hash_set<int>* resource_ids = GetSocketIds(); + std::unordered_set<int>* resource_ids = GetSocketIds(); if (resource_ids != NULL) { for (int socket_id : *resource_ids) { ResumableUDPSocket* socket = GetUdpSocket(socket_id);
diff --git a/extensions/browser/api/webcam_private/webcam_private_api_chromeos.cc b/extensions/browser/api/webcam_private/webcam_private_api_chromeos.cc index ee5aab8..76dcfdd 100644 --- a/extensions/browser/api/webcam_private/webcam_private_api_chromeos.cc +++ b/extensions/browser/api/webcam_private/webcam_private_api_chromeos.cc
@@ -137,7 +137,7 @@ const std::string& webcam_id) const { DCHECK(webcam_resource_manager_); - base::hash_set<int>* connection_ids = + std::unordered_set<int>* connection_ids = webcam_resource_manager_->GetResourceIds(extension_id); if (!connection_ids) return nullptr; @@ -156,7 +156,7 @@ const std::string& webcam_id) { DCHECK(webcam_resource_manager_); - base::hash_set<int>* connection_ids = + std::unordered_set<int>* connection_ids = webcam_resource_manager_->GetResourceIds(extension_id); if (!connection_ids) return false;
diff --git a/gpu/command_buffer/service/framebuffer_completeness_cache.h b/gpu/command_buffer/service/framebuffer_completeness_cache.h index 05be906b..358dda5a 100644 --- a/gpu/command_buffer/service/framebuffer_completeness_cache.h +++ b/gpu/command_buffer/service/framebuffer_completeness_cache.h
@@ -6,6 +6,7 @@ #define GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_COMPLETENESS_CACHE_H_ #include <string> +#include <unordered_set> #include "base/containers/hash_tables.h" #include "base/macros.h" @@ -26,7 +27,7 @@ void SetComplete(const std::string& signature); private: - typedef base::hash_set<std::string> Map; + typedef std::unordered_set<std::string> Map; Map cache_;
diff --git a/gpu/command_buffer/service/query_manager.h b/gpu/command_buffer/service/query_manager.h index 300101f..a383f0c 100644 --- a/gpu/command_buffer/service/query_manager.h +++ b/gpu/command_buffer/service/query_manager.h
@@ -9,6 +9,7 @@ #include <memory> #include <unordered_map> +#include <unordered_set> #include <vector> #include "base/atomicops.h" @@ -249,7 +250,7 @@ using QueryMap = std::unordered_map<GLuint, scoped_refptr<Query>>; QueryMap queries_; - using GeneratedQueryIds = base::hash_set<GLuint>; + using GeneratedQueryIds = std::unordered_set<GLuint>; GeneratedQueryIds generated_query_ids_; // A map of targets -> Query for current active queries.
diff --git a/gpu/ipc/host/gpu_memory_buffer_support.h b/gpu/ipc/host/gpu_memory_buffer_support.h index 8e177e8..2542942 100644 --- a/gpu/ipc/host/gpu_memory_buffer_support.h +++ b/gpu/ipc/host/gpu_memory_buffer_support.h
@@ -5,6 +5,7 @@ #ifndef GPU_IPC_HOST_GPU_MEMORY_BUFFER_SUPPORT_H_ #define GPU_IPC_HOST_GPU_MEMORY_BUFFER_SUPPORT_H_ +#include <unordered_set> #include <utility> #include <vector> @@ -17,11 +18,11 @@ using GpuMemoryBufferConfigurationKey = std::pair<gfx::BufferFormat, gfx::BufferUsage>; using GpuMemoryBufferConfigurationSet = - base::hash_set<GpuMemoryBufferConfigurationKey>; + std::unordered_set<GpuMemoryBufferConfigurationKey>; } // namespace gpu -namespace BASE_HASH_NAMESPACE { +namespace std { template <> struct hash<gpu::GpuMemoryBufferConfigurationKey> { @@ -31,7 +32,7 @@ } }; -} // namespace BASE_HASH_NAMESPACE +} // namespace std namespace gpu {
diff --git a/ios/chrome/browser/about_flags.mm b/ios/chrome/browser/about_flags.mm index e76cf57..afabcaf 100644 --- a/ios/chrome/browser/about_flags.mm +++ b/ios/chrome/browser/about_flags.mm
@@ -496,6 +496,9 @@ flag_descriptions::kOnlyNewPasswordFormParsingDescription, flags_ui::kOsIos, FEATURE_VALUE_TYPE(password_manager::features::kOnlyNewParser)}, + {"snapshot-draw-view", flag_descriptions::kSnapshotDrawViewName, + flag_descriptions::kSnapshotDrawViewDescription, flags_ui::kOsIos, + FEATURE_VALUE_TYPE(kSnapshotDrawView)}, }; // Add all switches from experimental flags to |command_line|.
diff --git a/ios/chrome/browser/ios_chrome_flag_descriptions.cc b/ios/chrome/browser/ios_chrome_flag_descriptions.cc index 7296720..e664c25 100644 --- a/ios/chrome/browser/ios_chrome_flag_descriptions.cc +++ b/ios/chrome/browser/ios_chrome_flag_descriptions.cc
@@ -361,6 +361,10 @@ "When enabled, SadTab UI will be presented with UIViewController instead " "of using WebState::ShowTransientView"; +const char kSnapshotDrawViewName[] = "Use DrawViewHierarchy for Snapshots"; +const char kSnapshotDrawViewDescription[] = + "When enabled, snapshots will be taken using |-drawViewHierarchy:|."; + const char kUnifiedConsentName[] = "Unified Consent"; const char kUnifiedConsentDescription[] = "Enables a unified management of user consent for privacy-related "
diff --git a/ios/chrome/browser/ios_chrome_flag_descriptions.h b/ios/chrome/browser/ios_chrome_flag_descriptions.h index f88c056..46fb822 100644 --- a/ios/chrome/browser/ios_chrome_flag_descriptions.h +++ b/ios/chrome/browser/ios_chrome_flag_descriptions.h
@@ -295,6 +295,11 @@ extern const char kPresentSadTabInViewControllerName[]; extern const char kPresentSadTabInViewControllerDescription[]; +// Title and description for the flag to use |-drawViewHierarchy:| for taking +// snapshots. +extern const char kSnapshotDrawViewName[]; +extern const char kSnapshotDrawViewDescription[]; + // Title and description for the flag to enable the unified consent. extern const char kUnifiedConsentName[]; extern const char kUnifiedConsentDescription[];
diff --git a/ios/chrome/browser/snapshots/snapshot_generator.mm b/ios/chrome/browser/snapshots/snapshot_generator.mm index 1b38acd..53a1416 100644 --- a/ios/chrome/browser/snapshots/snapshot_generator.mm +++ b/ios/chrome/browser/snapshots/snapshot_generator.mm
@@ -4,11 +4,6 @@ #import "ios/chrome/browser/snapshots/snapshot_generator.h" -// TODO(crbug.com/636188): required to implement ViewHierarchyContainsWKWebView -// for -drawViewHierarchyInRect:afterScreenUpdates:, remove once the workaround -// is no longer needed. -#import <WebKit/WebKit.h> - #include <algorithm> #include "base/bind.h" @@ -19,6 +14,7 @@ #import "ios/chrome/browser/snapshots/snapshot_cache_factory.h" #import "ios/chrome/browser/snapshots/snapshot_generator_delegate.h" #import "ios/chrome/browser/snapshots/snapshot_overlay.h" +#include "ios/chrome/browser/ui/ui_feature_flags.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/web/public/web_state/web_state.h" #import "ios/web/public/web_state/web_state_observer_bridge.h" @@ -30,19 +26,6 @@ #error "This file requires ARC support." #endif -namespace { -// Returns YES if |view| or any view it contains is a WKWebView. -BOOL ViewHierarchyContainsWKWebView(UIView* view) { - if ([view isKindOfClass:[WKWebView class]]) - return YES; - for (UIView* subview in view.subviews) { - if (ViewHierarchyContainsWKWebView(subview)) - return YES; - } - return NO; -} -} // namespace - @interface SnapshotGenerator ()<CRWWebStateObserver> // Property providing access to the snapshot's cache. May be nil. @@ -225,14 +208,7 @@ CGContext* context = UIGraphicsGetCurrentContext(); DCHECK(context); - // TODO(crbug.com/636188): -drawViewHierarchyInRect:afterScreenUpdates: is - // buggy on iOS 8/9/10 (and state is unknown for iOS 11) causing GPU glitches, - // screen redraws during animations, broken pinch to dismiss on tablet, etc. - // For the moment, only use it for WKWebView with depends on it. Remove this - // check and always use -drawViewHierarchyInRect:afterScreenUpdates: once it - // is working correctly in all version of iOS supported. - BOOL useDrawViewHierarchy = ViewHierarchyContainsWKWebView(view); - + BOOL useDrawViewHierarchy = base::FeatureList::IsEnabled(kSnapshotDrawView); BOOL snapshotSuccess = YES; CGContextSaveGState(context); CGContextTranslateCTM(context, -rect.origin.x, -rect.origin.y);
diff --git a/ios/chrome/browser/ui/ui_feature_flags.cc b/ios/chrome/browser/ui/ui_feature_flags.cc index ed0a595..d26f71e 100644 --- a/ios/chrome/browser/ui/ui_feature_flags.cc +++ b/ios/chrome/browser/ui/ui_feature_flags.cc
@@ -18,3 +18,6 @@ const base::Feature kSearchCopiedImage{"SearchCopiedImage", base::FEATURE_DISABLED_BY_DEFAULT}; + +const base::Feature kSnapshotDrawView{"SnapshotDrawView", + base::FEATURE_DISABLED_BY_DEFAULT};
diff --git a/ios/chrome/browser/ui/ui_feature_flags.h b/ios/chrome/browser/ui/ui_feature_flags.h index a56a4001..0d71d0cd 100644 --- a/ios/chrome/browser/ui/ui_feature_flags.h +++ b/ios/chrome/browser/ui/ui_feature_flags.h
@@ -24,4 +24,7 @@ // Feature to allow user to search for a copied image. extern const base::Feature kSearchCopiedImage; +// Feature to take snapshots using |-drawViewHierarchy:|. +extern const base::Feature kSnapshotDrawView; + #endif // IOS_CHROME_BROWSER_UI_UI_FEATURE_FLAGS_H_
diff --git a/media/filters/vp9_parser.cc b/media/filters/vp9_parser.cc index c343565..706ee7c 100644 --- a/media/filters/vp9_parser.cc +++ b/media/filters/vp9_parser.cc
@@ -653,11 +653,10 @@ frame_info = frames_.front(); frames_.pop_front(); if (frame_decrypt_config) { - if (frame_info.decrypt_config) { + if (frame_info.decrypt_config) *frame_decrypt_config = frame_info.decrypt_config->Clone(); - } else { + else *frame_decrypt_config = nullptr; - } } if (ParseUncompressedHeader(frame_info, fhdr, &result))
diff --git a/mojo/core/BUILD.gn b/mojo/core/BUILD.gn index 26301df6..acfbeb9 100644 --- a/mojo/core/BUILD.gn +++ b/mojo/core/BUILD.gn
@@ -186,10 +186,7 @@ "//mojo/public/c/system:headers", ] if (is_win) { - inputs = [ - "mojo_core.def", - ] - ldflags = [ "/DEF:" + rebase_path("mojo_core.def", root_build_dir) ] + sources += [ "mojo_core.def" ] } else { configs += [ ":export_only_thunks_api" ] }
diff --git a/net/nqe/throughput_analyzer.h b/net/nqe/throughput_analyzer.h index 73682a2..a66d313d 100644 --- a/net/nqe/throughput_analyzer.h +++ b/net/nqe/throughput_analyzer.h
@@ -129,7 +129,7 @@ // Set of URL requests to hold the requests that reduce the accuracy of // throughput computation. These requests are not used in throughput // computation. - typedef base::hash_set<const URLRequest*> AccuracyDegradingRequests; + typedef std::unordered_set<const URLRequest*> AccuracyDegradingRequests; // Returns true if downstream throughput can be recorded. In that case, // |downstream_kbps| is set to the computed downstream throughput (in
diff --git a/ppapi/proxy/plugin_resource_tracker.h b/ppapi/proxy/plugin_resource_tracker.h index df6e6be..74daca4 100644 --- a/ppapi/proxy/plugin_resource_tracker.h +++ b/ppapi/proxy/plugin_resource_tracker.h
@@ -6,6 +6,7 @@ #define PPAPI_PROXY_PLUGIN_RESOURCE_TRACKER_H_ #include <map> +#include <unordered_set> #include <utility> #include "base/compiler_specific.h" @@ -61,7 +62,7 @@ typedef std::map<HostResource, PP_Resource> HostResourceMap; HostResourceMap host_resource_map_; - base::hash_set<PP_Resource> abandoned_resources_; + std::unordered_set<PP_Resource> abandoned_resources_; DISALLOW_COPY_AND_ASSIGN(PluginResourceTracker); };
diff --git a/ppapi/proxy/raw_var_data.cc b/ppapi/proxy/raw_var_data.cc index dfa5626d..35a74e6 100644 --- a/ppapi/proxy/raw_var_data.cc +++ b/ppapi/proxy/raw_var_data.cc
@@ -88,7 +88,7 @@ std::unique_ptr<RawVarDataGraph> graph(new RawVarDataGraph); // Map of |var.value.as_id| to a RawVarData index in RawVarDataGraph. std::unordered_map<int64_t, size_t> visited_map; - base::hash_set<int64_t> parent_ids; + std::unordered_set<int64_t> parent_ids; base::stack<StackEntry> stack; stack.push(StackEntry(var, GetOrCreateRawVarData(var, &visited_map,
diff --git a/storage/browser/BUILD.gn b/storage/browser/BUILD.gn index c0f1005..674f0ab 100644 --- a/storage/browser/BUILD.gn +++ b/storage/browser/BUILD.gn
@@ -202,9 +202,6 @@ defines = [ "IS_STORAGE_BROWSER_IMPL" ] configs += [ "//build/config:precompiled_headers", - - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - "//build/config/compiler:no_size_t_to_int_warning", "//build/config/compiler:wexit_time_destructors", ]
diff --git a/testing/buildbot/filters/mojo.fyi.network_browser_tests.filter b/testing/buildbot/filters/mojo.fyi.network_browser_tests.filter index 66038eaf..9a92d9c8 100644 --- a/testing/buildbot/filters/mojo.fyi.network_browser_tests.filter +++ b/testing/buildbot/filters/mojo.fyi.network_browser_tests.filter
@@ -1,31 +1,8 @@ -# NOTE: if adding an exclusion for an existing failure (e.g. additional test for -# feature X that is already not working), please add it beside the existing -# failures. Otherwise please reach out to network-service-dev@. - # These tests currently fail when run with --enable-features=NetworkService # See https://crbug.com/769401 -# Uncategorized timeouts or test failures. --RegisterProtocolHandlerBrowserTest.CustomHandler - -# These tests use URLFetchers directly. -# https://crbug.com/853798 --ProfileBrowserTest.SeparateMediaCache - # https://crbug.com/816684 Track Page Load Metrics. -PageLoadMetricsBrowserTest.LoadingMetricsFailed -# https://crbug.com/773295 -# Remove this test when there are no more clients left that use URLFetcher. --VariationsHttpHeadersBrowserTest.TestStrippingHeadersFromInternalRequest - -# Channel ID is not hooked up to the network service yet. -# https://crbug.com/840412 --JavaScriptBindings/ExternallyConnectableMessagingTest.WebConnectableWithNonEmptyTlsChannelId/0 --JavaScriptBindings/MessagingApiTest.DifferentStoragePartitionTLSChannelID/0 --NativeBindings/ExternallyConnectableMessagingTest.WebConnectableWithNonEmptyTlsChannelId/0 --NativeBindings/MessagingApiTest.DifferentStoragePartitionTLSChannelID/0 - -# NOTE: if adding an exclusion for an existing failure (e.g. additional test for -# feature X that is already not working), please add it beside the existing -# failures. Otherwise please reach out to network-service-dev@. +# DO NOT ADD ANY MORE ENTRIES! Network service is about to ship to stable. +# Please reach out to network-service-dev@ if you have any questions.
diff --git a/third_party/blink/common/mime_util/mime_util.cc b/third_party/blink/common/mime_util/mime_util.cc index 48f984e..0f7413b 100644 --- a/third_party/blink/common/mime_util/mime_util.cc +++ b/third_party/blink/common/mime_util/mime_util.cc
@@ -113,7 +113,7 @@ private: friend struct base::LazyInstanceTraitsBase<MimeUtil>; - using MimeTypes = base::hash_set<std::string>; + using MimeTypes = std::unordered_set<std::string>; MimeUtil();
diff --git a/third_party/blink/public/platform/web_application_cache_host.h b/third_party/blink/public/platform/web_application_cache_host.h index 50322fc1..abe65c10 100644 --- a/third_party/blink/public/platform/web_application_cache_host.h +++ b/third_party/blink/public/platform/web_application_cache_host.h
@@ -100,8 +100,6 @@ // Called as the main resource is retrieved. virtual void DidReceiveResponseForMainResource(const WebURLResponse&) {} - virtual void DidReceiveDataForMainResource(const char* data, size_t len) {} - virtual void DidFinishLoadingMainResource(bool success) {} // Called on behalf of the scriptable interface. virtual Status GetStatus() { return kUncached; }
diff --git a/third_party/blink/public/platform/web_url_request.h b/third_party/blink/public/platform/web_url_request.h index 5e61452..7962405 100644 --- a/third_party/blink/public/platform/web_url_request.h +++ b/third_party/blink/public/platform/web_url_request.h
@@ -291,8 +291,6 @@ BLINK_PLATFORM_EXPORT network::mojom::CorsPreflightPolicy GetCorsPreflightPolicy() const; - BLINK_PLATFORM_EXPORT void SetNavigationStartTime(base::TimeTicks); - // If this request was created from an anchor with a download attribute, this // is the value provided there. BLINK_PLATFORM_EXPORT base::Optional<WebString> GetSuggestedFilename() const;
diff --git a/third_party/blink/renderer/core/BUILD.gn b/third_party/blink/renderer/core/BUILD.gn index 1dd75cc..8758327 100644 --- a/third_party/blink/renderer/core/BUILD.gn +++ b/third_party/blink/renderer/core/BUILD.gn
@@ -2208,10 +2208,6 @@ "testing/sim/sim_request.h", "testing/sim/sim_test.cc", "testing/sim/sim_test.h", - "testing/sim/sim_web_frame_client.cc", - "testing/sim/sim_web_frame_client.h", - "testing/sim/sim_web_view_client.cc", - "testing/sim/sim_web_view_client.h", "timing/memory_info_test.cc", "timing/performance_navigation_timing_test.cc", "timing/performance_observer_test.cc",
diff --git a/third_party/blink/renderer/core/dom/container_node.cc b/third_party/blink/renderer/core/dom/container_node.cc index cce4bc21..082d272 100644 --- a/third_party/blink/renderer/core/dom/container_node.cc +++ b/third_party/blink/renderer/core/dom/container_node.cc
@@ -673,7 +673,7 @@ Node* child = old_child; - GetDocument().RemoveFocusedElementOfSubtree(child); + GetDocument().RemoveFocusedElementOfSubtree(*child); // Events fired when blurring currently focused node might have moved this // child into a different parent. @@ -793,7 +793,7 @@ // children will be removed. // This must be later than willRemoveChildren, which might change focus // state of a child. - GetDocument().RemoveFocusedElementOfSubtree(this, true); + GetDocument().RemoveFocusedElementOfSubtree(*this, true); // Removing a node from a selection can cause widget updates. GetDocument().NodeChildrenWillBeRemoved(*this);
diff --git a/third_party/blink/renderer/core/dom/document.cc b/third_party/blink/renderer/core/dom/document.cc index 2349199..d40ed4d 100644 --- a/third_party/blink/renderer/core/dom/document.cc +++ b/third_party/blink/renderer/core/dom/document.cc
@@ -4614,17 +4614,17 @@ active_element_ = new_active_element; } -void Document::RemoveFocusedElementOfSubtree(Node* node, +void Document::RemoveFocusedElementOfSubtree(Node& node, bool among_children_only) { if (!focused_element_) return; // We can't be focused if we're not in the document. - if (!node->isConnected()) + if (!node.isConnected()) return; bool contains = - node->IsShadowIncludingInclusiveAncestorOf(focused_element_.Get()); - if (contains && (focused_element_ != node || !among_children_only)) + node.IsShadowIncludingInclusiveAncestorOf(focused_element_.Get()); + if (contains && (focused_element_ != &node || !among_children_only)) ClearFocusedElement(); }
diff --git a/third_party/blink/renderer/core/dom/document.h b/third_party/blink/renderer/core/dom/document.h index 95bdebf..570622d 100644 --- a/third_party/blink/renderer/core/dom/document.h +++ b/third_party/blink/renderer/core/dom/document.h
@@ -784,7 +784,7 @@ Element* HoverElement() const { return hover_element_.Get(); } - void RemoveFocusedElementOfSubtree(Node*, bool among_children_only = false); + void RemoveFocusedElementOfSubtree(Node&, bool among_children_only = false); void HoveredElementDetached(Element&); void ActiveChainNodeDetached(Element&);
diff --git a/third_party/blink/renderer/core/exported/web_meaningful_layouts_test.cc b/third_party/blink/renderer/core/exported/web_meaningful_layouts_test.cc index 52ec30b..8a9e2ede 100644 --- a/third_party/blink/renderer/core/exported/web_meaningful_layouts_test.cc +++ b/third_party/blink/renderer/core/exported/web_meaningful_layouts_test.cc
@@ -28,7 +28,7 @@ Compositor().BeginFrame(); - EXPECT_EQ(1, WebViewClient().VisuallyNonEmptyLayoutCount()); + EXPECT_EQ(1, WebWidgetClient().VisuallyNonEmptyLayoutCount()); } TEST_F(WebMeaningfulLayoutsTest, VisuallyNonEmptyTextCharactersEventually) { @@ -44,7 +44,7 @@ // Pump a frame mid-load. Compositor().BeginFrame(); - EXPECT_EQ(0, WebViewClient().VisuallyNonEmptyLayoutCount()); + EXPECT_EQ(0, WebWidgetClient().VisuallyNonEmptyLayoutCount()); // Write more than 200 characters. main_resource.Write("!"); @@ -55,7 +55,7 @@ // not as the character count goes over 200. Compositor().BeginFrame(); - EXPECT_EQ(1, WebViewClient().VisuallyNonEmptyLayoutCount()); + EXPECT_EQ(1, WebWidgetClient().VisuallyNonEmptyLayoutCount()); } // TODO(dglazkov): Write pixel-count and canvas-based VisuallyNonEmpty tests @@ -83,7 +83,7 @@ Compositor().BeginFrame(); // ... which correctly signals the VisuallyNonEmpty. - EXPECT_EQ(1, WebViewClient().VisuallyNonEmptyLayoutCount()); + EXPECT_EQ(1, WebWidgetClient().VisuallyNonEmptyLayoutCount()); } TEST_F(WebMeaningfulLayoutsTest, FinishedParsing) { @@ -95,7 +95,7 @@ Compositor().BeginFrame(); - EXPECT_EQ(1, WebViewClient().FinishedParsingLayoutCount()); + EXPECT_EQ(1, WebWidgetClient().FinishedParsingLayoutCount()); } TEST_F(WebMeaningfulLayoutsTest, FinishedLoading) { @@ -107,7 +107,7 @@ Compositor().BeginFrame(); - EXPECT_EQ(1, WebViewClient().FinishedLoadingLayoutCount()); + EXPECT_EQ(1, WebWidgetClient().FinishedLoadingLayoutCount()); } TEST_F(WebMeaningfulLayoutsTest, FinishedParsingThenLoading) { @@ -121,8 +121,8 @@ Compositor().BeginFrame(); - EXPECT_EQ(1, WebViewClient().FinishedParsingLayoutCount()); - EXPECT_EQ(0, WebViewClient().FinishedLoadingLayoutCount()); + EXPECT_EQ(1, WebWidgetClient().FinishedParsingLayoutCount()); + EXPECT_EQ(0, WebWidgetClient().FinishedLoadingLayoutCount()); image_resource.Complete("image data"); @@ -131,8 +131,8 @@ Compositor().BeginFrame(); - EXPECT_EQ(1, WebViewClient().FinishedParsingLayoutCount()); - EXPECT_EQ(1, WebViewClient().FinishedLoadingLayoutCount()); + EXPECT_EQ(1, WebWidgetClient().FinishedParsingLayoutCount()); + EXPECT_EQ(1, WebWidgetClient().FinishedLoadingLayoutCount()); } TEST_F(WebMeaningfulLayoutsTest, WithIFrames) { @@ -145,9 +145,9 @@ Compositor().BeginFrame(); - EXPECT_EQ(1, WebViewClient().VisuallyNonEmptyLayoutCount()); - EXPECT_EQ(1, WebViewClient().FinishedParsingLayoutCount()); - EXPECT_EQ(0, WebViewClient().FinishedLoadingLayoutCount()); + EXPECT_EQ(1, WebWidgetClient().VisuallyNonEmptyLayoutCount()); + EXPECT_EQ(1, WebWidgetClient().FinishedParsingLayoutCount()); + EXPECT_EQ(0, WebWidgetClient().FinishedLoadingLayoutCount()); iframe_resource.Complete("iframe data"); @@ -156,9 +156,9 @@ Compositor().BeginFrame(); - EXPECT_EQ(1, WebViewClient().VisuallyNonEmptyLayoutCount()); - EXPECT_EQ(1, WebViewClient().FinishedParsingLayoutCount()); - EXPECT_EQ(1, WebViewClient().FinishedLoadingLayoutCount()); + EXPECT_EQ(1, WebWidgetClient().VisuallyNonEmptyLayoutCount()); + EXPECT_EQ(1, WebWidgetClient().FinishedParsingLayoutCount()); + EXPECT_EQ(1, WebWidgetClient().FinishedLoadingLayoutCount()); } // NoOverflowInIncrementVisuallyNonEmptyPixelCount tests fail if the number of @@ -175,7 +175,7 @@ main_resource.Write("<DOCTYPE html><body><img src=\"test.svg\">"); // Run pending tasks to initiate the request to test.svg. test::RunPendingTasks(); - EXPECT_EQ(0, WebViewClient().VisuallyNonEmptyLayoutCount()); + EXPECT_EQ(0, WebWidgetClient().VisuallyNonEmptyLayoutCount()); // We serve the SVG file and check visuallyNonEmptyLayoutCount() before // mainResource.finish() because finishing the main resource causes @@ -187,7 +187,7 @@ "width=\"65536\"></svg>"); svg_resource.Finish(); Compositor().BeginFrame(); - EXPECT_EQ(1, WebViewClient().VisuallyNonEmptyLayoutCount()); + EXPECT_EQ(1, WebWidgetClient().VisuallyNonEmptyLayoutCount()); main_resource.Finish(); }
diff --git a/third_party/blink/renderer/core/frame/frame_test_helpers.cc b/third_party/blink/renderer/core/frame/frame_test_helpers.cc index fe3e5b7..2a8d37d4 100644 --- a/third_party/blink/renderer/core/frame/frame_test_helpers.cc +++ b/third_party/blink/renderer/core/frame/frame_test_helpers.cc
@@ -41,6 +41,7 @@ #include "third_party/blink/public/platform/web_url_loader_mock_factory.h" #include "third_party/blink/public/platform/web_url_request.h" #include "third_party/blink/public/platform/web_url_response.h" +#include "third_party/blink/public/web/web_console_message.h" #include "third_party/blink/public/web/web_frame_widget.h" #include "third_party/blink/public/web/web_navigation_params.h" #include "third_party/blink/public/web/web_settings.h" @@ -49,6 +50,7 @@ #include "third_party/blink/renderer/core/exported/web_remote_frame_impl.h" #include "third_party/blink/renderer/core/frame/web_local_frame_impl.h" #include "third_party/blink/renderer/core/testing/core_unit_test_helper.h" +#include "third_party/blink/renderer/core/testing/fake_web_plugin.h" #include "third_party/blink/renderer/platform/scheduler/public/thread.h" #include "third_party/blink/renderer/platform/testing/unit_test_helpers.h" #include "third_party/blink/renderer/platform/testing/url_test_helpers.h" @@ -369,12 +371,15 @@ } void WebViewHelper::Reset() { + if (test_web_view_client_) + test_web_view_client_->DestroyChildViews(); if (web_view_) { DCHECK(!TestWebFrameClient::IsLoading()); // This closes the WebView also. web_view_->MainFrameWidget()->Close(); web_view_ = nullptr; } + test_web_view_client_ = nullptr; } WebLocalFrameImpl* WebViewHelper::LocalMainFrame() const { @@ -416,7 +421,8 @@ int TestWebFrameClient::loads_in_progress_ = 0; TestWebFrameClient::TestWebFrameClient() - : interface_provider_(new service_manager::InterfaceProvider()) {} + : interface_provider_(new service_manager::InterfaceProvider()), + effective_connection_type_(WebEffectiveConnectionType::kTypeUnknown) {} void TestWebFrameClient::Bind(WebLocalFrame* frame, std::unique_ptr<TestWebFrameClient> self_owned) { @@ -470,8 +476,25 @@ nullptr /* extra_data */); } -void TestWebFrameClient::DidCreateDocumentLoader( - WebDocumentLoader* document_loader) { +WebEffectiveConnectionType TestWebFrameClient::GetEffectiveConnectionType() { + return effective_connection_type_; +} + +void TestWebFrameClient::SetEffectiveConnectionTypeForTesting( + WebEffectiveConnectionType effective_connection_type) { + effective_connection_type_ = effective_connection_type; +} + +void TestWebFrameClient::DidAddMessageToConsole( + const WebConsoleMessage& message, + const WebString& source_name, + unsigned source_line, + const WebString& stack_trace) { + console_messages_.push_back(message.text); +} + +WebPlugin* TestWebFrameClient::CreatePlugin(const WebPluginParams& params) { + return new FakeWebPlugin(params); } TestWebRemoteFrameClient::TestWebRemoteFrameClient() = default; @@ -525,6 +548,21 @@ layer_tree_view_ = layer_tree_view_factory_.Initialize(); } +void TestWebWidgetClient::DidMeaningfulLayout( + WebMeaningfulLayout meaningful_layout) { + switch (meaningful_layout) { + case WebMeaningfulLayout::kVisuallyNonEmpty: + visually_non_empty_layout_count_++; + break; + case WebMeaningfulLayout::kFinishedParsing: + finished_parsing_layout_count_++; + break; + case WebMeaningfulLayout::kFinishedLoading: + finished_loading_layout_count_++; + break; + } +} + TestWebViewClient::TestWebViewClient(TestWebWidgetClient* widget_client, content::LayerTreeViewDelegate* delegate) { // NOTE: The WebWidgetClient* could possibly be |this|, so do not call any @@ -534,5 +572,23 @@ layer_tree_view_ = layer_tree_view_factory_.Initialize(delegate); } +void TestWebViewClient::DestroyChildViews() { + child_web_views_.clear(); +} + +WebView* TestWebViewClient::CreateView(WebLocalFrame* opener, + const WebURLRequest&, + const WebWindowFeatures&, + const WebString& name, + WebNavigationPolicy, + bool, + WebSandboxFlags, + const SessionStorageNamespaceId&) { + auto webview_helper = std::make_unique<WebViewHelper>(); + WebView* result = webview_helper->InitializeWithOpener(opener); + child_web_views_.push_back(std::move(webview_helper)); + return result; +} + } // namespace frame_test_helpers } // namespace blink
diff --git a/third_party/blink/renderer/core/frame/frame_test_helpers.h b/third_party/blink/renderer/core/frame/frame_test_helpers.h index ad24426..0b139a0 100644 --- a/third_party/blink/renderer/core/frame/frame_test_helpers.h +++ b/third_party/blink/renderer/core/frame/frame_test_helpers.h
@@ -59,6 +59,7 @@ #include "third_party/blink/renderer/core/scroll/scrollbar_theme.h" #include "third_party/blink/renderer/core/testing/use_mock_scrollbar_settings.h" #include "third_party/blink/renderer/platform/runtime_enabled_features.h" +#include "third_party/blink/renderer/platform/wtf/vector.h" #define EXPECT_FLOAT_POINT_EQ(expected, actual) \ do { \ @@ -93,6 +94,7 @@ class TestWebRemoteFrameClient; class TestWebWidgetClient; class TestWebViewClient; +class WebViewHelper; // Loads a url into the specified WebLocalFrame for testing purposes. Pumps any // pending resource requests, as well as waiting for the threaded parser to @@ -192,10 +194,25 @@ bool AnimationScheduled() { return animation_scheduled_; } void ClearAnimationScheduled() { animation_scheduled_ = false; } + void DidMeaningfulLayout(WebMeaningfulLayout) override; + + int VisuallyNonEmptyLayoutCount() const { + return visually_non_empty_layout_count_; + } + int FinishedParsingLayoutCount() const { + return finished_parsing_layout_count_; + } + int FinishedLoadingLayoutCount() const { + return finished_loading_layout_count_; + } + private: content::LayerTreeView* layer_tree_view_ = nullptr; LayerTreeViewFactory layer_tree_view_factory_; bool animation_scheduled_ = false; + int visually_non_empty_layout_count_ = 0; + int finished_parsing_layout_count_ = 0; + int finished_loading_layout_count_ = 0; }; class TestWebViewClient : public WebViewClient { @@ -208,18 +225,28 @@ content::LayerTreeView* layer_tree_view() { return layer_tree_view_; } TestWebWidgetClient* TestWidgetClient() { return test_web_widget_client_; } + void DestroyChildViews(); // WebViewClient overrides. bool CanHandleGestureEvent() override { return true; } bool CanUpdateLayout() override { return true; } WebWidgetClient* WidgetClient() override { return test_web_widget_client_; } blink::WebScreenInfo GetScreenInfo() override { return {}; } + WebView* CreateView(WebLocalFrame* opener, + const WebURLRequest&, + const WebWindowFeatures&, + const WebString& name, + WebNavigationPolicy, + bool, + WebSandboxFlags, + const SessionStorageNamespaceId&) override; private: std::unique_ptr<TestWebWidgetClient> owned_test_web_widget_client_; TestWebWidgetClient* test_web_widget_client_; content::LayerTreeView* layer_tree_view_ = nullptr; LayerTreeViewFactory layer_tree_view_factory_; + WTF::Vector<std::unique_ptr<WebViewHelper>> child_web_views_; }; // Convenience class for handling the lifetime of a WebView and its associated @@ -286,7 +313,7 @@ WebViewImpl* web_view_; UseMockScrollbarSettings mock_scrollbar_settings_; std::unique_ptr<TestWebViewClient> owned_test_web_view_client_; - TestWebViewClient* test_web_view_client_; + TestWebViewClient* test_web_view_client_ = nullptr; DISALLOW_COPY_AND_ASSIGN(WebViewHelper); }; @@ -300,6 +327,7 @@ ~TestWebFrameClient() override = default; static bool IsLoading() { return loads_in_progress_ > 0; } + Vector<String>& ConsoleMessages() { return console_messages_; } WebNavigationControl* Frame() const { return frame_; } // Pass ownership of the TestWebFrameClient to |self_owned| here if the @@ -321,7 +349,6 @@ FrameOwnerElementType) override; void DidStartLoading() override; void DidStopLoading() override; - void DidCreateDocumentLoader(WebDocumentLoader*) override; service_manager::InterfaceProvider* GetInterfaceProvider() override { return interface_provider_.get(); } @@ -332,6 +359,14 @@ return Platform::Current()->CreateDefaultURLLoaderFactory(); } void BeginNavigation(std::unique_ptr<WebNavigationInfo> info) override; + WebEffectiveConnectionType GetEffectiveConnectionType() override; + void SetEffectiveConnectionTypeForTesting( + WebEffectiveConnectionType) override; + void DidAddMessageToConsole(const WebConsoleMessage&, + const WebString& source_name, + unsigned source_line, + const WebString& stack_trace) override; + WebPlugin* CreatePlugin(const WebPluginParams& params) override; private: static int loads_in_progress_; @@ -348,6 +383,8 @@ WebNavigationControl* frame_ = nullptr; std::unique_ptr<WebWidgetClient> owned_widget_client_; + WebEffectiveConnectionType effective_connection_type_; + Vector<String> console_messages_; }; // Minimal implementation of WebRemoteFrameClient needed for unit tests that
diff --git a/third_party/blink/renderer/core/html/custom/element_internals.cc b/third_party/blink/renderer/core/html/custom/element_internals.cc index f20c50b7b..83f706a 100644 --- a/third_party/blink/renderer/core/html/custom/element_internals.cc +++ b/third_party/blink/renderer/core/html/custom/element_internals.cc
@@ -56,7 +56,7 @@ "The target element is not a form-associated custom element."); return; } - if (!entry_source || entry_source->size() == 0u) { + if (!entry_source) { value_ = value; entry_source_ = nullptr; return; @@ -220,7 +220,7 @@ if (Target().IsDisabledFormControl()) return; const AtomicString& name = Target().FastGetAttribute(html_names::kNameAttr); - if (!entry_source_ || entry_source_->size() == 0u) { + if (!entry_source_) { if (name.IsNull()) return; if (value_.IsFile())
diff --git a/third_party/blink/renderer/core/html/lazy_load_frame_observer_test.cc b/third_party/blink/renderer/core/html/lazy_load_frame_observer_test.cc index b46efa70..aeb515f 100644 --- a/third_party/blink/renderer/core/html/lazy_load_frame_observer_test.cc +++ b/third_party/blink/renderer/core/html/lazy_load_frame_observer_test.cc
@@ -98,7 +98,7 @@ scoped_restrict_lazy_frame_loading_to_data_saver_for_test_(false) {} void SetUp() override { - SetEffectiveConnectionTypeForTesting( + WebFrameClient().SetEffectiveConnectionTypeForTesting( std::get<WebEffectiveConnectionType>(GetParam())); SimTest::SetUp(); @@ -1106,7 +1106,7 @@ static constexpr int kLoadingDistanceThresholdPx = 1000; void SetUp() override { - SetEffectiveConnectionTypeForTesting( + WebFrameClient().SetEffectiveConnectionTypeForTesting( WebEffectiveConnectionType::kTypeUnknown); SimTest::SetUp();
diff --git a/third_party/blink/renderer/core/html/media/media_document.cc b/third_party/blink/renderer/core/html/media/media_document.cc index 0cd4b948..0c2805f 100644 --- a/third_party/blink/renderer/core/html/media/media_document.cc +++ b/third_party/blink/renderer/core/html/media/media_document.cc
@@ -54,25 +54,25 @@ using namespace html_names; -// FIXME: Share more code with PluginDocumentParser. class MediaDocumentParser : public RawDataDocumentParser { public: - static MediaDocumentParser* Create(MediaDocument* document) { - return MakeGarbageCollected<MediaDocumentParser>(document); - } - explicit MediaDocumentParser(Document* document) - : RawDataDocumentParser(document), did_build_document_structure_(false) {} + : RawDataDocumentParser(document) {} private: - void AppendBytes(const char*, size_t) override; + void AppendBytes(const char*, size_t) override {} + void Finish() override; void CreateDocumentStructure(); - bool did_build_document_structure_; + bool did_build_document_structure_ = false; }; void MediaDocumentParser::CreateDocumentStructure() { + if (did_build_document_structure_) + return; + did_build_document_structure_ = true; + DCHECK(GetDocument()); HTMLHtmlElement* root_element = HTMLHtmlElement::Create(*GetDocument()); GetDocument()->AppendChild(root_element); @@ -109,16 +109,11 @@ if (IsDetached()) return; // DOM insertion events can detach the frame. root_element->AppendChild(body); - - did_build_document_structure_ = true; } -void MediaDocumentParser::AppendBytes(const char*, size_t) { - if (did_build_document_structure_) - return; - +void MediaDocumentParser::Finish() { CreateDocumentStructure(); - Finish(); + RawDataDocumentParser::Finish(); } MediaDocument::MediaDocument(const DocumentInit& initializer) @@ -134,7 +129,7 @@ } DocumentParser* MediaDocument::CreateParser() { - return MediaDocumentParser::Create(this); + return MakeGarbageCollected<MediaDocumentParser>(this); } void MediaDocument::DefaultEventHandler(Event& event) {
diff --git a/third_party/blink/renderer/core/html/parser/html_parser_scheduler.cc b/third_party/blink/renderer/core/html/parser/html_parser_scheduler.cc index 19c9292..da16698 100644 --- a/third_party/blink/renderer/core/html/parser/html_parser_scheduler.cc +++ b/third_party/blink/renderer/core/html/parser/html_parser_scheduler.cc
@@ -25,8 +25,6 @@ #include "third_party/blink/renderer/core/html/parser/html_parser_scheduler.h" -#include "base/feature_list.h" -#include "base/metrics/field_trial_params.h" #include "third_party/blink/public/platform/platform.h" #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/frame/local_frame_view.h" @@ -37,10 +35,6 @@ namespace blink { -const base::Feature kHTMLParsingYieldTime { - "HTMLParsingYieldTime", base::FEATURE_DISABLED_BY_DEFAULT -}; - PumpSession::PumpSession(unsigned& nesting_level) : NestingLevelIncrementer(nesting_level) {} @@ -61,18 +55,12 @@ processed_element_tokens_ += count; } -const double kDefaultParserTimeLimit = 0.5; - HTMLParserScheduler::HTMLParserScheduler( HTMLDocumentParser* parser, scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner) : parser_(parser), loading_task_runner_(std::move(loading_task_runner)), - is_paused_with_active_timer_(false), - parser_time_limit_( - base::GetFieldTrialParamByFeatureAsDouble(kHTMLParsingYieldTime, - "limit", - kDefaultParserTimeLimit)) {} + is_paused_with_active_timer_(false) {} HTMLParserScheduler::~HTMLParserScheduler() = default; @@ -120,7 +108,8 @@ if (ThreadScheduler::Current()->ShouldYieldForHighPriorityWork()) return true; - if (session.ElapsedTime() > parser_time_limit_) + const double kParserTimeLimit = 0.5; + if (session.ElapsedTime() > kParserTimeLimit) return true; // Yield if a lot of DOM work has been done in this session and a script tag
diff --git a/third_party/blink/renderer/core/html/parser/html_parser_scheduler.h b/third_party/blink/renderer/core/html/parser/html_parser_scheduler.h index f555db1e..629d75a 100644 --- a/third_party/blink/renderer/core/html/parser/html_parser_scheduler.h +++ b/third_party/blink/renderer/core/html/parser/html_parser_scheduler.h
@@ -106,7 +106,6 @@ TaskHandle cancellable_continue_parse_task_handle_; bool is_paused_with_active_timer_; - const double parser_time_limit_; DISALLOW_COPY_AND_ASSIGN(HTMLParserScheduler); };
diff --git a/third_party/blink/renderer/core/html/plugin_document.cc b/third_party/blink/renderer/core/html/plugin_document.cc index c4d24f1..b57b300b 100644 --- a/third_party/blink/renderer/core/html/plugin_document.cc +++ b/third_party/blink/renderer/core/html/plugin_document.cc
@@ -99,8 +99,8 @@ private: void AppendBytes(const char*, size_t) override; - void Finish() override; + void StopParsing() override; void CreateDocumentStructure(); @@ -111,6 +111,9 @@ }; void PluginDocumentParser::CreateDocumentStructure() { + if (embed_element_) + return; + // FIXME: Assert we have a loader to figure out why the original null checks // and assert were added for the security bug in // http://trac.webkit.org/changeset/87566 @@ -183,12 +186,9 @@ } void PluginDocumentParser::AppendBytes(const char* data, size_t length) { - if (!embed_element_) { - CreateDocumentStructure(); - if (IsStopped()) - return; - } - + CreateDocumentStructure(); + if (IsStopped()) + return; if (!length) return; if (WebPluginContainerImpl* view = GetPluginView()) @@ -196,10 +196,16 @@ } void PluginDocumentParser::Finish() { + CreateDocumentStructure(); embed_element_ = nullptr; RawDataDocumentParser::Finish(); } +void PluginDocumentParser::StopParsing() { + CreateDocumentStructure(); + RawDataDocumentParser::StopParsing(); +} + WebPluginContainerImpl* PluginDocumentParser::GetPluginView() const { return ToPluginDocument(GetDocument())->GetPluginView(); }
diff --git a/third_party/blink/renderer/core/layout/ng/ng_flex_layout_algorithm.cc b/third_party/blink/renderer/core/layout/ng/ng_flex_layout_algorithm.cc index 1f9e95b..7afc944 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_flex_layout_algorithm.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_flex_layout_algorithm.cc
@@ -255,9 +255,9 @@ max_main_axis_extent = std::max(max_main_axis_extent, line->main_axis_extent); } - LayoutUnit intrinsic_block_content_size = cross_axis_offset; - if (is_column) - intrinsic_block_content_size = max_main_axis_extent; + LayoutUnit intrinsic_block_content_size = + is_column ? max_main_axis_extent + : cross_axis_offset - border_scrollbar_padding_.block_start; LayoutUnit intrinsic_block_size = intrinsic_block_content_size + border_scrollbar_padding_.BlockSum(); LayoutUnit block_size = ComputeBlockSizeForFragment(
diff --git a/third_party/blink/renderer/core/loader/appcache/application_cache_host.cc b/third_party/blink/renderer/core/loader/appcache/application_cache_host.cc index ec240a0..ca3044f 100644 --- a/third_party/blink/renderer/core/loader/appcache/application_cache_host.cc +++ b/third_party/blink/renderer/core/loader/appcache/application_cache_host.cc
@@ -179,22 +179,6 @@ } } -void ApplicationCacheHost::MainResourceDataReceived(const char* data, - size_t length) { - if (host_) - host_->DidReceiveDataForMainResource(data, length); -} - -void ApplicationCacheHost::FailedLoadingMainResource() { - if (host_) - host_->DidFinishLoadingMainResource(false); -} - -void ApplicationCacheHost::FinishedLoadingMainResource() { - if (host_) - host_->DidFinishLoadingMainResource(true); -} - void ApplicationCacheHost::SetApplicationCache( ApplicationCache* dom_application_cache) { DCHECK(!dom_application_cache_ || !dom_application_cache);
diff --git a/third_party/blink/renderer/core/loader/appcache/application_cache_host.h b/third_party/blink/renderer/core/loader/appcache/application_cache_host.h index cddf5be..fcc6068 100644 --- a/third_party/blink/renderer/core/loader/appcache/application_cache_host.h +++ b/third_party/blink/renderer/core/loader/appcache/application_cache_host.h
@@ -136,8 +136,6 @@ void DidReceiveResponseForMainResource(const ResourceResponse&); void MainResourceDataReceived(const char* data, size_t length); - void FinishedLoadingMainResource(); - void FailedLoadingMainResource(); Status GetStatus() const; bool Update();
diff --git a/third_party/blink/renderer/core/loader/document_loader.cc b/third_party/blink/renderer/core/loader/document_loader.cc index f11a7adc..1995d578 100644 --- a/third_party/blink/renderer/core/loader/document_loader.cc +++ b/third_party/blink/renderer/core/loader/document_loader.cc
@@ -421,14 +421,15 @@ const int64_t encoded_data_length = response.EncodedDataLength(); navigation_timing_info_->AddFinalTransferSize( encoded_data_length == -1 ? 0 : encoded_data_length); + if (response.HttpStatusCode() < 400 && report_timing_info_to_parent_) { + navigation_timing_info_->SetLoadFinishTime(resource->LoadFinishTime()); + fetcher_->Context().AddResourceTiming(*navigation_timing_info_); + } } FinishedLoading(resource->LoadFinishTime()); return; } - if (application_cache_host_) - application_cache_host_->FailedLoadingMainResource(); - if (resource->GetResourceError().WasBlockedByResponse()) { probe::didReceiveResourceResponse( probe::ToCoreProbeSink(frame_->GetDocument()), MainResourceIdentifier(), @@ -486,7 +487,7 @@ scoped_refptr<SharedBuffer> buffer = GenerateFtpDirectoryListingHtml( response_.CurrentRequestUrl(), data_buffer_.get()); for (const auto& span : *buffer) - ProcessData(span.data(), span.size()); + CommitData(span.data(), span.size()); } TimeTicks response_end_time = finish_time; @@ -496,16 +497,16 @@ response_end_time = CurrentTimeTicks(); GetTiming().SetResponseEnd(response_end_time); if (!MaybeCreateArchive()) { - // If this is an empty document, it will not have actually been created yet. - // Force a commit so that the Document actually gets created. + // If this is an empty document, it might not have actually been + // committed yet. Force a commit so that the Document actually gets created. if (state_ == kProvisional) - CommitData(nullptr, 0); + CommitNavigation(response_.MimeType()); } + DCHECK_GE(state_, kCommitted); if (!frame_) return; - application_cache_host_->FinishedLoadingMainResource(); if (parser_) { if (parser_blocked_count_) { finished_loading_ = true; @@ -792,6 +793,12 @@ response_.HttpHeaderField(http_names::kRefresh), Document::kHttpRefreshFromHeader); ReportPreviewsIntervention(); + + // If we did commit MediaDocument, we should stop here. + if (frame_ && frame_->GetDocument()->IsMediaDocument()) { + parser_->Finish(); + fetcher_->StopFetching(); + } } void DocumentLoader::CommitData(const char* bytes, size_t length) { @@ -823,6 +830,7 @@ DCHECK_EQ(resource, GetResource()); DCHECK(!response_.IsNull()); DCHECK(!frame_->GetPage()->Paused()); + time_of_last_data_received_ = CurrentTimeTicks(); if (listing_ftp_directory_ || loading_mhtml_archive_) { data_buffer_->Append(data, length); @@ -841,31 +849,20 @@ } base::AutoReset<bool> reentrancy_protector(&in_data_received_, true); - ProcessData(data, length); + CommitData(data, length); ProcessDataBuffer(); } void DocumentLoader::ProcessDataBuffer() { // Process data received in reentrant invocations. Note that the invocations - // of processData() may queue more data in reentrant invocations, so iterate + // of CommitData() may queue more data in reentrant invocations, so iterate // until it's empty. for (const auto& span : *data_buffer_) - ProcessData(span.data(), span.size()); + CommitData(span.data(), span.size()); // All data has been consumed, so flush the buffer. data_buffer_->Clear(); } -void DocumentLoader::ProcessData(const char* data, size_t length) { - application_cache_host_->MainResourceDataReceived(data, length); - time_of_last_data_received_ = CurrentTimeTicks(); - CommitData(data, length); - - // If we are sending data to MediaDocument, we should stop here and cancel the - // request. - if (frame_ && frame_->GetDocument()->IsMediaDocument()) - fetcher_->StopFetching(); -} - void DocumentLoader::ClearRedirectChain() { redirect_chain_.clear(); } @@ -986,6 +983,8 @@ fetch_initiator_type_names::kDocument, GetTiming().NavigationStart(), true /* is_main_resource */); navigation_timing_info_->SetInitialURL(request_.Url()); + report_timing_info_to_parent_ = To<FrameFetchContext>(fetcher_->Context()) + .UpdateTimingInfoForIFrameNavigation(); ResourceLoaderOptions options; options.data_buffering_policy = kDoNotBufferData;
diff --git a/third_party/blink/renderer/core/loader/document_loader.h b/third_party/blink/renderer/core/loader/document_loader.h index 0395dd14..e3df20e 100644 --- a/third_party/blink/renderer/core/loader/document_loader.h +++ b/third_party/blink/renderer/core/loader/document_loader.h
@@ -334,8 +334,6 @@ void NotifyFinished(Resource*) final; String DebugName() const override { return "DocumentLoader"; } - void ProcessData(const char* data, size_t length); - bool MaybeLoadEmpty(); bool IsRedirectAfterPost(const ResourceRequest&, const ResourceResponse&); @@ -423,6 +421,7 @@ bool loading_mhtml_archive_ = false; unsigned long main_resource_identifier_ = 0; scoped_refptr<ResourceTimingInfo> navigation_timing_info_; + bool report_timing_info_to_parent_ = false; // This UseCounter tracks feature usage associated with the lifetime of the // document load. Features recorded prior to commit will be recorded locally.
diff --git a/third_party/blink/renderer/core/loader/frame_fetch_context.cc b/third_party/blink/renderer/core/loader/frame_fetch_context.cc index eec8749..ce6af86 100644 --- a/third_party/blink/renderer/core/loader/frame_fetch_context.cc +++ b/third_party/blink/renderer/core/loader/frame_fetch_context.cc
@@ -932,8 +932,7 @@ return document_ && document_->LoadEventFinished(); } -bool FrameFetchContext::UpdateTimingInfoForIFrameNavigation( - ResourceTimingInfo* info) { +bool FrameFetchContext::UpdateTimingInfoForIFrameNavigation() { if (IsDetached()) return false;
diff --git a/third_party/blink/renderer/core/loader/frame_fetch_context.h b/third_party/blink/renderer/core/loader/frame_fetch_context.h index ad43a51..90c8ede 100644 --- a/third_party/blink/renderer/core/loader/frame_fetch_context.h +++ b/third_party/blink/renderer/core/loader/frame_fetch_context.h
@@ -139,7 +139,7 @@ bool IsMainFrame() const override; bool DefersLoading() const override; bool IsLoadComplete() const override; - bool UpdateTimingInfoForIFrameNavigation(ResourceTimingInfo*) override; + bool UpdateTimingInfoForIFrameNavigation(); void PopulateResourceRequest(ResourceType, const ClientHintsPreferences&,
diff --git a/third_party/blink/renderer/core/loader/frame_fetch_context_test.cc b/third_party/blink/renderer/core/loader/frame_fetch_context_test.cc index 632ec5a8..6fa664e 100644 --- a/third_party/blink/renderer/core/loader/frame_fetch_context_test.cc +++ b/third_party/blink/renderer/core/loader/frame_fetch_context_test.cc
@@ -1392,12 +1392,8 @@ } TEST_F(FrameFetchContextTest, UpdateTimingInfoForIFrameNavigationWhenDetached) { - scoped_refptr<ResourceTimingInfo> info = - ResourceTimingInfo::Create("type", TimeTicksFromSeconds(0.3), false); - dummy_page_holder = nullptr; - - fetch_context->UpdateTimingInfoForIFrameNavigation(info.get()); + fetch_context->UpdateTimingInfoForIFrameNavigation(); // Should not crash. }
diff --git a/third_party/blink/renderer/core/testing/sim/sim_test.cc b/third_party/blink/renderer/core/testing/sim/sim_test.cc index 9b34e5f..448295f 100644 --- a/third_party/blink/renderer/core/testing/sim/sim_test.cc +++ b/third_party/blink/renderer/core/testing/sim/sim_test.cc
@@ -18,10 +18,9 @@ namespace blink { SimTest::SimTest() - : web_frame_client_(*this), - // SimCompositor overrides the LayerTreeViewDelegate to respond to - // BeginMainFrame(), which will update and paint the WebViewImpl given to - // SetWebView(). + : // SimCompositor overrides the LayerTreeViewDelegate to respond to + // BeginMainFrame(), which will update and paint the WebViewImpl given to + // SetWebView(). web_view_client_(&web_widget_client_, &compositor_) { Document::SetThreadedParsingEnabledForTesting(false); // Use the mock theme to get more predictable code paths, this also avoids @@ -88,22 +87,24 @@ return *WebView().MainFrameImpl(); } -const SimWebViewClient& SimTest::WebViewClient() const { +frame_test_helpers::TestWebViewClient& SimTest::WebViewClient() { return web_view_client_; } +frame_test_helpers::TestWebWidgetClient& SimTest::WebWidgetClient() { + return web_widget_client_; +} + +frame_test_helpers::TestWebFrameClient& SimTest::WebFrameClient() { + return web_frame_client_; +} + SimCompositor& SimTest::Compositor() { return compositor_; } -void SimTest::SetEffectiveConnectionTypeForTesting( - WebEffectiveConnectionType effective_connection_type) { - web_frame_client_.SetEffectiveConnectionTypeForTesting( - effective_connection_type); -} - -void SimTest::AddConsoleMessage(const String& message) { - console_messages_.push_back(message); +Vector<String>& SimTest::ConsoleMessages() { + return web_frame_client_.ConsoleMessages(); } } // namespace blink
diff --git a/third_party/blink/renderer/core/testing/sim/sim_test.h b/third_party/blink/renderer/core/testing/sim/sim_test.h index 3f1c9c7..fc3f6dc8 100644 --- a/third_party/blink/renderer/core/testing/sim/sim_test.h +++ b/third_party/blink/renderer/core/testing/sim/sim_test.h
@@ -11,8 +11,6 @@ #include "third_party/blink/renderer/core/testing/sim/sim_compositor.h" #include "third_party/blink/renderer/core/testing/sim/sim_network.h" #include "third_party/blink/renderer/core/testing/sim/sim_page.h" -#include "third_party/blink/renderer/core/testing/sim/sim_web_frame_client.h" -#include "third_party/blink/renderer/core/testing/sim/sim_web_view_client.h" namespace blink { @@ -38,27 +36,21 @@ Document& GetDocument(); WebViewImpl& WebView(); WebLocalFrameImpl& MainFrame(); - const SimWebViewClient& WebViewClient() const; + frame_test_helpers::TestWebViewClient& WebViewClient(); + frame_test_helpers::TestWebWidgetClient& WebWidgetClient(); + frame_test_helpers::TestWebFrameClient& WebFrameClient(); SimCompositor& Compositor(); - Vector<String>& ConsoleMessages() { return console_messages_; } - - void SetEffectiveConnectionTypeForTesting(WebEffectiveConnectionType); + Vector<String>& ConsoleMessages(); private: - friend class SimWebFrameClient; - - void AddConsoleMessage(const String&); - SimNetwork network_; SimCompositor compositor_; - SimWebFrameClient web_frame_client_; - SimWebWidgetClient web_widget_client_; - SimWebViewClient web_view_client_; + frame_test_helpers::TestWebFrameClient web_frame_client_; + frame_test_helpers::TestWebWidgetClient web_widget_client_; + frame_test_helpers::TestWebViewClient web_view_client_; SimPage page_; frame_test_helpers::WebViewHelper web_view_helper_; - - Vector<String> console_messages_; }; } // namespace blink
diff --git a/third_party/blink/renderer/core/testing/sim/sim_web_frame_client.cc b/third_party/blink/renderer/core/testing/sim/sim_web_frame_client.cc deleted file mode 100644 index 9ede2eb..0000000 --- a/third_party/blink/renderer/core/testing/sim/sim_web_frame_client.cc +++ /dev/null
@@ -1,32 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "third_party/blink/renderer/core/testing/sim/sim_web_frame_client.h" - -#include "third_party/blink/public/web/web_console_message.h" -#include "third_party/blink/renderer/core/testing/sim/sim_test.h" - -namespace blink { - -SimWebFrameClient::SimWebFrameClient(SimTest& test) - : test_(&test), - effective_connection_type_(WebEffectiveConnectionType::kTypeUnknown) {} - -void SimWebFrameClient::DidAddMessageToConsole(const WebConsoleMessage& message, - const WebString& source_name, - unsigned source_line, - const WebString& stack_trace) { - test_->AddConsoleMessage(message.text); -} - -WebEffectiveConnectionType SimWebFrameClient::GetEffectiveConnectionType() { - return effective_connection_type_; -} - -void SimWebFrameClient::SetEffectiveConnectionTypeForTesting( - WebEffectiveConnectionType effective_connection_type) { - effective_connection_type_ = effective_connection_type; -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/testing/sim/sim_web_frame_client.h b/third_party/blink/renderer/core/testing/sim/sim_web_frame_client.h deleted file mode 100644 index c185309..0000000 --- a/third_party/blink/renderer/core/testing/sim/sim_web_frame_client.h +++ /dev/null
@@ -1,41 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_TESTING_SIM_SIM_WEB_FRAME_CLIENT_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_TESTING_SIM_SIM_WEB_FRAME_CLIENT_H_ - -#include "third_party/blink/public/platform/web_effective_connection_type.h" -#include "third_party/blink/renderer/core/frame/frame_test_helpers.h" -#include "third_party/blink/renderer/core/testing/fake_web_plugin.h" - -namespace blink { - -class SimTest; - -class SimWebFrameClient final : public frame_test_helpers::TestWebFrameClient { - public: - explicit SimWebFrameClient(SimTest&); - - // WebLocalFrameClient overrides: - void DidAddMessageToConsole(const WebConsoleMessage&, - const WebString& source_name, - unsigned source_line, - const WebString& stack_trace) override; - - WebEffectiveConnectionType GetEffectiveConnectionType() override; - void SetEffectiveConnectionTypeForTesting( - WebEffectiveConnectionType) override; - - WebPlugin* CreatePlugin(const WebPluginParams& params) override { - return new FakeWebPlugin(params); - } - - private: - SimTest* test_; - WebEffectiveConnectionType effective_connection_type_; -}; - -} // namespace blink - -#endif
diff --git a/third_party/blink/renderer/core/testing/sim/sim_web_view_client.cc b/third_party/blink/renderer/core/testing/sim/sim_web_view_client.cc deleted file mode 100644 index adffbff8..0000000 --- a/third_party/blink/renderer/core/testing/sim/sim_web_view_client.cc +++ /dev/null
@@ -1,42 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "third_party/blink/renderer/core/testing/sim/sim_web_view_client.h" - -#include "third_party/blink/public/web/web_local_frame.h" - -namespace blink { - -void SimWebWidgetClient::DidMeaningfulLayout( - WebMeaningfulLayout meaningful_layout) { - switch (meaningful_layout) { - case WebMeaningfulLayout::kVisuallyNonEmpty: - visually_non_empty_layout_count_++; - break; - case WebMeaningfulLayout::kFinishedParsing: - finished_parsing_layout_count_++; - break; - case WebMeaningfulLayout::kFinishedLoading: - finished_loading_layout_count_++; - break; - } -} - -SimWebViewClient::SimWebViewClient(SimWebWidgetClient* sim_web_widget_client, - content::LayerTreeViewDelegate* delegate) - : frame_test_helpers::TestWebViewClient(sim_web_widget_client, delegate), - widget_client_(sim_web_widget_client) {} - -WebView* SimWebViewClient::CreateView(WebLocalFrame* opener, - const WebURLRequest&, - const WebWindowFeatures&, - const WebString& name, - WebNavigationPolicy, - bool, - WebSandboxFlags, - const SessionStorageNamespaceId&) { - return web_view_helper_.InitializeWithOpener(opener); -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/testing/sim/sim_web_view_client.h b/third_party/blink/renderer/core/testing/sim/sim_web_view_client.h deleted file mode 100644 index 8da3e19b..0000000 --- a/third_party/blink/renderer/core/testing/sim/sim_web_view_client.h +++ /dev/null
@@ -1,67 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_TESTING_SIM_SIM_WEB_VIEW_CLIENT_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_TESTING_SIM_SIM_WEB_VIEW_CLIENT_H_ - -#include "third_party/blink/renderer/core/frame/frame_test_helpers.h" - -namespace blink { - -class SimWebWidgetClient final - : public frame_test_helpers::TestWebWidgetClient { - public: - // WebWidgetClient overrides. - void DidMeaningfulLayout(WebMeaningfulLayout) override; - - int VisuallyNonEmptyLayoutCount() const { - return visually_non_empty_layout_count_; - } - int FinishedParsingLayoutCount() const { - return finished_parsing_layout_count_; - } - int FinishedLoadingLayoutCount() const { - return finished_loading_layout_count_; - } - - private: - int visually_non_empty_layout_count_ = 0; - int finished_parsing_layout_count_ = 0; - int finished_loading_layout_count_ = 0; -}; - -class SimWebViewClient final : public frame_test_helpers::TestWebViewClient { - public: - explicit SimWebViewClient(SimWebWidgetClient*, - content::LayerTreeViewDelegate*); - - // WebViewClient implementation. - WebView* CreateView(WebLocalFrame* opener, - const WebURLRequest&, - const WebWindowFeatures&, - const WebString& name, - WebNavigationPolicy, - bool, - WebSandboxFlags, - const SessionStorageNamespaceId&) override; - - int VisuallyNonEmptyLayoutCount() const { - return widget_client_->VisuallyNonEmptyLayoutCount(); - } - int FinishedParsingLayoutCount() const { - return widget_client_->FinishedParsingLayoutCount(); - } - int FinishedLoadingLayoutCount() const { - return widget_client_->FinishedLoadingLayoutCount(); - } - - private: - SimWebWidgetClient* const widget_client_; - - frame_test_helpers::WebViewHelper web_view_helper_; -}; - -} // namespace blink - -#endif
diff --git a/third_party/blink/renderer/platform/exported/web_url_request.cc b/third_party/blink/renderer/platform/exported/web_url_request.cc index 51f57324..b32baa20 100644 --- a/third_party/blink/renderer/platform/exported/web_url_request.cc +++ b/third_party/blink/renderer/platform/exported/web_url_request.cc
@@ -393,11 +393,6 @@ return resource_request_->CorsPreflightPolicy(); } -void WebURLRequest::SetNavigationStartTime( - base::TimeTicks navigation_start_seconds) { - resource_request_->SetNavigationStartTime(navigation_start_seconds); -} - base::Optional<WebString> WebURLRequest::GetSuggestedFilename() const { if (!resource_request_->GetSuggestedFilename().has_value()) return base::Optional<WebString>();
diff --git a/third_party/blink/renderer/platform/loader/fetch/fetch_context.h b/third_party/blink/renderer/platform/loader/fetch/fetch_context.h index e80a076a..bc744fc2 100644 --- a/third_party/blink/renderer/platform/loader/fetch/fetch_context.h +++ b/third_party/blink/renderer/platform/loader/fetch/fetch_context.h
@@ -195,9 +195,6 @@ virtual bool IsMainFrame() const { return true; } virtual bool DefersLoading() const { return false; } virtual bool IsLoadComplete() const { return false; } - virtual bool UpdateTimingInfoForIFrameNavigation(ResourceTimingInfo*) { - return false; - } virtual void CountUsage(mojom::WebFeature) const = 0; virtual void CountDeprecation(mojom::WebFeature) const = 0;
diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.cc b/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.cc index 14fee98b..927997e5 100644 --- a/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.cc +++ b/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.cc
@@ -1034,17 +1034,11 @@ if (fetch_initiator == fetch_initiator_type_names::kInternal) return; - bool is_main_resource = resource->GetType() == ResourceType::kMainResource; + if (resource->GetType() == ResourceType::kMainResource) + return; - // The request can already be fetched in a previous navigation. Thus - // startTime must be set accordingly. - TimeTicks start_time = - !resource->GetResourceRequest().NavigationStartTime().is_null() - ? resource->GetResourceRequest().NavigationStartTime() - : CurrentTimeTicks(); - - scoped_refptr<ResourceTimingInfo> info = - ResourceTimingInfo::Create(fetch_initiator, start_time, is_main_resource); + scoped_refptr<ResourceTimingInfo> info = ResourceTimingInfo::Create( + fetch_initiator, CurrentTimeTicks(), false /* is_main_resource */); if (resource->IsCacheValidator()) { const AtomicString& timing_allow_origin = @@ -1053,10 +1047,7 @@ info->SetOriginalTimingAllowOrigin(timing_allow_origin); } - if (!is_main_resource || - Context().UpdateTimingInfoForIFrameNavigation(info.get())) { - resource_timing_info_map_.insert(resource, std::move(info)); - } + resource_timing_info_map_.insert(resource, std::move(info)); } void ResourceFetcher::RecordResourceTimingOnRedirect(
diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_request.cc b/third_party/blink/renderer/platform/loader/fetch/resource_request.cc index 0fa7840b..7f7ff43 100644 --- a/third_party/blink/renderer/platform/loader/fetch/resource_request.cc +++ b/third_party/blink/renderer/platform/loader/fetch/resource_request.cc
@@ -329,10 +329,6 @@ is_external_request_ = requestor_space > target_space; } -void ResourceRequest::SetNavigationStartTime(TimeTicks navigation_start) { - navigation_start_ = navigation_start; -} - bool ResourceRequest::IsConditional() const { return (http_header_fields_.Contains(http_names::kIfMatch) || http_header_fields_.Contains(http_names::kIfModifiedSince) ||
diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_request.h b/third_party/blink/renderer/platform/loader/fetch/resource_request.h index 518ddf96..e4d9085 100644 --- a/third_party/blink/renderer/platform/loader/fetch/resource_request.h +++ b/third_party/blink/renderer/platform/loader/fetch/resource_request.h
@@ -362,9 +362,6 @@ return suggested_filename_; } - void SetNavigationStartTime(TimeTicks); - TimeTicks NavigationStartTime() const { return navigation_start_; } - void SetIsAdResource() { is_ad_resource_ = true; } bool IsAdResource() const { return is_ad_resource_; } @@ -492,8 +489,6 @@ static base::TimeDelta default_timeout_interval_; - TimeTicks navigation_start_; - bool is_ad_resource_ = false; WebContentSecurityPolicyList initiator_csp_;
diff --git a/third_party/blink/web_tests/TestExpectations b/third_party/blink/web_tests/TestExpectations index 5e613b4..65df4c4 100644 --- a/third_party/blink/web_tests/TestExpectations +++ b/third_party/blink/web_tests/TestExpectations
@@ -1724,15 +1724,11 @@ crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_flow-column-wrap-reverse.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_flow-column-wrap.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_flow-row-wrap-reverse.html [ Failure ] -crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_flow-row-wrap.html [ Failure ] -crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_generated-nested-flex.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_inline-abspos.html [ Skip ] crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_inline-float.html [ Skip ] crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_inline.html [ Skip ] -crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_item-vertical-align.html [ Failure ] crbug.com/467127 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_justifycontent-center-overflow.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_margin-collapse.html [ Failure ] -crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_nested-flex.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_order-box.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_order.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_quirks_body.html [ Failure ] @@ -1744,9 +1740,7 @@ crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_stf-table-singleline.html [ Failure ] crbug.com/336604 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_visibility-collapse-line-wrapping.html [ Failure ] crbug.com/336604 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_visibility-collapse.html [ Failure ] -crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_wrap-long.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_wrap-reverse.html [ Failure ] -crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/flexbox_wrap.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/layout-algorithm_algo-cross-line-002.html [ Failure ] crbug.com/467127 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/negative-margins-001.html [ Skip ] crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/order_value.html [ Failure ] @@ -1764,7 +1758,6 @@ crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/ttwf-reftest-flex-align-content-space-between.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/ttwf-reftest-flex-direction-column-reverse.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/ttwf-reftest-flex-direction-column.html [ Failure ] -crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/ttwf-reftest-flex-direction-row-reverse.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/ttwf-reftest-flex-inline.html [ Skip ] crbug.com/591099 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/ttwf-reftest-flex-order.html [ Failure ] crbug.com/467127 virtual/layout_ng_experimental/external/wpt/css/css-flexbox/ttwf-reftest-flex-wrap-reverse.html [ Failure ] @@ -3210,6 +3203,7 @@ crbug.com/918664 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/sizing/block-size-with-min-or-max-content-table-1a.html [ Failure Pass ] # ====== New tests from wpt-importer added here ====== +crbug.com/626703 external/wpt/css/css-values/vh-support-atviewport.html [ Failure ] crbug.com/626703 external/wpt/css/css-backgrounds/border-image-calc.html [ Failure ] crbug.com/626703 external/wpt/css/css-text/boundary-shaping/boundary-shaping-005.html [ Failure ] crbug.com/626703 external/wpt/css/CSS2/text/white-space-nowrap-attribute-001.xht [ Failure ]
diff --git a/third_party/blink/web_tests/custom-elements/tentative/form-submission.html b/third_party/blink/web_tests/custom-elements/tentative/form-submission.html index 15afe86..d4c82794 100644 --- a/third_party/blink/web_tests/custom-elements/tentative/form-submission.html +++ b/third_party/blink/web_tests/custom-elements/tentative/form-submission.html
@@ -79,7 +79,7 @@ promise_test(t => { $('#container').innerHTML = '<form action="../../external/wpt/common/blank.html" target="if1">' + '<input name=name-pd1 value="value-pd1">' + - '<my-control></my-control>' + + '<my-control name=name-ce1></my-control>' + '</form>' + '<iframe name="if1"></iframe>'; $('my-control').value = 'value-ce1'; @@ -90,4 +90,17 @@ assert_equals(query, '?name-pd1=value-pd1&sub1=subvalue1&sub2=subvalue2&sub2=subvalue3'); }); }, 'Multiple values - name content attribute is ignored'); + +promise_test(t => { + $('#container').innerHTML = '<form action="../../external/wpt/common/blank.html" target="if1">' + + '<input name=name-pd1 value="value-pd1">' + + '<my-control name=name-ce1></my-control>' + + '</form>' + + '<iframe name="if1"></iframe>'; + $('my-control').value = 'value-ce1'; + $('my-control').setValues([]); + return submitPromise(t).then(query => { + assert_equals(query, '?name-pd1=value-pd1'); + }); +}, 'setFormValue with an empty FormData should submit nothing'); </script>
diff --git a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_5.json b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_5.json index c96ae9fd..6571860 100644 --- a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_5.json +++ b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_5.json
@@ -80202,7 +80202,7 @@ "/css/css-values/vh-support-atviewport.html", [ [ - "/css/css-values/reference/all-green.html", + "/css/css-values/reference/vh-support-atviewport-ref.htm", "==" ] ], @@ -147089,6 +147089,11 @@ {} ] ], + "css/css-values/reference/vh-support-atviewport-ref.htm": [ + [ + {} + ] + ], "css/css-values/reference/vh_not_refreshing_on_chrome-ref.html": [ [ {} @@ -199865,6 +199870,12 @@ {} ] ], + "async-local-storage/undefined-value.https.html": [ + [ + "/async-local-storage/undefined-value.https.html", + {} + ] + ], "audio-output/idlharness.https.window.js": [ [ "/audio-output/idlharness.https.window.html", @@ -218393,6 +218404,12 @@ {} ] ], + "custom-elements/enqueue-custom-element-callback-reactions-inside-another-callback.html": [ + [ + "/custom-elements/enqueue-custom-element-callback-reactions-inside-another-callback.html", + {} + ] + ], "custom-elements/historical.html": [ [ "/custom-elements/historical.html", @@ -302885,11 +302902,11 @@ "support" ], "async-local-storage/api-surface.tentative.https.html": [ - "eea51abd539787f531cbf32e28737c135c63c8d7", + "927871a8961c44bd8adfee1b82aadc9f514962a7", "testharness" ], "async-local-storage/helpers/als-tests.js": [ - "fd6d6844f72e39d16e070ec461b99ab62a0b4547", + "28087abf811dacda1ca00d81fe1306f97dde88ef", "support" ], "async-local-storage/helpers/class-assert.js": [ @@ -302901,7 +302918,7 @@ "support" ], "async-local-storage/key-types.tentative.https.html": [ - "771ee2f9749a00ec4e33019512a9bf8d145a3ce6", + "c3985b7711f77818260f08635d35ce3da553178b", "testharness" ], "async-local-storage/non-secure-context-dynamic-import.tentative.html": [ @@ -302920,6 +302937,10 @@ "f978480ff2b80ba5f892c2a2c429e882d655574d", "testharness" ], + "async-local-storage/undefined-value.https.html": [ + "c76c32f950704e42c06d498c4c8614dfbabb2aae", + "testharness" + ], "audio-output/META.yml": [ "b6a7d4d06259117af8fb843f6a8d252bac01a8f3", "support" @@ -368904,6 +368925,10 @@ "962a748d2c059b45fca4d7788b04b77c61e0b923", "support" ], + "css/css-values/reference/vh-support-atviewport-ref.htm": [ + "cfa9e8d02d48436ee1c311da7c7bd65b0f4291cf", + "support" + ], "css/css-values/reference/vh_not_refreshing_on_chrome-ref.html": [ "279d1c69b9f7fbe60edb55b7e8a5d507eda24936", "support" @@ -369141,7 +369166,7 @@ "reftest" ], "css/css-values/vh-support-atviewport.html": [ - "c79ace6df18a7432dba34fa83cdb1af183206156", + "c1999c4a22e2933259b3f77193c2b20c3b53f199", "reftest" ], "css/css-values/vh-support-margin.html": [ @@ -385056,6 +385081,10 @@ "7f5a4d0f8e76d495acfdedfe172ef5acfdac75b4", "testharness" ], + "custom-elements/enqueue-custom-element-callback-reactions-inside-another-callback.html": [ + "2fd932f29a3bae3e80ee90a1996c1d25ea7934cf", + "testharness" + ], "custom-elements/historical-expected.txt": [ "cfda088aac6a7a59d182bab359d02ff0eddeb46f", "support" @@ -454493,7 +454522,7 @@ "support" ], "webxr/idlharness.https.window-expected.txt": [ - "4eb2240f492e8e4d3dab067941de1ff72716ca52", + "3aee6bef4bc82f522e56fdd641985b4d1f683000", "support" ], "webxr/idlharness.https.window.js": [ @@ -454513,15 +454542,15 @@ "support" ], "webxr/resources/webxr_util.js": [ - "ee6e67f4c3d090015ead8b8718c2a836871a68ba", + "10bdc12810c3b34d140e6f04b0068c28c9dc1873", "support" ], "webxr/webGLCanvasContext_create_xrcompatible.https.html": [ - "94731ccfbb4937cabe175de5acce4423fbf8de43", + "8b2f196fa76ecc102319bf9409cba143d0d35e13", "testharness" ], "webxr/webGLCanvasContext_makecompatible_contextlost.https.html": [ - "25f9869b70e27ca563df2860dd01a679e140d221", + "3102008c57db1e32a0910eabfc93c55809b8300c", "testharness" ], "webxr/webxr_availability.http.sub.html": [
diff --git a/third_party/blink/web_tests/external/wpt/css/css-values/reference/vh-support-atviewport-ref.htm b/third_party/blink/web_tests/external/wpt/css/css-values/reference/vh-support-atviewport-ref.htm new file mode 100644 index 0000000..cfa9e8d02 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-values/reference/vh-support-atviewport-ref.htm
@@ -0,0 +1,22 @@ +<!DOCTYPE html> +<html><head> + <meta charset="utf-8"> + <title> + CSS Reftest Reference + </title> + + <link href="mailto:fremycompany.developer@yahoo.fr" rel="author" title="François REMY"> + + <style type="text/css"> + html + { + background-color: yellow; + border-left: blue solid 50vw; + height: 100vh; + } + </style> + +</head> +<body> + +</body></html> \ No newline at end of file
diff --git a/third_party/blink/web_tests/external/wpt/css/css-values/vh-support-atviewport.html b/third_party/blink/web_tests/external/wpt/css/css-values/vh-support-atviewport.html index c79ace6..c1999c4a 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-values/vh-support-atviewport.html +++ b/third_party/blink/web_tests/external/wpt/css/css-values/vh-support-atviewport.html
@@ -1,44 +1,41 @@ <!DOCTYPE html> -<html> -<head> +<html><head> <meta charset="utf-8"> <title> CSS Values and Units Test: Viewports units are supported in @viewport rules </title> - <meta name="assert" content=" + <meta content=" Viewports units are supported in @viewport rules - " /> + " name="assert"> - <link - rel="author" - title="François REMY" - href="mailto:fremycompany.developer@yahoo.fr" - /> + <link href="mailto:fremycompany.developer@yahoo.fr" rel="author" title="François REMY"> - <link rel="help" href="http://www.w3.org/TR/css3-values/#viewport-relative-lengths" /> - <link rel="help" href="https://drafts.csswg.org/css-device-adapt-1/" /> + <link href="http://www.w3.org/TR/css3-values/#viewport-relative-lengths" rel="help"> + <link href="https://drafts.csswg.org/css-device-adapt-1/#atviewport-rule" rel="help"> - <link - rel="match" - href="reference/all-green.html" - /> + <link href="reference/vh-support-atviewport-ref.htm" rel="match"> <style type="text/css"> + html + { + background-color: yellow; + } - html, body { margin: 0px; padding: 0px; overflow: hidden; } + body + { + background-color: blue; + height: 100vh; + margin: 0; + } - @viewport { width: 1vw; } - - html { background: red; } - #target { background: green; width: 100vw; height: 100vh; } - + @viewport + { + width: 50vw; + } </style> </head> <body> - <div id="target"></div> - -</body> -</html> +</body></html> \ No newline at end of file
diff --git a/third_party/blink/web_tests/external/wpt/custom-elements/enqueue-custom-element-callback-reactions-inside-another-callback.html b/third_party/blink/web_tests/external/wpt/custom-elements/enqueue-custom-element-callback-reactions-inside-another-callback.html new file mode 100644 index 0000000..2fd932f2 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/custom-elements/enqueue-custom-element-callback-reactions-inside-another-callback.html
@@ -0,0 +1,223 @@ +<!DOCTYPE html> +<html> +<head> +<title>Custom Elements: must enqueue an element on the appropriate element queue after checking callback is null and the attribute name</title> +<meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org"> +<meta name="assert" content="To enqueue a custom element callback reaction, the callback must be checked of being null and whether the attribute name is observed or not"> +<link rel="help" content="https://html.spec.whatwg.org/multipage/custom-elements.html#enqueue-a-custom-element-callback-reaction"> +<link rel="help" content="https://github.com/w3c/webcomponents/issues/760"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/custom-elements-helpers.js"></script> +</head> +<body> +<script> + +test_with_window((contentWindow, contentDocument) => { + class ParentElement extends contentWindow.HTMLElement { + connectedCallback() + { + logs.push('begin'); + const child = this.firstChild; + child.remove(); + logs.push('end'); + } + } + contentWindow.customElements.define('parent-element', ParentElement); + + const logs = []; + class ChildElement extends contentWindow.HTMLElement { + connectedCallback() { logs.push('connected'); } + disconnectedCallback() { logs.push('disconnected'); } + } + contentWindow.customElements.define('child-element', ChildElement); + + const parent = new ParentElement; + const child = new ChildElement; + parent.appendChild(child); + + contentDocument.body.appendChild(parent); + assert_array_equals(logs, ['begin', 'connected', 'disconnected', 'end']); +}, 'Disconnecting an element with disconnectedCallback while it has a connectedCallback in its custom element reaction queue must result in connectedCallback getting invoked before the removal completes'); + +test_with_window((contentWindow, contentDocument) => { + class ParentElement extends contentWindow.HTMLElement { + connectedCallback() + { + logs.push('begin'); + const child = this.firstChild; + child.remove(); + logs.push('end'); + } + } + contentWindow.customElements.define('parent-element', ParentElement); + + const logs = []; + class ChildElement extends contentWindow.HTMLElement { + connectedCallback() { logs.push('connected'); } + } + contentWindow.customElements.define('child-element', ChildElement); + + const parent = new ParentElement; + const child = new ChildElement; + parent.appendChild(child); + + contentDocument.body.appendChild(parent); + assert_array_equals(logs, ['begin', 'end', 'connected']); +}, 'Disconnecting an element without disconnectedCallback while it has a connectedCallback in its custom element reaction queue must not result in connectedCallback getting invoked before the removal completes'); + +test_with_window((contentWindow, contentDocument) => { + class ParentElement extends contentWindow.HTMLElement { + disconnectedCallback() + { + logs.push('begin'); + contentDocument.body.appendChild(this.firstChild); + logs.push('end'); + } + } + contentWindow.customElements.define('parent-element', ParentElement); + + const logs = []; + class ChildElement extends contentWindow.HTMLElement { + connectedCallback() { logs.push('connected'); } + disconnectedCallback() { logs.push('disconnected'); } + } + contentWindow.customElements.define('child-element', ChildElement); + + const parent = new ParentElement; + const child = new ChildElement; + parent.appendChild(child); + contentDocument.body.appendChild(parent); + parent.remove(); + assert_array_equals(logs, ['connected', 'begin', 'disconnected', 'connected', 'end']); +}, 'Connecting a element with connectedCallback while it has a disconnectedCallback in its custom element reaction queue must result in disconnectedCallback getting invoked before the insertion completes'); + +test_with_window((contentWindow, contentDocument) => { + class ParentElement extends contentWindow.HTMLElement { + disconnectedCallback() + { + logs.push('begin'); + contentDocument.body.appendChild(this.firstChild); + logs.push('end'); + } + } + contentWindow.customElements.define('parent-element', ParentElement); + + const logs = []; + class ChildElement extends contentWindow.HTMLElement { + disconnectedCallback() { logs.push('disconnected'); } + } + contentWindow.customElements.define('child-element', ChildElement); + + const parent = new ParentElement; + const child = new ChildElement; + parent.appendChild(child); + contentDocument.body.appendChild(parent); + parent.remove(); + assert_array_equals(logs, ['begin', 'end', 'disconnected']); +}, 'Connecting an element without connectedCallback while it has a disconnectedCallback in its custom element reaction queue must not result in disconnectedCallback getting invoked before the insertion completes'); + +test_with_window((contentWindow, contentDocument) => { + class ParentElement extends contentWindow.HTMLElement { + connectedCallback() + { + logs.push('begin'); + document.adoptNode(this.firstChild); + logs.push('end'); + } + } + contentWindow.customElements.define('parent-element', ParentElement); + + const logs = []; + class ChildElement extends contentWindow.HTMLElement { + adoptedCallback() { logs.push('adopted'); } + connectedCallback() { logs.push('connected'); } + } + contentWindow.customElements.define('child-element', ChildElement); + + const parent = new ParentElement; + const child = new ChildElement; + parent.appendChild(child); + contentDocument.body.appendChild(parent); + assert_array_equals(logs, ['begin', 'connected', 'adopted', 'end']); +}, 'Adopting an element with adoptingCallback while it has a connectedCallback in its custom element reaction queue must result in connectedCallback getting invoked before the adoption completes'); + +test_with_window((contentWindow, contentDocument) => { + class ParentElement extends contentWindow.HTMLElement { + connectedCallback() + { + logs.push('begin'); + document.adoptNode(this.firstChild); + logs.push('end'); + } + } + contentWindow.customElements.define('parent-element', ParentElement); + + const logs = []; + class ChildElement extends contentWindow.HTMLElement { + connectedCallback() { logs.push('connected'); } + } + contentWindow.customElements.define('child-element', ChildElement); + + const parent = new ParentElement; + const child = new ChildElement; + parent.appendChild(child); + contentDocument.body.appendChild(parent); + assert_array_equals(logs, ['begin', 'end', 'connected']); +}, 'Adopting an element without adoptingCallback while it has a connectedCallback in its custom element reaction queue must not result in connectedCallback getting invoked before the adoption completes'); + +test_with_window((contentWindow, contentDocument) => { + class ParentElement extends contentWindow.HTMLElement { + connectedCallback() + { + logs.push('begin'); + this.firstChild.setAttribute('title', 'foo'); + logs.push('end'); + } + } + contentWindow.customElements.define('parent-element', ParentElement); + + const logs = []; + class ChildElement extends contentWindow.HTMLElement { + attributeChangedCallback() { logs.push('attributeChanged'); } + connectedCallback() { logs.push('connected'); } + static get observedAttributes() { return ['title']; } + } + contentWindow.customElements.define('child-element', ChildElement); + + const parent = new ParentElement; + const child = new ChildElement; + parent.appendChild(child); + contentDocument.body.appendChild(parent); + assert_array_equals(logs, ['begin', 'connected', 'attributeChanged', 'end']); +}, 'Setting an observed attribute on an element with attributeChangedCallback while it has a connectedCallback in its custom element reaction queue must result in connectedCallback getting invoked before the attribute change completes'); + +test_with_window((contentWindow, contentDocument) => { + class ParentElement extends contentWindow.HTMLElement { + connectedCallback() + { + logs.push('begin'); + this.firstChild.setAttribute('lang', 'en'); + logs.push('end'); + } + } + contentWindow.customElements.define('parent-element', ParentElement); + + const logs = []; + class ChildElement extends contentWindow.HTMLElement { + attributeChangedCallback() { logs.push('attributeChanged'); } + connectedCallback() { logs.push('connected'); } + static get observedAttributes() { return ['title']; } + } + contentWindow.customElements.define('child-element', ChildElement); + + const parent = new ParentElement; + const child = new ChildElement; + parent.appendChild(child); + contentDocument.body.appendChild(parent); + assert_array_equals(logs, ['begin', 'end', 'connected']); +}, 'Setting an observed attribute on an element with attributeChangedCallback while it has a connectedCallback in its custom element reaction queue must not result in connectedCallback getting invoked before the attribute change completes'); + +</script> +</body> +</html>
diff --git a/tools/android/memdump/memdump.cc b/tools/android/memdump/memdump.cc index 9d27a55c..1cfc174 100644 --- a/tools/android/memdump/memdump.cc +++ b/tools/android/memdump/memdump.cc
@@ -16,6 +16,7 @@ #include <limits> #include <string> #include <unordered_map> +#include <unordered_set> #include <utility> #include <vector> @@ -292,7 +293,7 @@ FillPFNMaps(*processes_memory, &pfn_maps); // Hash set keeping track of the physical pages mapped in a single process so // that they can be counted only once. - base::hash_set<uint64_t> physical_pages_mapped_in_process; + std::unordered_set<uint64_t> physical_pages_mapped_in_process; for (std::vector<ProcessMemory>::iterator it = processes_memory->begin(); it != processes_memory->end(); ++it) { @@ -314,7 +315,7 @@ continue; } const uint64_t page_frame_number = page_info.page_frame_number; - const std::pair<base::hash_set<uint64_t>::iterator, bool> result = + const std::pair<std::unordered_set<uint64_t>::iterator, bool> result = physical_pages_mapped_in_process.insert(page_frame_number); const bool did_insert = result.second; if (!did_insert) {
diff --git a/ui/accessibility/ax_tree_serializer.h b/ui/accessibility/ax_tree_serializer.h index 4e7a6e1f..ce39bda4 100644 --- a/ui/accessibility/ax_tree_serializer.h +++ b/ui/accessibility/ax_tree_serializer.h
@@ -9,6 +9,7 @@ #include <stdint.h> #include <unordered_map> +#include <unordered_set> #include <vector> #include "base/containers/hash_tables.h" @@ -497,7 +498,7 @@ // If we've hit the maximum number of serialized nodes, pretend // this node has no children but keep going so that we get // consistent results. - base::hash_set<int32_t> new_child_ids; + std::unordered_set<int32_t> new_child_ids; std::vector<AXSourceNode> children; if (max_node_count_ == 0 || out_update->nodes.size() < max_node_count_) { tree_->GetChildren(node, &children);
diff --git a/ui/accessibility/platform/ax_platform_node_win.cc b/ui/accessibility/platform/ax_platform_node_win.cc index aee5d86..e22afa9 100644 --- a/ui/accessibility/platform/ax_platform_node_win.cc +++ b/ui/accessibility/platform/ax_platform_node_win.cc
@@ -11,6 +11,7 @@ #include <set> #include <string> #include <unordered_map> +#include <unordered_set> #include <utility> #include <vector> @@ -167,7 +168,7 @@ namespace { -typedef base::hash_set<AXPlatformNodeWin*> AXPlatformNodeWinSet; +typedef std::unordered_set<AXPlatformNodeWin*> AXPlatformNodeWinSet; // Set of all AXPlatformNodeWin objects that were the target of an // alert event. base::LazyInstance<AXPlatformNodeWinSet>::Leaky g_alert_targets =
diff --git a/ui/gfx/BUILD.gn b/ui/gfx/BUILD.gn index f8f5508..774ec74 100644 --- a/ui/gfx/BUILD.gn +++ b/ui/gfx/BUILD.gn
@@ -26,6 +26,8 @@ jumbo_component("geometry_skia") { sources = [ "geometry_skia_export.h", + "rrect_f.cc", + "rrect_f.h", "skia_util.cc", "skia_util.h", "transform.cc", @@ -612,6 +614,7 @@ "image/image_unittest.cc", "ios/NSString+CrStringDrawing_unittest.mm", "ios/uikit_util_unittest.mm", + "rrect_f_unittest.cc", "test/run_all_unittests.cc", "text_elider_unittest.cc", "text_utils_unittest.cc",
diff --git a/ui/gfx/rrect_f.cc b/ui/gfx/rrect_f.cc new file mode 100644 index 0000000..32d2475 --- /dev/null +++ b/ui/gfx/rrect_f.cc
@@ -0,0 +1,148 @@ +// Copyright (c) 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/gfx/rrect_f.h" + +#include <iomanip> +#include <iostream> + +#include "base/strings/stringprintf.h" +#include "base/values.h" + +namespace gfx { + +RRectF::RRectF() = default; + +RRectF::RRectF(const SkRRect& rect) : skrrect_(rect) {} + +RRectF::RRectF(const RRectF& rect) = default; + +RRectF::RRectF(const gfx::RectF& rect) + : skrrect_(SkRRect::MakeRect(gfx::RectFToSkRect(rect))) {} + +RRectF::RRectF(float x, float y, float width, float height, float radius) + : skrrect_(SkRRect::MakeRectXY(SkRect::MakeXYWH(x, y, width, height), + radius, + radius)) {} + +RRectF::RRectF(float x, + float y, + float width, + float height, + float x_rad, + float y_rad) + : skrrect_(SkRRect::MakeRectXY(SkRect::MakeXYWH(x, y, width, height), + x_rad, + y_rad)) {} + +RRectF::~RRectF() = default; + +gfx::Vector2dF RRectF::GetSimpleRadii() const { + DCHECK(type() <= Type::kOval); + SkPoint result = skrrect_.getSimpleRadii(); + return gfx::Vector2dF(result.x(), result.y()); +} +float RRectF::GetSimpleRadius() const { + DCHECK(type() <= Type::kSingle); + SkPoint result = skrrect_.getSimpleRadii(); + return result.x(); +} + +RRectF::Type RRectF::type() const { + SkPoint rad; + switch (skrrect_.getType()) { + case SkRRect::kEmpty_Type: + return Type::kEmpty; + case SkRRect::kRect_Type: + return Type::kRect; + case SkRRect::kSimple_Type: + rad = skrrect_.getSimpleRadii(); + if (rad.x() == rad.y()) { + return Type::kSingle; + } + return Type::kSimple; + case SkRRect::kOval_Type: + return Type::kOval; + case SkRRect::kNinePatch_Type: + case SkRRect::kComplex_Type: + default: + return Type::kComplex; + }; +} + +gfx::Vector2dF RRectF::GetCornerRadii(Corner corner) const { + SkPoint result = skrrect_.radii(SkRRect::Corner(corner)); + return gfx::Vector2dF(result.x(), result.y()); +} + +void RRectF::GetAllRadii(SkVector radii[4]) const { + // Unfortunately, the only way to get all radii is one at a time. + radii[SkRRect::kUpperLeft_Corner] = + skrrect_.radii(SkRRect::kUpperLeft_Corner); + radii[SkRRect::kUpperRight_Corner] = + skrrect_.radii(SkRRect::kUpperRight_Corner); + radii[SkRRect::kLowerRight_Corner] = + skrrect_.radii(SkRRect::kLowerRight_Corner); + radii[SkRRect::kLowerLeft_Corner] = + skrrect_.radii(SkRRect::kLowerLeft_Corner); +} +void RRectF::SetCornerRadii(Corner corner, const gfx::Vector2dF& radius) { + // Unfortunately, the only way to set this is to create a new SkRRect. + SkVector radii[4]; + GetAllRadii(radii); + radii[SkRRect::Corner(corner)] = SkPoint::Make(radius.x(), radius.y()); + skrrect_.setRectRadii(skrrect_.rect(), radii); +} + +void RRectF::Scale(float x_scale, float y_scale) { + SkMatrix scale = SkMatrix::MakeScale(x_scale, y_scale); + SkRRect result; + bool success = skrrect_.transform(scale, &result); + DCHECK(success); + skrrect_ = result; +} + +const RRectF& RRectF::operator=(const RRectF& rect) { + skrrect_ = rect.skrrect_; + return *this; +} + +void RRectF::Offset(float horizontal, float vertical) { + skrrect_.offset(horizontal, vertical); +} +const RRectF& RRectF::operator+=(const gfx::Vector2dF& offset) { + Offset(offset.x(), offset.y()); + return *this; +} +const RRectF& RRectF::operator-=(const gfx::Vector2dF& offset) { + Offset(-offset.x(), -offset.y()); + return *this; +} + +std::string RRectF::ToString() const { + std::stringstream ss; + ss << std::fixed << std::setprecision(3); + ss << rect().origin().x() << "," << rect().origin().y() << " " + << rect().size().width() << "x" << rect().size().height(); + Type type = this->type(); + if (type <= Type::kRect) { + ss << ", rectangular"; + } else if (type <= Type::kSingle) { + ss << ", radius " << GetSimpleRadius(); + } else if (type <= Type::kSimple) { + gfx::Vector2dF radii = GetSimpleRadii(); + ss << ", x_rad " << radii.x() << ", y_rad " << radii.y(); + } else { + ss << ","; + const Corner corners[] = {Corner::kUpperLeft, Corner::kUpperRight, + Corner::kLowerRight, Corner::kLowerLeft}; + for (const auto& c : corners) { + auto this_corner = GetCornerRadii(c); + ss << " [" << this_corner.x() << " " << this_corner.y() << "]"; + } + } + return ss.str(); +} + +} // namespace gfx
diff --git a/ui/gfx/rrect_f.h b/ui/gfx/rrect_f.h new file mode 100644 index 0000000..9319ab1 --- /dev/null +++ b/ui/gfx/rrect_f.h
@@ -0,0 +1,138 @@ +// Copyright (c) 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_GFX_RRECT_F_H_ +#define UI_GFX_RRECT_F_H_ + +#include <memory> +#include <string> + +#include "third_party/skia/include/core/SkRRect.h" +#include "ui/gfx/geometry/rect.h" +#include "ui/gfx/geometry/rect_f.h" +#include "ui/gfx/skia_util.h" + +namespace gfx { + +class GEOMETRY_SKIA_EXPORT RRectF { + public: + RRectF(); + RRectF(const RRectF& rect); + explicit RRectF(const SkRRect& rect); + explicit RRectF(const gfx::RectF& rect); + // Sets all x and y radii to radius. + RRectF(float x, float y, float width, float height, float radius); + // Sets all x radii to x_rad, and all y radii to y_rad. If one of x_rad or + // y_rad are zero, sets ALL radii to zero. + RRectF(float x, float y, float width, float height, float x_rad, float y_rad); + ~RRectF(); + + // The rectangular portion of the RRectF, without the corner radii. + gfx::RectF rect() const { return gfx::SkRectToRectF(skrrect_.rect()); } + + // Returns the radii of the all corners. DCHECKs that all corners + // have the same radii (the type is <= kOval). + gfx::Vector2dF GetSimpleRadii() const; + // Returns the radius of all corners. DCHECKs that all corners have the same + // radii, and that x_rad == y_rad (the type is <= kSingle). + float GetSimpleRadius() const; + + // Make the RRectF empty. + void Clear() { skrrect_.setEmpty(); } + + bool Equals(const RRectF& other) const { return skrrect_ == other.skrrect_; } + + // These are all mutually exclusive, and ordered in increasing complexity. The + // order is assumed in several functions. + enum class Type { + kEmpty, // Zero width or height. + kRect, // Non-zero width and height, and zeroed radii - a pure rectangle. + kSingle, // Non-zero width and height, and a single, non-zero value for all + // X and Y radii. + kSimple, // Non-zero width and height, X radii all equal and non-zero, Y + // radii all equal and non-zero, and x_rad != y_rad. + kOval, // Non-zero width and height, X radii all equal to width/2, and Y + // radii all equal to height/2. + kComplex, // Non-zero width and height, and arbitrary (non-equal) radii. + }; + Type type() const; + + bool IsEmpty() const { return type() == Type::kEmpty; } + + enum class Corner { + kUpperLeft = SkRRect::kUpperLeft_Corner, + kUpperRight = SkRRect::kUpperRight_Corner, + kLowerRight = SkRRect::kLowerRight_Corner, + kLowerLeft = SkRRect::kLowerLeft_Corner, + }; + gfx::Vector2dF GetCornerRadii(Corner corner) const; + void SetCornerRadii(Corner corner, const gfx::Vector2dF& radius); + + std::string ToString() const; + + // Returns true if |rect| is inside the bounds and corner radii of this + // RRectF, and if both this RRectF and rect are not empty. + bool Contains(const RectF& rect) const { + return skrrect_.contains(gfx::RectFToSkRect(rect)); + } + + // Scales the rectangle by |scale|. + void Scale(float scale) { Scale(scale, scale); } + // Scales the rectangle by |x_scale| and |y_scale|. + void Scale(float x_scale, float y_scale); + + // Move the rectangle by a horizontal and vertical distance. + void Offset(float horizontal, float vertical); + void Offset(const Vector2dF& distance) { Offset(distance.x(), distance.y()); } + const RRectF& operator+=(const gfx::Vector2dF& offset); + const RRectF& operator-=(const gfx::Vector2dF& offset); + + // Insets bounds by dx and dy, and adjusts radii by dx and dy. dx and dy may + // be positive, negative, or zero. If either corner radius is zero, the corner + // has no curvature and is unchanged. Otherwise, if adjusted radius becomes + // negative, the radius is pinned to zero. + void Inset(float val) { skrrect_.inset(val, val); } + void Inset(float dx, float dy) { skrrect_.inset(dx, dy); } + // Outsets bounds by dx and dy, and adjusts radii by dx and dy. dx and dy may + // be positive, negative, or zero. If either corner radius is zero, the corner + // has no curvature and is unchanged. Otherwise, if adjusted radius becomes + // negative, the radius is pinned to zero. + void Outset(float val) { skrrect_.outset(val, val); } + void Outset(float dx, float dy) { skrrect_.outset(dx, dy); } + + const RRectF& operator=(const RRectF& rect); + + private: + void GetAllRadii(SkVector radii[4]) const; + + SkRRect skrrect_; +}; + +inline std::ostream& operator<<(std::ostream& os, const RRectF& rect) { + return os << rect.ToString(); +} + +inline bool operator==(const RRectF& a, const RRectF& b) { + return a.Equals(b); +} + +inline bool operator!=(const RRectF& a, const RRectF& b) { + return !(a == b); +} + +inline RRectF operator+(const RRectF& a, const gfx::Vector2dF& b) { + RRectF result = a; + result += b; + return result; +} + +inline RRectF operator-(const RRectF& a, const Vector2dF& b) { + RRectF result = a; + result -= b; + return result; +} + +} // namespace gfx + +#endif // UI_GFX_RRECT_F_H_
diff --git a/ui/gfx/rrect_f_unittest.cc b/ui/gfx/rrect_f_unittest.cc new file mode 100644 index 0000000..01000e9d --- /dev/null +++ b/ui/gfx/rrect_f_unittest.cc
@@ -0,0 +1,232 @@ +// Copyright (c) 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/gfx/rrect_f.h" +#include "base/stl_util.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace gfx { + +TEST(RRectFTest, IsEmpty) { + EXPECT_TRUE(RRectF().IsEmpty()); + EXPECT_TRUE(RRectF(0, 0, 0, 0, 0).IsEmpty()); + EXPECT_TRUE(RRectF(0, 0, 10, 0, 0).IsEmpty()); + EXPECT_TRUE(RRectF(0, 0, 0, 10, 0).IsEmpty()); + EXPECT_TRUE(RRectF(0, 0, 0, 10, 10).IsEmpty()); + EXPECT_FALSE(RRectF(0, 0, 10, 10, 0).IsEmpty()); +} + +TEST(RRectFTest, Equals) { + ASSERT_TRUE(RRectF(0, 0, 0, 0, 0, 0) == RRectF(0, 0, 0, 0, 0, 0)); + ASSERT_TRUE(RRectF(1, 2, 3, 4, 5, 6) == RRectF(1, 2, 3, 4, 5, 6)); + ASSERT_TRUE(RRectF(1, 2, 3, 4, 5, 5) == RRectF(1, 2, 3, 4, 5)); + ASSERT_TRUE(RRectF(0, 0, 2, 3, 0, 0) == RRectF(0, 0, 2, 3, 0, 1)); + ASSERT_TRUE(RRectF(0, 0, 2, 3, 0, 0) == RRectF(0, 0, 2, 3, 1, 0)); + + ASSERT_TRUE(RRectF(10, 20, 30, 40, 7, 8) != RRectF(1, 20, 30, 40, 7, 8)); + ASSERT_TRUE(RRectF(10, 20, 30, 40, 7, 8) != RRectF(10, 2, 30, 40, 7, 8)); + ASSERT_TRUE(RRectF(10, 20, 30, 40, 7, 8) != RRectF(10, 20, 3, 40, 7, 8)); + ASSERT_TRUE(RRectF(10, 20, 30, 40, 7, 8) != RRectF(10, 20, 30, 4, 7, 8)); + ASSERT_TRUE(RRectF(10, 20, 30, 40, 7, 8) != RRectF(10, 20, 30, 40, 5, 8)); + ASSERT_TRUE(RRectF(10, 20, 30, 40, 7, 8) != RRectF(10, 20, 30, 40, 7, 6)); +} + +TEST(RRectFTest, PlusMinusOffset) { + const RRectF a(40, 50, 60, 70, 5); + gfx::Vector2d offset(23, 34); + RRectF correct(63, 84, 60, 70, 5); + RRectF b = a + offset; + ASSERT_EQ(b, correct); + b = a; + b.Offset(offset); + ASSERT_EQ(b, correct); + + correct = RRectF(17, 16, 60, 70, 5); + b = a - offset; + ASSERT_EQ(b, correct); + b = a; + b.Offset(-offset); + ASSERT_EQ(b, correct); +} + +TEST(RRectFTest, RRectTypes) { + RRectF a(40, 50, 0, 70, 0); + EXPECT_EQ(a.type(), RRectF::Type::kEmpty); + EXPECT_TRUE(a.IsEmpty()); + a = RRectF(40, 50, 60, 70, 0); + EXPECT_EQ(a.type(), RRectF::Type::kRect); + a = RRectF(40, 50, 60, 70, 5); + EXPECT_EQ(a.type(), RRectF::Type::kSingle); + a = RRectF(40, 50, 60, 70, 5, 5); + EXPECT_EQ(a.type(), RRectF::Type::kSingle); + a = RRectF(40, 50, 60, 70, 6, 3); + EXPECT_EQ(a.type(), RRectF::Type::kSimple); + a = RRectF(40, 50, 60, 70, 30, 3); + EXPECT_EQ(a.type(), RRectF::Type::kSimple); + a = RRectF(40, 50, 60, 70, 30, 35); + EXPECT_EQ(a.type(), RRectF::Type::kOval); + a.SetCornerRadii(RRectF::Corner::kLowerRight, gfx::Vector2dF(7, 8)); + EXPECT_EQ(a.type(), RRectF::Type::kComplex); + + // When one radius is larger than half its dimension, both radii are scaled + // down proportionately. + a = RRectF(40, 50, 60, 70, 30, 70); + EXPECT_EQ(a.type(), RRectF::Type::kSimple); + EXPECT_EQ(a, RRectF(40, 50, 60, 70, 15, 35)); + // If they stay equal to half the radius, it stays oval. + a = RRectF(40, 50, 60, 70, 120, 140); + EXPECT_EQ(a.type(), RRectF::Type::kOval); +} + +void CheckRadii(RRectF val, + float ulx, + float uly, + float urx, + float ury, + float lrx, + float lry, + float llx, + float lly) { + EXPECT_EQ(val.GetCornerRadii(RRectF::Corner::kUpperLeft), + gfx::Vector2dF(ulx, uly)); + EXPECT_EQ(val.GetCornerRadii(RRectF::Corner::kUpperRight), + gfx::Vector2dF(urx, ury)); + EXPECT_EQ(val.GetCornerRadii(RRectF::Corner::kLowerRight), + gfx::Vector2dF(lrx, lry)); + EXPECT_EQ(val.GetCornerRadii(RRectF::Corner::kLowerLeft), + gfx::Vector2dF(llx, lly)); +} + +TEST(RRectFTest, RRectRadii) { + RRectF a(40, 50, 60, 70, 0); + CheckRadii(a, 0, 0, 0, 0, 0, 0, 0, 0); + + a.SetCornerRadii(RRectF::Corner::kUpperLeft, gfx::Vector2dF(1, 2)); + CheckRadii(a, 1, 2, 0, 0, 0, 0, 0, 0); + + a.SetCornerRadii(RRectF::Corner::kUpperRight, gfx::Vector2dF(3, 4)); + CheckRadii(a, 1, 2, 3, 4, 0, 0, 0, 0); + + a.SetCornerRadii(RRectF::Corner::kLowerRight, gfx::Vector2dF(5, 6)); + CheckRadii(a, 1, 2, 3, 4, 5, 6, 0, 0); + + a.SetCornerRadii(RRectF::Corner::kLowerLeft, gfx::Vector2dF(7, 8)); + CheckRadii(a, 1, 2, 3, 4, 5, 6, 7, 8); +} + +TEST(RRectFTest, FromRectF) { + // Check that explicit conversion from float rect works. + RectF a(40, 50, 60, 70); + RRectF b(40, 50, 60, 70, 0); + RRectF c = RRectF(a); + EXPECT_EQ(b, c); +} + +TEST(RRectFTest, FromSkRRect) { + // Check that explicit conversion from SkRRect works. + SkRRect a = SkRRect::MakeRectXY(SkRect::MakeXYWH(40, 50, 60, 70), 15, 25); + RRectF b(40, 50, 60, 70, 15, 25); + RRectF c = RRectF(a); + EXPECT_EQ(b, c); + + // Try with single radius constructor. + a = SkRRect::MakeRectXY(SkRect::MakeXYWH(40, 50, 60, 70), 15, 15); + b = RRectF(40, 50, 60, 70, 15); + c = RRectF(a); + EXPECT_EQ(b, c); +} + +TEST(RRectFTest, ToString) { + RRectF a(40, 50, 60, 70, 0); + EXPECT_EQ(a.ToString(), "40.000,50.000 60.000x70.000, rectangular"); + a = RRectF(40, 50, 60, 70, 15); + EXPECT_EQ(a.ToString(), "40.000,50.000 60.000x70.000, radius 15.000"); + a = RRectF(40, 50, 60, 70, 15, 25); + EXPECT_EQ(a.ToString(), + "40.000,50.000 60.000x70.000, x_rad 15.000, y_rad 25.000"); + a.SetCornerRadii(RRectF::Corner::kLowerRight, gfx::Vector2dF(7, 8)); + EXPECT_EQ(a.ToString(), + "40.000,50.000 60.000x70.000, [15.000 25.000] " + "[15.000 25.000] [7.000 8.000] [15.000 25.000]"); +} + +TEST(RRectFTest, Sizes) { + RRectF a(40, 50, 60, 70, 5, 6); + EXPECT_EQ(a.rect().x(), 40); + EXPECT_EQ(a.rect().y(), 50); + EXPECT_EQ(a.rect().width(), 60); + EXPECT_EQ(a.rect().height(), 70); + EXPECT_EQ(a.GetSimpleRadii().x(), 5); + EXPECT_EQ(a.GetSimpleRadii().y(), 6); + a = RRectF(40, 50, 60, 70, 5, 5); + EXPECT_EQ(a.GetSimpleRadius(), 5); + a.Clear(); + EXPECT_TRUE(a.IsEmpty()); + // Make sure ovals can still get simple radii + a = RRectF(40, 50, 60, 70, 30, 35); + EXPECT_EQ(a.type(), RRectF::Type::kOval); + EXPECT_EQ(a.GetSimpleRadii().x(), 30); + EXPECT_EQ(a.GetSimpleRadii().y(), 35); +} + +TEST(RRectFTest, Contains) { + RRectF a(40, 50, 60, 70, 5, 6); + RectF b(50, 60, 5, 6); + EXPECT_TRUE(a.Contains(b)); + b = RectF(40, 50, 5, 6); // Right on the border + EXPECT_FALSE(a.Contains(b)); + b = RectF(95, 114, 5, 6); // Right on the border + EXPECT_FALSE(a.Contains(b)); + b = RectF(40, 50, 60, 70); + EXPECT_FALSE(a.Contains(b)); +} + +TEST(RRectFTest, Scale) { + // Note that SKRRect (the backing for RRectF) does not support scaling by NaN, + // scaling out of numerical bounds, or scaling to zero. So this test doesn't + // exercise those. + static const struct Test { + float x1; // source + float y1; + float w1; + float h1; + float r1; + + float scale; + float x2; // target + float y2; + float w2; + float h2; + float r2; + } tests[] = { + {3.0f, 4.0f, 5.0f, 6.0f, 1.0f, 1.5f, 4.5f, 6.0f, 7.5f, 9.0f, 1.5f}, + {3.0f, 4.0f, 5.0f, 6.0f, 0.0f, 1.5f, 4.5f, 6.0f, 7.5f, 9.0f, 0.0f}, + }; + + for (size_t i = 0; i < base::size(tests); ++i) { + RRectF r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1, tests[i].r1); + RRectF r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2, tests[i].r2); + + r1.Scale(tests[i].scale); + EXPECT_TRUE((r1.type() == RRectF::Type::kRect) || + (r1.type() == RRectF::Type::kSingle)); + EXPECT_EQ(r1.rect().x(), r2.rect().x()); + EXPECT_EQ(r1.rect().y(), r2.rect().y()); + EXPECT_EQ(r1.rect().width(), r2.rect().width()); + EXPECT_EQ(r1.rect().height(), r2.rect().height()); + EXPECT_EQ(r1.GetSimpleRadius(), r2.GetSimpleRadius()); + } +} + +TEST(RRectFTest, InsetOutset) { + RRectF a(40, 50, 60, 70, 5); + RRectF b = a; + b.Inset(3); + ASSERT_EQ(b, RRectF(43, 53, 54, 64, 2)); + b = a; + b.Outset(3); + ASSERT_EQ(b, RRectF(37, 47, 66, 76, 8)); +} + +} // namespace gfx
diff --git a/url/origin.cc b/url/origin.cc index 59573faa..916ad36 100644 --- a/url/origin.cc +++ b/url/origin.cc
@@ -155,6 +155,78 @@ return std::tie(tuple_, nonce_) == std::tie(other.tuple_, other.nonce_); } +bool Origin::CanBeDerivedFrom(const GURL& url) const { + DCHECK(url.is_valid()); + + // For "no access" schemes, blink's SecurityOrigin will always create an + // opaque unique one. However, about: scheme is also registered as such but + // does not behave this way, therefore exclude it from this check. + if (base::ContainsValue(url::GetNoAccessSchemes(), url.scheme()) && + !url.SchemeIs(kAboutScheme)) { + // If |this| is not opaque, definitely return false as the expectation + // is for opaque origin. + if (!opaque()) + return false; + + // And if it is unique opaque origin, it definitely is fine. But if there + // is a precursor stored, we should fall through to compare the tuples. + if (tuple_.IsInvalid()) + return true; + } + + SchemeHostPort url_tuple; + + // Optimization for the common, success case: Scheme/Host/Port match on the + // precursor, and the URL is standard. Opaqueness does not matter as a tuple + // origin can always create an opaque tuple origin. + if (url.IsStandard()) { + // Note: if extra copies of the scheme and host are undesirable, this check + // can be implemented using StringPiece comparisons, but it has to account + // explicitly checks on port numbers. + if (url.SchemeIsFileSystem()) { + url_tuple = SchemeHostPort(*url.inner_url()); + } else { + url_tuple = SchemeHostPort(url); + } + return url_tuple == tuple_; + + // Blob URLs still contain an inner origin, however it is not accessible + // through inner_url(), therefore it requires specific case to handle it. + } else if (url.SchemeIsBlob()) { + // If |this| doesn't contain any precursor information, it is an unique + // opaque origin. It is valid case, as any browser-initiated navigation + // to about:blank or data: URL will result in a document with such + // origin and it is valid for it to create blob: URLs. + if (tuple_.IsInvalid()) + return true; + + url_tuple = SchemeHostPort(GURL(url.GetContent())); + return url_tuple == tuple_; + } + + // At this point, the URL has non-standard scheme. + DCHECK(!url.IsStandard()); + + // All about: URLs (about:blank, about:srcdoc) inherit their origin from + // the context which navigated them, which means that they can be in any + // type of origin. + if (url.SchemeIs(kAboutScheme)) + return true; + + // All data: URLs commit in opaque origins, therefore |this| must be opaque + // if |url| has data: scheme. + if (url.SchemeIs(kDataScheme)) + return opaque(); + + // If |this| does not have valid precursor tuple, it is unique opaque origin, + // which is what we expect non-standard schemes to get. + if (tuple_.IsInvalid()) + return true; + + // However, when there is precursor present, the schemes must match. + return url.scheme() == tuple_.scheme(); +} + bool Origin::DomainIs(base::StringPiece canonical_domain) const { return !opaque() && url::DomainIs(tuple_.host(), canonical_domain); }
diff --git a/url/origin.h b/url/origin.h index 4205767..0833254 100644 --- a/url/origin.h +++ b/url/origin.h
@@ -199,6 +199,10 @@ return !IsSameOriginWith(other); } + // This method returns true for any |url| which if navigated to could result + // in an origin compatible with |this|. + bool CanBeDerivedFrom(const GURL& url) const; + // Get the scheme, host, and port from which this origin derives. For // a tuple Origin, this gives the same values as calling scheme(), host() // and port(). For an opaque Origin that was created by calling
diff --git a/url/origin_unittest.cc b/url/origin_unittest.cc index 99ff2aee..36f2f51 100644 --- a/url/origin_unittest.cc +++ b/url/origin_unittest.cc
@@ -669,4 +669,166 @@ Shutdown(); } +TEST_F(OriginTest, CanBeDerivedFrom) { + Origin opaque_unique_origin = Origin(); + + Origin regular_origin = Origin::Create(GURL("https://a.com/")); + Origin opaque_precursor_origin = regular_origin.DeriveNewOpaqueOrigin(); + + Origin file_origin = Origin::Create(GURL("file:///foo/bar")); + Origin file_opaque_precursor_origin = file_origin.DeriveNewOpaqueOrigin(); + Origin file_host_origin = Origin::Create(GURL("file://a.com/foo/bar")); + Origin file_host_opaque_precursor_origin = + file_host_origin.DeriveNewOpaqueOrigin(); + + Origin non_standard_scheme_origin = + Origin::Create(GURL("non-standard-scheme:foo")); + Origin non_standard_opaque_precursor_origin = + non_standard_scheme_origin.DeriveNewOpaqueOrigin(); + + // Also, add new standard scheme that is local to the test. + AddStandardScheme("new-standard", SchemeType::SCHEME_WITH_HOST); + Origin new_standard_origin = Origin::Create(GURL("new-standard://host/")); + Origin new_standard_opaque_precursor_origin = + new_standard_origin.DeriveNewOpaqueOrigin(); + + // No access schemes always get unique opaque origins. + Origin no_access_origin = + Origin::Create(GURL("standard-but-noaccess://b.com")); + Origin no_access_opaque_precursor_origin = + no_access_origin.DeriveNewOpaqueOrigin(); + + Origin local_non_standard_origin = + Origin::Create(GURL("local-but-nonstandard://a.com")); + Origin local_non_standard_opaque_precursor_origin = + local_non_standard_origin.DeriveNewOpaqueOrigin(); + + // Call origin.CanBeDerivedFrom(url) for each of the following test cases + // and ensure that it returns |expected_value| + const struct { + const char* url; + Origin* origin; + bool expected_value; + } kTestCases[] = { + {"https://a.com", ®ular_origin, true}, + // Web URL can commit in an opaque origin with precursor information. + // Example: iframe sandbox navigated to a.com. + {"https://a.com", &opaque_precursor_origin, true}, + // URL that comes from the web can never commit in an opaque unique + // origin. It must have precursor information. + {"https://a.com", &opaque_unique_origin, false}, + + // Cross-origin URLs should never work. + {"https://b.com", ®ular_origin, false}, + {"https://b.com", &opaque_precursor_origin, false}, + + // data: URL can never commit in a regular, non-opaque origin. + {"data:text/html,foo", ®ular_origin, false}, + // This is the default case: data: URLs commit in opaque origin carrying + // precursor information for the origin that created them. + {"data:text/html,foo", &opaque_precursor_origin, true}, + // Browser-initiated navigations can result in data: URL committing in + // opaque unique origin. + {"data:text/html,foo", &opaque_unique_origin, true}, + + // about:blank can commit in regular origin (default case for iframes). + {"about:blank", ®ular_origin, true}, + // This can happen if data: URL that originated at a.com creates an + // about:blank iframe. + {"about:blank", &opaque_precursor_origin, true}, + // Browser-initiated navigations can result in about:blank URL committing + // in opaque unique origin. + {"about:blank", &opaque_unique_origin, true}, + + // Default behavior of srcdoc is to inherit the origin of the parent + // document. + {"about:srcdoc", ®ular_origin, true}, + // This happens for sandboxed srcdoc iframe. + {"about:srcdoc", &opaque_precursor_origin, true}, + // This can happen with browser-initiated navigation to about:blank or + // data: URL, which in turn add srcdoc iframe. + {"about:srcdoc", &opaque_unique_origin, true}, + + // Just like srcdoc, blob: URLs can be created in all the cases. + {"blob:https://a.com/foo", ®ular_origin, true}, + {"blob:https://a.com/foo", &opaque_precursor_origin, true}, + {"blob:https://a.com/foo", &opaque_unique_origin, true}, + + {"filesystem:https://a.com/foo", ®ular_origin, true}, + {"filesystem:https://a.com/foo", &opaque_precursor_origin, true}, + // Unlike blob: URLs, filesystem: ones cannot be created in an unique + // opaque origin. + {"filesystem:https://a.com/foo", &opaque_unique_origin, false}, + + // file: URLs cannot result in regular web origins, regardless of + // opaqueness. + {"file:///etc/passwd", ®ular_origin, false}, + {"file:///etc/passwd", &opaque_precursor_origin, false}, + // However, they can result in regular file: origin and an opaque one + // containing another file: origin as precursor. + {"file:///etc/passwd", &file_origin, true}, + {"file:///etc/passwd", &file_opaque_precursor_origin, true}, + // It should not be possible to get an opaque unique origin for file: + // as it is a standard scheme and will always result in a tuple origin + // or will always be derived by other origin. + // Note: file:// URLs should become unique opaque origins at some point. + {"file:///etc/passwd", &opaque_unique_origin, false}, + + // The same set as above, but including a host. + {"file://a.com/etc/passwd", ®ular_origin, false}, + {"file://a.com/etc/passwd", &opaque_precursor_origin, false}, + {"file://a.com/etc/passwd", &file_host_origin, true}, + {"file://a.com/etc/passwd", &file_host_opaque_precursor_origin, true}, + {"file://a.com/etc/passwd", &opaque_unique_origin, false}, + + // Locally registered standard scheme should behave the same way + // as built-in standard schemes. + {"new-standard://host/foo", &new_standard_origin, true}, + {"new-standard://host/foo", &new_standard_opaque_precursor_origin, true}, + {"new-standard://host/foo", &opaque_unique_origin, false}, + {"new-standard://host2/foo", &new_standard_origin, false}, + {"new-standard://host2/foo", &new_standard_opaque_precursor_origin, + false}, + + // A non-standard scheme should never commit in an standard origin or + // opaque origin with standard precursor information. + {"non-standard-scheme://a.com/foo", ®ular_origin, false}, + {"non-standard-scheme://a.com/foo", &opaque_precursor_origin, false}, + // However, it should be fine to commit in unique opaque origins or in its + // own origin. + // Note: since non-standard scheme URLs don't parse out anything + // but the scheme, using a random different hostname here would work. + {"non-standard-scheme://b.com/foo2", &opaque_unique_origin, true}, + {"non-standard-scheme://b.com/foo3", &non_standard_scheme_origin, true}, + {"non-standard-scheme://b.com/foo4", + &non_standard_opaque_precursor_origin, true}, + + // No access scheme can only commit in opaque origin. + {"standard-but-noaccess://a.com/foo", ®ular_origin, false}, + {"standard-but-noaccess://a.com/foo", &opaque_precursor_origin, false}, + {"standard-but-noaccess://a.com/foo", &opaque_unique_origin, true}, + {"standard-but-noaccess://a.com/foo", &no_access_origin, false}, + {"standard-but-noaccess://a.com/foo", &no_access_opaque_precursor_origin, + false}, + {"standard-but-noaccess://b.com/foo", &no_access_origin, false}, + {"standard-but-noaccess://b.com/foo", &no_access_opaque_precursor_origin, + true}, + + // Local schemes can be non-standard, verify they also work as expected. + {"local-but-nonstandard://a.com", ®ular_origin, false}, + {"local-but-nonstandard://a.com", &opaque_precursor_origin, false}, + {"local-but-nonstandard://a.com", &opaque_unique_origin, true}, + {"local-but-nonstandard://a.com", &local_non_standard_origin, true}, + {"local-but-nonstandard://a.com", + &local_non_standard_opaque_precursor_origin, true}, + }; + + for (const auto& test_case : kTestCases) { + SCOPED_TRACE(testing::Message() << "(origin, url): (" << *test_case.origin + << ", " << test_case.url << ")"); + EXPECT_EQ(test_case.expected_value, + test_case.origin->CanBeDerivedFrom(GURL(test_case.url))); + } +} + } // namespace url