diff --git a/DEPS b/DEPS index 4cb279e..3825b55 100644 --- a/DEPS +++ b/DEPS
@@ -129,7 +129,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': '25e371f7ee5a770ba0d7fe5b8b51887c616cc52b', + 'skia_revision': '812499d7f61ddeb776906ef398f0f31a37157a71', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other. @@ -141,15 +141,15 @@ # 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': 'd581f918e90dd5a1e827ddc15abf83a17656262c', + 'angle_revision': '2249d4a727f27644b98c9a96677863757b8dee7f', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling SwiftShader # and whatever else without interference from each other. - 'swiftshader_revision': 'f41ca6b57107978252fdd14deaefe9fbc396c86c', + 'swiftshader_revision': '13f230772370735840798bcea504986c14af8e1a', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling PDFium # and whatever else without interference from each other. - 'pdfium_revision': '9cf260b9d7f4491833bd5fd997a286ce6926678e', + 'pdfium_revision': 'fd2819274d7fcca0840745c992bb50fedaa0f070', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling openmax_dl # and whatever else without interference from each other. @@ -196,7 +196,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling catapult # and whatever else without interference from each other. - 'catapult_revision': '50b06f012a60d306c1edafb6544fb9e36f07e645', + 'catapult_revision': '6bef8df14cbd2153175071cfd3627f035a70b95f', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libFuzzer # and whatever else without interference from each other. @@ -252,7 +252,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. - 'spv_tools_revision': '82ebbbba15c2adb7933489130374b43be970b8d4', + 'spv_tools_revision': '98b3f26c2f1fc0633dbbddc71a7e101a3dad8c80', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. @@ -805,7 +805,7 @@ # Build tools for Chrome OS. Note: This depends on third_party/pyelftools. 'src/third_party/chromite': { - 'url': Var('chromium_git') + '/chromiumos/chromite.git' + '@' + 'f5a6b40dd0b3dc5181f6898236e04622ff2a640d', + 'url': Var('chromium_git') + '/chromiumos/chromite.git' + '@' + 'bddc5ac8c77d35ee0f5fc89e1894e04d5d81839a', 'condition': 'checkout_linux', }, @@ -830,7 +830,7 @@ }, 'src/third_party/depot_tools': - Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + 'a67950d67088163e315e3bc4c6d66fb1968f2724', + Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '1de3cd440cf8883c0586420fc19423d83fcb7eb0', 'src/third_party/devtools-node-modules': Var('chromium_git') + '/external/github.com/ChromeDevTools/devtools-node-modules' + '@' + Var('devtools_node_modules_revision'), @@ -1063,7 +1063,7 @@ }, 'src/third_party/libvpx/source/libvpx': - Var('chromium_git') + '/webm/libvpx.git' + '@' + '4117995a8ecef413849bdc51ddaa82c77f5967bd', + Var('chromium_git') + '/webm/libvpx.git' + '@' + 'c46694c1d93ccfa40cb1c3b7c04c167be59fded4', 'src/third_party/libwebm/source': Var('chromium_git') + '/webm/libwebm.git' + '@' + '51ca718c3adf0ddedacd7df25fe45f67dc5a9ce1', @@ -1340,10 +1340,10 @@ Var('chromium_git') + '/external/selenium/py.git' + '@' + '5fd78261a75fe08d27ca4835fb6c5ce4b42275bd', 'src/third_party/webgl/src': - Var('chromium_git') + '/external/khronosgroup/webgl.git' + '@' + '688fbfe33779392aa210d67d4aa12cb012f112c2', + Var('chromium_git') + '/external/khronosgroup/webgl.git' + '@' + '3f6583d3fee4ab71866ade794504a20eb6f63f88', 'src/third_party/webrtc': - Var('webrtc_git') + '/src.git' + '@' + '21d42d27103eedfa24696e4168a44bd1cbade2ee', + Var('webrtc_git') + '/src.git' + '@' + 'e80fb30d44840a4fd1e587979304865f827ff828', 'src/third_party/xdg-utils': { 'url': Var('chromium_git') + '/chromium/deps/xdg-utils.git' + '@' + 'd80274d5869b17b8c9067a1022e4416ee7ed5e0d', @@ -1384,7 +1384,7 @@ Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'), 'src-internal': { - 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@c1ad291dcb9c9d1b97ca42d16739693531f1af52', + 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@59195e83d8853cd17950c2cf6d3e43d613e1c0ce', 'condition': 'checkout_src_internal', },
diff --git a/android_webview/BUILD.gn b/android_webview/BUILD.gn index 1231b076..511f16e7 100644 --- a/android_webview/BUILD.gn +++ b/android_webview/BUILD.gn
@@ -16,11 +16,6 @@ import("//tools/resources/generate_resource_whitelist.gni") import("//tools/v8_context_snapshot/v8_context_snapshot.gni") -declare_args() { - # Package name of the system_webview_apk target. - system_webview_package_name = "com.android.webview" -} - if (enable_resource_whitelist_generation) { system_webview_pak_whitelist = "$target_gen_dir/system_webview_pak_whitelist.txt"
diff --git a/android_webview/browser/network_service/aw_proxying_url_loader_factory.cc b/android_webview/browser/network_service/aw_proxying_url_loader_factory.cc index 9a4adc5..42c86c4a 100644 --- a/android_webview/browser/network_service/aw_proxying_url_loader_factory.cc +++ b/android_webview/browser/network_service/aw_proxying_url_loader_factory.cc
@@ -18,6 +18,7 @@ #include "android_webview/common/url_constants.h" #include "base/android/build_info.h" #include "base/bind.h" +#include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" #include "base/task/post_task.h" #include "components/safe_browsing/common/safebrowsing_constants.h" @@ -133,6 +134,7 @@ int error_status_ = net::OK; network::ResourceRequest request_; + const net::MutableNetworkTrafficAnnotationTag traffic_annotation_; mojo::Binding<network::mojom::URLLoader> proxied_loader_binding_; @@ -521,7 +523,6 @@ const net::RedirectInfo& redirect_info, const network::ResourceResponseHead& head) { // TODO(timvolodine): handle redirect override. - // TODO(timvolodine): handle unsafe redirect case. request_was_redirected_ = true; target_client_->OnReceiveRedirect(redirect_info, head); request_.url = redirect_info.new_url; @@ -623,8 +624,17 @@ void InterceptedRequest::OnURLLoaderError(uint32_t custom_reason, const std::string& description) { - if (custom_reason == network::mojom::URLLoader::kClientDisconnectReason) - SendErrorCallback(safe_browsing::GetNetErrorCodeForSafeBrowsing(), true); + if (custom_reason == network::mojom::URLLoader::kClientDisconnectReason) { + if (description == safe_browsing::kCustomCancelReasonForURLLoader) { + SendErrorCallback(safe_browsing::GetNetErrorCodeForSafeBrowsing(), true); + } else { + int parsed_error_code; + if (base::StringToInt(base::StringPiece(description), + &parsed_error_code)) { + SendErrorCallback(parsed_error_code, false); + } + } + } // If CallOnComplete was already called, then this object is ready to be // deleted.
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/ClientOnReceivedError2Test.java b/android_webview/javatests/src/org/chromium/android_webview/test/ClientOnReceivedError2Test.java index ba695e6..42f2957 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/ClientOnReceivedError2Test.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/ClientOnReceivedError2Test.java
@@ -401,4 +401,25 @@ Assert.assertEquals(onReceivedError2CallCount + 1, onReceivedError2Helper.getCallCount()); Assert.assertEquals(BAD_HTML_URL, onReceivedError2Helper.getRequest().url); } + + @Test + @SmallTest + @Feature({"AndroidWebView"}) + public void testUnsafeRedirect_FileUrl() throws Throwable { + startWebServer(); + final String redirectUrl = mWebServer.setRedirect("/302.html", "file:///foo"); + + TestAwContentsClient.OnReceivedError2Helper onReceivedError2Helper = + mContentsClient.getOnReceivedError2Helper(); + final int onReceivedError2CallCount = onReceivedError2Helper.getCallCount(); + + mActivityTestRule.loadUrlSync( + mAwContents, mContentsClient.getOnPageFinishedHelper(), redirectUrl); + + onReceivedError2Helper.waitForCallback(onReceivedError2CallCount, + 1 /* numberOfCallsToWaitFor */, WAIT_TIMEOUT_MS, TimeUnit.MILLISECONDS); + Assert.assertEquals(onReceivedError2CallCount + 1, onReceivedError2Helper.getCallCount()); + AwWebResourceError error = onReceivedError2Helper.getError(); + Assert.assertEquals("net::ERR_UNSAFE_REDIRECT", error.description); + } }
diff --git a/android_webview/system_webview_apk_tmpl.gni b/android_webview/system_webview_apk_tmpl.gni index 804b2f9..1bfdf49 100644 --- a/android_webview/system_webview_apk_tmpl.gni +++ b/android_webview/system_webview_apk_tmpl.gni
@@ -10,6 +10,11 @@ import("//chrome/android/trichrome.gni") import("//tools/v8_context_snapshot/v8_context_snapshot.gni") +declare_args() { + # Package name of the system_webview_apk target. + system_webview_package_name = "com.android.webview" +} + template("system_webview_apk_tmpl") { android_apk(target_name) { forward_variables_from(invoker, "*")
diff --git a/android_webview/ui/README.md b/android_webview/ui/README.md new file mode 100644 index 0000000..2928f51 --- /dev/null +++ b/android_webview/ui/README.md
@@ -0,0 +1,55 @@ +# Android WebView Resources + +This folder is responsible for managing WebView's application resources. Please +also consult [general UI/localization information][1] for the chromium +repository. + +## Adding a WebView-specific string/resource + +The process is similar to the [general instructions][1], with the caveat that +strings should be added to the WebView-specific GRD file +([`aw_strings.grd`](./aw_strings.grd), translations live in +[translations/](./translations/)). + +WebView-specific file resources should be declared in +[`aw_resources.grd`](./aw_resources.grd), and the file templates should live +under [resources/](./resources/)). + +No `<if>` clause is generally necessary: it's already implied these are for +WebView builds only. + +## Adding a WebView-specific Android/Java string + +The process is again similar to the [general instructions][1]. Use +[`//android_webview/java/strings/android_webview_strings.grd`](/android_webview/java/strings/android_webview_strings.grd). +A string `IDS_MY_STRING` can be accessed in Java with +`org.chromium.android_webview.R.string.MY_STRING`. + +Resources are added under +[`//android_webview/java/res/`](/android_webview/java/res/). Similarly, a +resource `drawable-xxxhdpi/ic_play_circle_outline_black_48dp.png` can be +accessed in Java with +`org.chromium.android_webview.R.drawable.ic_play_circle_outline_black_48dp`. + +*** note +**Note:** WebView-specific resources are prefixed by the +`org.chromium.android_webview` package name. +*** + +## Shared/common resources + +WebView can use strings and resources defined in GRD files in other layers (for +now, only `//components/`). Unlike other Chrome, we trim out all such resources +by default. To use these resources, you must add the resource to the appropriate +whitelist file: [`grit_strings_whitelist.txt`](./grit_strings_whitelist.txt) for +`IDS_*` strings or +[`grit_resources_whitelist.txt`](./grit_resources_whitelist.txt) for `IDR_*` +resources. + +*** note +**Note:** Inflating a +non-whitelisted resource triggers a `DCHECK` (in release builds, this usually +inflates to empty content). +*** + +[1]: http://www.chromium.org/developers/design-documents/ui-localization
diff --git a/ash/BUILD.gn b/ash/BUILD.gn index e8bf5f2..8eb81c7f 100644 --- a/ash/BUILD.gn +++ b/ash/BUILD.gn
@@ -1968,6 +1968,7 @@ "//extensions/common:common_constants", "//mojo/core/embedder", "//net:net", + "//services/device/public/cpp/bluetooth", "//services/media_session/public/cpp/test:test_support", "//services/media_session/public/mojom", "//services/ws:test_support",
diff --git a/ash/accelerators/accelerator_controller_unittest.cc b/ash/accelerators/accelerator_controller_unittest.cc index a743306..e480c60 100644 --- a/ash/accelerators/accelerator_controller_unittest.cc +++ b/ash/accelerators/accelerator_controller_unittest.cc
@@ -894,7 +894,7 @@ base::RunLoop().RunUntilIdle(); GetAppListTestHelper()->CheckVisibility(true); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); histogram_tester.ExpectTotalCount(app_list::kAppListToggleMethodHistogram, ++toggle_count_total); histogram_tester.ExpectBucketCount(app_list::kAppListToggleMethodHistogram, @@ -912,7 +912,7 @@ ui::Accelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE))); base::RunLoop().RunUntilIdle(); GetAppListTestHelper()->CheckVisibility(true); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); histogram_tester.ExpectTotalCount(app_list::kAppListToggleMethodHistogram, ++toggle_count_total); histogram_tester.ExpectBucketCount(app_list::kAppListToggleMethodHistogram, @@ -924,7 +924,7 @@ base::RunLoop().RunUntilIdle(); GetAppListTestHelper()->CheckVisibility(true); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); histogram_tester.ExpectTotalCount(app_list::kAppListToggleMethodHistogram, ++toggle_count_total); histogram_tester.ExpectBucketCount(app_list::kAppListToggleMethodHistogram, @@ -942,7 +942,7 @@ ui::Accelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE))); base::RunLoop().RunUntilIdle(); GetAppListTestHelper()->CheckVisibility(true); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); histogram_tester.ExpectTotalCount(app_list::kAppListToggleMethodHistogram, ++toggle_count_total); histogram_tester.ExpectBucketCount(app_list::kAppListToggleMethodHistogram, @@ -953,14 +953,14 @@ generator->ReleaseKey(ui::VKEY_0, ui::EF_NONE); base::RunLoop().RunUntilIdle(); GetAppListTestHelper()->CheckVisibility(true); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::HALF); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kHalf); // Shift+VKEY_BROWSER_SEARCH transitions to FULLSCREEN_SEARCH. EXPECT_TRUE(ProcessInController( ui::Accelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_SHIFT_DOWN))); base::RunLoop().RunUntilIdle(); GetAppListTestHelper()->CheckVisibility(true); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_SEARCH); + ash::mojom::AppListViewState::kFullscreenSearch); histogram_tester.ExpectTotalCount(app_list::kAppListToggleMethodHistogram, ++toggle_count_total); histogram_tester.ExpectBucketCount(app_list::kAppListToggleMethodHistogram,
diff --git a/ash/app_list/app_list_controller_impl.cc b/ash/app_list/app_list_controller_impl.cc index 8bbf6044..f6db694 100644 --- a/ash/app_list/app_list_controller_impl.cc +++ b/ash/app_list/app_list_controller_impl.cc
@@ -12,7 +12,6 @@ #include "ash/app_list/app_list_presenter_delegate_impl.h" #include "ash/app_list/model/app_list_folder_item.h" #include "ash/app_list/model/app_list_item.h" -#include "ash/app_list/model/app_list_view_state.h" #include "ash/app_list/views/app_list_main_view.h" #include "ash/app_list/views/app_list_view.h" #include "ash/app_list/views/contents_view.h" @@ -28,6 +27,7 @@ #include "ash/public/cpp/app_list/app_list_features.h" #include "ash/public/cpp/app_list/app_list_metrics.h" #include "ash/public/cpp/shell_window_ids.h" +#include "ash/public/interfaces/app_list_view.mojom.h" #include "ash/root_window_controller.h" #include "ash/session/session_controller.h" #include "ash/shelf/shelf_layout_manager.h" @@ -499,7 +499,7 @@ } void AppListControllerImpl::EndDragFromShelf( - app_list::AppListViewState app_list_state) { + ash::mojom::AppListViewState app_list_state) { // Avoid dragging app list when homecher is enabled. if (IsHomeScreenAvailable()) return; @@ -524,7 +524,7 @@ return action; } -app_list::AppListViewState AppListControllerImpl::GetAppListViewState() { +ash::mojom::AppListViewState AppListControllerImpl::GetAppListViewState() { return model_->state_fullscreen(); } @@ -636,8 +636,8 @@ if (!IsShowingEmbeddedAssistantUI()) { if (presenter_.GetView()->app_list_state() == - app_list::AppListViewState::PEEKING) { - presenter_.GetView()->SetState(app_list::AppListViewState::HALF); + ash::mojom::AppListViewState::kPeeking) { + presenter_.GetView()->SetState(ash::mojom::AppListViewState::kHalf); } presenter_.ShowEmbeddedAssistantUI(true); } @@ -654,7 +654,7 @@ if (IsHomeScreenAvailable()) { presenter_.GetView()->app_list_main_view()->ResetForShow(); presenter_.GetView()->SetState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); } else if (exit_point != AssistantExitPoint::kBackInLauncher) { DismissAppList(); } @@ -751,13 +751,14 @@ presenter_.SetExpandArrowViewVisibility(should_show); } -app_list::AppListViewState AppListControllerImpl::CalculateStateAfterShelfDrag( +ash::mojom::AppListViewState +AppListControllerImpl::CalculateStateAfterShelfDrag( const ui::GestureEvent& gesture_in_screen, float launcher_above_shelf_bottom_amount) const { if (presenter_.GetView()) return presenter_.GetView()->CalculateStateAfterShelfDrag( gesture_in_screen, launcher_above_shelf_bottom_amount); - return app_list::AppListViewState::CLOSED; + return ash::mojom::AppListViewState::kClosed; } void AppListControllerImpl::SetStateTransitionAnimationCallback( @@ -1031,7 +1032,7 @@ } void AppListControllerImpl::OnStateTransitionAnimationCompleted( - app_list::AppListViewState state) { + ash::mojom::AppListViewState state) { if (!state_transition_animation_callback_.is_null()) state_transition_animation_callback_.Run(state); }
diff --git a/ash/app_list/app_list_controller_impl.h b/ash/app_list/app_list_controller_impl.h index c60cb726..c28277f 100644 --- a/ash/app_list/app_list_controller_impl.h +++ b/ash/app_list/app_list_controller_impl.h
@@ -13,7 +13,6 @@ #include "ash/app_list/app_list_view_delegate.h" #include "ash/app_list/model/app_list_model.h" #include "ash/app_list/model/app_list_model_observer.h" -#include "ash/app_list/model/app_list_view_state.h" #include "ash/app_list/model/search/search_model.h" #include "ash/app_list/presenter/app_list_presenter_impl.h" #include "ash/ash_export.h" @@ -24,6 +23,7 @@ #include "ash/public/cpp/assistant/default_voice_interaction_observer.h" #include "ash/public/cpp/shelf_types.h" #include "ash/public/interfaces/app_list.mojom.h" +#include "ash/public/interfaces/app_list_view.mojom.h" #include "ash/public/interfaces/voice_interaction_controller.mojom.h" #include "ash/session/session_observer.h" #include "ash/shell_observer.h" @@ -145,12 +145,12 @@ base::TimeTicks event_time_stamp); void UpdateYPositionAndOpacity(int y_position_in_screen, float background_opacity); - void EndDragFromShelf(app_list::AppListViewState app_list_state); + void EndDragFromShelf(ash::mojom::AppListViewState app_list_state); void ProcessMouseWheelEvent(const ui::MouseWheelEvent& event); ash::ShelfAction ToggleAppList(int64_t display_id, app_list::AppListShowSource show_source, base::TimeTicks event_time_stamp); - app_list::AppListViewState GetAppListViewState(); + ash::mojom::AppListViewState GetAppListViewState(); // app_list::AppListViewDelegate: app_list::AppListModel* GetModel() override; @@ -201,7 +201,7 @@ bool visibility) override; bool IsAssistantAllowedAndEnabled() const override; void OnStateTransitionAnimationCompleted( - app_list::AppListViewState state) override; + ash::mojom::AppListViewState state) override; void AddObserver(AppListControllerObserver* observer); void RemoveObserver(AppListControllerObserver* obsever); @@ -282,14 +282,14 @@ bool IsShowingEmbeddedAssistantUI() const; // Get updated app list view state after dragging from shelf. - app_list::AppListViewState CalculateStateAfterShelfDrag( + ash::mojom::AppListViewState CalculateStateAfterShelfDrag( const ui::GestureEvent& gesture_in_screen, float launcher_above_shelf_bottom_amount) const; void SetAppListModelForTest(std::unique_ptr<app_list::AppListModel> model); using StateTransitionAnimationCallback = - base::RepeatingCallback<void(app_list::AppListViewState)>; + base::RepeatingCallback<void(ash::mojom::AppListViewState)>; void SetStateTransitionAnimationCallback( StateTransitionAnimationCallback callback);
diff --git a/ash/app_list/app_list_controller_impl_unittest.cc b/ash/app_list/app_list_controller_impl_unittest.cc index 4a2329a..5827595 100644 --- a/ash/app_list/app_list_controller_impl_unittest.cc +++ b/ash/app_list/app_list_controller_impl_unittest.cc
@@ -150,7 +150,7 @@ GetAppListView()->get_fullscreen_widget_for_test()->GetNativeView(); gfx::Rect app_list_screen_bounds = native_window->GetBoundsInScreen(); EXPECT_EQ(0, app_list_screen_bounds.y()); - EXPECT_EQ(app_list::AppListViewState::HALF, + EXPECT_EQ(ash::mojom::AppListViewState::kHalf, GetAppListView()->app_list_state()); gfx::Transform expected_transform; expected_transform.Translate(0, -app_list::kAppListBackgroundRadius); @@ -196,11 +196,11 @@ // the PEEKING state. ShowAppListNow(); base::RunLoop().RunUntilIdle(); - EXPECT_EQ(app_list::AppListViewState::PEEKING, + EXPECT_EQ(ash::mojom::AppListViewState::kPeeking, GetAppListView()->app_list_state()); EXPECT_EQ(nullptr, GetVirtualKeyboardWindow()); EXPECT_EQ(GetAppListView()->GetPreferredWidgetBoundsForState( - app_list::AppListViewState::PEEKING), + ash::mojom::AppListViewState::kPeeking), GetAppListViewNativeWindow()->bounds()); } @@ -232,10 +232,10 @@ // (1) AppListView's state is FULLSCREEN_SEARCH // (2) AppListView's bounds are the same as the preferred bounds for // the FULLSCREEN_SEARCH state. - EXPECT_EQ(app_list::AppListViewState::FULLSCREEN_SEARCH, + EXPECT_EQ(ash::mojom::AppListViewState::kFullscreenSearch, GetAppListView()->app_list_state()); EXPECT_EQ(GetAppListView()->GetPreferredWidgetBoundsForState( - app_list::AppListViewState::FULLSCREEN_SEARCH), + ash::mojom::AppListViewState::kFullscreenSearch), GetAppListViewNativeWindow()->bounds()); }
diff --git a/ash/app_list/app_list_metrics.cc b/ash/app_list/app_list_metrics.cc index 699394b..7fea925 100644 --- a/ash/app_list/app_list_metrics.cc +++ b/ash/app_list/app_list_metrics.cc
@@ -117,11 +117,11 @@ return; ApplistSearchResultOpenedSource source; - AppListViewState state = model->state_fullscreen(); + ash::mojom::AppListViewState state = model->state_fullscreen(); if (search_model->tablet_mode()) { source = ApplistSearchResultOpenedSource::kFullscreenTablet; } else { - source = state == AppListViewState::HALF + source = state == ash::mojom::AppListViewState::kHalf ? ApplistSearchResultOpenedSource::kHalfClamshell : ApplistSearchResultOpenedSource::kFullscreenClamshell; }
diff --git a/ash/app_list/app_list_presenter_delegate_unittest.cc b/ash/app_list/app_list_presenter_delegate_unittest.cc index f837843..38feec3a 100644 --- a/ash/app_list/app_list_presenter_delegate_unittest.cc +++ b/ash/app_list/app_list_presenter_delegate_unittest.cc
@@ -5,7 +5,6 @@ #include <algorithm> #include <memory> -#include "ash/app_list/model/app_list_view_state.h" #include "ash/app_list/pagination_model.h" #include "ash/app_list/presenter/app_list_presenter_impl.h" #include "ash/app_list/test/app_list_test_helper.h" @@ -26,6 +25,7 @@ #include "ash/public/cpp/shelf_model.h" #include "ash/public/cpp/shelf_types.h" #include "ash/public/cpp/shell_window_ids.h" +#include "ash/public/interfaces/app_list_view.mojom.h" #include "ash/root_window_controller.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_controller.h" @@ -360,7 +360,7 @@ const app_list::AppListView* app_list = GetAppListView(); EXPECT_TRUE(app_list->is_fullscreen()); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); // Drag the widget across the screen over an arbitrary 100Ms, this would // normally result in the app list transitioning to PEEKING but will now @@ -371,12 +371,12 @@ base::TimeDelta::FromMilliseconds(100), 10); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); // Tap the app list body. This should still close the app list. generator->GestureTapAt(GetPointOutsideSearchbox()); GetAppListTestHelper()->WaitUntilIdle(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); GetAppListTestHelper()->CheckVisibility(false); } @@ -392,7 +392,7 @@ app_list::AppListView* app_list = GetAppListView(); EXPECT_TRUE(app_list->is_fullscreen()); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); // Enter text in the searchbox, the app list should transition to fullscreen // search. @@ -400,14 +400,14 @@ generator->PressKey(ui::KeyboardCode::VKEY_0, 0); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_SEARCH); + ash::mojom::AppListViewState::kFullscreenSearch); // Delete the text in the searchbox, the app list should transition to // fullscreen all apps. generator->PressKey(ui::KeyboardCode::VKEY_BACK, 0); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); } // Tests that the app list initializes in peeking with bottom shelf alignment @@ -417,18 +417,18 @@ GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId()); app_list::AppListView* app_list = GetAppListView(); EXPECT_FALSE(app_list->is_fullscreen()); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); // Enter text in the searchbox, this should transition the app list to half // state. ui::test::EventGenerator* generator = GetEventGenerator(); generator->PressKey(ui::KeyboardCode::VKEY_0, 0); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::HALF); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kHalf); // Empty the searchbox, this should transition the app list to it's previous // state. generator->PressKey(ui::KeyboardCode::VKEY_BACK, 0); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); } // Tests that the app list initializes in fullscreen with tablet mode active @@ -438,7 +438,7 @@ EnableTabletMode(true); GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId()); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); // Enter text in the searchbox, the app list should transition to fullscreen // search. @@ -446,14 +446,14 @@ generator->PressKey(ui::KeyboardCode::VKEY_0, 0); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_SEARCH); + ash::mojom::AppListViewState::kFullscreenSearch); // Delete the text in the searchbox, the app list should transition to // fullscreen all apps. generator->PressKey(ui::KeyboardCode::VKEY_BACK, 0); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); } // Tests that the app list state responds correctly to tablet mode being @@ -461,28 +461,28 @@ TEST_F(AppListPresenterDelegateTest, HalfToFullscreenWhenTabletModeIsActive) { // TODO(newcomer): Investigate mash failures crbug.com/726838 GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId()); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); // Enter text in the search box to transition to half app list. ui::test::EventGenerator* generator = GetEventGenerator(); generator->PressKey(ui::KeyboardCode::VKEY_0, 0); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::HALF); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kHalf); // Enable tablet mode and force the app list to transition to the fullscreen // equivalent of the current state. EnableTabletMode(true); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_SEARCH); + ash::mojom::AppListViewState::kFullscreenSearch); generator->PressKey(ui::KeyboardCode::VKEY_BACK, 0); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); } // Tests that the app list view handles drag properly in laptop mode. TEST_F(AppListPresenterDelegateTest, AppListViewDragHandler) { // TODO(newcomer): Investigate mash failures crbug.com/726838 GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId()); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); ui::test::EventGenerator* generator = GetEventGenerator(); // Execute a slow short upwards drag this should fail to transition the app @@ -492,14 +492,14 @@ generator->GestureScrollSequence(gfx::Point(0, top_of_app_list + 20), gfx::Point(0, top_of_app_list - 20), base::TimeDelta::FromMilliseconds(500), 50); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); // Execute a long upwards drag, this should transition the app list. generator->GestureScrollSequence(gfx::Point(10, top_of_app_list + 20), gfx::Point(10, 10), base::TimeDelta::FromMilliseconds(100), 10); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); // Execute a short downward drag, this should fail to transition the app list. gfx::Point start(10, 10); @@ -509,7 +509,7 @@ generator->CalculateScrollDurationForFlingVelocity(start, end, 1, 100), 100); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); // Execute a long and slow downward drag to switch to peeking. start = gfx::Point(10, 200); @@ -518,19 +518,19 @@ start, end, generator->CalculateScrollDurationForFlingVelocity(start, end, 1, 100), 100); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); // Transition to fullscreen. generator->GestureScrollSequence(gfx::Point(10, top_of_app_list + 20), gfx::Point(10, 10), base::TimeDelta::FromMilliseconds(100), 10); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); // Enter text to transition to |FULLSCREEN_SEARCH|. generator->PressKey(ui::KeyboardCode::VKEY_0, 0); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_SEARCH); + ash::mojom::AppListViewState::kFullscreenSearch); // Execute a short downward drag, this should fail to close the app list. start = gfx::Point(10, 10); @@ -540,13 +540,13 @@ generator->CalculateScrollDurationForFlingVelocity(start, end, 1, 100), 100); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_SEARCH); + ash::mojom::AppListViewState::kFullscreenSearch); // Execute a long downward drag, this should close the app list. generator->GestureScrollSequence(gfx::Point(10, 10), gfx::Point(10, 900), base::TimeDelta::FromMilliseconds(100), 10); GetAppListTestHelper()->WaitUntilIdle(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); GetAppListTestHelper()->CheckVisibility(false); } @@ -601,7 +601,7 @@ TEST_P(AppListPresenterDelegateTest, TapAndClickOutsideClosesPeekingAppList) { const bool test_mouse_event = TestMouseEventParam(); GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId()); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); ui::test::EventGenerator* generator = GetEventGenerator(); // Tapping outside the bounds closes the app list. @@ -684,12 +684,12 @@ app_list::SearchBoxView* search_box_view = app_list_view->search_box_view(); ui::test::EventGenerator* generator = GetEventGenerator(); GetAppListTestHelper()->WaitUntilIdle(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); // Press a key, the AppListView should transition to half. generator->PressKey(ui::KeyboardCode::VKEY_0, 0); GetAppListTestHelper()->WaitUntilIdle(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::HALF); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kHalf); EXPECT_TRUE(search_box_view->is_search_box_active()); // Tap outside the search box, the AppListView should transition to Peeking @@ -702,7 +702,7 @@ generator->GestureTapDownAndUp(GetPointOutsideSearchbox()); } GetAppListTestHelper()->WaitUntilIdle(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); EXPECT_FALSE(search_box_view->is_search_box_active()); // Tap outside the search box again, the AppListView should hide. @@ -714,7 +714,7 @@ generator->GestureTapDownAndUp(GetPointOutsideSearchbox()); } GetAppListTestHelper()->WaitUntilIdle(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); GetAppListTestHelper()->CheckVisibility(false); } @@ -738,14 +738,14 @@ base::TimeDelta::FromMilliseconds(100), 10); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); // Press a key, this should activate the searchbox and transition to // fullscreen search. generator->PressKey(ui::KeyboardCode::VKEY_0, 0); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_SEARCH); + ash::mojom::AppListViewState::kFullscreenSearch); EXPECT_TRUE(search_box_view->is_search_box_active()); // Tap outside the searchbox, this should deactivate the searchbox and the @@ -758,7 +758,7 @@ } GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); EXPECT_FALSE(search_box_view->is_search_box_active()); // Tap outside the searchbox again, this should close the applistview. @@ -769,7 +769,7 @@ generator->GestureTapDownAndUp(GetPointOutsideSearchbox()); } GetAppListTestHelper()->WaitUntilIdle(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); GetAppListTestHelper()->CheckVisibility(false); } @@ -813,7 +813,7 @@ generator->GestureTapAt(GetPointOutsideSearchbox()); } GetAppListTestHelper()->WaitUntilIdle(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); GetAppListTestHelper()->CheckVisibility(false); } @@ -851,7 +851,7 @@ // Transition to half app list by entering text. generator->PressKey(ui::KeyboardCode::VKEY_0, 0); GetAppListTestHelper()->WaitUntilIdle(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::HALF); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kHalf); // A point outside the bounds of launcher. gfx::Point to_point( @@ -865,7 +865,7 @@ generator->GestureTapAt(to_point); } GetAppListTestHelper()->WaitUntilIdle(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); // Clicking/tapping outside the bounds closes the app list. if (TestMouseEventParam()) { @@ -885,25 +885,25 @@ app_list::AppListView* view = GetAppListView(); ui::test::EventGenerator* generator = GetEventGenerator(); EXPECT_FALSE(view->search_box_view()->is_search_box_active()); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); // Enter a whitespace query, the searchbox should activate but stay in peeking // mode. generator->PressKey(ui::VKEY_SPACE, 0); EXPECT_TRUE(view->search_box_view()->is_search_box_active()); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); // Enter a non-whitespace character, the Searchbox should stay active and go // to HALF generator->PressKey(ui::VKEY_0, 0); EXPECT_TRUE(view->search_box_view()->is_search_box_active()); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::HALF); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kHalf); // Delete the non whitespace character, the Searchbox should not deactivate // but go to PEEKING generator->PressKey(ui::VKEY_BACK, 0); EXPECT_TRUE(view->search_box_view()->is_search_box_active()); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); } // Tests that an unhandled two finger tap/right click does not close the app @@ -911,7 +911,7 @@ // Peeking mode. TEST_P(AppListPresenterDelegateTest, UnhandledEventOnPeeking) { GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId()); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); // Two finger tap or right click in the empty space below the searchbox. The // app list should not close. @@ -930,7 +930,7 @@ generator->Dispatch(&two_finger_tap); } GetAppListTestHelper()->WaitUntilIdle(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); GetAppListTestHelper()->CheckVisibility(true); // One finger tap or left click in the empty space below the searchbox. The @@ -942,7 +942,7 @@ generator->GestureTapAt(empty_space); } GetAppListTestHelper()->WaitUntilIdle(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); GetAppListTestHelper()->CheckVisibility(false); } @@ -953,13 +953,13 @@ const bool test_fullscreen = GetParam(); GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId()); app_list::AppListView* view = GetAppListView(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); if (test_fullscreen) { FlingUpOrDown(GetEventGenerator(), view, true /* up */); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); } // Drag the app list to 50 DIPs from the bottom bezel. @@ -974,7 +974,7 @@ base::TimeDelta::FromMilliseconds(1500), 100); GetAppListTestHelper()->WaitUntilIdle(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); GetAppListTestHelper()->CheckVisibility(false); } @@ -984,31 +984,31 @@ const bool test_fullscreen = GetParam(); GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId()); app_list::AppListView* view = GetAppListView(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); if (test_fullscreen) { FlingUpOrDown(GetEventGenerator(), view, true /* up */); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); } // Fling down, the app list should close. FlingUpOrDown(GetEventGenerator(), view, false /* down */); GetAppListTestHelper()->WaitUntilIdle(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); GetAppListTestHelper()->CheckVisibility(false); } TEST_F(AppListPresenterDelegateTest, MouseWheelFromAppListPresenterImplTransitionsAppListState) { GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId()); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); GetAppListView()->HandleScroll(gfx::Vector2d(0, -30), ui::ET_MOUSEWHEEL); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); } TEST_P(AppListPresenterDelegateTest, LongUpwardDragInFullscreenShouldNotClose) { @@ -1017,14 +1017,14 @@ app_list::AppListView* view = GetAppListView(); FlingUpOrDown(GetEventGenerator(), view, true); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); if (test_fullscreen_search) { // Enter a character into the searchbox to transition to FULLSCREEN_SEARCH. GetEventGenerator()->PressKey(ui::VKEY_0, 0); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_SEARCH); + ash::mojom::AppListViewState::kFullscreenSearch); } // Drag from the center of the applist to the top of the screen very slowly. @@ -1041,10 +1041,10 @@ GetAppListTestHelper()->WaitUntilIdle(); if (test_fullscreen_search) GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_SEARCH); + ash::mojom::AppListViewState::kFullscreenSearch); else GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); } // Tests that a drag can not make the app list smaller than the shelf height. @@ -1076,18 +1076,18 @@ ui::test::EventGenerator* generator = GetEventGenerator(); generator->PressKey(ui::KeyboardCode::VKEY_0, 0); app_list::AppListView* view = GetAppListView(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::HALF); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::HALF); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kHalf); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kHalf); EXPECT_LE(0, view->GetWidget()->GetNativeView()->bounds().y()); // Animate to peeking. generator->PressKey(ui::KeyboardCode::VKEY_BACK, 0); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); EXPECT_LE(0, view->GetWidget()->GetNativeView()->bounds().y()); // Animate back to Half. generator->PressKey(ui::KeyboardCode::VKEY_0, 0); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::HALF); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kHalf); EXPECT_LE(0, view->GetWidget()->GetNativeView()->bounds().y()); } @@ -1102,20 +1102,20 @@ ui::test::EventGenerator* generator = GetEventGenerator(); generator->PressKey(ui::KeyboardCode::VKEY_0, 0); app_list::AppListView* view = GetAppListView(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::HALF); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::HALF); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kHalf); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kHalf); EXPECT_LE(GetPrimaryDisplay().work_area().y(), view->GetWidget()->GetNativeView()->bounds().y()); // Animate to peeking. generator->PressKey(ui::KeyboardCode::VKEY_BACK, 0); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); EXPECT_LE(GetPrimaryDisplay().work_area().y(), view->GetWidget()->GetNativeView()->bounds().y()); // Animate back to Half. generator->PressKey(ui::KeyboardCode::VKEY_0, 0); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::HALF); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kHalf); EXPECT_LE(GetPrimaryDisplay().work_area().y(), view->GetWidget()->GetNativeView()->bounds().y()); } @@ -1124,7 +1124,7 @@ // display. TEST_F(AppListPresenterDelegateTest, ShowInInvalidDisplay) { GetAppListTestHelper()->ShowAndRunLoop(display::kInvalidDisplayId); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); } // Tests that tap the auto-hide shelf with app list opened should dismiss the @@ -1390,7 +1390,7 @@ MouseScrollDoesntDismissPeekingLauncher) { // Show app list in non-tablet mode. Mouse-scroll up. GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId()); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); GetAppListTestHelper()->CheckVisibility(true); ui::test::EventGenerator* generator = GetEventGenerator(); generator->MoveMouseTo(GetPointOutsideSearchbox()); @@ -1399,20 +1399,20 @@ generator->MoveMouseWheel(0, 1); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); GetAppListTestHelper()->CheckVisibility(true); // Reset and show app list in non-tablet mode. Mouse-scroll down. GetAppListTestHelper()->DismissAndRunLoop(); GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId()); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); GetAppListTestHelper()->CheckVisibility(true); // Scroll down to get fullscreen. generator->MoveMouseWheel(0, -1); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); GetAppListTestHelper()->CheckVisibility(true); // Show app list in tablet mode. Mouse-scroll up. @@ -1429,7 +1429,7 @@ MouseScrollToDismissFromFullscreen) { // Show app list in non-tablet mode. Mouse-scroll down. GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId()); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); ui::test::EventGenerator* generator = GetEventGenerator(); generator->MoveMouseTo(GetPointOutsideSearchbox()); @@ -1437,14 +1437,14 @@ generator->MoveMouseWheel(0, 1); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); GetAppListTestHelper()->CheckVisibility(true); generator->MoveMouseTo(GetPointOutsideSearchbox()); // Scroll up with mouse wheel to close app list. generator->MoveMouseWheel(0, 1); GetAppListTestHelper()->WaitUntilIdle(); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); GetAppListTestHelper()->CheckVisibility(false); } @@ -1790,7 +1790,7 @@ generator->PressKey(ui::KeyboardCode::VKEY_0, 0); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_SEARCH); + ash::mojom::AppListViewState::kFullscreenSearch); // Manually show the virtual keyboard. auto* const keyboard_controller = keyboard::KeyboardController::Get(); @@ -1811,7 +1811,7 @@ // FULLSCREEN_SEARCH. GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_SEARCH); + ash::mojom::AppListViewState::kFullscreenSearch); EXPECT_TRUE(GetAppListView()->search_box_view()->is_search_box_active()); // Tap or click the body of the AppList again, the searchbox should deactivate @@ -1824,7 +1824,7 @@ generator->GestureTapAt(GetPointOutsideSearchbox()); } GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); EXPECT_FALSE(GetAppListView()->search_box_view()->is_search_box_active()); }
diff --git a/ash/app_list/app_list_view_delegate.h b/ash/app_list/app_list_view_delegate.h index ac9f3cf0..71b912c 100644 --- a/ash/app_list/app_list_view_delegate.h +++ b/ash/app_list/app_list_view_delegate.h
@@ -9,10 +9,10 @@ #include <vector> #include "ash/app_list/app_list_metrics.h" -#include "ash/app_list/model/app_list_view_state.h" #include "ash/assistant/ui/assistant_view_delegate.h" #include "ash/public/cpp/ash_public_export.h" #include "ash/public/interfaces/app_list.mojom.h" +#include "ash/public/interfaces/app_list_view.mojom.h" #include "ash/public/interfaces/menu.mojom.h" #include "base/callback_forward.h" #include "base/strings/string16.h" @@ -170,7 +170,8 @@ virtual bool IsAssistantAllowedAndEnabled() const = 0; // Called when the app list view animation is completed. - virtual void OnStateTransitionAnimationCompleted(AppListViewState state) = 0; + virtual void OnStateTransitionAnimationCompleted( + ash::mojom::AppListViewState state) = 0; }; } // namespace app_list
diff --git a/ash/app_list/model/BUILD.gn b/ash/app_list/model/BUILD.gn index 8a86493..76bbc61a 100644 --- a/ash/app_list/model/BUILD.gn +++ b/ash/app_list/model/BUILD.gn
@@ -15,7 +15,6 @@ "app_list_model.cc", "app_list_model.h", "app_list_model_observer.h", - "app_list_view_state.h", "folder_image.cc", "folder_image.h", ]
diff --git a/ash/app_list/model/app_list_model.cc b/ash/app_list/model/app_list_model.cc index 5567ab6..8636aa3f 100644 --- a/ash/app_list/model/app_list_model.cc +++ b/ash/app_list/model/app_list_model.cc
@@ -49,7 +49,7 @@ observer.OnAppListStateChanged(state_, old_state); } -void AppListModel::SetStateFullscreen(AppListViewState state) { +void AppListModel::SetStateFullscreen(ash::mojom::AppListViewState state) { state_fullscreen_ = state; }
diff --git a/ash/app_list/model/app_list_model.h b/ash/app_list/model/app_list_model.h index 26e7288..2bb9184a 100644 --- a/ash/app_list/model/app_list_model.h +++ b/ash/app_list/model/app_list_model.h
@@ -14,8 +14,8 @@ #include "ash/app_list/model/app_list_item_list.h" #include "ash/app_list/model/app_list_item_list_observer.h" #include "ash/app_list/model/app_list_model_export.h" -#include "ash/app_list/model/app_list_view_state.h" #include "ash/public/interfaces/app_list.mojom.h" +#include "ash/public/interfaces/app_list_view.mojom.h" #include "base/macros.h" #include "base/observer_list.h" @@ -45,8 +45,10 @@ ash::AppListState state() const { return state_; } // The current state of the AppListView. Controlled by AppListView. - void SetStateFullscreen(AppListViewState state); - AppListViewState state_fullscreen() const { return state_fullscreen_; } + void SetStateFullscreen(ash::mojom::AppListViewState state); + ash::mojom::AppListViewState state_fullscreen() const { + return state_fullscreen_; + } // Finds the item matching |id|. AppListItem* FindItem(const std::string& id); @@ -163,7 +165,8 @@ ash::AppListModelStatus status_ = ash::AppListModelStatus::kStatusNormal; ash::AppListState state_ = ash::AppListState::kInvalidState; // The AppListView state. Controlled by the AppListView. - AppListViewState state_fullscreen_ = AppListViewState::CLOSED; + ash::mojom::AppListViewState state_fullscreen_ = + ash::mojom::AppListViewState::kClosed; base::ObserverList<AppListModelObserver, true>::Unchecked observers_; DISALLOW_COPY_AND_ASSIGN(AppListModel);
diff --git a/ash/app_list/presenter/app_list_presenter_impl.cc b/ash/app_list/presenter/app_list_presenter_impl.cc index d8057a1..4dfd81d 100644 --- a/ash/app_list/presenter/app_list_presenter_impl.cc +++ b/ash/app_list/presenter/app_list_presenter_impl.cc
@@ -176,11 +176,12 @@ show_source == kShelfButtonFullscreen; if (IsVisible()) { if (request_fullscreen) { - if (view_->app_list_state() == AppListViewState::PEEKING) { - view_->SetState(AppListViewState::FULLSCREEN_ALL_APPS); + if (view_->app_list_state() == ash::mojom::AppListViewState::kPeeking) { + view_->SetState(ash::mojom::AppListViewState::kFullscreenAllApps); return ash::SHELF_ACTION_APP_LIST_SHOWN; - } else if (view_->app_list_state() == AppListViewState::HALF) { - view_->SetState(AppListViewState::FULLSCREEN_SEARCH); + } else if (view_->app_list_state() == + ash::mojom::AppListViewState::kHalf) { + view_->SetState(ash::mojom::AppListViewState::kFullscreenSearch); return ash::SHELF_ACTION_APP_LIST_SHOWN; } } @@ -189,7 +190,7 @@ } Show(display_id, event_time_stamp); if (request_fullscreen) - view_->SetState(AppListViewState::FULLSCREEN_ALL_APPS); + view_->SetState(ash::mojom::AppListViewState::kFullscreenAllApps); return ash::SHELF_ACTION_APP_LIST_SHOWN; } @@ -210,13 +211,14 @@ view_->UpdateYPositionAndOpacity(y_position_in_screen, background_opacity); } -void AppListPresenterImpl::EndDragFromShelf(AppListViewState app_list_state) { +void AppListPresenterImpl::EndDragFromShelf( + ash::mojom::AppListViewState app_list_state) { if (view_) { - if (app_list_state == AppListViewState::CLOSED || - view_->app_list_state() == AppListViewState::CLOSED) { + if (app_list_state == ash::mojom::AppListViewState::kClosed || + view_->app_list_state() == ash::mojom::AppListViewState::kClosed) { view_->Dismiss(); } else { - view_->SetState(AppListViewState(app_list_state)); + view_->SetState(app_list_state); } view_->SetIsInDrag(false); view_->UpdateChildViewsYPositionAndOpacity();
diff --git a/ash/app_list/presenter/app_list_presenter_impl.h b/ash/app_list/presenter/app_list_presenter_impl.h index d9ce9de..e577f591 100644 --- a/ash/app_list/presenter/app_list_presenter_impl.h +++ b/ash/app_list/presenter/app_list_presenter_impl.h
@@ -10,11 +10,11 @@ #include <memory> #include "ash/app_list/app_list_metrics.h" -#include "ash/app_list/model/app_list_view_state.h" #include "ash/app_list/pagination_model_observer.h" #include "ash/app_list/presenter/app_list_presenter_delegate.h" #include "ash/app_list/presenter/app_list_presenter_export.h" #include "ash/public/cpp/shelf_types.h" +#include "ash/public/interfaces/app_list_view.mojom.h" #include "base/callback.h" #include "base/compiler_specific.h" #include "base/macros.h" @@ -104,7 +104,7 @@ float background_opacity); // Ends the drag of app list from shelf. - void EndDragFromShelf(AppListViewState app_list_state); + void EndDragFromShelf(ash::mojom::AppListViewState app_list_state); // Passes a MouseWheelEvent from the shelf to the AppListView. void ProcessMouseWheelOffset(const gfx::Vector2d& scroll_offset_vector);
diff --git a/ash/app_list/test/app_list_test_helper.cc b/ash/app_list/test/app_list_test_helper.cc index 6371fa2..ebeb739a 100644 --- a/ash/app_list/test/app_list_test_helper.cc +++ b/ash/app_list/test/app_list_test_helper.cc
@@ -74,7 +74,7 @@ EXPECT_EQ(visible, app_list_controller_->GetTargetVisibility()); } -void AppListTestHelper::CheckState(app_list::AppListViewState state) { +void AppListTestHelper::CheckState(ash::mojom::AppListViewState state) { EXPECT_EQ(state, app_list_controller_->GetAppListViewState()); }
diff --git a/ash/app_list/test/app_list_test_helper.h b/ash/app_list/test/app_list_test_helper.h index 43b1506..4a1001a 100644 --- a/ash/app_list/test/app_list_test_helper.h +++ b/ash/app_list/test/app_list_test_helper.h
@@ -8,8 +8,8 @@ #include <memory> #include "ash/app_list/app_list_metrics.h" -#include "ash/app_list/model/app_list_view_state.h" #include "ash/app_list/test/test_app_list_client.h" +#include "ash/public/interfaces/app_list_view.mojom.h" namespace app_list { class AppListView; @@ -58,7 +58,7 @@ void CheckVisibility(bool visible); // Check the current app list view state. - void CheckState(app_list::AppListViewState state); + void CheckState(ash::mojom::AppListViewState state); // Run all pending in message loop and flush all mojo calls. void WaitUntilIdle();
diff --git a/ash/app_list/test/app_list_test_view_delegate.cc b/ash/app_list/test/app_list_test_view_delegate.cc index d4bb588..6c223b2 100644 --- a/ash/app_list/test/app_list_test_view_delegate.cc +++ b/ash/app_list/test/app_list_test_view_delegate.cc
@@ -138,7 +138,7 @@ } void AppListTestViewDelegate::OnStateTransitionAnimationCompleted( - AppListViewState state) {} + ash::mojom::AppListViewState state) {} bool AppListTestViewDelegate::IsCommandIdChecked(int command_id) const { return true;
diff --git a/ash/app_list/test/app_list_test_view_delegate.h b/ash/app_list/test/app_list_test_view_delegate.h index c11ed62e..b832494e 100644 --- a/ash/app_list/test/app_list_test_view_delegate.h +++ b/ash/app_list/test/app_list_test_view_delegate.h
@@ -101,7 +101,8 @@ void OnSearchResultVisibilityChanged(const std::string& id, bool visibility) override; bool IsAssistantAllowedAndEnabled() const override; - void OnStateTransitionAnimationCompleted(AppListViewState state) override; + void OnStateTransitionAnimationCompleted( + ash::mojom::AppListViewState state) override; // Do a bulk replacement of the items in the model. void ReplaceTestModel(int item_count);
diff --git a/ash/app_list/views/app_list_view.cc b/ash/app_list/views/app_list_view.cc index 59836967..2dc0bad 100644 --- a/ash/app_list/views/app_list_view.cc +++ b/ash/app_list/views/app_list_view.cc
@@ -416,7 +416,7 @@ void AppListView::Dismiss() { CloseKeyboardIfVisible(); app_list_main_view_->Close(); - SetState(AppListViewState::CLOSED); + SetState(ash::mojom::AppListViewState::kClosed); delegate_->DismissAppList(); GetWidget()->Deactivate(); } @@ -546,8 +546,8 @@ // Overridden from WidgetObserver: void OnWidgetClosing(views::Widget* widget) override { - if (view_->app_list_state() != AppListViewState::CLOSED) - view_->SetState(AppListViewState::CLOSED); + if (view_->app_list_state() != ash::mojom::AppListViewState::kClosed) + view_->SetState(ash::mojom::AppListViewState::kClosed); widget_observer_.Remove(view_->GetWidget()); } @@ -664,7 +664,7 @@ // entire screen, then animate the layer up into position. crbug.com/768437 // The initial bounds of app list should be the same as that in closed state. fullscreen_widget_->GetNativeView()->SetBounds( - GetPreferredWidgetBoundsForState(AppListViewState::CLOSED)); + GetPreferredWidgetBoundsForState(ash::mojom::AppListViewState::kClosed)); // Enable arrow key in FocusManager. Arrow left/right and up/down triggers // the same focus movement as tab/shift+tab. @@ -746,7 +746,7 @@ void AppListView::EndDrag(const gfx::Point& location) { // When the SearchBoxView closes the app list, ignore the final event. - if (app_list_state_ == AppListViewState::CLOSED) + if (app_list_state_ == ash::mojom::AppListViewState::kClosed) return; // Change the app list state based on where the drag ended. If fling velocity @@ -758,31 +758,31 @@ if (last_fling_velocity_ > 0) { switch (app_list_state_) { - case AppListViewState::PEEKING: - case AppListViewState::HALF: - case AppListViewState::FULLSCREEN_SEARCH: - case AppListViewState::FULLSCREEN_ALL_APPS: + case ash::mojom::AppListViewState::kPeeking: + case ash::mojom::AppListViewState::kHalf: + case ash::mojom::AppListViewState::kFullscreenSearch: + case ash::mojom::AppListViewState::kFullscreenAllApps: Dismiss(); break; - case AppListViewState::CLOSED: + case ash::mojom::AppListViewState::kClosed: NOTREACHED(); break; } } else { switch (app_list_state_) { - case AppListViewState::FULLSCREEN_ALL_APPS: - case AppListViewState::FULLSCREEN_SEARCH: + case ash::mojom::AppListViewState::kFullscreenAllApps: + case ash::mojom::AppListViewState::kFullscreenSearch: SetState(app_list_state_); break; - case AppListViewState::HALF: - SetState(AppListViewState::FULLSCREEN_SEARCH); + case ash::mojom::AppListViewState::kHalf: + SetState(ash::mojom::AppListViewState::kFullscreenSearch); break; - case AppListViewState::PEEKING: + case ash::mojom::AppListViewState::kPeeking: UMA_HISTOGRAM_ENUMERATION(kAppListPeekingToFullscreenHistogram, kSwipe, kMaxPeekingToFullscreen); - SetState(AppListViewState::FULLSCREEN_ALL_APPS); + SetState(ash::mojom::AppListViewState::kFullscreenAllApps); break; - case AppListViewState::CLOSED: + case ash::mojom::AppListViewState::kClosed: NOTREACHED(); break; } @@ -791,17 +791,17 @@ const int fullscreen_height = GetFullscreenStateHeight(); int app_list_height = 0; switch (app_list_state_) { - case AppListViewState::FULLSCREEN_ALL_APPS: - case AppListViewState::FULLSCREEN_SEARCH: + case ash::mojom::AppListViewState::kFullscreenAllApps: + case ash::mojom::AppListViewState::kFullscreenSearch: app_list_height = fullscreen_height; break; - case AppListViewState::HALF: + case ash::mojom::AppListViewState::kHalf: app_list_height = std::min(fullscreen_height, kHalfAppListHeight); break; - case AppListViewState::PEEKING: + case ash::mojom::AppListViewState::kPeeking: app_list_height = AppListConfig::instance().peeking_app_list_height(); break; - case AppListViewState::CLOSED: + case ash::mojom::AppListViewState::kClosed: NOTREACHED(); break; } @@ -822,33 +822,33 @@ return; } switch (app_list_state_) { - case AppListViewState::FULLSCREEN_ALL_APPS: + case ash::mojom::AppListViewState::kFullscreenAllApps: if (drag_delta < -app_list_threshold) { if (is_tablet_mode_ || is_side_shelf_) Dismiss(); else - SetState(AppListViewState::PEEKING); + SetState(ash::mojom::AppListViewState::kPeeking); } else { SetState(app_list_state_); } break; - case AppListViewState::FULLSCREEN_SEARCH: + case ash::mojom::AppListViewState::kFullscreenSearch: if (drag_delta < -app_list_threshold) Dismiss(); else SetState(app_list_state_); break; - case AppListViewState::HALF: + case ash::mojom::AppListViewState::kHalf: if (drag_delta > app_list_threshold) - SetState(AppListViewState::FULLSCREEN_SEARCH); + SetState(ash::mojom::AppListViewState::kFullscreenSearch); else if (drag_delta < -app_list_threshold) Dismiss(); else SetState(app_list_state_); break; - case AppListViewState::PEEKING: + case ash::mojom::AppListViewState::kPeeking: if (drag_delta > app_list_threshold) { - SetState(AppListViewState::FULLSCREEN_ALL_APPS); + SetState(ash::mojom::AppListViewState::kFullscreenAllApps); UMA_HISTOGRAM_ENUMERATION(kAppListPeekingToFullscreenHistogram, kSwipe, kMaxPeekingToFullscreen); } else if (drag_delta < -app_list_threshold) { @@ -857,7 +857,7 @@ SetState(app_list_state_); } break; - case AppListViewState::CLOSED: + case ash::mojom::AppListViewState::kClosed: NOTREACHED(); break; } @@ -867,17 +867,17 @@ } void AppListView::SetChildViewsForStateTransition( - AppListViewState target_state) { - if (target_state != AppListViewState::PEEKING && - target_state != AppListViewState::FULLSCREEN_ALL_APPS && - target_state != AppListViewState::HALF) { + ash::mojom::AppListViewState target_state) { + if (target_state != ash::mojom::AppListViewState::kPeeking && + target_state != ash::mojom::AppListViewState::kFullscreenAllApps && + target_state != ash::mojom::AppListViewState::kHalf) { return; } app_list_main_view_->contents_view()->OnAppListViewTargetStateChanged( target_state); - if (target_state == AppListViewState::HALF) + if (target_state == ash::mojom::AppListViewState::kHalf) return; if (GetAppsContainerView()->IsInFolderView()) @@ -886,7 +886,7 @@ app_list_main_view_->contents_view()->SetActiveState( ash::AppListState::kStateApps, !is_side_shelf_); - if (target_state == AppListViewState::PEEKING) { + if (target_state == ash::mojom::AppListViewState::kPeeking) { // Set the apps to the initial page when PEEKING. PaginationModel* pagination_model = GetAppsPaginationModel(); if (pagination_model->total_pages() > 0 && @@ -897,24 +897,26 @@ } void AppListView::ConvertAppListStateToFullscreenEquivalent( - AppListViewState* target_state) { + ash::mojom::AppListViewState* target_state) { if (!(is_side_shelf_ || is_tablet_mode_)) return; // If side shelf or tablet mode are active, all transitions should be // made to the tablet mode/side shelf friendly versions. - if (*target_state == AppListViewState::HALF) { - *target_state = AppListViewState::FULLSCREEN_SEARCH; - } else if (*target_state == AppListViewState::PEEKING) { + if (*target_state == ash::mojom::AppListViewState::kHalf) { + *target_state = ash::mojom::AppListViewState::kFullscreenSearch; + } else if (*target_state == ash::mojom::AppListViewState::kPeeking) { // FULLSCREEN_ALL_APPS->PEEKING in tablet/side shelf mode should close // instead of going to PEEKING. - *target_state = app_list_state_ == AppListViewState::FULLSCREEN_ALL_APPS - ? AppListViewState::CLOSED - : AppListViewState::FULLSCREEN_ALL_APPS; + *target_state = + app_list_state_ == ash::mojom::AppListViewState::kFullscreenAllApps + ? ash::mojom::AppListViewState::kClosed + : ash::mojom::AppListViewState::kFullscreenAllApps; } } -void AppListView::RecordStateTransitionForUma(AppListViewState new_state) { +void AppListView::RecordStateTransitionForUma( + ash::mojom::AppListViewState new_state) { AppListStateTransitionSource transition = GetAppListStateTransitionSource(new_state); // kMaxAppListStateTransition denotes a transition we are not interested in @@ -940,14 +942,15 @@ } } -void AppListView::MaybeCreateAccessibilityEvent(AppListViewState new_state) { - if (new_state != AppListViewState::PEEKING && - new_state != AppListViewState::FULLSCREEN_ALL_APPS) +void AppListView::MaybeCreateAccessibilityEvent( + ash::mojom::AppListViewState new_state) { + if (new_state != ash::mojom::AppListViewState::kPeeking && + new_state != ash::mojom::AppListViewState::kFullscreenAllApps) return; base::string16 state_announcement; - if (new_state == AppListViewState::PEEKING) { + if (new_state == ash::mojom::AppListViewState::kPeeking) { state_announcement = l10n_util::GetStringUTF16( IDS_APP_LIST_SUGGESTED_APPS_ACCESSIBILITY_ANNOUNCEMENT); } else { @@ -975,79 +978,79 @@ } AppListStateTransitionSource AppListView::GetAppListStateTransitionSource( - AppListViewState target_state) const { + ash::mojom::AppListViewState target_state) const { switch (app_list_state_) { - case AppListViewState::CLOSED: + case ash::mojom::AppListViewState::kClosed: // CLOSED->X transitions are not useful for UMA. return kMaxAppListStateTransition; - case AppListViewState::PEEKING: + case ash::mojom::AppListViewState::kPeeking: switch (target_state) { - case AppListViewState::CLOSED: + case ash::mojom::AppListViewState::kClosed: return kPeekingToClosed; - case AppListViewState::HALF: + case ash::mojom::AppListViewState::kHalf: return kPeekingToHalf; - case AppListViewState::FULLSCREEN_ALL_APPS: + case ash::mojom::AppListViewState::kFullscreenAllApps: return kPeekingToFullscreenAllApps; - case AppListViewState::PEEKING: + case ash::mojom::AppListViewState::kPeeking: // PEEKING->PEEKING is used when resetting the widget position after a // failed state transition. Not useful for UMA. return kMaxAppListStateTransition; - case AppListViewState::FULLSCREEN_SEARCH: + case ash::mojom::AppListViewState::kFullscreenSearch: // PEEKING->FULLSCREEN_SEARCH is not a valid transition. NOTREACHED(); return kMaxAppListStateTransition; } - case AppListViewState::HALF: + case ash::mojom::AppListViewState::kHalf: switch (target_state) { - case AppListViewState::CLOSED: + case ash::mojom::AppListViewState::kClosed: return kHalfToClosed; - case AppListViewState::PEEKING: + case ash::mojom::AppListViewState::kPeeking: return kHalfToPeeking; - case AppListViewState::FULLSCREEN_SEARCH: + case ash::mojom::AppListViewState::kFullscreenSearch: return KHalfToFullscreenSearch; - case AppListViewState::HALF: + case ash::mojom::AppListViewState::kHalf: // HALF->HALF is used when resetting the widget position after a // failed state transition. Not useful for UMA. return kMaxAppListStateTransition; - case AppListViewState::FULLSCREEN_ALL_APPS: + case ash::mojom::AppListViewState::kFullscreenAllApps: // HALF->FULLSCREEN_ALL_APPS is not a valid transition. NOTREACHED(); return kMaxAppListStateTransition; } - case AppListViewState::FULLSCREEN_ALL_APPS: + case ash::mojom::AppListViewState::kFullscreenAllApps: switch (target_state) { - case AppListViewState::CLOSED: + case ash::mojom::AppListViewState::kClosed: return kFullscreenAllAppsToClosed; - case AppListViewState::PEEKING: + case ash::mojom::AppListViewState::kPeeking: return kFullscreenAllAppsToPeeking; - case AppListViewState::FULLSCREEN_SEARCH: + case ash::mojom::AppListViewState::kFullscreenSearch: return kFullscreenAllAppsToFullscreenSearch; - case AppListViewState::HALF: + case ash::mojom::AppListViewState::kHalf: // FULLSCREEN_ALL_APPS->HALF is not a valid transition. NOTREACHED(); return kMaxAppListStateTransition; - case AppListViewState::FULLSCREEN_ALL_APPS: + case ash::mojom::AppListViewState::kFullscreenAllApps: // FULLSCREEN_ALL_APPS->FULLSCREEN_ALL_APPS is used when resetting the // widget positon after a failed state transition. Not useful for UMA. return kMaxAppListStateTransition; } - case AppListViewState::FULLSCREEN_SEARCH: + case ash::mojom::AppListViewState::kFullscreenSearch: switch (target_state) { - case AppListViewState::CLOSED: + case ash::mojom::AppListViewState::kClosed: return kFullscreenSearchToClosed; - case AppListViewState::FULLSCREEN_ALL_APPS: + case ash::mojom::AppListViewState::kFullscreenAllApps: return kFullscreenSearchToFullscreenAllApps; - case AppListViewState::FULLSCREEN_SEARCH: + case ash::mojom::AppListViewState::kFullscreenSearch: // FULLSCREEN_SEARCH->FULLSCREEN_SEARCH is used when resetting the // widget position after a failed state transition. Not useful for // UMA. return kMaxAppListStateTransition; - case AppListViewState::PEEKING: + case ash::mojom::AppListViewState::kPeeking: // FULLSCREEN_SEARCH->PEEKING is not a valid transition. NOTREACHED(); return kMaxAppListStateTransition; - case AppListViewState::HALF: + case ash::mojom::AppListViewState::kHalf: // FULLSCREEN_SEARCH->HALF is not a valid transition. NOTREACHED(); return kMaxAppListStateTransition; @@ -1197,10 +1200,11 @@ // Set fullscreen state. When current state is fullscreen, we still need to // set it again because app list may be in dragging. - SetState(app_list_state_ == AppListViewState::HALF || - app_list_state_ == AppListViewState::FULLSCREEN_SEARCH - ? AppListViewState::FULLSCREEN_SEARCH - : AppListViewState::FULLSCREEN_ALL_APPS); + SetState(app_list_state_ == ash::mojom::AppListViewState::kHalf || + app_list_state_ == + ash::mojom::AppListViewState::kFullscreenSearch + ? ash::mojom::AppListViewState::kFullscreenSearch + : ash::mojom::AppListViewState::kFullscreenAllApps); // In tablet mode, AppListView should not be moved because of the change in // virtual keyboard's visibility. @@ -1232,13 +1236,13 @@ return false; } - if (app_list_state_ != AppListViewState::PEEKING && - app_list_state_ != AppListViewState::FULLSCREEN_ALL_APPS) { + if (app_list_state_ != ash::mojom::AppListViewState::kPeeking && + app_list_state_ != ash::mojom::AppListViewState::kFullscreenAllApps) { return false; } // Let the Apps grid view handle the event first in FULLSCREEN_ALL_APPS. - if (app_list_state_ == AppListViewState::FULLSCREEN_ALL_APPS) { + if (app_list_state_ == ash::mojom::AppListViewState::kFullscreenAllApps) { AppsGridView* apps_grid_view = GetAppsContainerView()->IsInFolderView() ? GetFolderAppsGridView() : GetRootAppsGridView(); @@ -1254,13 +1258,13 @@ // otherwise the offset must be larger than the scroll threshold. if (type == ui::ET_MOUSEWHEEL || abs(offset.y()) > kAppListMinScrollToSwitchStates) { - if (app_list_state_ == AppListViewState::FULLSCREEN_ALL_APPS) { + if (app_list_state_ == ash::mojom::AppListViewState::kFullscreenAllApps) { if (offset.y() > 0) Dismiss(); return true; } - SetState(AppListViewState::FULLSCREEN_ALL_APPS); + SetState(ash::mojom::AppListViewState::kFullscreenAllApps); const AppListPeekingToFullscreenSource source = type == ui::ET_MOUSEWHEEL ? kMousewheelScroll : kMousepadScroll; UMA_HISTOGRAM_ENUMERATION(kAppListPeekingToFullscreenHistogram, source, @@ -1269,12 +1273,12 @@ return true; } -void AppListView::SetState(AppListViewState new_state) { +void AppListView::SetState(ash::mojom::AppListViewState new_state) { // Do not allow the state to be changed once it has been set to CLOSED. - if (app_list_state_ == AppListViewState::CLOSED) + if (app_list_state_ == ash::mojom::AppListViewState::kClosed) return; - AppListViewState new_state_override = new_state; + ash::mojom::AppListViewState new_state_override = new_state; ConvertAppListStateToFullscreenEquivalent(&new_state_override); MaybeCreateAccessibilityEvent(new_state_override); SetChildViewsForStateTransition(new_state_override); @@ -1288,7 +1292,7 @@ if (is_side_shelf_) Layout(); - if (new_state_override == AppListViewState::CLOSED) + if (new_state_override == ash::mojom::AppListViewState::kClosed) return; if (fullscreen_widget_->IsActive()) { @@ -1304,12 +1308,13 @@ GetAppsContainerView()->UpdateControlVisibility(app_list_state_, is_in_drag_); } -void AppListView::StartAnimationForState(AppListViewState target_state) { +void AppListView::StartAnimationForState( + ash::mojom::AppListViewState target_state) { if (is_side_shelf_) return; // The close animation is handled by the delegate. - if (target_state == AppListViewState::CLOSED) + if (target_state == ash::mojom::AppListViewState::kClosed) return; const display::Display display = GetDisplayNearestView(); @@ -1324,8 +1329,8 @@ if (ShortAnimationsForTesting()) { animation_duration = kAppListAnimationDurationTestMs; } else if (is_fullscreen() || - target_state == AppListViewState::FULLSCREEN_ALL_APPS || - target_state == AppListViewState::FULLSCREEN_SEARCH) { + target_state == ash::mojom::AppListViewState::kFullscreenAllApps || + target_state == ash::mojom::AppListViewState::kFullscreenSearch) { animation_duration = kAppListAnimationDurationFromFullscreenMs; } else { animation_duration = kAppListAnimationDurationMs; @@ -1371,62 +1376,62 @@ // If animating from PEEKING, animate the opacity twice as fast so the // SearchBoxView does not flash behind the shelf. - if (app_list_state_ == AppListViewState::PEEKING || - app_list_state_ == AppListViewState::CLOSED) { + if (app_list_state_ == ash::mojom::AppListViewState::kPeeking || + app_list_state_ == ash::mojom::AppListViewState::kClosed) { animation_duration /= 2; } - SetState(AppListViewState::CLOSED); + SetState(ash::mojom::AppListViewState::kClosed); app_list_main_view_->contents_view()->FadeOutOnClose(animation_duration); } void AppListView::SetStateFromSearchBoxView(bool search_box_is_empty, bool triggered_by_contents_change) { switch (app_list_state_) { - case AppListViewState::PEEKING: + case ash::mojom::AppListViewState::kPeeking: if (app_list_features::IsZeroStateSuggestionsEnabled()) { if (!search_box_is_empty || search_box_view()->is_search_box_active()) - SetState(AppListViewState::HALF); + SetState(ash::mojom::AppListViewState::kHalf); } else { if (!search_box_is_empty) - SetState(AppListViewState::HALF); + SetState(ash::mojom::AppListViewState::kHalf); } break; - case AppListViewState::HALF: + case ash::mojom::AppListViewState::kHalf: if (app_list_features::IsZeroStateSuggestionsEnabled()) { if (search_box_is_empty && !triggered_by_contents_change) - SetState(AppListViewState::PEEKING); + SetState(ash::mojom::AppListViewState::kPeeking); } else { if (search_box_is_empty) - SetState(AppListViewState::PEEKING); + SetState(ash::mojom::AppListViewState::kPeeking); } break; - case AppListViewState::FULLSCREEN_SEARCH: + case ash::mojom::AppListViewState::kFullscreenSearch: if (app_list_features::IsZeroStateSuggestionsEnabled()) { if (search_box_is_empty && !triggered_by_contents_change) { - SetState(AppListViewState::FULLSCREEN_ALL_APPS); + SetState(ash::mojom::AppListViewState::kFullscreenAllApps); app_list_main_view()->contents_view()->SetActiveState( ash::AppListState::kStateApps); } } else { if (search_box_is_empty) { - SetState(AppListViewState::FULLSCREEN_ALL_APPS); + SetState(ash::mojom::AppListViewState::kFullscreenAllApps); app_list_main_view()->contents_view()->SetActiveState( ash::AppListState::kStateApps); } } break; - case AppListViewState::FULLSCREEN_ALL_APPS: + case ash::mojom::AppListViewState::kFullscreenAllApps: if (app_list_features::IsZeroStateSuggestionsEnabled()) { if (!search_box_is_empty || (search_box_is_empty && triggered_by_contents_change)) - SetState(AppListViewState::FULLSCREEN_SEARCH); + SetState(ash::mojom::AppListViewState::kFullscreenSearch); } else { if (!search_box_is_empty) - SetState(AppListViewState::FULLSCREEN_SEARCH); + SetState(ash::mojom::AppListViewState::kFullscreenSearch); } break; - case AppListViewState::CLOSED: + case ash::mojom::AppListViewState::kClosed: // We clean search on app list close. break; } @@ -1435,7 +1440,7 @@ void AppListView::UpdateYPositionAndOpacity(int y_position_in_screen, float background_opacity) { DCHECK(!is_side_shelf_); - if (app_list_state_ == AppListViewState::CLOSED) + if (app_list_state_ == ash::mojom::AppListViewState::kClosed) return; if (fullscreen_widget_->GetLayer()->GetAnimator()->IsAnimatingProperty( @@ -1482,7 +1487,7 @@ if (!is_in_drag) presentation_time_recorder_.reset(); - if (app_list_state_ == AppListViewState::CLOSED) + if (app_list_state_ == ash::mojom::AppListViewState::kClosed) return; if (is_in_drag == is_in_drag_) @@ -1545,44 +1550,45 @@ return display_bounds.height() - display.work_area().y() + display_bounds.y(); } -AppListViewState AppListView::CalculateStateAfterShelfDrag( +ash::mojom::AppListViewState AppListView::CalculateStateAfterShelfDrag( const ui::GestureEvent& gesture_in_screen, float launcher_above_shelf_bottom_amount) const { - AppListViewState app_list_state = AppListViewState::PEEKING; + ash::mojom::AppListViewState app_list_state = + ash::mojom::AppListViewState::kPeeking; if (gesture_in_screen.type() == ui::ET_SCROLL_FLING_START && fabs(gesture_in_screen.details().velocity_y()) > kDragVelocityThreshold) { // If the scroll sequence terminates with a fling, show the fullscreen app // list if the fling was fast enough and in the correct direction, otherwise // close it. app_list_state = gesture_in_screen.details().velocity_y() < 0 - ? AppListViewState::FULLSCREEN_ALL_APPS - : AppListViewState::CLOSED; + ? ash::mojom::AppListViewState::kFullscreenAllApps + : ash::mojom::AppListViewState::kClosed; } else { // Snap the app list to corresponding state according to the snapping // thresholds. if (is_tablet_mode_) { app_list_state = launcher_above_shelf_bottom_amount > kDragSnapToFullscreenThreshold - ? AppListViewState::FULLSCREEN_ALL_APPS - : AppListViewState::CLOSED; + ? ash::mojom::AppListViewState::kFullscreenAllApps + : ash::mojom::AppListViewState::kClosed; } else { if (launcher_above_shelf_bottom_amount <= kDragSnapToClosedThreshold) - app_list_state = AppListViewState::CLOSED; + app_list_state = ash::mojom::AppListViewState::kClosed; else if (launcher_above_shelf_bottom_amount <= kDragSnapToPeekingThreshold) - app_list_state = AppListViewState::PEEKING; + app_list_state = ash::mojom::AppListViewState::kPeeking; else - app_list_state = AppListViewState::FULLSCREEN_ALL_APPS; + app_list_state = ash::mojom::AppListViewState::kFullscreenAllApps; } } // Deal with the situation of dragging app list from shelf while typing in // the search box. - if (app_list_state == AppListViewState::FULLSCREEN_ALL_APPS) { + if (app_list_state == ash::mojom::AppListViewState::kFullscreenAllApps) { ash::AppListState active_state = app_list_main_view_->contents_view()->GetActiveState(); if (active_state == ash::AppListState::kStateSearchResults) - app_list_state = AppListViewState::FULLSCREEN_SEARCH; + app_list_state = ash::mojom::AppListViewState::kFullscreenSearch; } return app_list_state; @@ -1609,7 +1615,8 @@ // side may be on the display edge. Stop showing the rounded corners under // this circumstance. const bool hide_rounded_corners = - app_list_state_ == AppListViewState::HALF && new_bounds.y() == 0; + app_list_state_ == ash::mojom::AppListViewState::kHalf && + new_bounds.y() == 0; gfx::Transform transform; if (hide_rounded_corners) @@ -1620,7 +1627,7 @@ } void AppListView::UpdateChildViewsYPositionAndOpacity() { - if (app_list_state_ == AppListViewState::CLOSED) + if (app_list_state_ == ash::mojom::AppListViewState::kClosed) return; UpdateAppListBackgroundYPosition(); @@ -1789,25 +1796,26 @@ GetRootAppsGridView()->pagination_model()->has_transition(); } -int AppListView::GetPreferredWidgetYForState(AppListViewState state) { +int AppListView::GetPreferredWidgetYForState( + ash::mojom::AppListViewState state) { // Note that app list container fills the screen, so we can treat the // container's y as the top of display. const display::Display display = GetDisplayNearestView(); const gfx::Rect work_area_bounds = display.work_area(); switch (state) { - case AppListViewState::PEEKING: + case ash::mojom::AppListViewState::kPeeking: return display.bounds().height() - AppListConfig::instance().peeking_app_list_height(); - case AppListViewState::HALF: + case ash::mojom::AppListViewState::kHalf: return std::max(work_area_bounds.y(), display.bounds().height() - kHalfAppListHeight); - case AppListViewState::FULLSCREEN_ALL_APPS: - case AppListViewState::FULLSCREEN_SEARCH: + case ash::mojom::AppListViewState::kFullscreenAllApps: + case ash::mojom::AppListViewState::kFullscreenSearch: // The ChromeVox panel as well as the Docked Magnifier viewport affect the // workarea of the display. We need to account for that when applist is in // fullscreen to avoid being shown below them. return work_area_bounds.y() - display.bounds().y(); - case AppListViewState::CLOSED: + case ash::mojom::AppListViewState::kClosed: // Align the widget y with shelf y to avoid flicker in show animation. In // side shelf mode, the widget y is the top of work area because the // widget does not animate. @@ -1818,7 +1826,7 @@ } gfx::Rect AppListView::GetPreferredWidgetBoundsForState( - AppListViewState state) { + ash::mojom::AppListViewState state) { // Use parent's width instead of display width to avoid 1 px gap (See // https://crbug.com/884889). CHECK(fullscreen_widget_);
diff --git a/ash/app_list/views/app_list_view.h b/ash/app_list/views/app_list_view.h index d93b9e6..c94310b 100644 --- a/ash/app_list/views/app_list_view.h +++ b/ash/app_list/views/app_list_view.h
@@ -11,8 +11,8 @@ #include "ash/app_list/app_list_export.h" #include "ash/app_list/app_list_metrics.h" #include "ash/app_list/app_list_view_delegate.h" -#include "ash/app_list/model/app_list_view_state.h" #include "ash/public/cpp/presentation_time_recorder.h" +#include "ash/public/interfaces/app_list_view.mojom.h" #include "base/callback.h" #include "base/macros.h" #include "build/build_config.h" @@ -180,7 +180,7 @@ bool HandleScroll(const gfx::Vector2d& offset, ui::EventType type); // Changes the app list state. - void SetState(AppListViewState new_state); + void SetState(ash::mojom::AppListViewState new_state); // Starts the close animation. void StartCloseAnimation(base::TimeDelta animation_duration); @@ -241,7 +241,7 @@ // Calculates and returns the app list view state after dragging from shelf // ends. - AppListViewState CalculateStateAfterShelfDrag( + ash::mojom::AppListViewState CalculateStateAfterShelfDrag( const ui::GestureEvent& gesture_in_screen, float launcher_above_shelf_bottom_amount) const; @@ -264,7 +264,9 @@ gfx::NativeView parent_window() const { return parent_window_; } - AppListViewState app_list_state() const { return app_list_state_; } + ash::mojom::AppListViewState app_list_state() const { + return app_list_state_; + } views::Widget* search_box_widget() const { return search_box_widget_; } @@ -275,8 +277,9 @@ views::View* announcement_view() const { return announcement_view_; } bool is_fullscreen() const { - return app_list_state_ == AppListViewState::FULLSCREEN_ALL_APPS || - app_list_state_ == AppListViewState::FULLSCREEN_SEARCH; + return app_list_state_ == + ash::mojom::AppListViewState::kFullscreenAllApps || + app_list_state_ == ash::mojom::AppListViewState::kFullscreenSearch; } bool is_tablet_mode() const { return is_tablet_mode_; } @@ -334,20 +337,22 @@ void EndDrag(const gfx::Point& location); // Set child views for |target_state|. - void SetChildViewsForStateTransition(AppListViewState target_state); + void SetChildViewsForStateTransition( + ash::mojom::AppListViewState target_state); // Converts |state| to the fullscreen equivalent. - void ConvertAppListStateToFullscreenEquivalent(AppListViewState* state); + void ConvertAppListStateToFullscreenEquivalent( + ash::mojom::AppListViewState* state); // Kicks off the proper animation for the state change. If an animation is // in progress it will be interrupted. - void StartAnimationForState(AppListViewState new_state); + void StartAnimationForState(ash::mojom::AppListViewState new_state); // Records the state transition for UMA. - void RecordStateTransitionForUma(AppListViewState new_state); + void RecordStateTransitionForUma(ash::mojom::AppListViewState new_state); // Creates an Accessibility Event if the state transition warrants one. - void MaybeCreateAccessibilityEvent(AppListViewState new_state); + void MaybeCreateAccessibilityEvent(ash::mojom::AppListViewState new_state); // Gets the display nearest to the parent window. display::Display GetDisplayNearestView() const; @@ -366,7 +371,7 @@ // (ie. PEEKING->PEEKING) then return kMaxAppListStateTransition. If this is // modified, histograms will be affected. AppListStateTransitionSource GetAppListStateTransitionSource( - AppListViewState target_state) const; + ash::mojom::AppListViewState target_state) const; // Overridden from views::WidgetDelegateView: views::View* GetInitiallyFocusedView() override; @@ -387,12 +392,13 @@ // Returns preferred y of fullscreen widget bounds in parent window for the // specified state. - int GetPreferredWidgetYForState(AppListViewState state); + int GetPreferredWidgetYForState(ash::mojom::AppListViewState state); // Returns preferred fullscreen widget bounds in parent window for the // specified state. Note that this function should only be called after the // widget is initialized. - gfx::Rect GetPreferredWidgetBoundsForState(AppListViewState state); + gfx::Rect GetPreferredWidgetBoundsForState( + ash::mojom::AppListViewState state); // Updates y position of |app_list_background_shield_| based on the // |app_list_state_| and |is_in_drag_|. @@ -443,7 +449,8 @@ // Whether the background blur is enabled. const bool is_background_blur_enabled_; // The state of the app list, controlled via SetState(). - AppListViewState app_list_state_ = AppListViewState::PEEKING; + ash::mojom::AppListViewState app_list_state_ = + ash::mojom::AppListViewState::kPeeking; // A widget observer that sets the AppListView state when the widget is // closed.
diff --git a/ash/app_list/views/app_list_view_unittest.cc b/ash/app_list/views/app_list_view_unittest.cc index 54c52a27..bbecf7db 100644 --- a/ash/app_list/views/app_list_view_unittest.cc +++ b/ash/app_list/views/app_list_view_unittest.cc
@@ -294,8 +294,8 @@ views::ViewsTestBase::TearDown(); } - void SetAppListState(AppListViewState state) { - if (state == AppListViewState::CLOSED) { + void SetAppListState(ash::mojom::AppListViewState state) { + if (state == ash::mojom::AppListViewState::kClosed) { view_->Dismiss(); return; } @@ -626,7 +626,7 @@ // Tests the linear focus traversal in PEEKING state. TEST_P(AppListViewFocusTest, LinearFocusTraversalInPeekingState) { Show(); - SetAppListState(AppListViewState::PEEKING); + SetAppListState(ash::mojom::AppListViewState::kPeeking); std::vector<views::View*> forward_view_list; forward_view_list.push_back(search_box_view()->search_box()); @@ -655,7 +655,7 @@ // Tests the linear focus traversal in FULLSCREEN_ALL_APPS state. TEST_P(AppListViewFocusTest, LinearFocusTraversalInFullscreenAllAppsState) { Show(); - SetAppListState(AppListViewState::FULLSCREEN_ALL_APPS); + SetAppListState(ash::mojom::AppListViewState::kFullscreenAllApps); std::vector<views::View*> forward_view_list; forward_view_list.push_back(search_box_view()->search_box()); @@ -691,7 +691,8 @@ // Type something in search box to transition to HALF state and populate // fake search results. search_box_view()->search_box()->InsertText(base::ASCIIToUTF16("test")); - EXPECT_EQ(app_list_view()->app_list_state(), AppListViewState::HALF); + EXPECT_EQ(app_list_view()->app_list_state(), + ash::mojom::AppListViewState::kHalf); constexpr int kTileResults = 3; constexpr int kListResults = 2; SetUpSearchResults(kTileResults, kListResults, true); @@ -738,7 +739,8 @@ "\xd8\xa7\xd8\xae\xd8\xaa\xd8\xa8\xd8\xa7\xd8\xb1") : base::UTF8ToUTF16("test"); search_box_view()->search_box()->InsertText(text); - EXPECT_EQ(app_list_view()->app_list_state(), AppListViewState::HALF); + EXPECT_EQ(app_list_view()->app_list_state(), + ash::mojom::AppListViewState::kHalf); constexpr int kTileResults = 6; SetUpSearchResults(kTileResults, 0, false); @@ -783,7 +785,7 @@ Show(); // Transition to FULLSCREEN_ALL_APPS state and open the folder. - SetAppListState(AppListViewState::FULLSCREEN_ALL_APPS); + SetAppListState(ash::mojom::AppListViewState::kFullscreenAllApps); folder_item_view()->RequestFocus(); SimulateKeyPress(ui::VKEY_RETURN, false); EXPECT_TRUE(contents_view()->GetAppsContainerView()->IsInFolderView()); @@ -818,7 +820,7 @@ // Tests the vertical focus traversal by in PEEKING state. TEST_P(AppListViewFocusTest, VerticalFocusTraversalInPeekingState) { Show(); - SetAppListState(AppListViewState::PEEKING); + SetAppListState(ash::mojom::AppListViewState::kPeeking); std::vector<views::View*> forward_view_list; forward_view_list.push_back(search_box_view()->search_box()); @@ -843,7 +845,7 @@ // Tests the vertical focus traversal in FULLSCREEN_ALL_APPS state. TEST_P(AppListViewFocusTest, VerticalFocusTraversalInFullscreenAllAppsState) { Show(); - SetAppListState(AppListViewState::FULLSCREEN_ALL_APPS); + SetAppListState(ash::mojom::AppListViewState::kFullscreenAllApps); std::vector<views::View*> forward_view_list; forward_view_list.push_back(search_box_view()->search_box()); @@ -880,7 +882,8 @@ // Type something in search box to transition to HALF state and populate // fake search results. search_box_view()->search_box()->InsertText(base::ASCIIToUTF16("test")); - EXPECT_EQ(app_list_view()->app_list_state(), AppListViewState::HALF); + EXPECT_EQ(app_list_view()->app_list_state(), + ash::mojom::AppListViewState::kHalf); constexpr int kTileResults = 3; constexpr int kListResults = 2; SetUpSearchResults(kTileResults, kListResults, true); @@ -927,7 +930,7 @@ Show(); // Transition to FULLSCREEN_ALL_APPS state and open the folder. - SetAppListState(AppListViewState::FULLSCREEN_ALL_APPS); + SetAppListState(ash::mojom::AppListViewState::kFullscreenAllApps); folder_item_view()->RequestFocus(); SimulateKeyPress(ui::VKEY_RETURN, false); EXPECT_TRUE(contents_view()->GetAppsContainerView()->IsInFolderView()); @@ -967,7 +970,7 @@ Show(); // Transition to FULLSCREEN_ALL_APPS state and open the folder. - SetAppListState(AppListViewState::FULLSCREEN_ALL_APPS); + SetAppListState(ash::mojom::AppListViewState::kFullscreenAllApps); folder_item_view()->RequestFocus(); SimulateKeyPress(ui::VKEY_RETURN, false); EXPECT_TRUE(contents_view()->GetAppsContainerView()->IsInFolderView()); @@ -1017,22 +1020,24 @@ const int kTileResults = 3; const int kListResults = 2; SetUpSearchResults(kTileResults, kListResults, true); - EXPECT_EQ(app_list_view()->app_list_state(), AppListViewState::HALF); + EXPECT_EQ(app_list_view()->app_list_state(), + ash::mojom::AppListViewState::kHalf); EXPECT_EQ(search_box_view()->search_box(), focused_view()); // Move focus to the first search result, then transition to PEEKING state. SimulateKeyPress(ui::VKEY_TAB, false); SimulateKeyPress(ui::VKEY_TAB, false); - SetAppListState(AppListViewState::PEEKING); - EXPECT_EQ(app_list_view()->app_list_state(), AppListViewState::PEEKING); + SetAppListState(ash::mojom::AppListViewState::kPeeking); + EXPECT_EQ(app_list_view()->app_list_state(), + ash::mojom::AppListViewState::kPeeking); EXPECT_EQ(search_box_view()->search_box(), focused_view()); // Move focus to the first suggestion app, then transition to // FULLSCREEN_ALL_APPS state. SimulateKeyPress(ui::VKEY_TAB, false); - SetAppListState(AppListViewState::FULLSCREEN_ALL_APPS); + SetAppListState(ash::mojom::AppListViewState::kFullscreenAllApps); EXPECT_EQ(app_list_view()->app_list_state(), - AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); EXPECT_EQ(search_box_view()->search_box(), focused_view()); // Move focus to first suggestion app, then open the folder. @@ -1043,8 +1048,9 @@ // Move focus to the first app, then transition to PEEKING state. SimulateKeyPress(ui::VKEY_TAB, false); - SetAppListState(AppListViewState::PEEKING); - EXPECT_EQ(app_list_view()->app_list_state(), AppListViewState::PEEKING); + SetAppListState(ash::mojom::AppListViewState::kPeeking); + EXPECT_EQ(app_list_view()->app_list_state(), + ash::mojom::AppListViewState::kPeeking); EXPECT_EQ(search_box_view()->search_box(), focused_view()); } @@ -1139,7 +1145,8 @@ TEST_F(AppListViewFocusTest, SearchBoxSelectionCoversWholeQueryOnFocus) { Show(); search_box_view()->search_box()->InsertText(base::ASCIIToUTF16("test")); - EXPECT_EQ(app_list_view()->app_list_state(), AppListViewState::HALF); + EXPECT_EQ(app_list_view()->app_list_state(), + ash::mojom::AppListViewState::kHalf); constexpr int kListResults = 1; SetUpSearchResults(0, kListResults, false); EXPECT_EQ(search_box_view()->search_box(), focused_view()); @@ -1187,7 +1194,8 @@ TEST_F(AppListViewFocusTest, CtrlASelectsAllTextInSearchbox) { Show(); search_box_view()->search_box()->InsertText(base::ASCIIToUTF16("test")); - EXPECT_EQ(app_list_view()->app_list_state(), AppListViewState::HALF); + EXPECT_EQ(app_list_view()->app_list_state(), + ash::mojom::AppListViewState::kHalf); constexpr int kTileResults = 3; constexpr int kListResults = 2; SetUpSearchResults(kTileResults, kListResults, false); @@ -1383,7 +1391,7 @@ Show(); // Transition to FULLSCREEN_ALL_APPS state and open the folder. - SetAppListState(AppListViewState::FULLSCREEN_ALL_APPS); + SetAppListState(ash::mojom::AppListViewState::kFullscreenAllApps); folder_item_view()->RequestFocus(); SimulateKeyPress(ui::VKEY_RETURN, false); @@ -1410,7 +1418,7 @@ Show(); // Transition to FULLSCREEN_ALL_APPS state and open the folder. - SetAppListState(AppListViewState::FULLSCREEN_ALL_APPS); + SetAppListState(ash::mojom::AppListViewState::kFullscreenAllApps); folder_item_view()->RequestFocus(); SimulateKeyPress(ui::VKEY_RETURN, false); EXPECT_TRUE(contents_view()->GetAppsContainerView()->IsInFolderView()); @@ -1432,7 +1440,7 @@ Show(); - ASSERT_EQ(AppListViewState::PEEKING, view_->app_list_state()); + ASSERT_EQ(ash::mojom::AppListViewState::kPeeking, view_->app_list_state()); } // Tests that in side shelf mode, the app list opens in fullscreen by default @@ -1443,7 +1451,8 @@ Show(); - EXPECT_EQ(AppListViewState::FULLSCREEN_ALL_APPS, view_->app_list_state()); + EXPECT_EQ(ash::mojom::AppListViewState::kFullscreenAllApps, + view_->app_list_state()); // Get the end point of the rounded corner and transform it into screen // coordinates. It should be on the screen's bottom line. @@ -1459,7 +1468,8 @@ Show(); - ASSERT_EQ(AppListViewState::FULLSCREEN_ALL_APPS, view_->app_list_state()); + ASSERT_EQ(ash::mojom::AppListViewState::kFullscreenAllApps, + view_->app_list_state()); } // Tests that setting empty text in the search box does not change the state. @@ -1471,7 +1481,7 @@ Show(); search_box->SetText(base::string16()); - ASSERT_EQ(AppListViewState::PEEKING, view_->app_list_state()); + ASSERT_EQ(ash::mojom::AppListViewState::kPeeking, view_->app_list_state()); } TEST_F(AppListViewTest, MouseWheelScrollTransitionsToFullscreen) { @@ -1482,7 +1492,8 @@ Show(); view_->HandleScroll(gfx::Vector2d(0, -30), ui::ET_MOUSEWHEEL); - EXPECT_EQ(AppListViewState::FULLSCREEN_ALL_APPS, view_->app_list_state()); + EXPECT_EQ(ash::mojom::AppListViewState::kFullscreenAllApps, + view_->app_list_state()); // This should use animation instead of drag. // TODO(oshima): Test AnimationSmoothness. histogram_tester.ExpectTotalCount( @@ -1496,7 +1507,8 @@ Show(); view_->HandleScroll(gfx::Vector2d(0, -30), ui::ET_SCROLL); - EXPECT_EQ(AppListViewState::FULLSCREEN_ALL_APPS, view_->app_list_state()); + EXPECT_EQ(ash::mojom::AppListViewState::kFullscreenAllApps, + view_->app_list_state()); // This should use animation instead of drag. // TODO(oshima): Test AnimationSmoothness. histogram_tester.ExpectTotalCount( @@ -1513,13 +1525,13 @@ search_box->SetText(base::string16()); search_box->InsertText(base::UTF8ToUTF16("nice")); - ASSERT_EQ(AppListViewState::HALF, view_->app_list_state()); + ASSERT_EQ(ash::mojom::AppListViewState::kHalf, view_->app_list_state()); } // Tests that typing when in fullscreen changes the state to fullscreen search. TEST_F(AppListViewTest, TypingFullscreenToFullscreenSearch) { Initialize(0, false, false); - view_->SetState(AppListViewState::FULLSCREEN_ALL_APPS); + view_->SetState(ash::mojom::AppListViewState::kFullscreenAllApps); views::Textfield* search_box = view_->app_list_main_view()->search_box_view()->search_box(); @@ -1527,7 +1539,8 @@ search_box->SetText(base::string16()); search_box->InsertText(base::UTF8ToUTF16("https://youtu.be/dQw4w9WgXcQ")); - ASSERT_EQ(AppListViewState::FULLSCREEN_SEARCH, view_->app_list_state()); + ASSERT_EQ(ash::mojom::AppListViewState::kFullscreenSearch, + view_->app_list_state()); } // Tests that in tablet mode, typing changes the state to fullscreen search. @@ -1540,7 +1553,8 @@ search_box->SetText(base::string16()); search_box->InsertText(base::UTF8ToUTF16("cool!")); - ASSERT_EQ(AppListViewState::FULLSCREEN_SEARCH, view_->app_list_state()); + ASSERT_EQ(ash::mojom::AppListViewState::kFullscreenSearch, + view_->app_list_state()); } // Tests that pressing escape when in peeking closes the app list. @@ -1550,7 +1564,7 @@ Show(); view_->AcceleratorPressed(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); - ASSERT_EQ(AppListViewState::CLOSED, view_->app_list_state()); + ASSERT_EQ(ash::mojom::AppListViewState::kClosed, view_->app_list_state()); } // Tests that pressing escape when in half screen changes the state to peeking. @@ -1564,18 +1578,18 @@ search_box->InsertText(base::UTF8ToUTF16("doggie")); view_->AcceleratorPressed(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); - ASSERT_EQ(AppListViewState::PEEKING, view_->app_list_state()); + ASSERT_EQ(ash::mojom::AppListViewState::kPeeking, view_->app_list_state()); } // Tests that pressing escape when in fullscreen changes the state to closed. TEST_F(AppListViewTest, EscapeKeyFullscreenToClosed) { Initialize(0, false, false); - view_->SetState(AppListViewState::FULLSCREEN_ALL_APPS); + view_->SetState(ash::mojom::AppListViewState::kFullscreenAllApps); Show(); view_->AcceleratorPressed(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); - ASSERT_EQ(AppListViewState::CLOSED, view_->app_list_state()); + ASSERT_EQ(ash::mojom::AppListViewState::kClosed, view_->app_list_state()); } // Tests that pressing escape when in fullscreen side-shelf closes the app list. @@ -1586,7 +1600,7 @@ Show(); view_->AcceleratorPressed(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); - ASSERT_EQ(AppListViewState::CLOSED, view_->app_list_state()); + ASSERT_EQ(ash::mojom::AppListViewState::kClosed, view_->app_list_state()); } // Tests that pressing escape when in tablet mode closes the app list. @@ -1597,13 +1611,14 @@ Show(); view_->AcceleratorPressed(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); - ASSERT_EQ(AppListViewState::FULLSCREEN_ALL_APPS, view_->app_list_state()); + ASSERT_EQ(ash::mojom::AppListViewState::kFullscreenAllApps, + view_->app_list_state()); } // Tests that pressing escape when in fullscreen search changes to fullscreen. TEST_F(AppListViewTest, EscapeKeyFullscreenSearchToFullscreen) { Initialize(0, false, false); - view_->SetState(AppListViewState::FULLSCREEN_ALL_APPS); + view_->SetState(ash::mojom::AppListViewState::kFullscreenAllApps); views::Textfield* search_box = view_->app_list_main_view()->search_box_view()->search_box(); @@ -1612,7 +1627,8 @@ search_box->InsertText(base::UTF8ToUTF16("https://youtu.be/dQw4w9WgXcQ")); view_->AcceleratorPressed(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); - ASSERT_EQ(AppListViewState::FULLSCREEN_ALL_APPS, view_->app_list_state()); + ASSERT_EQ(ash::mojom::AppListViewState::kFullscreenAllApps, + view_->app_list_state()); } // Tests that pressing escape when in sideshelf search changes to fullscreen. @@ -1627,7 +1643,8 @@ search_box->InsertText(base::UTF8ToUTF16("kitty")); view_->AcceleratorPressed(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); - ASSERT_EQ(AppListViewState::FULLSCREEN_ALL_APPS, view_->app_list_state()); + ASSERT_EQ(ash::mojom::AppListViewState::kFullscreenAllApps, + view_->app_list_state()); } // Tests that in fullscreen, the app list has multiple pages with enough apps. @@ -1672,7 +1689,8 @@ search_box->InsertText(base::UTF8ToUTF16("yay")); view_->AcceleratorPressed(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); - ASSERT_EQ(AppListViewState::FULLSCREEN_ALL_APPS, view_->app_list_state()); + ASSERT_EQ(ash::mojom::AppListViewState::kFullscreenAllApps, + view_->app_list_state()); } // Tests that leaving tablet mode when in tablet search closes launcher. @@ -1687,7 +1705,7 @@ search_box->InsertText(base::UTF8ToUTF16("something")); view_->OnTabletModeChanged(false); - ASSERT_EQ(AppListViewState::CLOSED, view_->app_list_state()); + ASSERT_EQ(ash::mojom::AppListViewState::kClosed, view_->app_list_state()); } // Tests that opening in peeking mode sets the correct height. @@ -1695,7 +1713,7 @@ Initialize(0, false, false); Show(); - view_->SetState(AppListViewState::PEEKING); + view_->SetState(ash::mojom::AppListViewState::kPeeking); ASSERT_EQ(AppListConfig::instance().peeking_app_list_height(), view_->GetCurrentAppListHeight()); } @@ -1705,7 +1723,7 @@ Initialize(0, false, false); Show(); - view_->SetState(AppListViewState::FULLSCREEN_ALL_APPS); + view_->SetState(ash::mojom::AppListViewState::kFullscreenAllApps); const views::Widget* widget = view_->get_fullscreen_widget_for_test(); const int y = widget->GetWindowBoundsInScreen().y(); @@ -1716,11 +1734,11 @@ TEST_F(AppListViewTest, SetStateFailsWhenClosing) { Initialize(0, false, false); Show(); - view_->SetState(AppListViewState::CLOSED); + view_->SetState(ash::mojom::AppListViewState::kClosed); - view_->SetState(AppListViewState::FULLSCREEN_ALL_APPS); + view_->SetState(ash::mojom::AppListViewState::kFullscreenAllApps); - ASSERT_EQ(AppListViewState::CLOSED, view_->app_list_state()); + ASSERT_EQ(ash::mojom::AppListViewState::kClosed, view_->app_list_state()); } // Tests that going into a folder view, then setting the AppListState to PEEKING @@ -1744,7 +1762,7 @@ ->GetAppsContainerView() ->IsInFolderView()); - view_->SetState(AppListViewState::PEEKING); + view_->SetState(ash::mojom::AppListViewState::kPeeking); EXPECT_FALSE(view_->app_list_main_view() ->contents_view() @@ -1760,8 +1778,9 @@ // region to click. delegate_->GetTestModel()->PopulateApps(6); Show(); - view_->SetState(AppListViewState::FULLSCREEN_ALL_APPS); - EXPECT_EQ(AppListViewState::FULLSCREEN_ALL_APPS, view_->app_list_state()); + view_->SetState(ash::mojom::AppListViewState::kFullscreenAllApps); + EXPECT_EQ(ash::mojom::AppListViewState::kFullscreenAllApps, + view_->app_list_state()); AppsGridView* apps_grid_view = view_->app_list_main_view() ->contents_view() ->GetAppsContainerView() @@ -1777,7 +1796,7 @@ ui::Event::DispatcherApi tap_dispatcher_api(static_cast<ui::Event*>(&tap)); tap_dispatcher_api.set_target(view_); view_->OnGestureEvent(&tap); - EXPECT_EQ(AppListViewState::CLOSED, view_->app_list_state()); + EXPECT_EQ(ash::mojom::AppListViewState::kClosed, view_->app_list_state()); Show(); @@ -1788,7 +1807,7 @@ static_cast<ui::Event*>(&mouse_click)); mouse_click_dispatcher_api.set_target(view_); view_->OnMouseEvent(&mouse_click); - EXPECT_EQ(AppListViewState::CLOSED, view_->app_list_state()); + EXPECT_EQ(ash::mojom::AppListViewState::kClosed, view_->app_list_state()); } // Tests that search box should not become a rectangle during drag. @@ -1797,8 +1816,9 @@ Initialize(0, false, false); delegate_->GetTestModel()->PopulateApps(kInitialItems); Show(); - view_->SetState(AppListViewState::FULLSCREEN_ALL_APPS); - EXPECT_EQ(AppListViewState::FULLSCREEN_ALL_APPS, view_->app_list_state()); + view_->SetState(ash::mojom::AppListViewState::kFullscreenAllApps); + EXPECT_EQ(ash::mojom::AppListViewState::kFullscreenAllApps, + view_->app_list_state()); histogram_tester.ExpectTotalCount( "Apps.StateTransition.Drag.PresentationTime.ClamshellMode", 0); @@ -2125,7 +2145,8 @@ // Show the app list Show(); - EXPECT_EQ(AppListViewState::FULLSCREEN_ALL_APPS, view_->app_list_state()); + EXPECT_EQ(ash::mojom::AppListViewState::kFullscreenAllApps, + view_->app_list_state()); EXPECT_EQ(2, apps_grid_view()->pagination_model()->total_pages()); // Select the second page and open the folder. @@ -2147,17 +2168,20 @@ // Select the second page and open search results page. apps_grid_view()->pagination_model()->SelectPage(1, false); search_box_view()->search_box()->InsertText(base::UTF8ToUTF16("A")); - EXPECT_EQ(AppListViewState::FULLSCREEN_SEARCH, view_->app_list_state()); + EXPECT_EQ(ash::mojom::AppListViewState::kFullscreenSearch, + view_->app_list_state()); EXPECT_EQ(1, apps_grid_view()->pagination_model()->selected_page()); // Back action will first close the search results page. contents_view()->Back(); - EXPECT_EQ(AppListViewState::FULLSCREEN_ALL_APPS, view_->app_list_state()); + EXPECT_EQ(ash::mojom::AppListViewState::kFullscreenAllApps, + view_->app_list_state()); EXPECT_EQ(1, apps_grid_view()->pagination_model()->selected_page()); // Back action will then select the first page. contents_view()->Back(); - EXPECT_EQ(AppListViewState::FULLSCREEN_ALL_APPS, view_->app_list_state()); + EXPECT_EQ(ash::mojom::AppListViewState::kFullscreenAllApps, + view_->app_list_state()); EXPECT_EQ(0, apps_grid_view()->pagination_model()->selected_page()); } @@ -2260,7 +2284,7 @@ static_cast<ui::Event*>(&mouse_click)); mouse_click_dispatcher_api.set_target(view_); view_->OnMouseEvent(&mouse_click); - EXPECT_EQ(AppListViewState::PEEKING, view_->app_list_state()); + EXPECT_EQ(ash::mojom::AppListViewState::kPeeking, view_->app_list_state()); } // Tests that expand arrow is not visible when showing embedded Assistant UI.
diff --git a/ash/app_list/views/apps_container_view.cc b/ash/app_list/views/apps_container_view.cc index c1f6c82..6b544f03 100644 --- a/ash/app_list/views/apps_container_view.cc +++ b/ash/app_list/views/apps_container_view.cc
@@ -151,19 +151,21 @@ show_state_ = AppsContainerView::SHOW_APPS; } -void AppsContainerView::UpdateControlVisibility(AppListViewState app_list_state, - bool is_in_drag) { +void AppsContainerView::UpdateControlVisibility( + ash::mojom::AppListViewState app_list_state, + bool is_in_drag) { apps_grid_view_->UpdateControlVisibility(app_list_state, is_in_drag); page_switcher_->SetVisible( - app_list_state == AppListViewState::FULLSCREEN_ALL_APPS || is_in_drag); + app_list_state == ash::mojom::AppListViewState::kFullscreenAllApps || + is_in_drag); // Ignore button press during dragging to avoid app list item views' opacity // being set to wrong value. page_switcher_->set_ignore_button_press(is_in_drag); suggestion_chip_container_view_->SetVisible( - app_list_state == AppListViewState::FULLSCREEN_ALL_APPS || - app_list_state == AppListViewState::PEEKING || is_in_drag); + app_list_state == ash::mojom::AppListViewState::kFullscreenAllApps || + app_list_state == ash::mojom::AppListViewState::kPeeking || is_in_drag); } void AppsContainerView::UpdateYPositionAndOpacity() { @@ -173,8 +175,8 @@ // AppsGridView. AppListView* app_list_view = contents_view_->app_list_view(); bool should_restore_opacity = - !app_list_view->is_in_drag() && - (app_list_view->app_list_state() != AppListViewState::CLOSED); + !app_list_view->is_in_drag() && (app_list_view->app_list_state() != + ash::mojom::AppListViewState::kClosed); int screen_bottom = app_list_view->GetScreenBottom(); gfx::Rect switcher_bounds = page_switcher_->GetBoundsInScreen(); float centerline_above_work_area =
diff --git a/ash/app_list/views/apps_container_view.h b/ash/app_list/views/apps_container_view.h index 9141431..0f04d616 100644 --- a/ash/app_list/views/apps_container_view.h +++ b/ash/app_list/views/apps_container_view.h
@@ -63,7 +63,7 @@ // Updates the visibility of the items in this view according to // |app_list_state| and |is_in_drag|. - void UpdateControlVisibility(AppListViewState app_list_state, + void UpdateControlVisibility(ash::mojom::AppListViewState app_list_state, bool is_in_drag); // Updates y position and opacity of the items in this view during dragging.
diff --git a/ash/app_list/views/apps_grid_view.cc b/ash/app_list/views/apps_grid_view.cc index f3b4b36..f945f37 100644 --- a/ash/app_list/views/apps_grid_view.cc +++ b/ash/app_list/views/apps_grid_view.cc
@@ -930,8 +930,9 @@ views::ViewModelUtils::SetViewBoundsToIdealBounds(pulsing_blocks_model_); } -void AppsGridView::UpdateControlVisibility(AppListViewState app_list_state, - bool is_in_drag) { +void AppsGridView::UpdateControlVisibility( + ash::mojom::AppListViewState app_list_state, + bool is_in_drag) { if (!folder_delegate_ && app_list_features::IsBackgroundBlurEnabled()) { if (is_in_drag) { layer()->SetMaskLayer(nullptr); @@ -950,7 +951,8 @@ } const bool fullscreen_apps_in_drag = - app_list_state == AppListViewState::FULLSCREEN_ALL_APPS || is_in_drag; + app_list_state == ash::mojom::AppListViewState::kFullscreenAllApps || + is_in_drag; for (int i = 0; i < view_model_.view_size(); ++i) { AppListItemView* view = GetItemViewAt(i); view->SetVisible(fullscreen_apps_in_drag); @@ -1852,8 +1854,8 @@ // centerline reaches |kAllAppsOpacityEndPx| above the work area bottom. AppListView* app_list_view = contents_view_->app_list_view(); const bool should_restore_opacity = - !app_list_view->is_in_drag() && - (app_list_view->app_list_state() != AppListViewState::CLOSED); + !app_list_view->is_in_drag() && (app_list_view->app_list_state() != + ash::mojom::AppListViewState::kClosed); const int selected_page = pagination_model_.selected_page(); auto current_page = view_structure_.pages()[selected_page]; float centerline_above_work_area = 0.f; @@ -2453,7 +2455,8 @@ // Ensure that AppListItems that are added to the AppListItemList are not // shown while in PEEKING. The visibility of the app icons will be updated // on drag/animation from PEEKING. - view->SetVisible(model_->state_fullscreen() != AppListViewState::PEEKING); + view->SetVisible(model_->state_fullscreen() != + ash::mojom::AppListViewState::kPeeking); } if (!folder_delegate_)
diff --git a/ash/app_list/views/apps_grid_view.h b/ash/app_list/views/apps_grid_view.h index 19d2504..5d492b4 100644 --- a/ash/app_list/views/apps_grid_view.h +++ b/ash/app_list/views/apps_grid_view.h
@@ -192,7 +192,7 @@ // Updates the visibility of app list items according to |app_list_state| and // |is_in_drag|. - void UpdateControlVisibility(AppListViewState app_list_state, + void UpdateControlVisibility(ash::mojom::AppListViewState app_list_state, bool is_in_drag); // Overridden from ui::EventHandler:
diff --git a/ash/app_list/views/apps_grid_view_unittest.cc b/ash/app_list/views/apps_grid_view_unittest.cc index be489b5..18c15c6 100644 --- a/ash/app_list/views/apps_grid_view_unittest.cc +++ b/ash/app_list/views/apps_grid_view_unittest.cc
@@ -186,7 +186,7 @@ } // Needed to update suggestions from |model_|. suggestions_container_->Update(); - app_list_view_->SetState(AppListViewState::FULLSCREEN_ALL_APPS); + app_list_view_->SetState(ash::mojom::AppListViewState::kFullscreenAllApps); app_list_view_->Layout(); test_api_ = std::make_unique<AppsGridViewTestApi>(apps_grid_view_);
diff --git a/ash/app_list/views/assistant/assistant_main_view.cc b/ash/app_list/views/assistant/assistant_main_view.cc index d68d097d..ad70fdd 100644 --- a/ash/app_list/views/assistant/assistant_main_view.cc +++ b/ash/app_list/views/assistant/assistant_main_view.cc
@@ -59,19 +59,12 @@ dialog_plate_->RequestFocus(); } -void AssistantMainView::OnBoundsChanged(const gfx::Rect& previous_bounds) { - layer_mask_->layer()->SetBounds(GetLocalBounds()); -} - void AssistantMainView::InitLayout() { + constexpr int radius = search_box::kSearchBoxBorderCornerRadiusSearchResult; + SetPaintToLayer(); layer()->SetFillsBoundsOpaquely(false); - - layer_mask_ = views::Painter::CreatePaintedLayer( - views::Painter::CreateSolidRoundRectPainter( - SK_ColorBLACK, search_box::kSearchBoxBorderCornerRadiusSearchResult)); - layer_mask_->layer()->SetFillsBoundsOpaquely(false); - layer()->SetMaskLayer(layer_mask_->layer()); + layer()->SetRoundedCornerRadius({radius, radius, radius, radius}); views::BoxLayout* layout = SetLayoutManager(std::make_unique<views::BoxLayout>(
diff --git a/ash/app_list/views/assistant/assistant_main_view.h b/ash/app_list/views/assistant/assistant_main_view.h index f47e72f..262919f8 100644 --- a/ash/app_list/views/assistant/assistant_main_view.h +++ b/ash/app_list/views/assistant/assistant_main_view.h
@@ -9,7 +9,6 @@ #include "ash/app_list/app_list_export.h" #include "base/macros.h" -#include "ui/compositor/layer_owner.h" #include "ui/views/view.h" namespace ash { @@ -32,7 +31,6 @@ void ChildPreferredSizeChanged(views::View* child) override; void ChildVisibilityChanged(views::View* child) override; void RequestFocus() override; - void OnBoundsChanged(const gfx::Rect& previous_bounds) override; // Returns the first focusable view or nullptr to defer to views::FocusSearch. views::View* FindFirstFocusableView(); @@ -45,9 +43,6 @@ DialogPlate* dialog_plate_; // Owned by view hierarchy. AssistantMainStage* main_stage_; // Owned by view hierarchy. - // Used to enforce child layers clip to rounded corner bounds. - std::unique_ptr<ui::LayerOwner> layer_mask_; - DISALLOW_COPY_AND_ASSIGN(AssistantMainView); };
diff --git a/ash/app_list/views/contents_view.cc b/ash/app_list/views/contents_view.cc index 2ef5357..8645f9b 100644 --- a/ash/app_list/views/contents_view.cc +++ b/ash/app_list/views/contents_view.cc
@@ -157,7 +157,7 @@ } void ContentsView::OnAppListViewTargetStateChanged( - AppListViewState target_state) { + ash::mojom::AppListViewState target_state) { UpdateExpandArrowFocusBehavior(target_state); } @@ -297,7 +297,7 @@ void ContentsView::UpdatePageBounds() { // No need to do anything while closed. To layout while closed may result in // the search-box going offscreen. - if (app_list_view_->app_list_state() == AppListViewState::CLOSED) + if (app_list_view_->app_list_state() == ash::mojom::AppListViewState::kClosed) return; // The bounds calculations will potentially be mid-transition (depending on @@ -389,8 +389,9 @@ } void ContentsView::UpdateExpandArrowFocusBehavior( - AppListViewState target_state) { - const bool expand_arrow_enabled = target_state == AppListViewState::PEEKING; + ash::mojom::AppListViewState target_state) { + const bool expand_arrow_enabled = + target_state == ash::mojom::AppListViewState::kPeeking; // The expand arrow is only focusable and has InkDropMode on in peeking // state. expand_arrow_view_->SetFocusBehavior( @@ -578,16 +579,16 @@ } void ContentsView::UpdateYPositionAndOpacity() { - AppListViewState state = app_list_view_->app_list_state(); - if (state == AppListViewState::CLOSED || - state == AppListViewState::FULLSCREEN_SEARCH || - state == AppListViewState::HALF) { + ash::mojom::AppListViewState state = app_list_view_->app_list_state(); + if (state == ash::mojom::AppListViewState::kClosed || + state == ash::mojom::AppListViewState::kFullscreenSearch || + state == ash::mojom::AppListViewState::kHalf) { return; } const bool should_restore_opacity = - !app_list_view_->is_in_drag() && - (app_list_view_->app_list_state() != AppListViewState::CLOSED); + !app_list_view_->is_in_drag() && (app_list_view_->app_list_state() != + ash::mojom::AppListViewState::kClosed); // Changes the opacity of expand arrow between 0 and 1 when app list // transition progress changes between |kExpandArrowOpacityStartProgress|
diff --git a/ash/app_list/views/contents_view.h b/ash/app_list/views/contents_view.h index abd9ac6..3195390 100644 --- a/ash/app_list/views/contents_view.h +++ b/ash/app_list/views/contents_view.h
@@ -79,7 +79,8 @@ ApplicationDragAndDropHost* drag_and_drop_host); // Called when the target state of AppListView changes. - void OnAppListViewTargetStateChanged(AppListViewState target_state); + void OnAppListViewTargetStateChanged( + ash::mojom::AppListViewState target_state); // Shows/hides the search results. Hiding the search results will cause the // app list to return to the page that was displayed before @@ -230,7 +231,8 @@ ash::AppListState target_state); // Updates the expand arrow's focus behavior based on AppListViewState. - void UpdateExpandArrowFocusBehavior(AppListViewState target_state); + void UpdateExpandArrowFocusBehavior( + ash::mojom::AppListViewState target_state); // Updates search box visibility based on the current state. void UpdateSearchBoxVisibility(ash::AppListState current_state);
diff --git a/ash/app_list/views/expand_arrow_view.cc b/ash/app_list/views/expand_arrow_view.cc index 85bd0b95..17216359 100644 --- a/ash/app_list/views/expand_arrow_view.cc +++ b/ash/app_list/views/expand_arrow_view.cc
@@ -349,7 +349,7 @@ UMA_HISTOGRAM_ENUMERATION(kAppListPeekingToFullscreenHistogram, kExpandArrow, kMaxPeekingToFullscreen); contents_view_->SetActiveState(ash::AppListState::kStateApps); - app_list_view_->SetState(AppListViewState::FULLSCREEN_ALL_APPS); + app_list_view_->SetState(ash::mojom::AppListViewState::kFullscreenAllApps); } void ExpandArrowView::ScheduleHintingAnimation(bool is_first_time) {
diff --git a/ash/app_list/views/search_box_view.cc b/ash/app_list/views/search_box_view.cc index 393a3dd..f9447659 100644 --- a/ash/app_list/views/search_box_view.cc +++ b/ash/app_list/views/search_box_view.cc
@@ -367,8 +367,8 @@ AppListView* app_list_view = contents_view_->app_list_view(); bool should_restore_opacity = - !app_list_view->is_in_drag() && - (app_list_view->app_list_state() != AppListViewState::CLOSED); + !app_list_view->is_in_drag() && (app_list_view->app_list_state() != + ash::mojom::AppListViewState::kClosed); // Restores the opacity of searchbox if the gesture dragging ends. this->layer()->SetOpacity(should_restore_opacity ? 1.0f : opacity); contents_view_->search_results_page_view()->layer()->SetOpacity(
diff --git a/ash/app_list/views/search_result_tile_item_view.cc b/ash/app_list/views/search_result_tile_item_view.cc index 9d7924d..6983d99 100644 --- a/ash/app_list/views/search_result_tile_item_view.cc +++ b/ash/app_list/views/search_result_tile_item_view.cc
@@ -9,7 +9,6 @@ #include "ash/app_list/app_list_metrics.h" #include "ash/app_list/app_list_view_delegate.h" #include "ash/app_list/model/app_list_model.h" -#include "ash/app_list/model/app_list_view_state.h" #include "ash/app_list/model/search/search_result.h" #include "ash/app_list/pagination_model.h" #include "ash/app_list/views/app_list_item_view.h" @@ -17,6 +16,7 @@ #include "ash/public/cpp/app_list/app_list_features.h" #include "ash/public/cpp/app_list/vector_icons/vector_icons.h" #include "ash/public/interfaces/app_list.mojom.h" +#include "ash/public/interfaces/app_list_view.mojom.h" #include "base/bind.h" #include "base/i18n/number_formatting.h" #include "base/metrics/histogram_macros.h" @@ -465,17 +465,17 @@ SearchResultTileItemView::GetAppType() const { if (IsSuggestedAppTile()) { if (view_delegate_->GetModel()->state_fullscreen() == - AppListViewState::PEEKING) { + ash::mojom::AppListViewState::kPeeking) { return AppListMenuModelAdapter::PEEKING_SUGGESTED; } else { return AppListMenuModelAdapter::FULLSCREEN_SUGGESTED; } } else { if (view_delegate_->GetModel()->state_fullscreen() == - AppListViewState::HALF) { + ash::mojom::AppListViewState::kHalf) { return AppListMenuModelAdapter::HALF_SEARCH_RESULT; } else if (view_delegate_->GetModel()->state_fullscreen() == - AppListViewState::FULLSCREEN_SEARCH) { + ash::mojom::AppListViewState::kFullscreenSearch) { return AppListMenuModelAdapter::FULLSCREEN_SEARCH_RESULT; } }
diff --git a/ash/ash_strings.grd b/ash/ash_strings.grd index a7433ab..893d745 100644 --- a/ash/ash_strings.grd +++ b/ash/ash_strings.grd
@@ -1879,6 +1879,12 @@ <message name="IDS_ASSISTANT_TIMER_NOTIFICATION_STOP_QUERY" desc="Query to issue to stop Assistant timer."> Stop timer </message> + <message name="IDS_ASSISTANT_CREATE_REMINDER_QUERY" desc="Query to issue to create reminder."> + Create reminder + </message> + <message name="IDS_ASSISTANT_EDIT_REMINDER_QUERY" desc="Query to issue to edit reminder."> + Edit reminder + </message> <message name="IDS_ASH_MESSAGE_CENTER_UNLOCK_TO_PERFORM_ACTION" desc="The short message to encourage user to unlock the device so that Chrome OS can perform the notification action selected by user after unlocking."> Unlock device to perform the notification action
diff --git a/ash/assistant/assistant_interaction_controller.cc b/ash/assistant/assistant_interaction_controller.cc index b4136561..f836044 100644 --- a/ash/assistant/assistant_interaction_controller.cc +++ b/ash/assistant/assistant_interaction_controller.cc
@@ -118,6 +118,39 @@ return; } + if (type == DeepLinkType::kReminders) { + using ReminderAction = assistant::util::ReminderAction; + const base::Optional<ReminderAction>& action = + GetDeepLinkParamAsRemindersAction(params, DeepLinkParam::kAction); + + // We treat reminders deeplinks without an action as web deep links. + if (!action) + return; + + switch (action.value()) { + case ReminderAction::kCreate: + StartTextInteraction( + l10n_util::GetStringUTF8(IDS_ASSISTANT_CREATE_REMINDER_QUERY), + /*allow_tts=*/model_.response() && model_.response()->has_tts(), + /*query_source=*/AssistantQuerySource::kDeepLink); + break; + + case ReminderAction::kEdit: + const base::Optional<std::string>& client_id = + GetDeepLinkParam(params, DeepLinkParam::kClientId); + if (client_id && !client_id.value().empty()) { + StopActiveInteraction(false); + model_.SetPendingQuery(std::make_unique<AssistantTextQuery>( + l10n_util::GetStringUTF8(IDS_ASSISTANT_EDIT_REMINDER_QUERY), + /*query_source=*/AssistantQuerySource::kDeepLink)); + assistant_->StartEditReminderInteraction(client_id.value()); + } + break; + } + + return; + } + if (type != DeepLinkType::kQuery) return;
diff --git a/ash/assistant/assistant_ui_controller.cc b/ash/assistant/assistant_ui_controller.cc index b12d0ba..694dcfc 100644 --- a/ash/assistant/assistant_ui_controller.cc +++ b/ash/assistant/assistant_ui_controller.cc
@@ -236,7 +236,7 @@ void AssistantUiController::OnDeepLinkReceived( assistant::util::DeepLinkType type, const std::map<std::string, std::string>& params) { - if (!assistant::util::IsWebDeepLinkType(type)) + if (!assistant::util::IsWebDeepLinkType(type, params)) return; ShowUi(AssistantEntryPoint::kDeepLink);
diff --git a/ash/assistant/test/test_assistant_service.h b/ash/assistant/test/test_assistant_service.h index 769f5ce..c84f24e 100644 --- a/ash/assistant/test/test_assistant_service.h +++ b/ash/assistant/test/test_assistant_service.h
@@ -22,6 +22,7 @@ // mojom::Assistant overrides: void StartCachedScreenContextInteraction() override {} + void StartEditReminderInteraction(const std::string& client_id) override {} void StartMetalayerInteraction(const gfx::Rect& region) override {} void StartTextInteraction(const std::string& query, bool allow_tts) override { }
diff --git a/ash/assistant/ui/assistant_web_view.cc b/ash/assistant/ui/assistant_web_view.cc index 99bfd4c9..3c4d8ba 100644 --- a/ash/assistant/ui/assistant_web_view.cc +++ b/ash/assistant/ui/assistant_web_view.cc
@@ -126,7 +126,7 @@ void AssistantWebView::OnDeepLinkReceived( assistant::util::DeepLinkType type, const std::map<std::string, std::string>& params) { - if (!assistant::util::IsWebDeepLinkType(type)) + if (!assistant::util::IsWebDeepLinkType(type, params)) return; RemoveContents();
diff --git a/ash/assistant/ui/main_stage/assistant_progress_indicator.cc b/ash/assistant/ui/main_stage/assistant_progress_indicator.cc index ac172e7..899901d 100644 --- a/ash/assistant/ui/main_stage/assistant_progress_indicator.cc +++ b/ash/assistant/ui/main_stage/assistant_progress_indicator.cc
@@ -101,17 +101,21 @@ void AssistantProgressIndicator::OnLayerOpacityChanged( ui::PropertyChangeReason reason) { VisibilityChanged(/*starting_from=*/this, - /*is_visible=*/layer()->opacity() > 0.f); + /*is_visible=*/visible()); } void AssistantProgressIndicator::VisibilityChanged(views::View* starting_from, bool is_visible) { - if (is_visible == is_visible_) + // Stop the animation when the view is either not visible or is "visible" but + // not actually visible to the user (because it is faded out). + const bool is_drawn = + IsDrawn() && !cc::MathUtil::IsWithinEpsilon(layer()->opacity(), 0.f); + if (is_drawn_ == is_drawn) return; - is_visible_ = is_visible; + is_drawn_ = is_drawn; - if (!is_visible_) { + if (!is_drawn_) { // Stop all animations. for (int i = 0; i < child_count(); ++i) { child_at(i)->layer()->GetAnimator()->StopAnimating();
diff --git a/ash/assistant/ui/main_stage/assistant_progress_indicator.h b/ash/assistant/ui/main_stage/assistant_progress_indicator.h index aecf343..0ab7ac4 100644 --- a/ash/assistant/ui/main_stage/assistant_progress_indicator.h +++ b/ash/assistant/ui/main_stage/assistant_progress_indicator.h
@@ -33,7 +33,7 @@ // Caches the last call to VisibilityChanged. Because we trigger this event // artificially, we want to make sure that we don't over trigger. - bool is_visible_ = false; + bool is_drawn_ = false; DISALLOW_COPY_AND_ASSIGN(AssistantProgressIndicator); };
diff --git a/ash/assistant/util/deep_link_util.cc b/ash/assistant/util/deep_link_util.cc index a297aa8..a3701c8 100644 --- a/ash/assistant/util/deep_link_util.cc +++ b/ash/assistant/util/deep_link_util.cc
@@ -23,12 +23,18 @@ // Supported deep link param keys. These values must be kept in sync with the // server. See more details at go/cros-assistant-deeplink. +constexpr char kActionParamKey[] = "action"; +constexpr char kClientIdParamKey[] = "clientId"; constexpr char kIdParamKey[] = "id"; constexpr char kQueryParamKey[] = "q"; constexpr char kPageParamKey[] = "page"; constexpr char kRelaunchParamKey[] = "relaunch"; constexpr char kSourceParamKey[] = "source"; +// Supported reminder action deep link param values. +constexpr char kCreateReminder[] = "create"; +constexpr char kEditReminder[] = "edit"; + // Supported deep link prefixes. These values must be kept in sync with the // server. See more details at go/cros-assistant-deeplink. constexpr char kChromeSettingsPrefix[] = "googleassistant://chrome-settings"; @@ -90,6 +96,8 @@ DeepLinkParam param) { // Map of supported deep link params to their keys. static const std::map<DeepLinkParam, std::string> kDeepLinkParamKeys = { + {DeepLinkParam::kAction, kActionParamKey}, + {DeepLinkParam::kClientId, kClientIdParamKey}, {DeepLinkParam::kId, kIdParamKey}, {DeepLinkParam::kPage, kPageParamKey}, {DeepLinkParam::kQuery, kQueryParamKey}, @@ -118,6 +126,19 @@ return base::nullopt; } +base::Optional<ReminderAction> GetDeepLinkParamAsRemindersAction( + const std::map<std::string, std::string> params, + DeepLinkParam param) { + const base::Optional<std::string>& value = GetDeepLinkParam(params, param); + if (value == kCreateReminder) + return ReminderAction::kCreate; + + if (value == kEditReminder) + return ReminderAction::kEdit; + + return base::nullopt; +} + DeepLinkType GetDeepLinkType(const GURL& url) { // Map of supported deep link types to their prefixes. static const std::map<DeepLinkType, std::string> kSupportedDeepLinks = { @@ -211,7 +232,7 @@ static constexpr char kAssistantSettingsWebUrl[] = "https://assistant.google.com/settings/mainpage"; - if (!IsWebDeepLinkType(type)) + if (!IsWebDeepLinkType(type, params)) return base::nullopt; switch (type) { @@ -240,10 +261,17 @@ } bool IsWebDeepLink(const GURL& deep_link) { - return IsWebDeepLinkType(GetDeepLinkType(deep_link)); + return IsWebDeepLinkType(GetDeepLinkType(deep_link), + GetDeepLinkParams(deep_link)); } -bool IsWebDeepLinkType(DeepLinkType type) { +bool IsWebDeepLinkType(DeepLinkType type, + const std::map<std::string, std::string>& params) { + // Create/edit reminder deeplink will trigger Assistant conversation flow. + if (type == DeepLinkType::kReminders && + GetDeepLinkParamAsRemindersAction(params, DeepLinkParam::kAction)) { + return false; + } // Set of deep link types which open web contents in the Assistant UI. static const std::set<DeepLinkType> kWebDeepLinks = { DeepLinkType::kLists, DeepLinkType::kNotes, DeepLinkType::kReminders,
diff --git a/ash/assistant/util/deep_link_util.h b/ash/assistant/util/deep_link_util.h index 8699c12..d22ff87 100644 --- a/ash/assistant/util/deep_link_util.h +++ b/ash/assistant/util/deep_link_util.h
@@ -35,12 +35,20 @@ // Enumeration of deep link parameters. enum class DeepLinkParam { + kAction, + kClientId, kId, kPage, kQuery, kRelaunch, }; +// Enumeration of deep link parameter reminder action. +enum class ReminderAction { + kCreate, + kEdit, +}; + // Returns a deep link to send an Assistant query. COMPONENT_EXPORT(ASSISTANT_UTIL) GURL CreateAssistantQueryDeepLink(const std::string& query); @@ -71,6 +79,13 @@ const std::map<std::string, std::string>& params, DeepLinkParam param); +// Returns a specific ReminderAction |param| from the given parameters. If the +// desired parameter is not found, an empty value is returned. +COMPONENT_EXPORT(ASSISTANT_UTIL) +base::Optional<ReminderAction> GetDeepLinkParamAsRemindersAction( + const std::map<std::string, std::string> params, + DeepLinkParam param); + // Returns the deep link type of the specified |url|. If the specified url is // not a supported deep link, DeepLinkType::kUnsupported is returned. COMPONENT_EXPORT(ASSISTANT_UTIL) DeepLinkType GetDeepLinkType(const GURL& url); @@ -114,7 +129,9 @@ COMPONENT_EXPORT(ASSISTANT_UTIL) bool IsWebDeepLink(const GURL& deep_link); // Returns true if the specified deep link |type| is a web deep link. -COMPONENT_EXPORT(ASSISTANT_UTIL) bool IsWebDeepLinkType(DeepLinkType type); +COMPONENT_EXPORT(ASSISTANT_UTIL) +bool IsWebDeepLinkType(DeepLinkType type, + const std::map<std::string, std::string>& params); } // namespace util } // namespace assistant
diff --git a/ash/assistant/util/deep_link_util_unittest.cc b/ash/assistant/util/deep_link_util_unittest.cc index d633c74f..e326d6e 100644 --- a/ash/assistant/util/deep_link_util_unittest.cc +++ b/ash/assistant/util/deep_link_util_unittest.cc
@@ -135,6 +135,32 @@ AssertDeepLinkParamEq(base::nullopt, DeepLinkParam::kRelaunch); } +TEST_F(DeepLinkUnitTest, GetDeepLinkParamAsRemindersAction) { + std::map<std::string, std::string> params; + + auto AssertDeepLinkParamEq = + [¶ms](const base::Optional<ReminderAction>& expected, + DeepLinkParam param) { + ASSERT_EQ(expected, GetDeepLinkParamAsRemindersAction(params, param)); + }; + + // Case: Deep link parameter present, well formed "create. + params["action"] = "create"; + AssertDeepLinkParamEq(ReminderAction::kCreate, DeepLinkParam::kAction); + + // Case: Deep link parameter present, well formed "edit". + params["action"] = "edit"; + AssertDeepLinkParamEq(ReminderAction::kEdit, DeepLinkParam::kAction); + + // Case: Deep link parameter present, incorrect parameter. + params["action"] = "invalid"; + AssertDeepLinkParamEq(base::nullopt, DeepLinkParam::kAction); + + // Case: Deep link parameter absent. + params.clear(); + AssertDeepLinkParamEq(base::nullopt, DeepLinkParam::kAction); +} + TEST_F(DeepLinkUnitTest, GetDeepLinkType) { const std::map<std::string, DeepLinkType> test_cases = { // OK: Supported deep links. @@ -593,6 +619,8 @@ {"googleassistant://take-screenshot", false}, {"googleassistant://task-manager", false}, {"googleassistant://whats-on-my-screen", false}, + {"googleassistant://reminders?action=create", false}, + {"googleassistant://reminders?action=edit", false}, // FAIL: Non-deep link URLs. {std::string(), false}, @@ -622,8 +650,15 @@ // FAIL: Unsupported deep link types. {DeepLinkType::kUnsupported, false}}; + auto params = std::map<std::string, std::string>(); + for (const auto& test_case : test_cases) - ASSERT_EQ(test_case.second, IsWebDeepLinkType(test_case.first)); + ASSERT_EQ(test_case.second, IsWebDeepLinkType(test_case.first, params)); + + ASSERT_FALSE( + IsWebDeepLinkType(DeepLinkType::kReminders, {{"action", "edit"}})); + ASSERT_FALSE( + IsWebDeepLinkType(DeepLinkType::kReminders, {{"action", "create"}})); } } // namespace util
diff --git a/ash/public/interfaces/BUILD.gn b/ash/public/interfaces/BUILD.gn index 875defeb4..9ed9614 100644 --- a/ash/public/interfaces/BUILD.gn +++ b/ash/public/interfaces/BUILD.gn
@@ -9,7 +9,10 @@ # and //ash/public/cpp needs to depend on this for generated code (such as # enums and constants). mojom("interfaces_internal") { - visibility = [ "//ash/public/cpp:*" ] + visibility = [ + "//ash/public/cpp:*", + "//ash/public/interfaces:test_interfaces", + ] disable_variants = true sources = [ @@ -18,6 +21,7 @@ "accessibility_controller_enums.mojom", "accessibility_focus_ring_controller.mojom", "app_list.mojom", + "app_list_view.mojom", "arc_custom_tab.mojom", "ash_display_controller.mojom", "ash_message_center_controller.mojom", @@ -110,6 +114,7 @@ "time_to_first_present_recorder_test_api.test-mojom", ] deps = [ + "//ash/public/interfaces:interfaces_internal", "//components/account_id/interfaces", "//mojo/public/mojom/base", "//ui/gfx/geometry/mojo",
diff --git a/ash/app_list/model/app_list_view_state.h b/ash/public/interfaces/app_list_view.mojom similarity index 62% rename from ash/app_list/model/app_list_view_state.h rename to ash/public/interfaces/app_list_view.mojom index 0c64d4c..e54a6bb5 100644 --- a/ash/app_list/model/app_list_view_state.h +++ b/ash/public/interfaces/app_list_view.mojom
@@ -1,29 +1,23 @@ -// Copyright (c) 2017 The Chromium Authors. All rights reserved. +// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ASH_APP_LIST_MODEL_APP_LIST_VIEW_STATE_H_ -#define ASH_APP_LIST_MODEL_APP_LIST_VIEW_STATE_H_ +module ash.mojom; -namespace app_list { - -enum class AppListViewState { +// All possible states of the app list view. +enum AppListViewState { // Closes |app_list_main_view_| and dismisses the delegate. - CLOSED = 0, + kClosed, // The initial state for the app list when neither maximize or side shelf // modes are active. If set, the widget will peek over the shelf by // kPeekingAppListHeight DIPs. - PEEKING = 1, + kPeeking, // Entered when text is entered into the search box from peeking mode. - HALF = 2, + kHalf, // Default app list state in maximize and side shelf modes. Entered from an // upward swipe from |PEEKING| or from clicking the chevron. - FULLSCREEN_ALL_APPS = 3, + kFullscreenAllApps, // Entered from an upward swipe from |HALF| or by entering text in the // search box from |FULLSCREEN_ALL_APPS|. - FULLSCREEN_SEARCH = 4, + kFullscreenSearch }; - -} // namespace app_list - -#endif // ASH_APP_LIST_MODEL_APP_LIST_VIEW_STATE_H_
diff --git a/ash/public/interfaces/shell_test_api.test-mojom b/ash/public/interfaces/shell_test_api.test-mojom index f0239f01..073e7acb 100644 --- a/ash/public/interfaces/shell_test_api.test-mojom +++ b/ash/public/interfaces/shell_test_api.test-mojom
@@ -4,19 +4,13 @@ module ash.mojom; +import "ash/public/interfaces/app_list_view.mojom"; + enum OverviewAnimationState { kEnterAnimationComplete, kExitAnimationComplete, }; -enum LauncherAnimationState { - kClosed, - kPeeking, - kHalf, - kFullscreenAllApps, - kFullscreenSearch -}; - interface ShellTestApi { // Returns true if a system modal window is open (e.g. the Wi-Fi network // password dialog). @@ -64,5 +58,5 @@ // Runs the callback when the launcher state becomes |state| after // state transition animation. - WaitForLauncherAnimationState(LauncherAnimationState state) => (); + WaitForLauncherAnimationState(AppListViewState state) => (); };
diff --git a/ash/shelf/app_list_button_unittest.cc b/ash/shelf/app_list_button_unittest.cc index f94e57c..f34b9a47 100644 --- a/ash/shelf/app_list_button_unittest.cc +++ b/ash/shelf/app_list_button_unittest.cc
@@ -85,12 +85,12 @@ start, end, base::TimeDelta::FromMilliseconds(100), 4 /* steps */); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckVisibility(true); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); // Closing the app list. GetAppListTestHelper()->DismissAndRunLoop(); GetAppListTestHelper()->CheckVisibility(false); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); // Swiping above the threshold should trigger a fullscreen app list. end.set_y(shelf->GetIdealBounds().bottom() - @@ -101,7 +101,7 @@ GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckVisibility(true); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); } TEST_F(AppListButtonTest, ClickToOpenAppList) { @@ -116,11 +116,11 @@ GetEventGenerator()->ClickLeftButton(); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckVisibility(true); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); GetEventGenerator()->ClickLeftButton(); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckVisibility(false); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); // Shift-click should open the app list in fullscreen. GetEventGenerator()->set_flags(ui::EF_SHIFT_DOWN); @@ -129,7 +129,7 @@ GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckVisibility(true); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); // Another shift-click should close the app list. GetEventGenerator()->set_flags(ui::EF_SHIFT_DOWN); @@ -137,7 +137,7 @@ GetEventGenerator()->set_flags(0); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckVisibility(false); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); } TEST_F(AppListButtonTest, ButtonPositionInTabletMode) {
diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc index 267bba1..8224457 100644 --- a/ash/shelf/shelf_layout_manager.cc +++ b/ash/shelf/shelf_layout_manager.cc
@@ -12,13 +12,13 @@ #include "ash/animation/animation_change_type.h" #include "ash/app_list/app_list_controller_impl.h" #include "ash/app_list/app_list_metrics.h" -#include "ash/app_list/model/app_list_view_state.h" #include "ash/app_list/views/app_list_view.h" #include "ash/home_screen/home_launcher_gesture_handler.h" #include "ash/home_screen/home_screen_controller.h" #include "ash/home_screen/home_screen_delegate.h" #include "ash/public/cpp/app_list/app_list_features.h" #include "ash/public/cpp/shell_window_ids.h" +#include "ash/public/interfaces/app_list_view.mojom.h" #include "ash/root_window_controller.h" #include "ash/screen_util.h" #include "ash/session/session_controller.h" @@ -1556,14 +1556,14 @@ } DCHECK(Shell::Get()->app_list_controller()); - using app_list::AppListViewState; + using ash::mojom::AppListViewState; AppListViewState app_list_state = Shell::Get()->app_list_controller()->CalculateStateAfterShelfDrag( gesture_in_screen, launcher_above_shelf_bottom_amount_); // Keep auto-hide shelf visible if failed to open the app list. base::Optional<Shelf::ScopedAutoHideLock> auto_hide_lock; - if (app_list_state == AppListViewState::CLOSED) + if (app_list_state == AppListViewState::kClosed) auto_hide_lock.emplace(shelf_); Shell::Get()->app_list_controller()->EndDragFromShelf(app_list_state); gesture_drag_status_ = GESTURE_DRAG_NONE;
diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc index 47e3400..c1c35bb4 100644 --- a/ash/shelf/shelf_layout_manager_unittest.cc +++ b/ash/shelf/shelf_layout_manager_unittest.cc
@@ -1807,12 +1807,12 @@ GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckVisibility(true); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); // Closing the app list. GetAppListTestHelper()->DismissAndRunLoop(); GetAppListTestHelper()->CheckVisibility(false); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); // Fling down that exceeds the velocity threshold should close the app list. StartScroll(start); @@ -1821,7 +1821,7 @@ app_list::AppListView::kDragVelocityThreshold + 10); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckVisibility(false); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); // Fling the app list not exceed the velocity threshold, the state depends on // the drag amount. @@ -1831,14 +1831,14 @@ -(app_list::AppListView::kDragVelocityThreshold - 10)); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckVisibility(true); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); } // Tests that duplicate swipe up from bottom bezel should not make app list // undraggable. (See https://crbug.com/896934) TEST_F(ShelfLayoutManagerTest, DuplicateDragUpFromBezel) { GetAppListTestHelper()->CheckVisibility(false); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); // Start the drag from the bottom bezel to the area that snaps to fullscreen // state. @@ -1856,14 +1856,14 @@ GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckVisibility(true); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); // Start the same drag event from bezel. generator->GestureScrollSequence(start, end, kTimeDelta, kNumScrollSteps); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckVisibility(true); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); // Start the drag from top screen to the area that snaps to closed state. (The // launcher is still draggable now.) @@ -1874,7 +1874,7 @@ generator->GestureScrollSequence(start, end, kTimeDelta, kNumScrollSteps); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckVisibility(false); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); } // Change the shelf alignment during dragging should dismiss the app list. @@ -1918,7 +1918,7 @@ EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckVisibility(false); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); // Swiping up more than the close threshold but less than peeking threshold // should keep the app list at PEEKING state. @@ -1928,12 +1928,12 @@ EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckVisibility(true); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kPeeking); // Closing the app list. GetAppListTestHelper()->DismissAndRunLoop(); GetAppListTestHelper()->CheckVisibility(false); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); // Swiping up more than the peeking threshold should keep the app list at // FULLSCREEN_ALL_APPS state. @@ -1944,12 +1944,12 @@ GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckVisibility(true); GetAppListTestHelper()->CheckState( - app_list::AppListViewState::FULLSCREEN_ALL_APPS); + ash::mojom::AppListViewState::kFullscreenAllApps); // Closing the app list. GetAppListTestHelper()->DismissAndRunLoop(); GetAppListTestHelper()->CheckVisibility(false); - GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED); + GetAppListTestHelper()->CheckState(ash::mojom::AppListViewState::kClosed); shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); // Create a normal unmaximized window, the auto-hide shelf should be hidden.
diff --git a/ash/shell_test_api.cc b/ash/shell_test_api.cc index 6d83764..fbe3d4d 100644 --- a/ash/shell_test_api.cc +++ b/ash/shell_test_api.cc
@@ -9,9 +9,9 @@ #include "ash/accelerators/accelerator_commands.h" #include "ash/app_list/app_list_controller_impl.h" -#include "ash/app_list/model/app_list_view_state.h" #include "ash/app_list/views/app_list_view.h" #include "ash/keyboard/ash_keyboard_controller.h" +#include "ash/public/interfaces/app_list_view.mojom.h" #include "ash/root_window_controller.h" #include "ash/shell.h" #include "ash/system/power/backlights_forced_off_setter.h" @@ -110,26 +110,9 @@ class LauncherStateWaiter { public: LauncherStateWaiter( - mojom::LauncherAnimationState state, + ash::mojom::AppListViewState state, ShellTestApi::WaitForLauncherAnimationStateCallback callback) - : callback_(std::move(callback)) { - switch (state) { - case mojom::LauncherAnimationState::kClosed: - target_state_ = app_list::AppListViewState::CLOSED; - break; - case mojom::LauncherAnimationState::kPeeking: - target_state_ = app_list::AppListViewState::PEEKING; - break; - case mojom::LauncherAnimationState::kHalf: - target_state_ = app_list::AppListViewState::HALF; - break; - case mojom::LauncherAnimationState::kFullscreenAllApps: - target_state_ = app_list::AppListViewState::FULLSCREEN_ALL_APPS; - break; - case mojom::LauncherAnimationState::kFullscreenSearch: - target_state_ = app_list::AppListViewState::FULLSCREEN_SEARCH; - break; - }; + : target_state_(state), callback_(std::move(callback)) { Shell::Get()->app_list_controller()->SetStateTransitionAnimationCallback( base::BindRepeating(&LauncherStateWaiter::OnStateChanged, base::Unretained(this))); @@ -139,7 +122,7 @@ base::NullCallback()); } - void OnStateChanged(app_list::AppListViewState state) { + void OnStateChanged(ash::mojom::AppListViewState state) { if (target_state_ == state) { std::move(callback_).Run(); delete this; @@ -147,7 +130,7 @@ } private: - app_list::AppListViewState target_state_; + ash::mojom::AppListViewState target_state_; ShellTestApi::WaitForLauncherAnimationStateCallback callback_; DISALLOW_COPY_AND_ASSIGN(LauncherStateWaiter); @@ -310,7 +293,7 @@ } void ShellTestApi::WaitForLauncherAnimationState( - mojom::LauncherAnimationState target_state, + ash::mojom::AppListViewState target_state, WaitForLauncherAnimationStateCallback callback) { new LauncherStateWaiter(target_state, std::move(callback)); }
diff --git a/ash/shell_test_api.h b/ash/shell_test_api.h index ee9e6fef..f29399a 100644 --- a/ash/shell_test_api.h +++ b/ash/shell_test_api.h
@@ -71,7 +71,7 @@ mojom::OverviewAnimationState state, WaitForOverviewAnimationStateCallback callback) override; void WaitForLauncherAnimationState( - mojom::LauncherAnimationState state, + ash::mojom::AppListViewState state, WaitForLauncherAnimationStateCallback callback) override; private:
diff --git a/ash/system/bluetooth/tray_bluetooth_helper_legacy_unittest.cc b/ash/system/bluetooth/tray_bluetooth_helper_legacy_unittest.cc index 5fd96739..1936b7a 100644 --- a/ash/system/bluetooth/tray_bluetooth_helper_legacy_unittest.cc +++ b/ash/system/bluetooth/tray_bluetooth_helper_legacy_unittest.cc
@@ -11,6 +11,7 @@ #include "ash/test/ash_test_base.h" #include "base/bind_helpers.h" #include "base/run_loop.h" +#include "base/strings/utf_string_conversions.h" #include "base/test/scoped_feature_list.h" #include "dbus/object_path.h" #include "device/base/features.h" @@ -319,8 +320,15 @@ base::RunLoop().RunUntilIdle(); const BluetoothDeviceList& devices = helper.GetAvailableBluetoothDevices(); - ASSERT_EQ(1u, devices.size()); - EXPECT_EQ(kDisplayPinCodeAddress, devices[0]->address); + ASSERT_EQ(3u, devices.size()); + EXPECT_EQ(base::UTF8ToUTF16( + FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress), + device::GetBluetoothAddressForDisplay(devices[0]->address)); + EXPECT_EQ(base::UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceAddress), + device::GetBluetoothAddressForDisplay(devices[1]->address)); + EXPECT_EQ( + base::UTF8ToUTF16(FakeBluetoothDeviceClient::kDisplayPinCodeAddress), + device::GetBluetoothAddressForDisplay(devices[2]->address)); } } // namespace
diff --git a/ash/system/tray/tray_constants.h b/ash/system/tray/tray_constants.h index 4c1f7a4..80666d5 100644 --- a/ash/system/tray/tray_constants.h +++ b/ash/system/tray/tray_constants.h
@@ -208,6 +208,8 @@ constexpr int kUnifiedSystemInfoHeight = 16; constexpr int kUnifiedSystemInfoSpacing = 8; +constexpr int kUnifiedSystemInfoSeparatorColor = + SkColorSetA(SK_ColorWHITE, 0x24); constexpr gfx::Insets kUnifiedSystemInfoDateViewPadding(3); // Constants used in FeaturePodsView of UnifiedSystemTray.
diff --git a/ash/system/unified/unified_system_info_view.cc b/ash/system/unified/unified_system_info_view.cc index efe5893..e6ded6d 100644 --- a/ash/system/unified/unified_system_info_view.cc +++ b/ash/system/unified/unified_system_info_view.cc
@@ -366,12 +366,14 @@ auto* layout = SetLayoutManager(std::make_unique<views::BoxLayout>( views::BoxLayout::kHorizontal, kUnifiedMenuItemPadding, kUnifiedSystemInfoSpacing)); + layout->set_cross_axis_alignment( + views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); AddChildView(new DateView(controller)); if (PowerStatus::Get()->IsBatteryPresent()) { auto* separator = new views::Separator(); - separator->SetColor(kUnifiedMenuSecondaryTextColor); + separator->SetColor(kUnifiedSystemInfoSeparatorColor); separator->SetPreferredHeight(kUnifiedSystemInfoHeight); AddChildView(separator);
diff --git a/base/sampling_heap_profiler/module_cache.cc b/base/sampling_heap_profiler/module_cache.cc index f8b64709..b22ca23 100644 --- a/base/sampling_heap_profiler/module_cache.cc +++ b/base/sampling_heap_profiler/module_cache.cc
@@ -12,32 +12,48 @@ ModuleCache::~ModuleCache() = default; const ModuleCache::Module* ModuleCache::GetModuleForAddress(uintptr_t address) { - auto it = std::find_if(modules_.begin(), modules_.end(), + Module* module = FindModuleForAddress(non_native_modules_, address); + if (module) + return module; + + module = FindModuleForAddress(native_modules_, address); + if (module) + return module; + + std::unique_ptr<Module> new_module = CreateModuleForAddress(address); + if (!new_module) + return nullptr; + native_modules_.push_back(std::move(new_module)); + return native_modules_.back().get(); +} + +std::vector<const ModuleCache::Module*> ModuleCache::GetModules() const { + std::vector<const Module*> result; + result.reserve(native_modules_.size()); + for (const std::unique_ptr<Module>& module : native_modules_) + result.push_back(module.get()); + return result; +} + +void ModuleCache::AddNonNativeModule(std::unique_ptr<Module> module) { + non_native_modules_.push_back(std::move(module)); +} + +void ModuleCache::InjectModuleForTesting(std::unique_ptr<Module> module) { + native_modules_.push_back(std::move(module)); +} + +// static +ModuleCache::Module* ModuleCache::FindModuleForAddress( + const std::vector<std::unique_ptr<Module>>& modules, + uintptr_t address) { + auto it = std::find_if(modules.begin(), modules.end(), [address](const std::unique_ptr<Module>& module) { return address >= module->GetBaseAddress() && address < module->GetBaseAddress() + module->GetSize(); }); - if (it != modules_.end()) - return it->get(); - - std::unique_ptr<Module> module = CreateModuleForAddress(address); - if (!module) - return nullptr; - modules_.push_back(std::move(module)); - return modules_.back().get(); -} - -std::vector<const ModuleCache::Module*> ModuleCache::GetModules() const { - std::vector<const Module*> result; - result.reserve(modules_.size()); - for (const std::unique_ptr<Module>& module : modules_) - result.push_back(module.get()); - return result; -} - -void ModuleCache::InjectModuleForTesting(std::unique_ptr<Module> module) { - modules_.push_back(std::move(module)); + return it != modules.end() ? it->get() : nullptr; } } // namespace base
diff --git a/base/sampling_heap_profiler/module_cache.h b/base/sampling_heap_profiler/module_cache.h index 9c7cc46..125c3bdd 100644 --- a/base/sampling_heap_profiler/module_cache.h +++ b/base/sampling_heap_profiler/module_cache.h
@@ -70,18 +70,39 @@ const Module* GetModuleForAddress(uintptr_t address); std::vector<const Module*> GetModules() const; + // Add a non-native module to the cache. Non-native modules represent regions + // of non-native executable code, like v8 generated code or compiled + // Java. + // + // Note that non-native modules may be embedded within native modules, as in + // the case of v8 builtin code compiled within Chrome. In that case + // GetModuleForAddress() will return the non-native module rather than the + // native module for the memory region it occupies. + void AddNonNativeModule(std::unique_ptr<Module> module); + void InjectModuleForTesting(std::unique_ptr<Module> module); private: + // Looks for a module containing |address| in |modules| returns the module if + // found, or null if not. + static Module* FindModuleForAddress( + const std::vector<std::unique_ptr<Module>>& modules, + uintptr_t address); + // Creates a Module object for the specified memory address. Returns null if // the address does not belong to a module. static std::unique_ptr<Module> CreateModuleForAddress(uintptr_t address); - // Unsorted vector of cached modules. The number of loaded modules is + // Unsorted vector of cached native modules. The number of loaded modules is // generally much less than 100, and more frequently seen modules will tend to // be added earlier and thus be closer to the front to the vector. So linear // search to find modules should be acceptable. - std::vector<std::unique_ptr<Module>> modules_; + std::vector<std::unique_ptr<Module>> native_modules_; + + // Unsorted vector of non-native modules. Separate from native_modules_ to + // support preferential lookup of non-native modules embedded in native + // modules. See comment on AddNonNativeModule(). + std::vector<std::unique_ptr<Module>> non_native_modules_; }; } // namespace base
diff --git a/base/sampling_heap_profiler/module_cache_unittest.cc b/base/sampling_heap_profiler/module_cache_unittest.cc index d835969..fd6e6fdc 100644 --- a/base/sampling_heap_profiler/module_cache_unittest.cc +++ b/base/sampling_heap_profiler/module_cache_unittest.cc
@@ -38,6 +38,25 @@ std::unique_ptr<char[]> memory_region_; }; +// Provides a fake module with configurable base address and size. +class FakeModule : public ModuleCache::Module { + public: + FakeModule(uintptr_t base_address, size_t size) + : base_address_(base_address), size_(size) {} + + FakeModule(const FakeModule&) = delete; + FakeModule& operator=(const FakeModule&) = delete; + + uintptr_t GetBaseAddress() const override { return base_address_; } + std::string GetId() const override { return ""; } + FilePath GetDebugBasename() const override { return FilePath(); } + size_t GetSize() const override { return size_; } + + private: + uintptr_t base_address_; + size_t size_; +}; + #if defined(OS_POSIX) && !defined(OS_IOS) || defined(OS_WIN) || \ defined(OS_FUCHSIA) #define MAYBE_TEST(TestSuite, TestName) TEST(TestSuite, TestName) @@ -74,6 +93,46 @@ module->GetSize())); } +MAYBE_TEST(ModuleCacheTest, LookupNonNativeModule) { + ModuleCache cache; + auto non_native_module_to_add = std::make_unique<IsolatedModule>(); + const ModuleCache::Module* module = non_native_module_to_add.get(); + cache.AddNonNativeModule(std::move(non_native_module_to_add)); + + EXPECT_EQ(nullptr, cache.GetModuleForAddress(module->GetBaseAddress() - 1)); + EXPECT_EQ(module, cache.GetModuleForAddress(module->GetBaseAddress())); + EXPECT_EQ(module, cache.GetModuleForAddress(module->GetBaseAddress() + + module->GetSize() - 1)); + EXPECT_EQ(nullptr, cache.GetModuleForAddress(module->GetBaseAddress() + + module->GetSize())); +} + +MAYBE_TEST(ModuleCacheTest, LookupOverlaidNonNativeModule) { + ModuleCache cache; + + auto native_module_to_inject = std::make_unique<IsolatedModule>(); + const ModuleCache::Module* native_module = native_module_to_inject.get(); + cache.InjectModuleForTesting(std::move(native_module_to_inject)); + + // Overlay the native module with the non-native module, starting 8 bytes into + // the native modules and ending 8 bytes before the end of the module. + auto non_native_module_to_add = std::make_unique<FakeModule>( + native_module->GetBaseAddress() + 8, native_module->GetSize() - 16); + const ModuleCache::Module* non_native_module = non_native_module_to_add.get(); + cache.AddNonNativeModule(std::move(non_native_module_to_add)); + + EXPECT_EQ(native_module, + cache.GetModuleForAddress(non_native_module->GetBaseAddress() - 1)); + EXPECT_EQ(non_native_module, + cache.GetModuleForAddress(non_native_module->GetBaseAddress())); + EXPECT_EQ(non_native_module, + cache.GetModuleForAddress(non_native_module->GetBaseAddress() + + non_native_module->GetSize() - 1)); + EXPECT_EQ(native_module, + cache.GetModuleForAddress(non_native_module->GetBaseAddress() + + non_native_module->GetSize())); +} + MAYBE_TEST(ModuleCacheTest, ModulesList) { ModuleCache cache; uintptr_t ptr = reinterpret_cast<uintptr_t>(&AFunctionForTest);
diff --git a/build/chromeos/test_runner.py b/build/chromeos/test_runner.py index 5ef6c1b7..be3d7b6 100755 --- a/build/chromeos/test_runner.py +++ b/build/chromeos/test_runner.py
@@ -214,6 +214,7 @@ self._suite_name = args.suite_name self._tests = args.tests self._conditional = args.conditional + self._use_host_tast = args.use_host_tast_bin @property def suite_name(self): @@ -253,7 +254,7 @@ # on_device_script in that case. For all other tests, use cros_run_test's # built-in '--tast' option. This gives us much better results reporting. # TODO(bpastene): s/True/self._llvm_profile_var/ once we parse Tast results. - if True: # pylint: disable=using-constant-test + if not self._use_host_tast: # Build the shell script that will be used on the device to invoke the # test. device_test_script_contents = self.BASIC_SHELL_SCRIPT[:] @@ -724,6 +725,10 @@ tast_test_parser.add_argument( '--test', '-t', action='append', dest='tests', help='A Tast test to run in the device (eg: "ui.ChromeLogin").') + tast_test_parser.add_argument( + '--use-host-tast-bin', action='store_true', + help='Use the host-side Tast bin to run the tests instead of the ' + 'DUT-side local_test_runner. TODO(bpastene): Make this default.') add_common_args(gtest_parser) add_common_args(tast_test_parser)
diff --git a/build/util/android_chrome_version.py b/build/util/android_chrome_version.py index f183441..5628f1a 100644 --- a/build/util/android_chrome_version.py +++ b/build/util/android_chrome_version.py
@@ -113,11 +113,11 @@ """ ARCH64_APK_VARIANTS = { '64_32': { - 'PACKAGES': frozenset(['MONOCHROME']), + 'PACKAGES': frozenset(['MONOCHROME', 'TRICHROME']), 'MODIFIER': 10 }, '64': { - 'PACKAGES': frozenset(['MONOCHROME']), + 'PACKAGES': frozenset(['MONOCHROME', 'TRICHROME']), 'MODIFIER': 20 } }
diff --git a/build/util/android_chrome_version_test.py b/build/util/android_chrome_version_test.py index ad3c5ca1..5e743d3 100644 --- a/build/util/android_chrome_version_test.py +++ b/build/util/android_chrome_version_test.py
@@ -172,9 +172,13 @@ self.EXAMPLE_VERSION_VALUES, arch='arm64', is_next_build=False) arch_monochrome_64_32_version_code = output['MONOCHROME_64_32_VERSION_CODE'] arch_monochrome_64_version_code = output['MONOCHROME_64_VERSION_CODE'] + arch_trichrome_64_32_version_code = output['TRICHROME_64_32_VERSION_CODE'] + arch_trichrome_64_version_code = output['TRICHROME_64_VERSION_CODE'] self.assertEqual(arch_monochrome_64_32_version_code, '372000042') self.assertEqual(arch_monochrome_64_version_code, '372000052') + self.assertEqual(arch_trichrome_64_32_version_code, '372000043') + self.assertEqual(arch_trichrome_64_version_code, '372000053') def testGenerateVersionCodesAndroidArchX64(self): """Assert it handles different architectures correctly. @@ -200,9 +204,13 @@ self.EXAMPLE_VERSION_VALUES, arch='x64', is_next_build=False) arch_monochrome_64_32_version_code = output['MONOCHROME_64_32_VERSION_CODE'] arch_monochrome_64_version_code = output['MONOCHROME_64_VERSION_CODE'] + arch_trichrome_64_32_version_code = output['TRICHROME_64_32_VERSION_CODE'] + arch_trichrome_64_version_code = output['TRICHROME_64_VERSION_CODE'] self.assertEqual(arch_monochrome_64_32_version_code, '372000072') self.assertEqual(arch_monochrome_64_version_code, '372000082') + self.assertEqual(arch_trichrome_64_32_version_code, '372000073') + self.assertEqual(arch_trichrome_64_version_code, '372000083') def testGenerateVersionCodesAndroidArchOrderArm(self): """Assert it handles different architectures correctly.
diff --git a/build/util/version.gni b/build/util/version.gni index 0bcae72..a28f2e46 100644 --- a/build/util/version.gni +++ b/build/util/version.gni
@@ -51,7 +51,9 @@ if (target_cpu == "arm64" || target_cpu == "x64") { _version_dictionary_template += "monochrome_64_32_version_code = \"@MONOCHROME_64_32_VERSION_CODE@\" " + - "monochrome_64_version_code = \"@MONOCHROME_64_VERSION_CODE@\" " + "monochrome_64_version_code = \"@MONOCHROME_64_VERSION_CODE@\" " + + "trichrome_64_32_version_code = \"@TRICHROME_64_32_VERSION_CODE@\" " + + "trichrome_64_version_code = \"@TRICHROME_64_VERSION_CODE@\" " } _script_arguments += [ @@ -96,16 +98,18 @@ } else if (target_os == "android") { forward_variables_from(_result, [ - "chrome_version_code", "chrome_modern_version_code", - "monochrome_version_code", - "trichrome_version_code", - "notouch_chrome_version_code", - "webview_stable_version_code", - "webview_beta_version_code", - "webview_dev_version_code", + "chrome_version_code", "monochrome_64_32_version_code", "monochrome_64_version_code", + "monochrome_version_code", + "notouch_chrome_version_code", + "trichrome_64_32_version_code", + "trichrome_64_version_code", + "trichrome_version_code", + "webview_beta_version_code", + "webview_dev_version_code", + "webview_stable_version_code", ]) chrome_version_name = chrome_version_full @@ -126,6 +130,8 @@ lines_to_write += [ "Monochrome_64_32=$monochrome_64_32_version_code", "Monochrome_64=$monochrome_64_version_code", + "TrichromeChrome_64_32=$trichrome_64_32_version_code", + "TrichromeChrome_64=$trichrome_64_version_code", ] }
diff --git a/build/util/version_test.py b/build/util/version_test.py index 290d026..2a65ddc7 100644 --- a/build/util/version_test.py +++ b/build/util/version_test.py
@@ -120,7 +120,9 @@ new_template = ( self._EXAMPLE_ANDROID_TEMPLATE + "monochrome_64_32_version_code = \"@MONOCHROME_64_32_VERSION_CODE@\" " - "monochrome_64_version_code = \"@MONOCHROME_64_VERSION_CODE@\" ") + "monochrome_64_version_code = \"@MONOCHROME_64_VERSION_CODE@\" " + "trichrome_64_32_version_code = \"@TRICHROME_64_32_VERSION_CODE@\" " + "trichrome_64_version_code = \"@TRICHROME_64_VERSION_CODE@\" ") args_with_template = _ReplaceArgs(self._EXAMPLE_ANDROID_ARGS, ['-t', new_template]) new_args = _ReplaceArgs(args_with_template, ['-a', 'arm64']) @@ -131,13 +133,19 @@ r'\bmonochrome_64_32_version_code = "\d+"\s') self.assertRegexpMatches(contents, r'\bmonochrome_64_version_code = "\d+"\s') + self.assertRegexpMatches(contents, + r'\btrichrome_64_32_version_code = "\d+"\s') + self.assertRegexpMatches(contents, + r'\btrichrome_64_version_code = "\d+"\s') def testBuildOutputAndroidArchVariantsX64(self): """Assert 64-bit-specific version codes""" new_template = ( self._EXAMPLE_ANDROID_TEMPLATE + "monochrome_64_32_version_code = \"@MONOCHROME_64_32_VERSION_CODE@\" " - "monochrome_64_version_code = \"@MONOCHROME_64_VERSION_CODE@\" ") + "monochrome_64_version_code = \"@MONOCHROME_64_VERSION_CODE@\" " + "trichrome_64_32_version_code = \"@TRICHROME_64_32_VERSION_CODE@\" " + "trichrome_64_version_code = \"@TRICHROME_64_VERSION_CODE@\" ") args_with_template = _ReplaceArgs(self._EXAMPLE_ANDROID_ARGS, ['-t', new_template]) new_args = _ReplaceArgs(args_with_template, ['-a', 'x64']) @@ -148,6 +156,10 @@ r'\bmonochrome_64_32_version_code = "\d+"\s') self.assertRegexpMatches(contents, r'\bmonochrome_64_version_code = "\d+"\s') + self.assertRegexpMatches(contents, + r'\btrichrome_64_32_version_code = "\d+"\s') + self.assertRegexpMatches(contents, + r'\btrichrome_64_version_code = "\d+"\s') def testBuildOutputAndroidChromeArchInput(self): """Assert it raises an exception when using an invalid architecture input"""
diff --git a/chrome/VERSION b/chrome/VERSION index b0e11ce..c8d034d 100644 --- a/chrome/VERSION +++ b/chrome/VERSION
@@ -1,4 +1,4 @@ MAJOR=75 MINOR=0 -BUILD=3762 +BUILD=3763 PATCH=0
diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn index 18d503a..b4b689c 100644 --- a/chrome/android/BUILD.gn +++ b/chrome/android/BUILD.gn
@@ -2046,7 +2046,7 @@ } } -template("monochrome_public_bundle_tmpl") { +template("monochrome_or_trichrome_public_bundle_tmpl") { _base_module_target_name = "${invoker.target_name}__base_bundle_module" _is_trichrome = defined(invoker.use_trichrome_library) && invoker.use_trichrome_library @@ -2059,15 +2059,25 @@ } if (_is_trichrome) { - _version_code = trichrome_version_code - } else if (defined(invoker.is_64_bit_browser) && invoker.is_64_bit_browser) { - if (invoker.build_apk_secondary_abi && invoker.include_32_bit_webview) { - _version_code = monochrome_64_32_version_code + if (defined(invoker.is_64_bit_browser) && invoker.is_64_bit_browser) { + if (invoker.build_apk_secondary_abi && invoker.include_32_bit_webview) { + _version_code = trichrome_64_32_version_code + } else { + _version_code = trichrome_64_version_code + } } else { - _version_code = monochrome_64_version_code + _version_code = trichrome_version_code } } else { - _version_code = monochrome_version_code + if (defined(invoker.is_64_bit_browser) && invoker.is_64_bit_browser) { + if (invoker.build_apk_secondary_abi && invoker.include_32_bit_webview) { + _version_code = monochrome_64_32_version_code + } else { + _version_code = monochrome_64_version_code + } + } else { + _version_code = monochrome_version_code + } } _version_name = chrome_version_name @@ -2175,7 +2185,7 @@ } } -monochrome_public_bundle_tmpl("monochrome_public_bundle") { +monochrome_or_trichrome_public_bundle_tmpl("monochrome_public_bundle") { bundle_suffix = "" } @@ -2189,8 +2199,13 @@ } } +monochrome_or_trichrome_public_bundle_tmpl("trichrome_chrome_bundle") { + bundle_suffix = "" + use_trichrome_library = true +} + if (android_64bit_target_cpu) { - monochrome_public_bundle_tmpl("monochrome_64_public_bundle") { + monochrome_or_trichrome_public_bundle_tmpl("monochrome_64_public_bundle") { bundle_suffix = "64" is_64_bit_browser = true if (build_apk_secondary_abi) { @@ -2198,18 +2213,31 @@ } } - monochrome_public_bundle_tmpl("monochrome_64_32_public_bundle") { + monochrome_or_trichrome_public_bundle_tmpl("monochrome_64_32_public_bundle") { bundle_suffix = "6432" is_64_bit_browser = true if (build_apk_secondary_abi) { include_32_bit_webview = true } } -} -monochrome_public_bundle_tmpl("trichrome_chrome_bundle") { - bundle_suffix = "" - use_trichrome_library = true + monochrome_or_trichrome_public_bundle_tmpl("trichrome_64_chrome_bundle") { + bundle_suffix = "64" + is_64_bit_browser = true + use_trichrome_library = true + if (build_apk_secondary_abi) { + include_32_bit_webview = false + } + } + + monochrome_or_trichrome_public_bundle_tmpl("trichrome_64_32_chrome_bundle") { + bundle_suffix = "6432" + is_64_bit_browser = true + use_trichrome_library = true + if (build_apk_secondary_abi) { + include_32_bit_webview = true + } + } } generate_jni("chrome_jni_headers") {
diff --git a/chrome/android/chrome_public_apk_tmpl.gni b/chrome/android/chrome_public_apk_tmpl.gni index 82795b4..8f7697b8 100644 --- a/chrome/android/chrome_public_apk_tmpl.gni +++ b/chrome/android/chrome_public_apk_tmpl.gni
@@ -371,7 +371,9 @@ # depend on their respective versions of the shared library APK even # though they're functionally the same. native_lib_placeholders = [ "libdummy.so" ] - if (android_64bit_target_cpu && build_apk_secondary_abi) { + if (android_64bit_target_cpu && build_apk_secondary_abi && + (!defined(invoker.is_64_bit_browser) || !invoker.is_64_bit_browser || + invoker.include_32_bit_webview)) { secondary_native_lib_placeholders = [ "libdummy.so" ] } _pak_prefix = "trichrome_chrome" @@ -397,7 +399,12 @@ # Configrations to make android load shared library from APK. uncompress_shared_libraries = true - forward_variables_from(invoker, "*", [ "include_32_bit_webview" ]) + forward_variables_from(invoker, + "*", + [ + "include_32_bit_webview", + "is_64_bit_browser", + ]) # Android N+ better supports multiple locales (https://crbug.com/780847). support_zh_hk = false
diff --git a/chrome/android/chrome_test_java_sources.gni b/chrome/android/chrome_test_java_sources.gni index ac72c180..00c78bde 100644 --- a/chrome/android/chrome_test_java_sources.gni +++ b/chrome/android/chrome_test_java_sources.gni
@@ -281,6 +281,7 @@ "javatests/src/org/chromium/chrome/browser/omnibox/OmniboxTest.java", "javatests/src/org/chromium/chrome/browser/omnibox/OmniboxUrlEmphasizerTest.java", "javatests/src/org/chromium/chrome/browser/omnibox/UrlBarTest.java", + "javatests/src/org/chromium/chrome/browser/omnibox/UrlBarIntegrationTest.java", "javatests/src/org/chromium/chrome/browser/omnibox/geo/GeolocationHeaderTest.java", "javatests/src/org/chromium/chrome/browser/omnibox/suggestions/VoiceSuggestionProviderTest.java", "javatests/src/org/chromium/chrome/browser/page_info/ConnectionInfoPopupTest.java",
diff --git a/chrome/android/java/res/layout/bottom_control_container.xml b/chrome/android/java/res/layout/bottom_control_container.xml index 49d44956..e5189e5 100644 --- a/chrome/android/java/res/layout/bottom_control_container.xml +++ b/chrome/android/java/res/layout/bottom_control_container.xml
@@ -12,6 +12,7 @@ <LinearLayout android:orientation="vertical" android:layout_width="match_parent" + android:id="@+id/bottom_controls_wrapper" android:layout_height="@dimen/bottom_toolbar_height_with_shadow" > <ImageView @@ -31,7 +32,7 @@ <ViewStub android:id="@+id/bottom_toolbar_stub" android:layout_width="match_parent" - android:layout_height="wrap_content" + android:layout_height="@dimen/bottom_toolbar_height" android:layout_gravity="start|bottom" android:inflatedId="@+id/bottom_toolbar" android:layout="@layout/bottom_toolbar" />
diff --git a/chrome/android/java/res/layout/bottom_toolbar.xml b/chrome/android/java/res/layout/bottom_toolbar.xml index 475e391..9921d3d 100644 --- a/chrome/android/java/res/layout/bottom_toolbar.xml +++ b/chrome/android/java/res/layout/bottom_toolbar.xml
@@ -13,7 +13,7 @@ <ViewStub android:id="@+id/bottom_toolbar_tab_switcher_mode_stub" android:layout_width="match_parent" - android:layout_height="wrap_content" + android:layout_height="match_parent" android:inflatedId="@+id/bottom_toolbar_tab_switcher_mode" android:layout="@layout/bottom_toolbar_tab_switcher" />
diff --git a/chrome/android/java/res/layout/bottom_toolbar_browsing.xml b/chrome/android/java/res/layout/bottom_toolbar_browsing.xml index f23b562..570e943 100644 --- a/chrome/android/java/res/layout/bottom_toolbar_browsing.xml +++ b/chrome/android/java/res/layout/bottom_toolbar_browsing.xml
@@ -3,57 +3,64 @@ Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. --> - -<LinearLayout +<!-- The toolbar is wrapped in a FrameLayout that matches the parent container's height so that + background color fills the entire parent. The LinearLayout then has a specific height and top + gravity so that items are anchored to the top of the parent container when the parent container + is bigger than the LinearLayout. --> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/bottom_toolbar_browsing" - android:orientation="horizontal" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:minHeight="@dimen/bottom_toolbar_height" - android:background="@color/toolbar_background_primary" - android:layout_gravity="top|center_horizontal" - android:paddingStart="@dimen/bottom_toolbar_start_padding" - android:paddingEnd="@dimen/bottom_toolbar_end_padding" > + android:layout_height="match_parent" + android:background="@color/toolbar_background_primary"> - <org.chromium.chrome.browser.toolbar.HomeButton - android:id="@+id/home_button" - app:tint="@color/standard_mode_tint" - style="@style/BottomToolbarButton" - android:contentDescription="@string/accessibility_toolbar_btn_home" /> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="@dimen/bottom_toolbar_height" + android:layout_gravity="top|center_horizontal" + android:orientation="horizontal" + android:paddingStart="@dimen/bottom_toolbar_start_padding" + android:paddingEnd="@dimen/bottom_toolbar_end_padding" > - <include layout="@layout/toolbar_space" /> + <org.chromium.chrome.browser.toolbar.HomeButton + android:id="@+id/home_button" + app:tint="@color/standard_mode_tint" + style="@style/BottomToolbarButton" + android:contentDescription="@string/accessibility_toolbar_btn_home" /> - <org.chromium.chrome.browser.toolbar.bottom.ShareButton - android:id="@+id/share_button" - style="@style/BottomToolbarButton" - android:src="@drawable/ic_share_white_24dp" - app:tint="@color/standard_mode_tint" - android:contentDescription="@string/share" /> + <include layout="@layout/toolbar_space" /> - <include layout="@layout/toolbar_space" /> + <org.chromium.chrome.browser.toolbar.bottom.ShareButton + android:id="@+id/share_button" + style="@style/BottomToolbarButton" + android:src="@drawable/ic_share_white_24dp" + app:tint="@color/standard_mode_tint" + android:contentDescription="@string/share" /> - <org.chromium.chrome.browser.toolbar.bottom.SearchAccelerator - android:id="@+id/search_accelerator" - android:layout_width="@dimen/search_accelerator_width" - android:layout_height="@dimen/search_accelerator_height" - android:layout_gravity="center" - android:paddingTop="@dimen/search_accelerator_height_padding" - android:paddingBottom="@dimen/search_accelerator_height_padding" - android:src="@drawable/ic_search" - android:contentDescription="@string/accessibility_toolbar_btn_search_accelerator" /> + <include layout="@layout/toolbar_space" /> - <include layout="@layout/toolbar_space" /> + <org.chromium.chrome.browser.toolbar.bottom.SearchAccelerator + android:id="@+id/search_accelerator" + android:layout_width="@dimen/search_accelerator_width" + android:layout_height="@dimen/search_accelerator_height" + android:layout_gravity="center" + android:paddingTop="@dimen/search_accelerator_height_padding" + android:paddingBottom="@dimen/search_accelerator_height_padding" + android:src="@drawable/ic_search" + android:contentDescription="@string/accessibility_toolbar_btn_search_accelerator" /> - <org.chromium.chrome.browser.toolbar.TabSwitcherButtonView - android:id="@+id/tab_switcher_button" - style="@style/BottomToolbarButton" - android:contentDescription="@string/accessibility_toolbar_btn_tabswitcher_toggle_default" /> + <include layout="@layout/toolbar_space" /> - <include layout="@layout/toolbar_space" /> + <org.chromium.chrome.browser.toolbar.TabSwitcherButtonView + android:id="@+id/tab_switcher_button" + style="@style/BottomToolbarButton" + android:contentDescription="@string/accessibility_toolbar_btn_tabswitcher_toggle_default" /> - <include layout="@layout/menu_button" /> + <include layout="@layout/toolbar_space" /> -</LinearLayout> + <include layout="@layout/menu_button" /> + + </LinearLayout> +</FrameLayout>
diff --git a/chrome/android/java/res/layout/bottom_toolbar_tab_switcher.xml b/chrome/android/java/res/layout/bottom_toolbar_tab_switcher.xml index 8f70ec69..d7c9630 100644 --- a/chrome/android/java/res/layout/bottom_toolbar_tab_switcher.xml +++ b/chrome/android/java/res/layout/bottom_toolbar_tab_switcher.xml
@@ -10,42 +10,46 @@ android:id="@+id/bottom_toolbar_tab_switcher" android:orientation="vertical" android:layout_width="match_parent" - android:layout_height="wrap_content" + android:layout_height="match_parent" android:visibility="gone" android:clickable="true" > - <LinearLayout + <FrameLayout android:id="@+id/bottom_toolbar_buttons" - android:orientation="horizontal" android:layout_width="match_parent" - android:layout_height="@dimen/bottom_toolbar_height" - android:background="@color/modern_primary_color" - android:paddingStart="@dimen/bottom_toolbar_start_padding" - android:paddingEnd="@dimen/bottom_toolbar_end_padding" > + android:layout_height="match_parent" + android:background="@color/modern_primary_color" > + <LinearLayout + android:orientation="horizontal" + android:layout_width="match_parent" + android:layout_height="@dimen/bottom_toolbar_height" + android:paddingStart="@dimen/bottom_toolbar_start_padding" + android:paddingEnd="@dimen/bottom_toolbar_end_padding" > - <org.chromium.chrome.browser.toolbar.bottom.CloseAllTabsButton - android:id="@+id/close_all_tabs_button" - style="@style/BottomToolbarButton" - android:src="@drawable/ic_close_all_tabs" - android:contentDescription="@string/accessibility_toolbar_btn_close_all_tabs" - app:tint="@color/standard_mode_tint" /> + <org.chromium.chrome.browser.toolbar.bottom.CloseAllTabsButton + android:id="@+id/close_all_tabs_button" + style="@style/BottomToolbarButton" + android:src="@drawable/ic_close_all_tabs" + android:contentDescription="@string/accessibility_toolbar_btn_close_all_tabs" + app:tint="@color/standard_mode_tint" /> - <include layout="@layout/toolbar_space" /> + <include layout="@layout/toolbar_space" /> - <org.chromium.chrome.browser.toolbar.bottom.BottomToolbarNewTabButton - android:id="@+id/tab_switcher_new_tab_button" - android:layout_width="@dimen/search_accelerator_height" - android:layout_height="@dimen/search_accelerator_height" - android:layout_gravity="center" - android:paddingTop="@dimen/search_accelerator_height_padding" - android:paddingBottom="@dimen/search_accelerator_height_padding" - android:contentDescription="@string/accessibility_toolbar_btn_new_tab" /> + <org.chromium.chrome.browser.toolbar.bottom.BottomToolbarNewTabButton + android:id="@+id/tab_switcher_new_tab_button" + android:layout_width="@dimen/search_accelerator_height" + android:layout_height="@dimen/search_accelerator_height" + android:layout_gravity="center" + android:paddingTop="@dimen/search_accelerator_height_padding" + android:paddingBottom="@dimen/search_accelerator_height_padding" + android:contentDescription="@string/accessibility_toolbar_btn_new_tab" /> - <include layout="@layout/toolbar_space" /> + <include layout="@layout/toolbar_space" /> - <include layout="@layout/menu_button" /> + <include layout="@layout/menu_button" /> - </LinearLayout> + </LinearLayout> + </FrameLayout> <ImageView android:id="@+id/bottom_toolbar_bottom_shadow"
diff --git a/chrome/android/java/res/layout/contextual_search_quick_action_icon_view.xml b/chrome/android/java/res/layout/contextual_search_quick_action_icon_view.xml index 2058924..d0eb7f2 100644 --- a/chrome/android/java/res/layout/contextual_search_quick_action_icon_view.xml +++ b/chrome/android/java/res/layout/contextual_search_quick_action_icon_view.xml
@@ -9,5 +9,4 @@ android:layout_width="@dimen/contextual_search_bar_image_size" android:layout_height="@dimen/contextual_search_bar_image_size" android:importantForAccessibility="no" - android:scaleType="center" - android:background="@color/light_background_color" /> \ No newline at end of file + android:scaleType="center"/> \ No newline at end of file
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/native_page/ContextMenuManager.java b/chrome/android/java/src/org/chromium/chrome/browser/native_page/ContextMenuManager.java index 43339f2..000c8061 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/native_page/ContextMenuManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/native_page/ContextMenuManager.java
@@ -22,8 +22,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import java.util.Map; -import java.util.TreeMap; /** * Takes care of creating, closing a context menu and triaging the item clicks. @@ -40,12 +38,15 @@ public @interface ContextMenuItemId { // The order of the items will be based on the value of their ID. So if new items are added, // the value of the existing ones should be modified so they stay in order. + // Values are also used for indexing - should start from 0 and can't have gaps. int OPEN_IN_NEW_WINDOW = 0; int OPEN_IN_NEW_TAB = 1; int OPEN_IN_INCOGNITO_TAB = 2; int SAVE_FOR_OFFLINE = 3; int REMOVE = 4; int LEARN_MORE = 5; + + int NUM_ENTRIES = 6; } private final NativePageNavigationDelegate mNavigationDelegate; @@ -111,12 +112,10 @@ new ItemClickListener(delegate, mNavigationDelegate, mUserActionPrefix); boolean hasItems = false; - for (@ContextMenuItemId int itemId : MenuItemLabelMatcher.STRING_MAP.keySet()) { + for (@ContextMenuItemId int itemId = 0; itemId < ContextMenuItemId.NUM_ENTRIES; itemId++) { if (!shouldShowItem(itemId, delegate)) continue; - - @StringRes - int itemString = MenuItemLabelMatcher.STRING_MAP.get(itemId); - menu.add(Menu.NONE, itemId, Menu.NONE, itemString).setOnMenuItemClickListener(listener); + menu.add(Menu.NONE, itemId, Menu.NONE, getResourceIdForMenuItem(itemId)) + .setOnMenuItemClickListener(listener); hasItems = true; } @@ -182,26 +181,28 @@ } } - private static class MenuItemLabelMatcher { - private static final Map<Integer, Integer> STRING_MAP = new TreeMap<Integer, Integer>() { - { - put(ContextMenuItemId.OPEN_IN_NEW_WINDOW, - R.string.contextmenu_open_in_other_window); - put(ContextMenuItemId.OPEN_IN_NEW_TAB, - FeatureUtilities.isTabGroupsAndroidEnabled() - ? R.string.contextmenu_open_in_new_tab_group - : R.string.contextmenu_open_in_new_tab); - put(ContextMenuItemId.OPEN_IN_INCOGNITO_TAB, - ChromeFeatureList.isInitialized() - && ChromeFeatureList.isEnabled( - ChromeFeatureList.INCOGNITO_STRINGS) - ? R.string.contextmenu_open_in_private_tab - : R.string.contextmenu_open_in_incognito_tab); - put(ContextMenuItemId.SAVE_FOR_OFFLINE, R.string.contextmenu_save_link); - put(ContextMenuItemId.REMOVE, R.string.remove); - put(ContextMenuItemId.LEARN_MORE, R.string.learn_more); - } - }; + private @StringRes int getResourceIdForMenuItem(@ContextMenuItemId int id) { + switch (id) { + case ContextMenuItemId.OPEN_IN_NEW_WINDOW: + return R.string.contextmenu_open_in_other_window; + case ContextMenuItemId.OPEN_IN_NEW_TAB: + return FeatureUtilities.isTabGroupsAndroidEnabled() + ? R.string.contextmenu_open_in_new_tab_group + : R.string.contextmenu_open_in_new_tab; + case ContextMenuItemId.OPEN_IN_INCOGNITO_TAB: + return ChromeFeatureList.isInitialized() + && ChromeFeatureList.isEnabled(ChromeFeatureList.INCOGNITO_STRINGS) + ? R.string.contextmenu_open_in_private_tab + : R.string.contextmenu_open_in_incognito_tab; + case ContextMenuItemId.SAVE_FOR_OFFLINE: + return R.string.contextmenu_save_link; + case ContextMenuItemId.REMOVE: + return R.string.remove; + case ContextMenuItemId.LEARN_MORE: + return R.string.learn_more; + } + assert false; + return 0; } private static class ItemClickListener implements OnMenuItemClickListener {
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java index e362d0aa..8d4cdef 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java
@@ -94,6 +94,7 @@ import org.chromium.chrome.browser.toolbar.top.TopToolbarCoordinator; import org.chromium.chrome.browser.toolbar.top.ViewShiftingActionBarDelegate; import org.chromium.chrome.browser.translate.TranslateBridge; +import org.chromium.chrome.browser.ui.ImmersiveModeManager; import org.chromium.chrome.browser.util.ColorUtils; import org.chromium.chrome.browser.util.FeatureUtilities; import org.chromium.chrome.browser.widget.ScrimView; @@ -1596,6 +1597,15 @@ } /** + * @param immersiveModeManager The {@link ImmersiveModeManager} for the containing activity. + */ + public void setImmersiveModeManager(ImmersiveModeManager immersiveModeManager) { + if (mBottomControlsCoordinator != null) { + mBottomControlsCoordinator.setImmersiveModeManager(immersiveModeManager); + } + } + + /** * Reverts any pending edits of the location bar and reset to the page state. This does not * change the focus state of the location bar. */
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsCoordinator.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsCoordinator.java index 9da4c98..5e78cd4 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsCoordinator.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsCoordinator.java
@@ -24,6 +24,7 @@ import org.chromium.chrome.browser.toolbar.MenuButton; import org.chromium.chrome.browser.toolbar.TabCountProvider; import org.chromium.chrome.browser.toolbar.bottom.BottomControlsViewBinder.ViewHolder; +import org.chromium.chrome.browser.ui.ImmersiveModeManager; import org.chromium.chrome.browser.util.FeatureUtilities; import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.modelutil.PropertyModel; @@ -77,7 +78,9 @@ model, new ViewHolder(root), BottomControlsViewBinder::bind); mMediator = new BottomControlsMediator(model, fullscreenManager, - root.getResources().getDimensionPixelOffset(R.dimen.bottom_toolbar_height)); + root.getResources().getDimensionPixelOffset(R.dimen.bottom_toolbar_height), + root.getResources().getDimensionPixelOffset( + R.dimen.bottom_toolbar_height_with_shadow)); if (FeatureUtilities.isTabGroupsAndroidEnabled()) { mTabGroupUi = TabManagementModuleProvider.getTabManagementModule().createTabGroupUi( @@ -90,6 +93,13 @@ } /** + * @param immersiveModeManager The {@link ImmersiveModeManager} for the containing activity. + */ + public void setImmersiveModeManager(ImmersiveModeManager immersiveModeManager) { + mMediator.setImmersiveModeManager(immersiveModeManager); + } + + /** * Initialize the bottom controls with the components that had native initialization * dependencies. * <p>
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsMediator.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsMediator.java index cc788bc..134fb7f 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsMediator.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsMediator.java
@@ -4,6 +4,8 @@ package org.chromium.chrome.browser.toolbar.bottom; +import android.support.annotation.Nullable; + import org.chromium.chrome.browser.compositor.bottombar.OverlayPanelManager; import org.chromium.chrome.browser.compositor.layouts.Layout; import org.chromium.chrome.browser.compositor.layouts.LayoutManager; @@ -11,6 +13,7 @@ import org.chromium.chrome.browser.compositor.layouts.ToolbarSwipeLayout; import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandler; import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; +import org.chromium.chrome.browser.ui.ImmersiveModeManager; import org.chromium.ui.KeyboardVisibilityDelegate; import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.modelutil.PropertyModel; @@ -24,15 +27,31 @@ class BottomControlsMediator implements ChromeFullscreenManager.FullscreenListener, KeyboardVisibilityDelegate.KeyboardVisibilityListener, SceneChangeObserver, - OverlayPanelManager.OverlayPanelManagerObserver { + OverlayPanelManager.OverlayPanelManagerObserver, + ImmersiveModeManager.ImmersiveModeObserver { /** The model for the bottom controls component that holds all of its view state. */ private final PropertyModel mModel; /** The fullscreen manager to observe browser controls events. */ private final ChromeFullscreenManager mFullscreenManager; - /** The height of the bottom bar in pixels */ - private final int mBottomControlContainerHeight; + /** + * The height of the bottom bar in pixels including any adjustments for immersive mode, but not + * including the top shadow. + */ + private int mBottomControlsHeight; + + /** + * The base height of the bottom bar in pixels not including adjustments for immersive mode or + * the top shadow. + */ + private final int mBottomControlsBaseHeight; + + /** + * The height of the bottom bar container (which includes the top shadow) in pixels not + * including any offset for immersive mode. + */ + private final int mBottomControlsContainerBaseHeight; /** A {@link WindowAndroid} for watching keyboard visibility events. */ private WindowAndroid mWindowAndroid; @@ -49,23 +68,30 @@ /** Whether the soft keyboard is visible. */ private boolean mIsKeyboardVisible; + /** The {@link ImmersiveModeManager} for the containing activity.*/ + private @Nullable ImmersiveModeManager mImmersiveModeManager; + /** * Build a new mediator that handles events from outside the bottom controls component. * @param model The {@link BottomControlsProperties} that holds all the view state for the - * bottom - * controls component. + * bottom controls component. * @param fullscreenManager A {@link ChromeFullscreenManager} for events related to the browser * controls. - * @param bottomControlContainerHeight The height of the bottom bar in pixels. + * @param bottomControlsHeight The height of the bottom bar in pixels. + * @param bottomControlsContainerHeight The height of the bottom bar container in px. This + * should be the height of {@code bottomControlsHeight} + * plus the height of the top shadow. */ BottomControlsMediator(PropertyModel model, ChromeFullscreenManager fullscreenManager, - int bottomControlContainerHeight) { + int bottomControlsHeight, int bottomControlsContainerHeight) { mModel = model; mFullscreenManager = fullscreenManager; mFullscreenManager.addListener(this); - mBottomControlContainerHeight = bottomControlContainerHeight; + mBottomControlsBaseHeight = bottomControlsHeight; + mBottomControlsHeight = mBottomControlsBaseHeight; + mBottomControlsContainerBaseHeight = bottomControlsContainerHeight; } /** @@ -103,6 +129,20 @@ } /** + * @param immersiveModeManager The {@link ImmersiveModeManager} for the containing activity. + */ + void setImmersiveModeManager(ImmersiveModeManager immersiveModeManager) { + if (!immersiveModeManager.isImmersiveModeSupported()) return; + + mImmersiveModeManager = immersiveModeManager; + mImmersiveModeManager.addObserver(this); + + if (mImmersiveModeManager.getBottomUiInsetPx() != 0) { + onBottomUiInsetChanged(mImmersiveModeManager.getBottomUiInsetPx()); + } + } + + /** * Clean up anything that needs to be when the bottom controls component is destroyed. */ void destroy() { @@ -116,6 +156,8 @@ manager.getOverlayPanelManager().removeObserver(this); manager.removeSceneChangeObserver(this); } + + if (mImmersiveModeManager != null) mImmersiveModeManager.removeObserver(this); } @Override @@ -172,7 +214,7 @@ final boolean isCompositedViewVisible = mIsBottomControlsVisible && !mIsKeyboardVisible; mModel.set(BottomControlsProperties.COMPOSITED_VIEW_VISIBLE, isCompositedViewVisible); mFullscreenManager.setBottomControlsHeight( - isCompositedViewVisible ? mBottomControlContainerHeight : 0); + isCompositedViewVisible ? mBottomControlsHeight : 0); } /** @@ -187,4 +229,17 @@ mIsBottomControlsVisible && !mIsKeyboardVisible && !mIsOverlayPanelShowing && !mIsInSwipeLayout && mFullscreenManager.getBottomControlOffset() == 0); } + + @Override + public void onImmersiveModeChanged(boolean inImmersiveMode) {} + + @Override + public void onBottomUiInsetChanged(int bottomUiInsetPx) { + mBottomControlsHeight = mBottomControlsBaseHeight + bottomUiInsetPx; + mModel.set(BottomControlsProperties.BOTTOM_CONTROLS_HEIGHT_PX, mBottomControlsHeight); + mModel.set(BottomControlsProperties.BOTTOM_CONTROLS_CONTAINER_HEIGHT_PX, + mBottomControlsContainerBaseHeight + bottomUiInsetPx); + + updateCompositedViewVisibility(); + } } \ No newline at end of file
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsProperties.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsProperties.java index 7817bfb..6e0e9068 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsProperties.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsProperties.java
@@ -14,6 +14,13 @@ import org.chromium.ui.resources.ResourceManager; class BottomControlsProperties { + /** The height of the bottom control container (view which includes the top shadow) in px. */ + static final WritableIntPropertyKey BOTTOM_CONTROLS_CONTAINER_HEIGHT_PX = + new WritableIntPropertyKey(); + + /** The height of the bottom toolbar view in px. */ + static final WritableIntPropertyKey BOTTOM_CONTROLS_HEIGHT_PX = new WritableIntPropertyKey(); + /** The Y offset of the view in px. */ static final WritableIntPropertyKey Y_OFFSET = new WritableIntPropertyKey(); @@ -40,7 +47,7 @@ static final WritableObjectPropertyKey<EdgeSwipeHandler> TOOLBAR_SWIPE_HANDLER = new WritableObjectPropertyKey<>(); - static final PropertyKey[] ALL_KEYS = - new PropertyKey[] {Y_OFFSET, ANDROID_VIEW_VISIBLE, COMPOSITED_VIEW_VISIBLE, - LAYOUT_MANAGER, TOOLBAR_SWIPE_LAYOUT, RESOURCE_MANAGER, TOOLBAR_SWIPE_HANDLER}; + static final PropertyKey[] ALL_KEYS = new PropertyKey[] {BOTTOM_CONTROLS_CONTAINER_HEIGHT_PX, + BOTTOM_CONTROLS_HEIGHT_PX, Y_OFFSET, ANDROID_VIEW_VISIBLE, COMPOSITED_VIEW_VISIBLE, + LAYOUT_MANAGER, TOOLBAR_SWIPE_LAYOUT, RESOURCE_MANAGER, TOOLBAR_SWIPE_HANDLER}; }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsViewBinder.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsViewBinder.java index 37f1df9..0519843 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsViewBinder.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsViewBinder.java
@@ -6,6 +6,7 @@ import android.view.View; +import org.chromium.chrome.R; import org.chromium.chrome.browser.compositor.scene_layer.ScrollingBottomViewSceneLayer; import org.chromium.ui.modelutil.PropertyKey; import org.chromium.ui.modelutil.PropertyModel; @@ -31,7 +32,15 @@ } static void bind(PropertyModel model, ViewHolder view, PropertyKey propertyKey) { - if (BottomControlsProperties.Y_OFFSET == propertyKey) { + if (BottomControlsProperties.BOTTOM_CONTROLS_CONTAINER_HEIGHT_PX == propertyKey) { + View bottomControlsWrapper = view.root.findViewById(R.id.bottom_controls_wrapper); + bottomControlsWrapper.getLayoutParams().height = + model.get(BottomControlsProperties.BOTTOM_CONTROLS_CONTAINER_HEIGHT_PX); + } else if (BottomControlsProperties.BOTTOM_CONTROLS_HEIGHT_PX == propertyKey) { + View bottomContainerSlot = view.root.findViewById(R.id.bottom_toolbar); + bottomContainerSlot.getLayoutParams().height = + model.get(BottomControlsProperties.BOTTOM_CONTROLS_HEIGHT_PX); + } else if (BottomControlsProperties.Y_OFFSET == propertyKey) { // Native may not have completely initialized by the time this is set. if (view.sceneLayer == null) return; view.sceneLayer.setYOffset(model.get(BottomControlsProperties.Y_OFFSET));
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ui/ImmersiveModeManager.java b/chrome/android/java/src/org/chromium/chrome/browser/ui/ImmersiveModeManager.java index 8913691..1daf1eee 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/ui/ImmersiveModeManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/ui/ImmersiveModeManager.java
@@ -34,6 +34,13 @@ boolean isImmersiveModeSupported(); /** + * @return The inset to apply to bottom anchored UI elements in pixels. + */ + default int getBottomUiInsetPx() { + return 0; + } + + /** * Add an observer to be notified of changes related to immersive UI mode. * @param observer The observer to add. */
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ui/RootUiCoordinator.java b/chrome/android/java/src/org/chromium/chrome/browser/ui/RootUiCoordinator.java index af61582..9bcd16d 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/ui/RootUiCoordinator.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/ui/RootUiCoordinator.java
@@ -56,6 +56,10 @@ mSystemUiCoordinator = new SystemUiCoordinator(mActivity.getWindow(), mActivity.getTabModelSelector(), mImmersiveModeManager, mActivity.getActivityType()); + + if (mImmersiveModeManager != null) { + mActivity.getToolbarManager().setImmersiveModeManager(mImmersiveModeManager); + } } @Override
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/UrlBarIntegrationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/UrlBarIntegrationTest.java new file mode 100644 index 0000000..0e2693f4 --- /dev/null +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/UrlBarIntegrationTest.java
@@ -0,0 +1,195 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.chrome.browser.omnibox; + +import android.content.ClipData; +import android.content.ClipboardManager; +import android.content.Context; +import android.content.Intent; +import android.support.test.filters.SmallTest; +import android.view.ActionMode; +import android.view.Menu; +import android.view.MenuItem; + +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.chromium.base.test.util.CommandLineFlags; +import org.chromium.base.test.util.Feature; +import org.chromium.base.test.util.RetryOnFailure; +import org.chromium.base.test.util.parameter.CommandLineParameter; +import org.chromium.chrome.R; +import org.chromium.chrome.browser.ChromeFeatureList; +import org.chromium.chrome.browser.ChromeSwitches; +import org.chromium.chrome.browser.ChromeTabbedActivity; +import org.chromium.chrome.test.ChromeActivityTestRule; +import org.chromium.chrome.test.ChromeJUnit4ClassRunner; +import org.chromium.chrome.test.util.OmniboxTestUtils; +import org.chromium.content_public.browser.test.util.Criteria; +import org.chromium.content_public.browser.test.util.CriteriaHelper; +import org.chromium.content_public.browser.test.util.TestThreadUtils; +import org.chromium.content_public.browser.test.util.TouchCommon; +import org.chromium.content_public.common.ContentUrlConstants; + +import java.util.concurrent.Callable; + +/** + * Integration tests for the UrlBar. + */ +@RunWith(ChromeJUnit4ClassRunner.class) +@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE}) +@CommandLineParameter({"", "disable-features=" + ChromeFeatureList.SPANNABLE_INLINE_AUTOCOMPLETE}) +public class UrlBarIntegrationTest { + // 9000+ chars of goodness + private static final String HUGE_URL = + "data:text/plain,H" + new String(new char[9000]).replace('\0', 'u') + "ge!"; + + @Rule + public ChromeActivityTestRule<ChromeTabbedActivity> mActivityTestRule = + new ChromeActivityTestRule<>(ChromeTabbedActivity.class); + + private UrlBar getUrlBar() { + return (UrlBar) mActivityTestRule.getActivity().findViewById(R.id.url_bar); + } + + /** + * Test to verify the omnibox can take focus during startup before native libraries have + * loaded. + */ + @Test + @SmallTest + @Feature({"Omnibox"}) + @RetryOnFailure + public void testFocusingOnStartup() { + Intent intent = new Intent(Intent.ACTION_MAIN); + intent.addCategory(Intent.CATEGORY_LAUNCHER); + mActivityTestRule.prepareUrlIntent(intent, "about:blank"); + mActivityTestRule.startActivityCompletely(intent); + + UrlBar urlBar = getUrlBar(); + Assert.assertNotNull(urlBar); + OmniboxTestUtils.toggleUrlBarFocus(urlBar, true); + OmniboxTestUtils.waitForFocusAndKeyboardActive(urlBar, true); + } + + // This test relies on logic in LocationBarLayout to clear the selection. Ideally, it can move + // to a more isolated test suite in the future. + @Test + @SmallTest + @Feature({"Omnibox"}) + @RetryOnFailure + public void testAutocompleteUpdatedOnDefocus() throws InterruptedException { + mActivityTestRule.startMainActivityOnBlankPage(); + + final UrlBar urlBar = getUrlBar(); + OmniboxTestUtils.toggleUrlBarFocus(urlBar, true); + + String textWithAutocomplete = TestThreadUtils.runOnUiThreadBlockingNoException(() -> { + urlBar.setText("test"); + urlBar.setAutocompleteText("test", "ing is fun"); + return urlBar.getTextWithAutocomplete(); + }); + + Assert.assertEquals("testing is fun", textWithAutocomplete); + OmniboxTestUtils.toggleUrlBarFocus(urlBar, false); + + textWithAutocomplete = TestThreadUtils.runOnUiThreadBlockingNoException( + () -> urlBar.getTextWithAutocomplete()); + Assert.assertEquals(ContentUrlConstants.ABOUT_BLANK_DISPLAY_URL, textWithAutocomplete); + } + + @Test + @SmallTest + @Feature({"Omnibox"}) + @RetryOnFailure + public void testCopyHuge() throws InterruptedException { + mActivityTestRule.startMainActivityWithURL(HUGE_URL); + OmniboxTestUtils.toggleUrlBarFocus(getUrlBar(), true); + Assert.assertEquals(HUGE_URL, copyUrlToClipboard(android.R.id.copy)); + } + + @Test + @SmallTest + @Feature({"Omnibox"}) + @RetryOnFailure + public void testCutHuge() throws InterruptedException { + mActivityTestRule.startMainActivityWithURL(HUGE_URL); + OmniboxTestUtils.toggleUrlBarFocus(getUrlBar(), true); + Assert.assertEquals(HUGE_URL, copyUrlToClipboard(android.R.id.cut)); + } + + /** + * Clears the clipboard, executes specified action on the omnibox and + * returns clipboard's content. Action can be either android.R.id.copy + * or android.R.id.cut. + */ + private String copyUrlToClipboard(final int action) { + return TestThreadUtils.runOnUiThreadBlockingNoException(new Callable<String>() { + @Override + public String call() { + ClipboardManager clipboardManager = + (ClipboardManager) mActivityTestRule.getActivity().getSystemService( + Context.CLIPBOARD_SERVICE); + + clipboardManager.setPrimaryClip(ClipData.newPlainText(null, "")); + + Assert.assertTrue(getUrlBar().onTextContextMenuItem(action)); + ClipData clip = clipboardManager.getPrimaryClip(); + CharSequence text = (clip != null && clip.getItemCount() != 0) + ? clip.getItemAt(0).getText() + : null; + return text != null ? text.toString() : null; + } + }); + } + + @Test + @SmallTest + @Feature({"Omnibox"}) + @RetryOnFailure + public void testLongPress() throws InterruptedException { + // This is a more realistic test than HUGE_URL because ita's full of separator characters + // which have historically been known to trigger odd behavior with long-pressing. + final String longPressUrl = "data:text/plain,hi.hi.hi.hi.hi.hi.hi.hi.hi.hi/hi/hi/hi/hi/hi/"; + mActivityTestRule.startMainActivityWithURL(longPressUrl); + + class ActionModeCreatedCallback implements ActionMode.Callback { + public boolean actionModeCreated; + + @Override + public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + return false; + } + + @Override + public boolean onCreateActionMode(ActionMode mode, Menu menu) { + actionModeCreated = true; + return true; + } + + @Override + public void onDestroyActionMode(ActionMode mode) {} + + @Override + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + return false; + } + } + ActionModeCreatedCallback callback = new ActionModeCreatedCallback(); + getUrlBar().setCustomSelectionActionModeCallback(callback); + + TouchCommon.longPressView(getUrlBar()); + + CriteriaHelper.pollUiThread(new Criteria() { + @Override + public boolean isSatisfied() { + return callback.actionModeCreated && getUrlBar().getSelectionStart() == 0 + && getUrlBar().getSelectionEnd() == longPressUrl.length(); + } + }); + } +}
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/UrlBarTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/UrlBarTest.java index 6c45be5..82cfcf8f 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/UrlBarTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/UrlBarTest.java
@@ -7,50 +7,49 @@ import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_END_DEVICE; import android.annotation.SuppressLint; -import android.content.ClipData; -import android.content.ClipboardManager; import android.content.Context; -import android.content.Intent; +import android.content.res.Resources; import android.support.test.InstrumentationRegistry; import android.support.test.filters.SmallTest; import android.text.Editable; import android.text.TextUtils; -import android.view.ActionMode; import android.view.KeyEvent; -import android.view.Menu; -import android.view.MenuItem; +import android.view.ViewGroup; import android.view.inputmethod.BaseInputConnection; import android.view.inputmethod.InputMethodManager; +import android.widget.FrameLayout; +import android.widget.LinearLayout; import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.chromium.base.test.params.ParameterAnnotations.ClassParameter; +import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate; +import org.chromium.base.test.params.ParameterSet; +import org.chromium.base.test.params.ParameterizedRunner; import org.chromium.base.test.util.CallbackHelper; -import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.DisabledTest; import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Restriction; import org.chromium.base.test.util.RetryOnFailure; -import org.chromium.base.test.util.parameter.CommandLineParameter; import org.chromium.chrome.R; -import org.chromium.chrome.browser.ChromeActivity; import org.chromium.chrome.browser.ChromeFeatureList; -import org.chromium.chrome.browser.ChromeSwitches; -import org.chromium.chrome.browser.omnibox.suggestions.AutocompleteController; -import org.chromium.chrome.browser.profiles.Profile; -import org.chromium.chrome.test.ChromeActivityTestRule; -import org.chromium.chrome.test.ChromeJUnit4ClassRunner; +import org.chromium.chrome.browser.omnibox.UrlBar.UrlBarDelegate; +import org.chromium.chrome.test.ChromeJUnit4RunnerDelegate; +import org.chromium.chrome.test.ui.DummyUiActivityTestCase; import org.chromium.chrome.test.util.OmniboxTestUtils; -import org.chromium.chrome.test.util.OmniboxTestUtils.StubAutocompleteController; import org.chromium.content_public.browser.test.util.Criteria; import org.chromium.content_public.browser.test.util.CriteriaHelper; import org.chromium.content_public.browser.test.util.KeyUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils; -import org.chromium.content_public.browser.test.util.TouchCommon; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; @@ -60,41 +59,73 @@ /** * Tests for the URL bar UI component. - * - * TODO(yolandyan): Replace the CommandLineParameter with new JUnit4 parameterized - * framework once it supports Test Rule Parameterization */ -@RunWith(ChromeJUnit4ClassRunner.class) -@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE}) -@CommandLineParameter({"", "disable-features=" + ChromeFeatureList.SPANNABLE_INLINE_AUTOCOMPLETE}) -public class UrlBarTest { +@RunWith(ParameterizedRunner.class) +@UseRunnerDelegate(ChromeJUnit4RunnerDelegate.class) +public class UrlBarTest extends DummyUiActivityTestCase { + @ClassParameter + private static List<ParameterSet> sClassParams = + Arrays.asList(new ParameterSet().value(false).name("DisableSpannableInline"), + new ParameterSet().value(true).name("EnableSpannableInline")); - @Rule - public ChromeActivityTestRule<ChromeActivity> mActivityTestRule = - new ChromeActivityTestRule<>(ChromeActivity.class); + private UrlBar mUrlBar; + @Mock + private UrlBarDelegate mUrlBarDelegate; - // 9000+ chars of goodness - private static final String HUGE_URL = - "data:text/plain,H" - + new String(new char[9000]).replace('\0', 'u') - + "ge!"; + public UrlBarTest(boolean enableSpannableInline) { + Map<String, Boolean> featureList = new HashMap<>(); + featureList.put(ChromeFeatureList.SPANNABLE_INLINE_AUTOCOMPLETE, enableSpannableInline); + ChromeFeatureList.setTestFeatures(featureList); + } + + @Override + public void setUpTest() throws Exception { + super.setUpTest(); + MockitoAnnotations.initMocks(this); + + TestThreadUtils.runOnUiThreadBlocking(() -> { + ViewGroup view = new LinearLayout(getActivity()); + FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + getActivity().setContentView(view, params); + + ViewGroup urlBarContainer = new FrameLayout(getActivity()); + urlBarContainer.setFocusable(true); + urlBarContainer.setFocusableInTouchMode(true); + + Resources res = getActivity().getResources(); + view.addView(urlBarContainer, + new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, + res.getDimensionPixelSize(R.dimen.toolbar_height_no_shadow) + - 2 + * res.getDimensionPixelSize( + R.dimen.location_bar_vertical_margin))); + + mUrlBar = (UrlBar) getActivity().getLayoutInflater().inflate(R.layout.url_bar, null); + mUrlBar.setDelegate(mUrlBarDelegate); + + urlBarContainer.addView(mUrlBar, new FrameLayout.LayoutParams(params)); + }); + } // Prevent real keyboard app from interfering with test result. After calling this function, // real keyboard app will interact with null InputConnection while the test can still interact // with BaseInputConnection's method and thus affects EditText's Editable through // {@link UrlBar#getInputConnection()}. https://crbug.com/723901 for details. - private void startIgnoringImeUntilRestart(final UrlBar urlBar) { - urlBar.setIgnoreImeForTest(true); + private void startIgnoringImeUntilRestart() { + mUrlBar.setIgnoreImeForTest(true); InputMethodManager imm = - (InputMethodManager) mActivityTestRule.getActivity().getSystemService( - Context.INPUT_METHOD_SERVICE); - imm.restartInput(urlBar); + (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); + imm.restartInput(mUrlBar); } private void toggleFocusAndIgnoreImeOperations(final UrlBar urlBar, final boolean gainFocus) { OmniboxTestUtils.toggleUrlBarFocus(urlBar, gainFocus); if (gainFocus) { - TestThreadUtils.runOnUiThreadBlocking(() -> startIgnoringImeUntilRestart(urlBar)); + TestThreadUtils.runOnUiThreadBlocking(() -> { + urlBar.setIgnoreTextChangesForAutocomplete(false); + startIgnoringImeUntilRestart(); + }); CriteriaHelper.pollUiThread(() -> urlBar.getInputConnection() != null, "Input connection never initialized for URL bar."); } @@ -102,31 +133,12 @@ private void runInputConnectionMethodOnUiThreadBlocking(final Runnable runnable) { TestThreadUtils.runOnUiThreadBlocking(() -> { - UrlBar urlBar = getUrlBar(); // Note: in order for this to work correctly, the following conditions should be met // 1) Unset and set ignoreImeForTest within one UI loop. // 2) Do not restartInput() in between. - urlBar.setIgnoreImeForTest(false); + mUrlBar.setIgnoreImeForTest(false); runnable.run(); - urlBar.setIgnoreImeForTest(true); - }); - } - - private UrlBar getUrlBar() { - return (UrlBar) mActivityTestRule.getActivity().findViewById(R.id.url_bar); - } - - private void stubLocationBarAutocomplete() { - setAutocompleteController(new StubAutocompleteController()); - } - - private void setAutocompleteController(final AutocompleteController controller) { - TestThreadUtils.runOnUiThreadBlocking(() -> { - LocationBarLayout locationBar = - (LocationBarLayout) mActivityTestRule.getActivity().findViewById( - R.id.location_bar); - locationBar.getAutocompleteCoordinator().cancelPendingAutocompleteStart(); - locationBar.getAutocompleteCoordinator().setAutocompleteController(controller); + mUrlBar.setIgnoreImeForTest(true); }); } @@ -144,39 +156,30 @@ } } - private Editable getUrlBarText(final UrlBar urlBar) throws ExecutionException { - return TestThreadUtils.runOnUiThreadBlocking(new Callable<Editable>() { - @Override - public Editable call() throws Exception { - return urlBar.getText(); - } - }); + private Editable getUrlBarText() { + return TestThreadUtils.runOnUiThreadBlockingNoException(() -> mUrlBar.getText()); } - private AutocompleteState getAutocompleteState( - final UrlBar urlBar, final Runnable action) { + private AutocompleteState getAutocompleteState(final Runnable action) { final AtomicBoolean hasAutocomplete = new AtomicBoolean(); final AtomicReference<String> textWithoutAutocomplete = new AtomicReference<String>(); final AtomicReference<String> textWithAutocomplete = new AtomicReference<String>(); TestThreadUtils.runOnUiThreadBlocking(() -> { if (action != null) action.run(); - textWithoutAutocomplete.set(urlBar.getTextWithoutAutocomplete()); - textWithAutocomplete.set(urlBar.getTextWithAutocomplete()); - hasAutocomplete.set(urlBar.hasAutocomplete()); + textWithoutAutocomplete.set(mUrlBar.getTextWithoutAutocomplete()); + textWithAutocomplete.set(mUrlBar.getTextWithAutocomplete()); + hasAutocomplete.set(mUrlBar.hasAutocomplete()); }); return new AutocompleteState( hasAutocomplete.get(), textWithoutAutocomplete.get(), textWithAutocomplete.get()); } - private void setTextAndVerifyNoAutocomplete(final UrlBar urlBar, final String text) { - AutocompleteState state = getAutocompleteState(urlBar, new Runnable() { - @Override - public void run() { - urlBar.setText(text); - urlBar.setSelection(text.length()); - } + private void setTextAndVerifyNoAutocomplete(final String text) { + AutocompleteState state = getAutocompleteState(() -> { + mUrlBar.setText(text); + mUrlBar.setSelection(text.length()); }); Assert.assertEquals(text, state.textWithoutAutocomplete); @@ -184,28 +187,17 @@ Assert.assertFalse(state.hasAutocomplete); } - private void setAutocomplete(final UrlBar urlBar, - final String userText, final String autocompleteText) { - AutocompleteState state = getAutocompleteState(urlBar, new Runnable() { - @Override - public void run() { - urlBar.setAutocompleteText(userText, autocompleteText); - } - }); + private void setAutocomplete(final String userText, final String autocompleteText) { + AutocompleteState state = + getAutocompleteState(() -> mUrlBar.setAutocompleteText(userText, autocompleteText)); Assert.assertEquals(userText, state.textWithoutAutocomplete); Assert.assertEquals(userText + autocompleteText, state.textWithAutocomplete); Assert.assertTrue(state.hasAutocomplete); } - private AutocompleteState setSelection( - final UrlBar urlBar, final int selectionStart, final int selectionEnd) { - return getAutocompleteState(urlBar, new Runnable() { - @Override - public void run() { - urlBar.setSelection(selectionStart, selectionEnd); - } - }); + private AutocompleteState setSelection(final int selectionStart, final int selectionEnd) { + return getAutocompleteState(() -> mUrlBar.setSelection(selectionStart, selectionEnd)); } @Test @@ -214,10 +206,8 @@ @RetryOnFailure @DisabledTest public void testRefocusing() throws InterruptedException { - mActivityTestRule.startMainActivityOnBlankPage(); - UrlBar urlBar = getUrlBar(); - Assert.assertFalse(OmniboxTestUtils.doesUrlBarHaveFocus(urlBar)); - OmniboxTestUtils.checkUrlBarRefocus(urlBar, 5); + Assert.assertFalse(OmniboxTestUtils.doesUrlBarHaveFocus(mUrlBar)); + OmniboxTestUtils.checkUrlBarRefocus(mUrlBar, 5); } @Test @@ -225,23 +215,20 @@ @Feature({"Omnibox"}) @RetryOnFailure public void testAutocompleteUpdatedOnSetText() throws InterruptedException { - mActivityTestRule.startMainActivityOnBlankPage(); - stubLocationBarAutocomplete(); - final UrlBar urlBar = getUrlBar(); - toggleFocusAndIgnoreImeOperations(urlBar, true); + toggleFocusAndIgnoreImeOperations(mUrlBar, true); // Verify that setting a new string will clear the autocomplete. - setTextAndVerifyNoAutocomplete(urlBar, "test"); - setAutocomplete(urlBar, "test", "ing is fun"); - setTextAndVerifyNoAutocomplete(urlBar, "new string"); + setTextAndVerifyNoAutocomplete("test"); + setAutocomplete("test", "ing is fun"); + setTextAndVerifyNoAutocomplete("new string"); // Replace part of the non-autocomplete text - setTextAndVerifyNoAutocomplete(urlBar, "test"); - setAutocomplete(urlBar, "test", "ing is fun"); - AutocompleteState state = getAutocompleteState(urlBar, new Runnable() { + setTextAndVerifyNoAutocomplete("test"); + setAutocomplete("test", "ing is fun"); + AutocompleteState state = getAutocompleteState(new Runnable() { @Override public void run() { - urlBar.setText(urlBar.getText().replace(1, 2, "a")); + mUrlBar.setText(mUrlBar.getText().replace(1, 2, "a")); } }); Assert.assertFalse(state.hasAutocomplete); @@ -251,12 +238,12 @@ Assert.assertEquals("tast", state.textWithAutocomplete); // Replace part of the autocomplete text. - setTextAndVerifyNoAutocomplete(urlBar, "test"); - setAutocomplete(urlBar, "test", "ing is fun"); - state = getAutocompleteState(urlBar, new Runnable() { + setTextAndVerifyNoAutocomplete("test"); + setAutocomplete("test", "ing is fun"); + state = getAutocompleteState(new Runnable() { @Override public void run() { - urlBar.setText(urlBar.getText().replace(8, 10, "no")); + mUrlBar.setText(mUrlBar.getText().replace(8, 10, "no")); } }); Assert.assertFalse(state.hasAutocomplete); @@ -278,29 +265,20 @@ String expectedTextWithAutocomplete, boolean expectedPreventInline, String expectedRequestedAutocompleteText) throws InterruptedException, TimeoutException { - final UrlBar urlBar = getUrlBar(); - - stubLocationBarAutocomplete(); - setTextAndVerifyNoAutocomplete(urlBar, text); - setAutocomplete(urlBar, text, inlineAutocomplete); + setTextAndVerifyNoAutocomplete(text); + setAutocomplete(text, inlineAutocomplete); final CallbackHelper autocompleteHelper = new CallbackHelper(); final AtomicReference<String> requestedAutocompleteText = new AtomicReference<String>(); final AtomicBoolean didPreventInlineAutocomplete = new AtomicBoolean(); - final StubAutocompleteController controller = new StubAutocompleteController() { - @Override - public void start(Profile profile, String url, String text, int cursorPosition, - boolean preventInlineAutocomplete, boolean focusedFromFakebox) { - if (autocompleteHelper.getCallCount() != 0) return; + mUrlBar.setUrlTextChangeListener(() -> { + autocompleteHelper.notifyCalled(); + requestedAutocompleteText.set(mUrlBar.getTextWithoutAutocomplete()); + didPreventInlineAutocomplete.set(!mUrlBar.shouldAutocomplete()); + mUrlBar.setUrlTextChangeListener(null); + }); - requestedAutocompleteText.set(text); - didPreventInlineAutocomplete.set(preventInlineAutocomplete); - autocompleteHelper.notifyCalled(); - } - }; - setAutocompleteController(controller); - - AutocompleteState state = setSelection(urlBar, selectionStart, selectionEnd); + AutocompleteState state = setSelection(selectionStart, selectionEnd); Assert.assertEquals("Has autocomplete", expectedHasAutocomplete, state.hasAutocomplete); Assert.assertEquals("Text w/o Autocomplete", expectedTextWithoutAutocomplete, state.textWithoutAutocomplete); @@ -319,10 +297,7 @@ @Feature({"Omnibox"}) @RetryOnFailure public void testAutocompleteUpdatedOnSelection() throws InterruptedException, TimeoutException { - mActivityTestRule.startMainActivityOnBlankPage(); - stubLocationBarAutocomplete(); - final UrlBar urlBar = getUrlBar(); - toggleFocusAndIgnoreImeOperations(urlBar, true); + toggleFocusAndIgnoreImeOperations(mUrlBar, true); // Verify that setting a selection before the autocomplete clears it. verifySelectionState("test", "ing is fun", 1, 1, false, "test", "test", true, "test"); @@ -370,10 +345,9 @@ // Select autocomplete text. As we do not expect the suggestions to be refreshed, we test // this slightly differently than the other cases. - stubLocationBarAutocomplete(); - setTextAndVerifyNoAutocomplete(urlBar, "test"); - setAutocomplete(urlBar, "test", "ing is fun"); - AutocompleteState state = setSelection(urlBar, 4, 14); + setTextAndVerifyNoAutocomplete("test"); + setAutocomplete("test", "ing is fun"); + AutocompleteState state = setSelection(4, 14); if (ChromeFeatureList.isEnabled(ChromeFeatureList.SPANNABLE_INLINE_AUTOCOMPLETE)) { // Note: with new model selecting the autocomplete text will commit autocomplete. @@ -402,27 +376,21 @@ @Feature({"Omnibox"}) @RetryOnFailure public void testSendCursorPosition() throws InterruptedException, TimeoutException { - mActivityTestRule.startMainActivityOnBlankPage(); - final CallbackHelper autocompleteHelper = new CallbackHelper(); final AtomicInteger cursorPositionUsed = new AtomicInteger(); - final StubAutocompleteController controller = new StubAutocompleteController() { - @Override - public void start(Profile profile, String url, String text, int cursorPosition, - boolean preventInlineAutocomplete, boolean focusedFromFakebox) { - cursorPositionUsed.set(cursorPosition); - autocompleteHelper.notifyCalled(); - } - }; - setAutocompleteController(controller); - - final UrlBar urlBar = getUrlBar(); - toggleFocusAndIgnoreImeOperations(urlBar, true); + mUrlBar.setUrlTextChangeListener(() -> { + int cursorPosition = mUrlBar.getSelectionEnd() == mUrlBar.getSelectionStart() + ? mUrlBar.getSelectionStart() + : -1; + cursorPositionUsed.set(cursorPosition); + autocompleteHelper.notifyCalled(); + }); + toggleFocusAndIgnoreImeOperations(mUrlBar, true); // Add "a" to the omnibox and leave the cursor at the end of the new // text. TestThreadUtils.runOnUiThreadBlocking( - () -> { urlBar.getInputConnection().commitText("a", 1); }); + () -> { mUrlBar.getInputConnection().commitText("a", 1); }); autocompleteHelper.waitForCallback(0); // omnmibox text: a| Assert.assertEquals(1, cursorPositionUsed.get()); @@ -430,14 +398,14 @@ // Append "cd" to the omnibox and leave the cursor at the end of the new // text. TestThreadUtils.runOnUiThreadBlocking( - () -> { urlBar.getInputConnection().commitText("cd", 1); }); + () -> { mUrlBar.getInputConnection().commitText("cd", 1); }); autocompleteHelper.waitForCallback(1); // omnmibox text: acd| Assert.assertEquals(3, cursorPositionUsed.get()); // Move the cursor. TestThreadUtils.runOnUiThreadBlocking( - () -> { urlBar.getInputConnection().setSelection(1, 1); }); + () -> { mUrlBar.getInputConnection().setSelection(1, 1); }); // omnmibox text: a|cd // Moving the cursor shouldn't have caused a new call. Assert.assertEquals(2, autocompleteHelper.getCallCount()); @@ -447,24 +415,26 @@ // Insert "b" at the current cursor position and leave the cursor at // the end of the new text. TestThreadUtils.runOnUiThreadBlocking( - () -> { urlBar.getInputConnection().commitText("b", 1); }); + () -> { mUrlBar.getInputConnection().commitText("b", 1); }); autocompleteHelper.waitForCallback(2); // omnmibox text: ab|cd Assert.assertEquals(2, cursorPositionUsed.get()); // Delete the character before the cursor. TestThreadUtils.runOnUiThreadBlocking( - () -> { urlBar.getInputConnection().deleteSurroundingText(1, 0); }); + () -> { mUrlBar.getInputConnection().deleteSurroundingText(1, 0); }); autocompleteHelper.waitForCallback(3); // omnmibox text: a|cd Assert.assertEquals(1, cursorPositionUsed.get()); // Delete the character before the cursor (again). TestThreadUtils.runOnUiThreadBlocking( - () -> { urlBar.getInputConnection().deleteSurroundingText(1, 0); }); + () -> { mUrlBar.getInputConnection().deleteSurroundingText(1, 0); }); autocompleteHelper.waitForCallback(4); // omnmibox text: |cd Assert.assertEquals(0, cursorPositionUsed.get()); + + mUrlBar.setUrlTextChangeListener(null); } /** @@ -482,30 +452,21 @@ @RetryOnFailure public void testAutocompleteAllowedWhenReplacingText() throws InterruptedException, TimeoutException { - mActivityTestRule.startMainActivityOnBlankPage(); - final String textToBeEntered = "c"; final CallbackHelper autocompleteHelper = new CallbackHelper(); final AtomicBoolean didPreventInlineAutocomplete = new AtomicBoolean(); - final StubAutocompleteController controller = new StubAutocompleteController() { - @Override - public void start(Profile profile, String url, String text, int cursorPosition, - boolean preventInlineAutocomplete, boolean focusedFromFakebox) { - if (!TextUtils.equals(textToBeEntered, text)) return; - if (autocompleteHelper.getCallCount() != 0) return; + mUrlBar.setUrlTextChangeListener(() -> { + if (!TextUtils.equals(textToBeEntered, mUrlBar.getTextWithoutAutocomplete())) return; + didPreventInlineAutocomplete.set(!mUrlBar.shouldAutocomplete()); + autocompleteHelper.notifyCalled(); + mUrlBar.setUrlTextChangeListener(null); + }); - didPreventInlineAutocomplete.set(preventInlineAutocomplete); - autocompleteHelper.notifyCalled(); - } - }; - setAutocompleteController(controller); - - final UrlBar urlBar = getUrlBar(); - toggleFocusAndIgnoreImeOperations(urlBar, true); + toggleFocusAndIgnoreImeOperations(mUrlBar, true); TestThreadUtils.runOnUiThreadBlocking( - () -> { urlBar.getInputConnection().commitText(textToBeEntered, 1); }); + () -> { mUrlBar.getInputConnection().commitText(textToBeEntered, 1); }); autocompleteHelper.waitForCallback(0); Assert.assertFalse( "Inline autocomplete incorrectly prevented.", didPreventInlineAutocomplete.get()); @@ -521,42 +482,32 @@ @RetryOnFailure public void testSuggestionsUpdatedWhenDeletingInlineAutocomplete() throws InterruptedException, TimeoutException { - mActivityTestRule.startMainActivityOnBlankPage(); + toggleFocusAndIgnoreImeOperations(mUrlBar, true); - stubLocationBarAutocomplete(); - final UrlBar urlBar = getUrlBar(); - toggleFocusAndIgnoreImeOperations(urlBar, true); - - setTextAndVerifyNoAutocomplete(urlBar, "test"); - setAutocomplete(urlBar, "test", "ing"); + setTextAndVerifyNoAutocomplete("test"); + setAutocomplete("test", "ing"); final CallbackHelper autocompleteHelper = new CallbackHelper(); final AtomicBoolean didPreventInlineAutocomplete = new AtomicBoolean(); - final StubAutocompleteController controller = new StubAutocompleteController() { - @Override - public void start(Profile profile, String url, String text, int cursorPosition, - boolean preventInlineAutocomplete, boolean focusedFromFakebox) { - if (!TextUtils.equals("test", text)) return; - if (autocompleteHelper.getCallCount() != 0) return; - - didPreventInlineAutocomplete.set(preventInlineAutocomplete); - autocompleteHelper.notifyCalled(); - } - }; - setAutocompleteController(controller); + mUrlBar.setUrlTextChangeListener(() -> { + if (!TextUtils.equals("test", mUrlBar.getTextWithoutAutocomplete())) return; + didPreventInlineAutocomplete.set(!mUrlBar.shouldAutocomplete()); + autocompleteHelper.notifyCalled(); + mUrlBar.setUrlTextChangeListener(null); + }); runInputConnectionMethodOnUiThreadBlocking(new Runnable() { @Override public void run() { - KeyUtils.singleKeyEventView( - InstrumentationRegistry.getInstrumentation(), urlBar, KeyEvent.KEYCODE_DEL); + KeyUtils.singleKeyEventView(InstrumentationRegistry.getInstrumentation(), mUrlBar, + KeyEvent.KEYCODE_DEL); } }); CriteriaHelper.pollUiThread(Criteria.equals("test", new Callable<String>() { @Override public String call() throws Exception { - return urlBar.getText().toString(); + return mUrlBar.getText().toString(); } })); @@ -570,31 +521,28 @@ @Feature({"Omnibox"}) @RetryOnFailure public void testSelectionChangesIgnoredInBatchMode() throws InterruptedException { - mActivityTestRule.startMainActivityOnBlankPage(); - stubLocationBarAutocomplete(); - final UrlBar urlBar = getUrlBar(); if (ChromeFeatureList.isEnabled(ChromeFeatureList.SPANNABLE_INLINE_AUTOCOMPLETE)) { // Note: with the new model, we remove autocomplete text at the beginning of a batch // edit and add it at the end of a batch edit. return; } - toggleFocusAndIgnoreImeOperations(urlBar, true); + toggleFocusAndIgnoreImeOperations(mUrlBar, true); - setTextAndVerifyNoAutocomplete(urlBar, "test"); - setAutocomplete(urlBar, "test", "ing is fun"); + setTextAndVerifyNoAutocomplete("test"); + setAutocomplete("test", "ing is fun"); TestThreadUtils.runOnUiThreadBlocking( - () -> { urlBar.getInputConnection().beginBatchEdit(); }); + () -> { mUrlBar.getInputConnection().beginBatchEdit(); }); // Ensure the autocomplete is not modified if in batch mode. - AutocompleteState state = setSelection(urlBar, 1, 1); + AutocompleteState state = setSelection(1, 1); Assert.assertTrue(state.hasAutocomplete); Assert.assertEquals("test", state.textWithoutAutocomplete); Assert.assertEquals("testing is fun", state.textWithAutocomplete); TestThreadUtils.runOnUiThreadBlocking( - () -> { urlBar.getInputConnection().endBatchEdit(); }); + () -> { mUrlBar.getInputConnection().endBatchEdit(); }); // Ensure that after batch mode has ended that the autocomplete is cleared due to the // invalid selection range. - state = getAutocompleteState(urlBar, null); + state = getAutocompleteState(null); Assert.assertFalse(state.hasAutocomplete); Assert.assertEquals("test", state.textWithoutAutocomplete); Assert.assertEquals("test", state.textWithAutocomplete); @@ -605,31 +553,21 @@ @Feature({"Omnibox"}) @RetryOnFailure public void testBatchModeChangesTriggerCorrectSuggestions() throws InterruptedException { - mActivityTestRule.startMainActivityOnBlankPage(); - final AtomicReference<String> requestedAutocompleteText = new AtomicReference<String>(); - final StubAutocompleteController controller = new StubAutocompleteController() { - @Override - public void start(Profile profile, String url, String text, int cursorPosition, - boolean preventInlineAutocomplete, boolean focusedFromFakebox) { - requestedAutocompleteText.set(text); - } - }; + mUrlBar.setUrlTextChangeListener( + () -> { requestedAutocompleteText.set(mUrlBar.getTextWithoutAutocomplete()); }); - setAutocompleteController(controller); + toggleFocusAndIgnoreImeOperations(mUrlBar, true); - final UrlBar urlBar = getUrlBar(); - toggleFocusAndIgnoreImeOperations(urlBar, true); - - setTextAndVerifyNoAutocomplete(urlBar, "test"); - setAutocomplete(urlBar, "test", "ing is fun"); + setTextAndVerifyNoAutocomplete("test"); + setAutocomplete("test", "ing is fun"); TestThreadUtils.runOnUiThreadBlocking( - () -> { urlBar.getInputConnection().beginBatchEdit(); }); + () -> { mUrlBar.getInputConnection().beginBatchEdit(); }); TestThreadUtils.runOnUiThreadBlocking( - () -> { urlBar.getInputConnection().commitText("y", 1); }); + () -> { mUrlBar.getInputConnection().commitText("y", 1); }); TestThreadUtils.runOnUiThreadBlocking( - () -> { urlBar.getInputConnection().endBatchEdit(); }); + () -> { mUrlBar.getInputConnection().endBatchEdit(); }); CriteriaHelper.pollUiThread(Criteria.equals("testy", new Callable<String>() { @Override @@ -637,6 +575,8 @@ return requestedAutocompleteText.get(); } })); + + mUrlBar.setUrlTextChangeListener(null); } @Test @@ -644,22 +584,18 @@ @Feature("Omnibox") @RetryOnFailure public void testAutocompleteCorrectlyPerservedOnBatchMode() throws InterruptedException { - mActivityTestRule.startMainActivityOnBlankPage(); - stubLocationBarAutocomplete(); - - final UrlBar urlBar = getUrlBar(); - toggleFocusAndIgnoreImeOperations(urlBar, true); - OmniboxTestUtils.waitForFocusAndKeyboardActive(urlBar, true); + toggleFocusAndIgnoreImeOperations(mUrlBar, true); + OmniboxTestUtils.waitForFocusAndKeyboardActive(mUrlBar, true); // Valid case (cursor at the end of text, single character, matches previous autocomplete). - setTextAndVerifyNoAutocomplete(urlBar, "g"); - setAutocomplete(urlBar, "g", "oogle.com"); - AutocompleteState state = getAutocompleteState(urlBar, new Runnable() { + setTextAndVerifyNoAutocomplete("g"); + setAutocomplete("g", "oogle.com"); + AutocompleteState state = getAutocompleteState(new Runnable() { @Override // TODO(crbug.com/635567): Fix this properly. @SuppressLint("SetTextI18n") public void run() { - urlBar.getInputConnection().commitText("o", 1); + mUrlBar.getInputConnection().commitText("o", 1); } }); Assert.assertTrue(state.hasAutocomplete); @@ -667,43 +603,43 @@ Assert.assertEquals("go", state.textWithoutAutocomplete); // Invalid case (cursor not at the end of the text) - setTextAndVerifyNoAutocomplete(urlBar, "g"); - setAutocomplete(urlBar, "g", "oogle.com"); - state = getAutocompleteState(urlBar, new Runnable() { + setTextAndVerifyNoAutocomplete("g"); + setAutocomplete("g", "oogle.com"); + state = getAutocompleteState(new Runnable() { @Override // TODO(crbug.com/635567): Fix this properly. @SuppressLint("SetTextI18n") public void run() { - urlBar.getInputConnection().beginBatchEdit(); - urlBar.getInputConnection().commitText("o", 1); - urlBar.getInputConnection().setSelection(0, 0); - urlBar.getInputConnection().endBatchEdit(); + mUrlBar.getInputConnection().beginBatchEdit(); + mUrlBar.getInputConnection().commitText("o", 1); + mUrlBar.getInputConnection().setSelection(0, 0); + mUrlBar.getInputConnection().endBatchEdit(); } }); Assert.assertFalse(state.hasAutocomplete); // Invalid case (next character did not match previous autocomplete) - setTextAndVerifyNoAutocomplete(urlBar, "g"); - setAutocomplete(urlBar, "g", "oogle.com"); - state = getAutocompleteState(urlBar, new Runnable() { + setTextAndVerifyNoAutocomplete("g"); + setAutocomplete("g", "oogle.com"); + state = getAutocompleteState(new Runnable() { @Override // TODO(crbug.com/635567): Fix this properly. @SuppressLint("SetTextI18n") public void run() { - urlBar.getInputConnection().commitText("a", 1); + mUrlBar.getInputConnection().commitText("a", 1); } }); Assert.assertFalse(state.hasAutocomplete); // Multiple characters entered instead of 1. - setTextAndVerifyNoAutocomplete(urlBar, "g"); - setAutocomplete(urlBar, "g", "oogle.com"); - state = getAutocompleteState(urlBar, new Runnable() { + setTextAndVerifyNoAutocomplete("g"); + setAutocomplete("g", "oogle.com"); + state = getAutocompleteState(new Runnable() { @Override // TODO(crbug.com/635567): Fix this properly. @SuppressLint("SetTextI18n") public void run() { - urlBar.getInputConnection().commitText("oogl", 1); + mUrlBar.getInputConnection().commitText("oogl", 1); } }); if (ChromeFeatureList.isEnabled(ChromeFeatureList.SPANNABLE_INLINE_AUTOCOMPLETE)) { @@ -720,28 +656,23 @@ @Feature("Omnibox") @RetryOnFailure public void testAutocompleteSpanClearedOnNonMatchingCommitText() throws InterruptedException { - mActivityTestRule.startMainActivityOnBlankPage(); + toggleFocusAndIgnoreImeOperations(mUrlBar, true); + OmniboxTestUtils.waitForFocusAndKeyboardActive(mUrlBar, true); - stubLocationBarAutocomplete(); - - final UrlBar urlBar = getUrlBar(); - toggleFocusAndIgnoreImeOperations(urlBar, true); - OmniboxTestUtils.waitForFocusAndKeyboardActive(urlBar, true); - - setTextAndVerifyNoAutocomplete(urlBar, "a"); - setAutocomplete(urlBar, "a", "mazon.com"); + setTextAndVerifyNoAutocomplete("a"); + setAutocomplete("a", "mazon.com"); TestThreadUtils.runOnUiThreadBlocking(() -> { - urlBar.getInputConnection().beginBatchEdit(); - urlBar.getInputConnection().commitText("l", 1); - urlBar.getInputConnection().setComposingText("", 1); - urlBar.getInputConnection().endBatchEdit(); + mUrlBar.getInputConnection().beginBatchEdit(); + mUrlBar.getInputConnection().commitText("l", 1); + mUrlBar.getInputConnection().setComposingText("", 1); + mUrlBar.getInputConnection().endBatchEdit(); }); CriteriaHelper.pollUiThread(Criteria.equals("al", new Callable<String>() { @Override public String call() { - return urlBar.getText().toString(); + return mUrlBar.getText().toString(); } })); } @@ -750,45 +681,24 @@ @SmallTest @Feature({"Omnibox"}) @RetryOnFailure - public void testAutocompleteUpdatedOnDefocus() throws InterruptedException { - mActivityTestRule.startMainActivityOnBlankPage(); - stubLocationBarAutocomplete(); - final UrlBar urlBar = getUrlBar(); - toggleFocusAndIgnoreImeOperations(urlBar, true); - - // Verify that defocusing the UrlBar clears the autocomplete. - setTextAndVerifyNoAutocomplete(urlBar, "test"); - setAutocomplete(urlBar, "test", "ing is fun"); - toggleFocusAndIgnoreImeOperations(urlBar, false); - AutocompleteState state = getAutocompleteState(urlBar, null); - Assert.assertFalse(state.hasAutocomplete); - } - - @Test - @SmallTest - @Feature({"Omnibox"}) - @RetryOnFailure public void testAutocompleteClearedOnComposition() throws InterruptedException, ExecutionException { - mActivityTestRule.startMainActivityOnBlankPage(); - stubLocationBarAutocomplete(); - final UrlBar urlBar = getUrlBar(); - toggleFocusAndIgnoreImeOperations(urlBar, true); - OmniboxTestUtils.waitForFocusAndKeyboardActive(urlBar, true); + toggleFocusAndIgnoreImeOperations(mUrlBar, true); + OmniboxTestUtils.waitForFocusAndKeyboardActive(mUrlBar, true); - setTextAndVerifyNoAutocomplete(urlBar, "test"); - setAutocomplete(urlBar, "test", "ing is fun"); + setTextAndVerifyNoAutocomplete("test"); + setAutocomplete("test", "ing is fun"); - Assert.assertNotNull(urlBar.getInputConnection()); - AutocompleteState state = getAutocompleteState(urlBar, new Runnable() { + Assert.assertNotNull(mUrlBar.getInputConnection()); + AutocompleteState state = getAutocompleteState(new Runnable() { @Override public void run() { - urlBar.getInputConnection().setComposingText("ing compose", 4); + mUrlBar.getInputConnection().setComposingText("ing compose", 4); } }); Assert.assertFalse(state.hasAutocomplete); - Editable urlText = getUrlBarText(urlBar); + Editable urlText = getUrlBarText(); Assert.assertEquals("testing compose", urlText.toString()); // TODO(tedchoc): Investigate why this fails on x86. //assertEquals(4, BaseInputConnection.getComposingSpanStart(urlText)); @@ -802,29 +712,25 @@ @Restriction({RESTRICTION_TYPE_NON_LOW_END_DEVICE}) // crbug.com/635714 public void testDelayedCompositionCorrectedWithAutocomplete() throws InterruptedException, ExecutionException { - mActivityTestRule.startMainActivityOnBlankPage(); - stubLocationBarAutocomplete(); + toggleFocusAndIgnoreImeOperations(mUrlBar, true); + OmniboxTestUtils.waitForFocusAndKeyboardActive(mUrlBar, true); - final UrlBar urlBar = getUrlBar(); - toggleFocusAndIgnoreImeOperations(urlBar, true); - OmniboxTestUtils.waitForFocusAndKeyboardActive(urlBar, true); - - Assert.assertNotNull(urlBar.getInputConnection()); + Assert.assertNotNull(mUrlBar.getInputConnection()); // Test with a single autocomplete - setTextAndVerifyNoAutocomplete(urlBar, "chrome://f"); - setAutocomplete(urlBar, "chrome://f", "lags"); + setTextAndVerifyNoAutocomplete("chrome://f"); + setAutocomplete("chrome://f", "lags"); - AutocompleteState state = getAutocompleteState(urlBar, new Runnable() { + AutocompleteState state = getAutocompleteState(new Runnable() { @Override public void run() { - urlBar.getInputConnection().setComposingRegion(13, 14); - urlBar.getInputConnection().setComposingText("f", 1); + mUrlBar.getInputConnection().setComposingRegion(13, 14); + mUrlBar.getInputConnection().setComposingText("f", 1); } }); - Editable urlText = getUrlBarText(urlBar); + Editable urlText = getUrlBarText(); if (ChromeFeatureList.isEnabled(ChromeFeatureList.SPANNABLE_INLINE_AUTOCOMPLETE)) { // Note: the new model hides autocomplete text from IME. // setComposingRegion fails because autocomplete is hidden from IME. In reality, IME @@ -842,17 +748,17 @@ // Test with > 1 characters in composition. - setTextAndVerifyNoAutocomplete(urlBar, "chrome://fl"); - setAutocomplete(urlBar, "chrome://fl", "ags"); + setTextAndVerifyNoAutocomplete("chrome://fl"); + setAutocomplete("chrome://fl", "ags"); - state = getAutocompleteState(urlBar, new Runnable() { + state = getAutocompleteState(new Runnable() { @Override public void run() { - urlBar.getInputConnection().setComposingRegion(12, 14); - urlBar.getInputConnection().setComposingText("fl", 1); + mUrlBar.getInputConnection().setComposingRegion(12, 14); + mUrlBar.getInputConnection().setComposingText("fl", 1); } }); - urlText = getUrlBarText(urlBar); + urlText = getUrlBarText(); if (ChromeFeatureList.isEnabled(ChromeFeatureList.SPANNABLE_INLINE_AUTOCOMPLETE)) { // Note: the new model hides autocomplete text from IME. @@ -871,36 +777,36 @@ // Test with non-matching composition. Should just append to the URL text. - setTextAndVerifyNoAutocomplete(urlBar, "chrome://f"); - setAutocomplete(urlBar, "chrome://f", "lags"); + setTextAndVerifyNoAutocomplete("chrome://f"); + setAutocomplete("chrome://f", "lags"); - state = getAutocompleteState(urlBar, new Runnable() { + state = getAutocompleteState(new Runnable() { @Override public void run() { - urlBar.getInputConnection().setComposingRegion(13, 14); - urlBar.getInputConnection().setComposingText("g", 1); + mUrlBar.getInputConnection().setComposingRegion(13, 14); + mUrlBar.getInputConnection().setComposingText("g", 1); } }); Assert.assertFalse(state.hasAutocomplete); - urlText = getUrlBarText(urlBar); + urlText = getUrlBarText(); Assert.assertEquals("chrome://fg", urlText.toString()); Assert.assertEquals(BaseInputConnection.getComposingSpanStart(urlText), 10); Assert.assertEquals(BaseInputConnection.getComposingSpanEnd(urlText), 11); // Test with composition text that matches the entire text w/o autocomplete. - setTextAndVerifyNoAutocomplete(urlBar, "chrome://f"); - setAutocomplete(urlBar, "chrome://f", "lags"); + setTextAndVerifyNoAutocomplete("chrome://f"); + setAutocomplete("chrome://f", "lags"); - state = getAutocompleteState(urlBar, new Runnable() { + state = getAutocompleteState(new Runnable() { @Override public void run() { - urlBar.getInputConnection().setComposingRegion(13, 14); - urlBar.getInputConnection().setComposingText("chrome://f", 1); + mUrlBar.getInputConnection().setComposingRegion(13, 14); + mUrlBar.getInputConnection().setComposingText("chrome://f", 1); } }); - urlText = getUrlBarText(urlBar); + urlText = getUrlBarText(); if (ChromeFeatureList.isEnabled(ChromeFeatureList.SPANNABLE_INLINE_AUTOCOMPLETE)) { // Note: the new model hides autocomplete text from IME. // setComposingRegion fails because autocomplete is hidden from IME. In reality, IME @@ -919,137 +825,21 @@ // Test with composition text longer than the URL text. Shouldn't crash and should // just append text. - setTextAndVerifyNoAutocomplete(urlBar, "chrome://f"); - setAutocomplete(urlBar, "chrome://f", "lags"); + setTextAndVerifyNoAutocomplete("chrome://f"); + setAutocomplete("chrome://f", "lags"); - state = getAutocompleteState(urlBar, new Runnable() { + state = getAutocompleteState(new Runnable() { @Override public void run() { - urlBar.getInputConnection().setComposingRegion(13, 14); - urlBar.getInputConnection().setComposingText("blahblahblah", 1); + mUrlBar.getInputConnection().setComposingRegion(13, 14); + mUrlBar.getInputConnection().setComposingText("blahblahblah", 1); } }); Assert.assertFalse(state.hasAutocomplete); - urlText = getUrlBarText(urlBar); + urlText = getUrlBarText(); Assert.assertEquals("chrome://fblahblahblah", urlText.toString()); Assert.assertEquals(BaseInputConnection.getComposingSpanStart(urlText), 10); Assert.assertEquals(BaseInputConnection.getComposingSpanEnd(urlText), 22); } - - /** - * Test to verify the omnibox can take focus during startup before native libraries have - * loaded. - */ - @Test - @SmallTest - @Feature({"Omnibox"}) - @RetryOnFailure - public void testFocusingOnStartup() { - Intent intent = new Intent(Intent.ACTION_MAIN); - intent.addCategory(Intent.CATEGORY_LAUNCHER); - mActivityTestRule.prepareUrlIntent(intent, "about:blank"); - mActivityTestRule.startActivityCompletely(intent); - - UrlBar urlBar = getUrlBar(); - Assert.assertNotNull(urlBar); - toggleFocusAndIgnoreImeOperations(urlBar, true); - OmniboxTestUtils.waitForFocusAndKeyboardActive(urlBar, true); - } - - @Test - @SmallTest - @Feature({"Omnibox"}) - @RetryOnFailure - public void testCopyHuge() throws InterruptedException { - mActivityTestRule.startMainActivityWithURL(HUGE_URL); - toggleFocusAndIgnoreImeOperations(getUrlBar(), true); - Assert.assertEquals(HUGE_URL, copyUrlToClipboard(android.R.id.copy)); - } - - @Test - @SmallTest - @Feature({"Omnibox"}) - @RetryOnFailure - public void testCutHuge() throws InterruptedException { - mActivityTestRule.startMainActivityWithURL(HUGE_URL); - toggleFocusAndIgnoreImeOperations(getUrlBar(), true); - Assert.assertEquals(HUGE_URL, copyUrlToClipboard(android.R.id.cut)); - } - - /** - * Clears the clipboard, executes specified action on the omnibox and - * returns clipboard's content. Action can be either android.R.id.copy - * or android.R.id.cut. - */ - private String copyUrlToClipboard(final int action) { - return TestThreadUtils.runOnUiThreadBlockingNoException(new Callable<String>() { - @Override - public String call() { - ClipboardManager clipboardManager = - (ClipboardManager) mActivityTestRule.getActivity().getSystemService( - Context.CLIPBOARD_SERVICE); - - clipboardManager.setPrimaryClip(ClipData.newPlainText(null, "")); - - Assert.assertTrue(getUrlBar().onTextContextMenuItem(action)); - ClipData clip = clipboardManager.getPrimaryClip(); - CharSequence text = (clip != null && clip.getItemCount() != 0) - ? clip.getItemAt(0).getText() - : null; - return text != null ? text.toString() : null; - } - }); - } - - @Test - @SmallTest - @Feature({"Omnibox"}) - @RetryOnFailure - public void testLongPress() throws InterruptedException { - // This is a more realistic test than HUGE_URL because ita's full of separator characters - // which have historically been known to trigger odd behavior with long-pressing. - final String longPressUrl = "data:text/plain,hi.hi.hi.hi.hi.hi.hi.hi.hi.hi/hi/hi/hi/hi/hi/"; - mActivityTestRule.startMainActivityWithURL(longPressUrl); - - class ActionModeCreatedCallback implements ActionMode.Callback { - public boolean actionModeCreated; - - @Override - public boolean onActionItemClicked(ActionMode mode, MenuItem item) { - return false; - } - - @Override - public boolean onCreateActionMode(ActionMode mode, Menu menu) { - actionModeCreated = true; - return true; - } - - @Override - public void onDestroyActionMode(ActionMode mode) {} - - @Override - public boolean onPrepareActionMode(ActionMode mode, Menu menu) { - return false; - } - } - ActionModeCreatedCallback callback = new ActionModeCreatedCallback(); - getUrlBar().setCustomSelectionActionModeCallback(callback); - - TouchCommon.longPressView(getUrlBar()); - - CriteriaHelper.pollUiThread(new Criteria() { - @Override - public boolean isSatisfied() { - return callback.actionModeCreated && getUrlBar().getSelectionStart() == 0 - && getUrlBar().getSelectionEnd() == longPressUrl.length(); - } - }); - } - - @Before - public void setUp() throws InterruptedException { - // Each test will start the activity. - } }
diff --git a/chrome/app/onboarding_welcome_strings.grdp b/chrome/app/onboarding_welcome_strings.grdp index 55845f3d..e4a5883 100644 --- a/chrome/app/onboarding_welcome_strings.grdp +++ b/chrome/app/onboarding_welcome_strings.grdp
@@ -29,11 +29,6 @@ Chrome is your default browser </message> - <!-- NUX email provider selection module --> - <message name="IDS_ONBOARDING_WELCOME_NUX_EMAIL_TITLE" desc="Text shown to prompt the users to select an email service to add as bookmark."> - Add a bookmark to your email - </message> - <!-- NUX Google apps selection module --> <message name="IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_DESCRIPTION" desc="Description of what this section in the onboarding workflow does."> Add bookmarks to your favorite Google Apps
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 7df20f2..37a74748 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn
@@ -1095,6 +1095,8 @@ "performance_manager/performance_manager_tab_helper.h", "performance_manager/render_process_user_data.cc", "performance_manager/render_process_user_data.h", + "performance_manager/web_contents_proxy.cc", + "performance_manager/web_contents_proxy.h", "performance_manager/webui_graph_dump_impl.cc", "performance_manager/webui_graph_dump_impl.h", "performance_monitor/metric_evaluator_helper_win.cc", @@ -1372,6 +1374,8 @@ "profiles/profile_info_interface.h", "profiles/profile_io_data.cc", "profiles/profile_io_data.h", + "profiles/profile_key.cc", + "profiles/profile_key.h", "profiles/profile_manager.cc", "profiles/profile_manager.h", "profiles/profile_metrics.cc",
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 2f69ec0d..5459fde 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc
@@ -2522,6 +2522,11 @@ flag_descriptions::kOmniboxPedalSuggestionsName, flag_descriptions::kOmniboxPedalSuggestionsDescription, kOsDesktop, FEATURE_VALUE_TYPE(omnibox::kOmniboxPedalSuggestions)}, + {"omnibox-suggestion-transparency-options", + flag_descriptions::kOmniboxSuggestionTransparencyOptionsName, + flag_descriptions::kOmniboxSuggestionTransparencyOptionsDescription, + kOsAll, + FEATURE_VALUE_TYPE(omnibox::kOmniboxSuggestionTransparencyOptions)}, {"omnibox-drive-suggestions", flag_descriptions::kOmniboxDriveSuggestionsName, flag_descriptions::kOmniboxDriveSuggestionsDescriptions, kOsDesktop, @@ -2861,6 +2866,11 @@ {"remove-ntp-fakebox", flag_descriptions::kRemoveNtpFakeboxName, flag_descriptions::kRemoveNtpFakeboxDescription, kOsDesktop, FEATURE_VALUE_TYPE(features::kRemoveNtpFakebox)}, + + {"ntp-customization-menu-v2", + flag_descriptions::kNtpCustomizationMenuV2Name, + flag_descriptions::kNtpCustomizationMenuV2Description, kOsDesktop, + FEATURE_VALUE_TYPE(features::kNtpCustomizationMenuV2)}, #endif // !defined(OS_ANDROID) #if defined(DCHECK_IS_CONFIGURABLE) @@ -3955,6 +3965,12 @@ flag_descriptions::kInSessionPasswordChangeName, flag_descriptions::kInSessionPasswordChangeDescription, kOsCrOS, FEATURE_VALUE_TYPE(features::kInSessionPasswordChange)}, + + {"enable-streamlined-usb-printer-setup", + flag_descriptions::kStreamlinedUsbPrinterSetupName, + flag_descriptions::kStreamlinedUsbPrinterSetupDescription, kOsCrOS, + FEATURE_VALUE_TYPE(features::kStreamlinedUsbPrinterSetup)}, + #endif // OS_CHROMEOS {"autofill-off-no-server-data",
diff --git a/chrome/browser/android/compositor/layer/contextual_search_layer.cc b/chrome/browser/android/compositor/layer/contextual_search_layer.cc index bedd6415..89bd4ebd 100644 --- a/chrome/browser/android/compositor/layer/contextual_search_layer.cc +++ b/chrome/browser/android/compositor/layer/contextual_search_layer.cc
@@ -305,61 +305,13 @@ // --------------------------------------------------------------------------- // Progress Bar // --------------------------------------------------------------------------- - if (should_render_progress_bar) { - // Grabs Progress Bar resources. - ui::NinePatchResource* progress_bar_background_resource = - ui::NinePatchResource::From(resource_manager_->GetResource( - ui::ANDROID_RESOURCE_TYPE_STATIC, - progress_bar_background_resource_id)); - ui::NinePatchResource* progress_bar_resource = - ui::NinePatchResource::From(resource_manager_->GetResource( - ui::ANDROID_RESOURCE_TYPE_STATIC, progress_bar_resource_id)); - - DCHECK(progress_bar_background_resource); - DCHECK(progress_bar_resource); - - // Progress Bar Background - if (progress_bar_background_->parent() != layer_) - layer_->AddChild(progress_bar_background_); - - float progress_bar_y = search_bar_bottom - progress_bar_height; - gfx::Size progress_bar_background_size(search_panel_width, - progress_bar_height); - - progress_bar_background_->SetUIResourceId( - progress_bar_background_resource->ui_resource()->id()); - progress_bar_background_->SetBorder( - progress_bar_background_resource->Border(progress_bar_background_size)); - progress_bar_background_->SetAperture( - progress_bar_background_resource->aperture()); - progress_bar_background_->SetBounds(progress_bar_background_size); - progress_bar_background_->SetPosition(gfx::PointF(0.f, progress_bar_y)); - progress_bar_background_->SetOpacity(progress_bar_opacity); - - // Progress Bar - if (progress_bar_->parent() != layer_) - layer_->AddChild(progress_bar_); - - float progress_bar_width = - floor(search_panel_width * progress_bar_completion / 100.f); - gfx::Size progress_bar_size(progress_bar_width, progress_bar_height); - progress_bar_->SetUIResourceId(progress_bar_resource->ui_resource()->id()); - progress_bar_->SetBorder(progress_bar_resource->Border(progress_bar_size)); - progress_bar_->SetAperture(progress_bar_resource->aperture()); - progress_bar_->SetBounds(progress_bar_size); - progress_bar_->SetPosition(gfx::PointF(0.f, progress_bar_y)); - progress_bar_->SetOpacity(progress_bar_opacity); - } else { - // Removes Progress Bar and its Background from the Layer Tree. - if (progress_bar_background_.get() && progress_bar_background_->parent()) - progress_bar_background_->RemoveFromParent(); - - if (progress_bar_.get() && progress_bar_->parent()) - progress_bar_->RemoveFromParent(); - } + OverlayPanelLayer::SetProgressBar( + progress_bar_background_resource_id, progress_bar_resource_id, + progress_bar_visible, search_bar_bottom, progress_bar_height, + progress_bar_opacity, progress_bar_completion, search_panel_width); // --------------------------------------------------------------------------- - // Divider Line + // Divider Line separator // --------------------------------------------------------------------------- if (divider_line_visibility_percentage > 0.f) { if (divider_line_->parent() != layer_) @@ -726,8 +678,6 @@ bar_banner_container_(cc::SolidColorLayer::Create()), bar_banner_ripple_(cc::NinePatchLayer::Create()), bar_banner_text_(cc::UIResourceLayer::Create()), - progress_bar_(cc::NinePatchLayer::Create()), - progress_bar_background_(cc::NinePatchLayer::Create()), search_caption_(cc::UIResourceLayer::Create()), text_layer_(cc::UIResourceLayer::Create()), divider_line_(cc::SolidColorLayer::Create()), @@ -756,14 +706,6 @@ search_promo_container_->SetBackgroundColor(kSearchBackgroundColor); search_promo_->SetIsDrawable(true); - // Progress Bar Background - progress_bar_background_->SetIsDrawable(true); - progress_bar_background_->SetFillCenter(true); - - // Progress Bar - progress_bar_->SetIsDrawable(true); - progress_bar_->SetFillCenter(true); - // Icon - holds thumbnail, search provider icon and/or quick action icon icon_layer_->SetIsDrawable(true); layer_->AddChild(icon_layer_);
diff --git a/chrome/browser/android/compositor/layer/contextual_search_layer.h b/chrome/browser/android/compositor/layer/contextual_search_layer.h index c45ae4b..1d1abb6 100644 --- a/chrome/browser/android/compositor/layer/contextual_search_layer.h +++ b/chrome/browser/android/compositor/layer/contextual_search_layer.h
@@ -144,8 +144,6 @@ scoped_refptr<cc::SolidColorLayer> bar_banner_container_; scoped_refptr<cc::NinePatchLayer> bar_banner_ripple_; scoped_refptr<cc::UIResourceLayer> bar_banner_text_; - scoped_refptr<cc::NinePatchLayer> progress_bar_; - scoped_refptr<cc::NinePatchLayer> progress_bar_background_; scoped_refptr<cc::UIResourceLayer> search_caption_; scoped_refptr<cc::UIResourceLayer> text_layer_; scoped_refptr<cc::SolidColorLayer> divider_line_;
diff --git a/chrome/browser/android/compositor/layer/ephemeral_tab_layer.cc b/chrome/browser/android/compositor/layer/ephemeral_tab_layer.cc index f13cb29..e9984b82 100644 --- a/chrome/browser/android/compositor/layer/ephemeral_tab_layer.cc +++ b/chrome/browser/android/compositor/layer/ephemeral_tab_layer.cc
@@ -49,8 +49,6 @@ bar_height = floor(bar_height); float bar_top = 0.f; float bar_bottom = bar_top + bar_height; - bool should_render_progress_bar = - progress_bar_visible && progress_bar_opacity > 0.f; // Title needs no rendering in the base layer as it can be rendered // together with caption below. Make it invisible. @@ -66,60 +64,10 @@ caption_visible, title_view_resource_id, title_caption_spacing); - // --------------------------------------------------------------------------- - // Progress Bar - // --------------------------------------------------------------------------- - - if (should_render_progress_bar) { - ui::NinePatchResource* progress_bar_background_resource = - ui::NinePatchResource::From(resource_manager_->GetResource( - ui::ANDROID_RESOURCE_TYPE_STATIC, - progress_bar_background_resource_id)); - ui::NinePatchResource* progress_bar_resource = - ui::NinePatchResource::From(resource_manager_->GetResource( - ui::ANDROID_RESOURCE_TYPE_STATIC, progress_bar_resource_id)); - - DCHECK(progress_bar_background_resource); - DCHECK(progress_bar_resource); - - // Progress Bar Background - if (progress_bar_background_->parent() != layer_) - layer_->AddChild(progress_bar_background_); - - float progress_bar_y = bar_bottom - progress_bar_height; - gfx::Size progress_bar_background_size(panel_width, progress_bar_height); - - progress_bar_background_->SetUIResourceId( - progress_bar_background_resource->ui_resource()->id()); - progress_bar_background_->SetBorder( - progress_bar_background_resource->Border(progress_bar_background_size)); - progress_bar_background_->SetAperture( - progress_bar_background_resource->aperture()); - progress_bar_background_->SetBounds(progress_bar_background_size); - progress_bar_background_->SetPosition(gfx::PointF(0.f, progress_bar_y)); - progress_bar_background_->SetOpacity(progress_bar_opacity); - - // Progress Bar - if (progress_bar_->parent() != layer_) - layer_->AddChild(progress_bar_); - - float progress_bar_width = - floor(panel_width * progress_bar_completion / 100.f); - gfx::Size progress_bar_size(progress_bar_width, progress_bar_height); - progress_bar_->SetUIResourceId(progress_bar_resource->ui_resource()->id()); - progress_bar_->SetBorder(progress_bar_resource->Border(progress_bar_size)); - progress_bar_->SetAperture(progress_bar_resource->aperture()); - progress_bar_->SetBounds(progress_bar_size); - progress_bar_->SetPosition(gfx::PointF(0.f, progress_bar_y)); - progress_bar_->SetOpacity(progress_bar_opacity); - } else { - // Removes Progress Bar and its Background from the Layer Tree. - if (progress_bar_background_.get() && progress_bar_background_->parent()) - progress_bar_background_->RemoveFromParent(); - - if (progress_bar_.get() && progress_bar_->parent()) - progress_bar_->RemoveFromParent(); - } + OverlayPanelLayer::SetProgressBar( + progress_bar_background_resource_id, progress_bar_resource_id, + progress_bar_visible, bar_bottom, progress_bar_height, + progress_bar_opacity, progress_bar_completion, panel_width); } void EphemeralTabLayer::SetupTextLayer(float bar_top, @@ -237,14 +185,7 @@ : OverlayPanelLayer(resource_manager), title_(cc::UIResourceLayer::Create()), caption_(cc::UIResourceLayer::Create()), - text_layer_(cc::UIResourceLayer::Create()), - progress_bar_(cc::NinePatchLayer::Create()), - progress_bar_background_(cc::NinePatchLayer::Create()) { - progress_bar_background_->SetIsDrawable(true); - progress_bar_background_->SetFillCenter(true); - progress_bar_->SetIsDrawable(true); - progress_bar_->SetFillCenter(true); - + text_layer_(cc::UIResourceLayer::Create()) { // Content layer text_layer_->SetIsDrawable(true);
diff --git a/chrome/browser/android/compositor/layer/ephemeral_tab_layer.h b/chrome/browser/android/compositor/layer/ephemeral_tab_layer.h index c0d864b..0efb300 100644 --- a/chrome/browser/android/compositor/layer/ephemeral_tab_layer.h +++ b/chrome/browser/android/compositor/layer/ephemeral_tab_layer.h
@@ -11,7 +11,6 @@ namespace cc { class Layer; -class NinePatchLayer; } // namespace cc namespace ui { @@ -66,8 +65,6 @@ scoped_refptr<cc::UIResourceLayer> title_; scoped_refptr<cc::UIResourceLayer> caption_; scoped_refptr<cc::UIResourceLayer> text_layer_; - scoped_refptr<cc::NinePatchLayer> progress_bar_; - scoped_refptr<cc::NinePatchLayer> progress_bar_background_; }; } // namespace android
diff --git a/chrome/browser/android/compositor/layer/overlay_panel_layer.cc b/chrome/browser/android/compositor/layer/overlay_panel_layer.cc index 3bdc50b..7f40435 100644 --- a/chrome/browser/android/compositor/layer/overlay_panel_layer.cc +++ b/chrome/browser/android/compositor/layer/overlay_panel_layer.cc
@@ -246,6 +246,69 @@ } } +void OverlayPanelLayer::SetProgressBar(int progress_bar_background_resource_id, + int progress_bar_resource_id, + bool progress_bar_visible, + float progress_bar_position_y, + float progress_bar_height, + float progress_bar_opacity, + int progress_bar_completion, + float panel_width) { + bool should_render_progress_bar = + progress_bar_visible && progress_bar_opacity > 0.f; + + if (should_render_progress_bar) { + ui::NinePatchResource* progress_bar_background_resource = + ui::NinePatchResource::From(resource_manager_->GetResource( + ui::ANDROID_RESOURCE_TYPE_STATIC, + progress_bar_background_resource_id)); + ui::NinePatchResource* progress_bar_resource = + ui::NinePatchResource::From(resource_manager_->GetResource( + ui::ANDROID_RESOURCE_TYPE_STATIC, progress_bar_resource_id)); + + DCHECK(progress_bar_background_resource); + DCHECK(progress_bar_resource); + + // Progress Bar Background + if (progress_bar_background_->parent() != layer_) + layer_->AddChild(progress_bar_background_); + + float progress_bar_y = progress_bar_position_y - progress_bar_height; + gfx::Size progress_bar_background_size(panel_width, progress_bar_height); + + progress_bar_background_->SetUIResourceId( + progress_bar_background_resource->ui_resource()->id()); + progress_bar_background_->SetBorder( + progress_bar_background_resource->Border(progress_bar_background_size)); + progress_bar_background_->SetAperture( + progress_bar_background_resource->aperture()); + progress_bar_background_->SetBounds(progress_bar_background_size); + progress_bar_background_->SetPosition(gfx::PointF(0.f, progress_bar_y)); + progress_bar_background_->SetOpacity(progress_bar_opacity); + + // Progress Bar + if (progress_bar_->parent() != layer_) + layer_->AddChild(progress_bar_); + + float progress_bar_width = + floor(panel_width * progress_bar_completion / 100.f); + gfx::Size progress_bar_size(progress_bar_width, progress_bar_height); + progress_bar_->SetUIResourceId(progress_bar_resource->ui_resource()->id()); + progress_bar_->SetBorder(progress_bar_resource->Border(progress_bar_size)); + progress_bar_->SetAperture(progress_bar_resource->aperture()); + progress_bar_->SetBounds(progress_bar_size); + progress_bar_->SetPosition(gfx::PointF(0.f, progress_bar_y)); + progress_bar_->SetOpacity(progress_bar_opacity); + } else { + // Removes Progress Bar and its Background from the Layer Tree. + if (progress_bar_background_.get() && progress_bar_background_->parent()) + progress_bar_background_->RemoveFromParent(); + + if (progress_bar_.get() && progress_bar_->parent()) + progress_bar_->RemoveFromParent(); + } +} + OverlayPanelLayer::OverlayPanelLayer(ui::ResourceManager* resource_manager) : resource_manager_(resource_manager), layer_(cc::Layer::Create()), @@ -257,7 +320,9 @@ close_icon_(cc::UIResourceLayer::Create()), content_container_(cc::SolidColorLayer::Create()), text_container_(cc::Layer::Create()), - bar_border_(cc::SolidColorLayer::Create()) { + bar_border_(cc::SolidColorLayer::Create()), + progress_bar_(cc::NinePatchLayer::Create()), + progress_bar_background_(cc::NinePatchLayer::Create()) { layer_->SetMasksToBounds(false); layer_->SetIsDrawable(true); @@ -297,6 +362,14 @@ // Bar Shadow bar_shadow_->SetIsDrawable(true); + + // Progress Bar Background + progress_bar_background_->SetIsDrawable(true); + progress_bar_background_->SetFillCenter(true); + + // Progress Bar + progress_bar_->SetIsDrawable(true); + progress_bar_->SetFillCenter(true); } OverlayPanelLayer::~OverlayPanelLayer() {
diff --git a/chrome/browser/android/compositor/layer/overlay_panel_layer.h b/chrome/browser/android/compositor/layer/overlay_panel_layer.h index 51feac2d..dfe2719 100644 --- a/chrome/browser/android/compositor/layer/overlay_panel_layer.h +++ b/chrome/browser/android/compositor/layer/overlay_panel_layer.h
@@ -49,6 +49,15 @@ int icon_tint, float close_icon_opacity); + void SetProgressBar(int progress_bar_background_resource_id, + int progress_bar_resource_id, + bool progress_bar_visible, + float progress_bar_position_y, + float progress_bar_height, + float progress_bar_opacity, + int progress_bar_completion, + float panel_width); + scoped_refptr<cc::Layer> layer() override; protected: @@ -70,6 +79,8 @@ scoped_refptr<cc::Layer> content_container_; scoped_refptr<cc::Layer> text_container_; scoped_refptr<cc::SolidColorLayer> bar_border_; + scoped_refptr<cc::NinePatchLayer> progress_bar_; + scoped_refptr<cc::NinePatchLayer> progress_bar_background_; int panel_icon_resource_id_; int bar_text_resource_id_;
diff --git a/chrome/browser/android/image_fetcher/image_fetcher_bridge.cc b/chrome/browser/android/image_fetcher/image_fetcher_bridge.cc index 929dcce..f7b21fa 100644 --- a/chrome/browser/android/image_fetcher/image_fetcher_bridge.cc +++ b/chrome/browser/android/image_fetcher/image_fetcher_bridge.cc
@@ -64,13 +64,13 @@ jlong JNI_ImageFetcherBridge_Init(JNIEnv* j_env, const JavaParamRef<jobject>& j_profile) { Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile); - SimpleFactoryKey* simple_factory_key = profile->GetSimpleFactoryKey(); + SimpleFactoryKey* simple_factory_key = profile->GetProfileKey(); base::FilePath file_path = ImageFetcherServiceFactory::GetCachePath(simple_factory_key) .Append(kPathPostfix); - ImageFetcherService* if_service = ImageFetcherServiceFactory::GetForKey( - simple_factory_key, profile->GetPrefs()); + ImageFetcherService* if_service = + ImageFetcherServiceFactory::GetForKey(simple_factory_key); ImageFetcherBridge* native_if_bridge = new ImageFetcherBridge(if_service, file_path);
diff --git a/chrome/browser/android/signin/signin_manager_android_unittest.cc b/chrome/browser/android/signin/signin_manager_android_unittest.cc index 14cfc70..e9bd83e 100644 --- a/chrome/browser/android/signin/signin_manager_android_unittest.cc +++ b/chrome/browser/android/signin/signin_manager_android_unittest.cc
@@ -74,8 +74,7 @@ // Creating a BookmarkModel also a creates a StubOfflinePageModel. // We need to replace this with a mock that responds to deletions. offline_pages::OfflinePageModelFactory::GetInstance()->SetTestingFactory( - profile_->GetSimpleFactoryKey(), - base::BindRepeating(&BuildOfflinePageModel)); + profile_->GetProfileKey(), base::BindRepeating(&BuildOfflinePageModel)); bookmarks::BookmarkModel* bookmark_model = BookmarkModelFactory::GetForBrowserContext(profile_); bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model);
diff --git a/chrome/browser/android/usage_stats/usage_stats_database.cc b/chrome/browser/android/usage_stats/usage_stats_database.cc index 5a99102..b352fd9 100644 --- a/chrome/browser/android/usage_stats/usage_stats_database.cc +++ b/chrome/browser/android/usage_stats/usage_stats_database.cc
@@ -38,8 +38,8 @@ suspension_db_initialized_(false), token_mapping_db_initialized_(false), weak_ptr_factory_(this) { - ProtoDatabaseProvider* db_provider = ProtoDatabaseProviderFactory::GetForKey( - profile->GetSimpleFactoryKey(), profile->GetPrefs()); + ProtoDatabaseProvider* db_provider = + ProtoDatabaseProviderFactory::GetForKey(profile->GetProfileKey()); base::FilePath usage_stats_dir = profile->GetPath().Append(kNamespace);
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index ef90d1fe..05efbfc 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd
@@ -571,22 +571,22 @@ <include name="IDR_SET_AS_DEFAULT_BROWSER_HTML" file="resources\set_as_default_browser.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> </if> <if expr="not is_android and not chromeos"> - <include name="IDR_MD_CONTROL_BAR_HTML" file="resources\md_user_manager\control_bar.html" type="BINDATA" /> - <include name="IDR_MD_CONTROL_BAR_JS" file="resources\md_user_manager\control_bar.js" type="BINDATA" /> - <include name="IDR_MD_CREATE_PROFILE_HTML" file="resources\md_user_manager\create_profile.html" type="BINDATA" /> - <include name="IDR_MD_CREATE_PROFILE_JS" file="resources\md_user_manager\create_profile.js" type="BINDATA" /> - <include name="IDR_MD_ERROR_DIALOG_HTML" file="resources\md_user_manager\error_dialog.html" type="BINDATA" /> - <include name="IDR_MD_ERROR_DIALOG_JS" file="resources\md_user_manager\error_dialog.js" type="BINDATA" /> - <include name="IDR_MD_PROFILE_BROWSER_PROXY_HTML" file="resources\md_user_manager\profile_browser_proxy.html" type="BINDATA" /> - <include name="IDR_MD_PROFILE_BROWSER_PROXY_JS" file="resources\md_user_manager\profile_browser_proxy.js" type="BINDATA" /> - <include name="IDR_MD_USER_MANAGER_HTML" file="resources\md_user_manager\user_manager.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> - <include name="IDR_MD_USER_MANAGER_JS" file="resources\md_user_manager\user_manager.js" flattenhtml="true" type="BINDATA" /> - <include name="IDR_MD_USER_MANAGER_PAGES_HTML" file="resources\md_user_manager\user_manager_pages.html" type="BINDATA" /> - <include name="IDR_MD_USER_MANAGER_PAGES_JS" file="resources\md_user_manager\user_manager_pages.js" type="BINDATA" /> - <include name="IDR_MD_USER_MANAGER_SHARED_STYLES_HTML" file="resources\md_user_manager\shared_styles.html" flattenhtml="true" type="BINDATA" /> - <include name="IDR_MD_USER_MANAGER_STRINGS_HTML" file="resources\md_user_manager\strings.html" type="BINDATA" /> - <include name="IDR_MD_USER_MANAGER_TUTORIAL_HTML" file="resources\md_user_manager\user_manager_tutorial.html" type="BINDATA" /> - <include name="IDR_MD_USER_MANAGER_TUTORIAL_JS" file="resources\md_user_manager\user_manager_tutorial.js" type="BINDATA" /> + <include name="IDR_CONTROL_BAR_HTML" file="resources\user_manager\control_bar.html" type="BINDATA" /> + <include name="IDR_CONTROL_BAR_JS" file="resources\user_manager\control_bar.js" type="BINDATA" /> + <include name="IDR_CREATE_PROFILE_HTML" file="resources\user_manager\create_profile.html" type="BINDATA" /> + <include name="IDR_CREATE_PROFILE_JS" file="resources\user_manager\create_profile.js" type="BINDATA" /> + <include name="IDR_ERROR_DIALOG_HTML" file="resources\user_manager\error_dialog.html" type="BINDATA" /> + <include name="IDR_ERROR_DIALOG_JS" file="resources\user_manager\error_dialog.js" type="BINDATA" /> + <include name="IDR_PROFILE_BROWSER_PROXY_HTML" file="resources\user_manager\profile_browser_proxy.html" type="BINDATA" /> + <include name="IDR_PROFILE_BROWSER_PROXY_JS" file="resources\user_manager\profile_browser_proxy.js" type="BINDATA" /> + <include name="IDR_USER_MANAGER_HTML" file="resources\user_manager\user_manager.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> + <include name="IDR_USER_MANAGER_JS" file="resources\user_manager\user_manager.js" flattenhtml="true" type="BINDATA" /> + <include name="IDR_USER_MANAGER_PAGES_HTML" file="resources\user_manager\user_manager_pages.html" type="BINDATA" /> + <include name="IDR_USER_MANAGER_PAGES_JS" file="resources\user_manager\user_manager_pages.js" type="BINDATA" /> + <include name="IDR_USER_MANAGER_SHARED_STYLES_HTML" file="resources\user_manager\shared_styles.html" flattenhtml="true" type="BINDATA" /> + <include name="IDR_USER_MANAGER_STRINGS_HTML" file="resources\user_manager\strings.html" type="BINDATA" /> + <include name="IDR_USER_MANAGER_TUTORIAL_HTML" file="resources\user_manager\user_manager_tutorial.html" type="BINDATA" /> + <include name="IDR_USER_MANAGER_TUTORIAL_JS" file="resources\user_manager\user_manager_tutorial.js" type="BINDATA" /> </if> <if expr="not is_android"> <include name="IDR_IDENTITY_INTERNALS_HTML" file="resources\identity_internals\identity_internals.html" type="BINDATA" />
diff --git a/chrome/browser/chromeos/BUILD.gn b/chrome/browser/chromeos/BUILD.gn index d8cd1ae8..b505f19 100644 --- a/chrome/browser/chromeos/BUILD.gn +++ b/chrome/browser/chromeos/BUILD.gn
@@ -2169,6 +2169,8 @@ "login/screens/mock_welcome_screen.h", "login/screens/recommend_apps/fake_recommend_apps_fetcher_delegate.cc", "login/screens/recommend_apps/fake_recommend_apps_fetcher_delegate.h", + "login/test/help_app_test_helper.cc", + "login/test/help_app_test_helper.h", "login/test/test_condition_waiter.h", "login/test/test_predicate_waiter.cc", "login/test/test_predicate_waiter.h",
diff --git a/chrome/browser/chromeos/arc/notification/arc_supervision_transition_notification_unittest.cc b/chrome/browser/chromeos/arc/notification/arc_supervision_transition_notification_unittest.cc index 69078298..e79a240 100644 --- a/chrome/browser/chromeos/arc/notification/arc_supervision_transition_notification_unittest.cc +++ b/chrome/browser/chromeos/arc/notification/arc_supervision_transition_notification_unittest.cc
@@ -68,7 +68,6 @@ TEST_P(ArcSupervisionTransitionNotificationTest, BaseFlow) { ASSERT_TRUE(arc_app_test()->fake_apps().size()); - arc_app_test()->app_instance()->RefreshAppList(); arc_app_test()->app_instance()->SendRefreshAppList( arc_app_test()->fake_apps()); const std::string app_id =
diff --git a/chrome/browser/chromeos/login/eula_browsertest.cc b/chrome/browser/chromeos/login/eula_browsertest.cc index 8092a60..4f4fef1 100644 --- a/chrome/browser/chromeos/login/eula_browsertest.cc +++ b/chrome/browser/chromeos/login/eula_browsertest.cc
@@ -8,17 +8,29 @@ #include <utility> #include "base/bind.h" +#include "base/callback.h" #include "base/macros.h" #include "base/run_loop.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" +#include "base/task/post_task.h" +#include "base/test/bind_test_util.h" +#include "chrome/browser/browser_process.h" +#include "chrome/browser/chromeos/login/test/help_app_test_helper.h" #include "chrome/browser/chromeos/login/test/js_checker.h" #include "chrome/browser/chromeos/login/test/oobe_base_test.h" #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" #include "chrome/browser/chromeos/login/ui/login_display_host.h" #include "chrome/browser/chromeos/login/wizard_controller.h" +#include "chrome/browser/chromeos/settings/stats_reporting_controller.h" +#include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" +#include "chrome/installer/util/google_update_settings.h" +#include "chromeos/dbus/cryptohome/fake_cryptohome_client.h" #include "components/guest_view/browser/guest_view_manager.h" +#include "components/metrics/metrics_pref_names.h" +#include "components/prefs/pref_service.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_ui.h" @@ -38,7 +50,6 @@ constexpr char kFakeOnlineEulaPath[] = "/intl/en-US/chrome/eula_text.html"; constexpr char kFakeOnlineEula[] = "No obligations at all"; - #if defined(GOOGLE_CHROME_BUILD) // See IDS_ABOUT_TERMS_OF_SERVICE for the complete text. constexpr char kOfflineEULAWarning[] = "Chrome OS Terms"; @@ -153,6 +164,46 @@ return *frame_set.begin(); } + // Returns an Oobe JSChecker that sends 'click' events instead of 'tap' + // events when interacting with UI elements. + test::JSChecker NonPolymerOobeJS() { + test::JSChecker js = test::OobeJS(); + js.set_polymer_ui(false); + return js; + } + + base::OnceClosure SetCollectStatsConsentClosure(bool consented) { + return base::BindOnce( + base::IgnoreResult(&GoogleUpdateSettings::SetCollectStatsConsent), + consented); + } + + // Waits until |blocking_closure| finishes executing. + void WaitForBlockingCall(base::OnceClosure blocking_closure) { + base::RunLoop runloop; + base::PostTaskWithTraitsAndReply(FROM_HERE, {base::MayBlock()}, + std::move(blocking_closure), + runloop.QuitClosure()); + runloop.Run(); + } + + // Waits and returns the result of evaluating |blocking_closure|. + bool EvaluateBlocking(base::OnceCallback<bool()> blocking_closure) { + bool result = false; + base::RunLoop runloop; + base::PostTaskWithTraitsAndReplyWithResult( + FROM_HERE, {base::MayBlock()}, std::move(blocking_closure), + base::BindOnce( + [](base::RepeatingClosure quit_closure, bool* result_out, + bool evaluation_result) { + *result_out = evaluation_result; + quit_closure.Run(); + }, + runloop.QuitClosure(), &result)); + runloop.Run(); + return result; + } + private: std::unique_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { GURL request_url = GURL("http://localhost").Resolve(request.relative_url); @@ -211,5 +262,113 @@ std::string::npos); } +// Tests that clicking on "System security settings" button opens a dialog +// showing the TPM password. +IN_PROC_BROWSER_TEST_F(EulaTest, DisplaysTpmPassword) { + ShowEulaScreen(); + + NonPolymerOobeJS().TapOnPath({"oobe-eula-md", "installationSettings"}); + test::OobeJS().ExpectVisiblePath( + {"oobe-eula-md", "installationSettingsDialog"}); + + test::OobeJS().CreateWaiter( + "$('oobe-eula-md').$$('#eula-password').textContent.trim() !== ''"); + test::OobeJS().ExpectEQ( + "$('oobe-eula-md').$$('#eula-password').textContent.trim()", + std::string(FakeCryptohomeClient::kStubTpmPassword)); +} + +// Verifies statistic collection accepted flow. +// Advaces to the next screen and verifies stats collection is enabled. +IN_PROC_BROWSER_TEST_F(EulaTest, EnableUsageStats) { + ShowEulaScreen(); + + // Verify that toggle is enabled by default. + test::OobeJS().ExpectTrue("$('oobe-eula-md').$$('#usageStats').checked"); + + ASSERT_TRUE(StatsReportingController::IsInitialized()); + + // Explicitly set as false to make sure test modifies these values. + StatsReportingController::Get()->SetEnabled( + ProfileManager::GetActiveUserProfile(), false); + g_browser_process->local_state()->SetBoolean( + metrics::prefs::kMetricsReportingEnabled, false); + + WaitForBlockingCall(SetCollectStatsConsentClosure(false)); + + // Start Listening for StatsReportingController updates. + base::RunLoop runloop; + auto subscription = + StatsReportingController::Get()->AddObserver(runloop.QuitClosure()); + + // Advance to the next screen for changes to take effect. + test::OobeJS().TapOnPath({"oobe-eula-md", "acceptButton"}); + + // Wait for StartReporting update. + runloop.Run(); + + // Verify stats collection is enabled. + EXPECT_TRUE(StatsReportingController::Get()->IsEnabled()); + EXPECT_TRUE(g_browser_process->local_state()->GetBoolean( + metrics::prefs::kMetricsReportingEnabled)); + EXPECT_TRUE(EvaluateBlocking( + base::BindOnce(&GoogleUpdateSettings::GetCollectStatsConsent))); +} + +// Verify statistic collection denied flow. Clicks on usage stats toggle, +// advaces to the next screen and verifies stats collection is disabled. +IN_PROC_BROWSER_TEST_F(EulaTest, DisableUsageStats) { + ShowEulaScreen(); + + // Verify that toggle is enabled by default. + test::OobeJS().ExpectTrue("$('oobe-eula-md').$$('#usageStats').checked"); + + ASSERT_TRUE(StatsReportingController::IsInitialized()); + + // Explicitly set as true to make sure test modifies these values. + StatsReportingController::Get()->SetEnabled( + ProfileManager::GetActiveUserProfile(), true); + g_browser_process->local_state()->SetBoolean( + metrics::prefs::kMetricsReportingEnabled, true); + + WaitForBlockingCall(SetCollectStatsConsentClosure(true)); + + // Start Listening for StatsReportingController updates. + base::RunLoop runloop; + auto subscription = + StatsReportingController::Get()->AddObserver(runloop.QuitClosure()); + + // Click on the toggle to disable stats collection and advance to the next + // screen for changes to take effect. + NonPolymerOobeJS().TapOnPath({"oobe-eula-md", "usageStats"}); + test::OobeJS().TapOnPath({"oobe-eula-md", "acceptButton"}); + + // Wait for StartReportingController update. + runloop.Run(); + + // Verify stats collection is disabled. + EXPECT_FALSE(StatsReportingController::Get()->IsEnabled()); + EXPECT_FALSE(g_browser_process->local_state()->GetBoolean( + metrics::prefs::kMetricsReportingEnabled)); + EXPECT_FALSE(EvaluateBlocking( + base::BindOnce(&GoogleUpdateSettings::GetCollectStatsConsent))); +} + +// Tests that clicking on "Learn more" button opens a help dialog. +IN_PROC_BROWSER_TEST_F(EulaTest, LearnMore) { + ShowEulaScreen(); + + // Load HelperApp extension. + HelpAppTestHelper scoped_helper; + + // Start listening for help dialog creation. + HelpAppTestHelper::Waiter waiter; + + NonPolymerOobeJS().TapOnPath({"oobe-eula-md", "learn-more"}); + + // Wait until help dialog is displayed. + waiter.Wait(); +} + } // namespace } // namespace chromeos
diff --git a/chrome/browser/chromeos/login/help_app_launcher.cc b/chrome/browser/chromeos/login/help_app_launcher.cc index 7ad126e..e8dd6863 100644 --- a/chrome/browser/chromeos/login/help_app_launcher.cc +++ b/chrome/browser/chromeos/login/help_app_launcher.cc
@@ -24,8 +24,12 @@ namespace { -const char kHelpAppFormat[] = - "chrome-extension://honijodknafkokifofgiaalefdiedpko/oobe.html?id=%d"; +// Official HelpApp extension id. +const char kExtensionId[] = "honijodknafkokifofgiaalefdiedpko"; + +const char kHelpAppFormat[] = "chrome-extension://%s/oobe.html?id=%d"; + +const char* g_extension_id_for_test = nullptr; } // namespace @@ -45,13 +49,24 @@ if (!registry) return; - GURL url(base::StringPrintf(kHelpAppFormat, static_cast<int>(help_topic_id))); + const char* extension_id = kExtensionId; + if (g_extension_id_for_test && *g_extension_id_for_test != '\0') { + extension_id = g_extension_id_for_test; + } + + GURL url(base::StringPrintf(kHelpAppFormat, extension_id, + static_cast<int>(help_topic_id))); // HelpApp component extension presents only in official builds so we can // show help only when the extensions is installed. if (registry->enabled_extensions().GetByID(url.host())) ShowHelpTopicDialog(profile, GURL(url)); } +// static +void HelpAppLauncher::SetExtensionIdForTest(const char* extension_id) { + g_extension_id_for_test = extension_id; +} + /////////////////////////////////////////////////////////////////////////////// // HelpApp, protected:
diff --git a/chrome/browser/chromeos/login/help_app_launcher.h b/chrome/browser/chromeos/login/help_app_launcher.h index 1a5b2bd..77309678 100644 --- a/chrome/browser/chromeos/login/help_app_launcher.h +++ b/chrome/browser/chromeos/login/help_app_launcher.h
@@ -47,6 +47,9 @@ // Shows specified help topic. void ShowHelpTopic(HelpTopic help_topic_id); + // Allows tests to specify a different extension id to connect to. + static void SetExtensionIdForTest(const char* extension_id); + protected: virtual ~HelpAppLauncher();
diff --git a/chrome/browser/chromeos/login/screen_manager.cc b/chrome/browser/chromeos/login/screen_manager.cc index b433fb6..83d68a0 100644 --- a/chrome/browser/chromeos/login/screen_manager.cc +++ b/chrome/browser/chromeos/login/screen_manager.cc
@@ -7,7 +7,7 @@ #include <utility> #include "base/memory/ptr_util.h" -#include "chrome/browser/chromeos/login/wizard_controller.h" +#include "chrome/browser/chromeos/login/screens/base_screen.h" namespace chromeos { @@ -15,17 +15,16 @@ ScreenManager::~ScreenManager() = default; +void ScreenManager::Init(std::vector<std::unique_ptr<BaseScreen>> screens) { + for (auto&& screen : screens) + screens_[screen->screen_id()] = std::move(screen); +} + BaseScreen* ScreenManager::GetScreen(OobeScreen screen) { auto iter = screens_.find(screen); - if (iter != screens_.end()) - return iter->second.get(); - - std::unique_ptr<BaseScreen> result = - WizardController::default_controller()->CreateScreen(screen); - DCHECK(result) << "Can not create screen named " << GetOobeScreenName(screen); - BaseScreen* unowned_result = result.get(); - screens_[screen] = std::move(result); - return unowned_result; + DCHECK(iter != screens_.end()) + << "Failed to find screen " << GetOobeScreenName(screen); + return iter->second.get(); } bool ScreenManager::HasScreen(OobeScreen screen) {
diff --git a/chrome/browser/chromeos/login/screen_manager.h b/chrome/browser/chromeos/login/screen_manager.h index 2e9b9e75..12ce1cf 100644 --- a/chrome/browser/chromeos/login/screen_manager.h +++ b/chrome/browser/chromeos/login/screen_manager.h
@@ -11,17 +11,22 @@ #include "base/gtest_prod_util.h" #include "base/macros.h" -#include "chrome/browser/chromeos/login/screens/base_screen.h" +#include "chrome/browser/chromeos/login/oobe_screen.h" namespace chromeos { +class BaseScreen; + // Class that manages creation and ownership of screens. class ScreenManager { public: ScreenManager(); ~ScreenManager(); - // Getter for screen with lazy initialization. + // Initialize all screen instances. + void Init(std::vector<std::unique_ptr<BaseScreen>> screens); + + // Getter for screen. Does not create the screen. BaseScreen* GetScreen(OobeScreen screen); bool HasScreen(OobeScreen screen);
diff --git a/chrome/browser/chromeos/login/screens/device_disabled_screen.cc b/chrome/browser/chromeos/login/screens/device_disabled_screen.cc index 74501352..2de720fbd 100644 --- a/chrome/browser/chromeos/login/screens/device_disabled_screen.cc +++ b/chrome/browser/chromeos/login/screens/device_disabled_screen.cc
@@ -13,20 +13,20 @@ namespace chromeos { +namespace { +system::DeviceDisablingManager* DeviceDisablingManager() { + return g_browser_process->platform_part()->device_disabling_manager(); +} +} // namespace + DeviceDisabledScreen::DeviceDisabledScreen(DeviceDisabledScreenView* view) - : BaseScreen(OobeScreen::SCREEN_DEVICE_DISABLED), - view_(view), - device_disabling_manager_( - g_browser_process->platform_part()->device_disabling_manager()), - showing_(false) { + : BaseScreen(OobeScreen::SCREEN_DEVICE_DISABLED), view_(view) { view_->SetDelegate(this); - device_disabling_manager_->AddObserver(this); } DeviceDisabledScreen::~DeviceDisabledScreen() { if (view_) view_->SetDelegate(nullptr); - device_disabling_manager_->RemoveObserver(this); } void DeviceDisabledScreen::Show() { @@ -35,6 +35,9 @@ showing_ = true; view_->Show(); + DeviceDisablingManager()->AddObserver(this); + if (!DeviceDisablingManager()->disabled_message().empty()) + view_->UpdateMessage(DeviceDisablingManager()->disabled_message()); } void DeviceDisabledScreen::Hide() { @@ -44,6 +47,7 @@ if (view_) view_->Hide(); + DeviceDisablingManager()->RemoveObserver(this); } void DeviceDisabledScreen::OnViewDestroyed(DeviceDisabledScreenView* view) { @@ -52,15 +56,15 @@ } const std::string& DeviceDisabledScreen::GetEnrollmentDomain() const { - return device_disabling_manager_->enrollment_domain(); + return DeviceDisablingManager()->enrollment_domain(); } const std::string& DeviceDisabledScreen::GetMessage() const { - return device_disabling_manager_->disabled_message(); + return DeviceDisablingManager()->disabled_message(); } const std::string& DeviceDisabledScreen::GetSerialNumber() const { - return device_disabling_manager_->serial_number(); + return DeviceDisablingManager()->serial_number(); } void DeviceDisabledScreen::OnDisabledMessageChanged(
diff --git a/chrome/browser/chromeos/login/screens/device_disabled_screen.h b/chrome/browser/chromeos/login/screens/device_disabled_screen.h index 2250543..4f2b50a 100644 --- a/chrome/browser/chromeos/login/screens/device_disabled_screen.h +++ b/chrome/browser/chromeos/login/screens/device_disabled_screen.h
@@ -39,10 +39,9 @@ private: DeviceDisabledScreenView* view_; - system::DeviceDisablingManager* device_disabling_manager_; // Whether the screen is currently showing. - bool showing_; + bool showing_ = false; DISALLOW_COPY_AND_ASSIGN(DeviceDisabledScreen); };
diff --git a/chrome/browser/chromeos/login/screens/eula_screen.cc b/chrome/browser/chromeos/login/screens/eula_screen.cc index 0acc4fd..3e48399 100644 --- a/chrome/browser/chromeos/login/screens/eula_screen.cc +++ b/chrome/browser/chromeos/login/screens/eula_screen.cc
@@ -44,24 +44,6 @@ view_->Unbind(); } -GURL EulaScreen::GetOemEulaUrl() const { - const StartupCustomizationDocument* customization = - StartupCustomizationDocument::GetInstance(); - if (customization->IsReady()) { - // Previously we're using "initial locale" that device initially - // booted with out-of-box. http://crbug.com/145142 - std::string locale = g_browser_process->GetApplicationLocale(); - std::string eula_page = customization->GetEULAPage(locale); - if (!eula_page.empty()) - return GURL(eula_page); - - VLOG(1) << "No eula found for locale: " << locale; - } else { - LOG(ERROR) << "No manifest found."; - } - return GURL(); -} - void EulaScreen::InitiatePasswordFetch() { if (tpm_password_.empty()) { password_fetcher_.Fetch();
diff --git a/chrome/browser/chromeos/login/screens/recommend_apps_screen_browsertest.cc b/chrome/browser/chromeos/login/screens/recommend_apps_screen_browsertest.cc index ac80d4c1..45ee7c5 100644 --- a/chrome/browser/chromeos/login/screens/recommend_apps_screen_browsertest.cc +++ b/chrome/browser/chromeos/login/screens/recommend_apps_screen_browsertest.cc
@@ -20,6 +20,7 @@ #include "chrome/browser/chromeos/login/test/js_checker.h" #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" #include "chrome/browser/chromeos/login/ui/login_display_host.h" +#include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" @@ -113,10 +114,14 @@ RecommendAppsFetcher::SetFactoryCallbackForTesting( &fetcher_factory_callback_); - recommend_apps_screen_ = std::make_unique<RecommendAppsScreen>( + auto recommend_apps_screen = std::make_unique<RecommendAppsScreen>( GetOobeUI()->GetRecommendAppsScreenView(), base::BindRepeating(&RecommendAppsScreenTest::HandleScreenExit, base::Unretained(this))); + recommend_apps_screen_ = recommend_apps_screen.get(); + WizardController::default_controller() + ->screen_manager() + ->SetScreenForTesting(std::move(recommend_apps_screen)); InProcessBrowserTest::SetUpOnMainThread(); } @@ -191,7 +196,7 @@ result; } - std::unique_ptr<RecommendAppsScreen> recommend_apps_screen_; + RecommendAppsScreen* recommend_apps_screen_; base::Optional<RecommendAppsScreen::Result> screen_result_; FakeRecommendAppsFetcher* recommend_apps_fetcher_ = nullptr; @@ -205,7 +210,7 @@ std::unique_ptr<RecommendAppsFetcher> CreateRecommendAppsFetcher( RecommendAppsFetcherDelegate* delegate) { - EXPECT_EQ(delegate, recommend_apps_screen_.get()); + EXPECT_EQ(delegate, recommend_apps_screen_); EXPECT_FALSE(recommend_apps_fetcher_); auto fetcher = std::make_unique<FakeRecommendAppsFetcher>(delegate);
diff --git a/chrome/browser/chromeos/login/test/help_app_test_helper.cc b/chrome/browser/chromeos/login/test/help_app_test_helper.cc new file mode 100644 index 0000000..4061091 --- /dev/null +++ b/chrome/browser/chromeos/login/test/help_app_test_helper.cc
@@ -0,0 +1,99 @@ +// 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/login/test/help_app_test_helper.h" + +#include "base/files/file_path.h" +#include "base/path_service.h" +#include "chrome/browser/chromeos/extensions/signin_screen_policy_provider.h" +#include "chrome/browser/chromeos/login/help_app_launcher.h" +#include "chrome/browser/chromeos/profiles/profile_helper.h" +#include "chrome/browser/extensions/chrome_test_extension_loader.h" +#include "chrome/common/chrome_paths.h" +#include "chrome/grit/generated_resources.h" +#include "ui/aura/env.h" +#include "ui/aura/window.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/views/widget/widget.h" + +namespace chromeos { + +/////////////////////////////////////////////////////////////////////////////// +// HelpAppTestHelper::Waiter +/////////////////////////////////////////////////////////////////////////////// + +HelpAppTestHelper::Waiter::Waiter() { + aura::Env::GetInstance()->AddObserver(this); +} + +HelpAppTestHelper::Waiter::~Waiter() { + aura::Env::GetInstance()->RemoveObserver(this); + window_observer_.RemoveAll(); + // Explicitly close any help app dialogs still open to prevent flaky errors in + // browser tests. Remove when crbug.com/951828 is fixed. + for (aura::Window* dialog_window : dialog_windows_) + views::Widget::GetWidgetForNativeView(dialog_window)->CloseNow(); +} + +void HelpAppTestHelper::Waiter::Wait() { + if (!help_app_dialog_opened_) + run_loop_.Run(); +} + +void HelpAppTestHelper::Waiter::OnWindowInitialized(aura::Window* window) { + DCHECK(!window_observer_.IsObserving(window)); + window_observer_.Add(window); +} + +void HelpAppTestHelper::Waiter::OnWindowDestroyed(aura::Window* window) { + if (window_observer_.IsObserving(window)) + window_observer_.Remove(window); + dialog_windows_.erase(window); +} + +void HelpAppTestHelper::Waiter::OnWindowVisibilityChanged(aura::Window* window, + bool visible) { + if (!IsHelpAppDialog(window)) + return; + + dialog_windows_.insert(window); + if (visible) { + help_app_dialog_opened_ = true; + run_loop_.Quit(); + } +} + +bool HelpAppTestHelper::Waiter::IsHelpAppDialog(aura::Window* window) { + return window->GetTitle() == + l10n_util::GetStringUTF16(IDS_LOGIN_OOBE_HELP_DIALOG_TITLE); +} + +/////////////////////////////////////////////////////////////////////////////// +// HelpAppTestHelper +/////////////////////////////////////////////////////////////////////////////// + +HelpAppTestHelper::HelpAppTestHelper() { + auto reset = GetScopedSigninScreenPolicyProviderDisablerForTesting(); + + base::FilePath test_data_dir; + base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); + extensions::ChromeTestExtensionLoader loader( + ProfileHelper::GetSigninProfile()); + loader.set_allow_incognito_access(true); + + scoped_refptr<const extensions::Extension> extension = + loader.LoadExtension(test_data_dir.AppendASCII("extensions") + .AppendASCII("api_test") + .AppendASCII("help_app")); + + DCHECK(extension && !extension->id().empty()); + + HelpAppLauncher::SetExtensionIdForTest(extension->id().c_str()); +} + +HelpAppTestHelper::~HelpAppTestHelper() { + HelpAppLauncher::SetExtensionIdForTest(nullptr); +} + +} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/test/help_app_test_helper.h b/chrome/browser/chromeos/login/test/help_app_test_helper.h new file mode 100644 index 0000000..d4ee1b6 --- /dev/null +++ b/chrome/browser/chromeos/login/test/help_app_test_helper.h
@@ -0,0 +1,70 @@ +// 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_LOGIN_TEST_HELP_APP_TEST_HELPER_H_ +#define CHROME_BROWSER_CHROMEOS_LOGIN_TEST_HELP_APP_TEST_HELPER_H_ + +#include <set> + +#include "base/macros.h" +#include "base/run_loop.h" +#include "base/scoped_observer.h" +#include "ui/aura/env_observer.h" +#include "ui/aura/window_observer.h" + +namespace chromeos { + +// Provides utilies for launching and interacting with HelpApp dialogs in tests. +class HelpAppTestHelper { + public: + // Waits for a HelpApp dialog to open and become visible. + // + // Starts listening for window creation events on construction. |Wait| blocks + // until a HelpApp window is visible. |Wait| returns immediately if a HelpApp + // window is already visible when |Wait| is called. + // + // HelpAppTestHelper::Waiter is single-use. It can only wait for one HelpApp + // dialog to be opened per lifetime. + class Waiter : public aura::EnvObserver, public aura::WindowObserver { + public: + Waiter(); + ~Waiter() override; + + // Blocks until a HelpApp dialog becomes visible. Once a HelpApp dialog + // becomes visible during this object's lifetime, all calls to |Wait| return + // immediately. + void Wait(); + + // aura::EnvObserver + void OnWindowInitialized(aura::Window* window) override; + + // aura::WindowObserver + void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; + void OnWindowDestroyed(aura::Window* window) override; + + private: + bool IsHelpAppDialog(aura::Window* window); + + base::RunLoop run_loop_; + std::set<aura::Window*> dialog_windows_; + ScopedObserver<aura::Window, Waiter> window_observer_{this}; + bool help_app_dialog_opened_ = false; + DISALLOW_COPY_AND_ASSIGN(Waiter); + }; + + HelpAppTestHelper(); + virtual ~HelpAppTestHelper(); + + // Performs setup to allow HelpApp dialogs to open in tests. + void SetUpHelpAppForTest(); + + // TODO(tonydeluna): Add utilities for interacting with the contents of the + // help dialogs. + + DISALLOW_COPY_AND_ASSIGN(HelpAppTestHelper); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_LOGIN_TEST_HELP_APP_TEST_HELPER_H_
diff --git a/chrome/browser/chromeos/login/test/js_checker.cc b/chrome/browser/chromeos/login/test/js_checker.cc index de4b376..b4f8a5c 100644 --- a/chrome/browser/chromeos/login/test/js_checker.cc +++ b/chrome/browser/chromeos/login/test/js_checker.cc
@@ -237,11 +237,11 @@ void JSChecker::TapOnPath( std::initializer_list<base::StringPiece> element_ids) { ExpectVisiblePath(element_ids); - // All OOBE UI should be mobile-friendly, so use "tap" instead of "click". + // TODO(crbug.com/949377): Switch to always firing 'click' events when + // missing OOBE UI components are migrated to handle 'click' events. if (polymer_ui_) { Evaluate(GetOobeElementPath(element_ids) + ".fire('tap')"); } else { - // Old test-only UI (fake GAIA, fake SAML) only support "click". Evaluate(GetOobeElementPath(element_ids) + ".click()"); } }
diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc index 19c349e..b2e2722 100644 --- a/chrome/browser/chromeos/login/wizard_controller.cc +++ b/chrome/browser/chromeos/login/wizard_controller.cc
@@ -299,6 +299,8 @@ } void WizardController::Init(OobeScreen first_screen) { + screen_manager_->Init(CreateScreens()); + VLOG(1) << "Starting OOBE wizard with screen: " << GetOobeScreenName(first_screen); first_screen_ = first_screen; @@ -369,148 +371,6 @@ return screen_manager_->GetScreen(screen); } -std::unique_ptr<BaseScreen> WizardController::CreateScreen(OobeScreen screen) { - OobeUI* oobe_ui = GetOobeUI(); - - if (screen == OobeScreen::SCREEN_OOBE_WELCOME) { - return std::make_unique<WelcomeScreen>( - oobe_ui->GetWelcomeView(), - base::BindRepeating(&WizardController::OnWelcomeScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_OOBE_NETWORK) { - return std::make_unique<NetworkScreen>( - oobe_ui->GetNetworkScreenView(), - base::BindRepeating(&WizardController::OnNetworkScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_OOBE_UPDATE) { - return std::make_unique<UpdateScreen>( - this, oobe_ui->GetUpdateView(), - base::BindRepeating(&WizardController::OnUpdateScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_OOBE_EULA) { - return std::make_unique<EulaScreen>( - oobe_ui->GetEulaView(), - base::BindRepeating(&WizardController::OnEulaScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_OOBE_ENROLLMENT) { - return std::make_unique<EnrollmentScreen>( - oobe_ui->GetEnrollmentScreenView(), - base::BindRepeating(&WizardController::OnEnrollmentScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_OOBE_RESET) { - return std::make_unique<chromeos::ResetScreen>( - this, oobe_ui->GetResetView(), - base::BindRepeating(&WizardController::OnResetScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_OOBE_DEMO_SETUP) { - return std::make_unique<chromeos::DemoSetupScreen>( - oobe_ui->GetDemoSetupScreenView(), - base::BindRepeating(&WizardController::OnDemoSetupScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_OOBE_DEMO_PREFERENCES) { - return std::make_unique<chromeos::DemoPreferencesScreen>( - oobe_ui->GetDemoPreferencesScreenView(), - base::BindRepeating(&WizardController::OnDemoPreferencesScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_OOBE_ENABLE_DEBUGGING) { - return std::make_unique<EnableDebuggingScreen>( - oobe_ui->GetEnableDebuggingScreenView(), - base::BindRepeating(&WizardController::OnEnableDebuggingScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_KIOSK_ENABLE) { - return std::make_unique<KioskEnableScreen>( - oobe_ui->GetKioskEnableScreenView(), - base::BindRepeating(&WizardController::OnKioskEnableScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_KIOSK_AUTOLAUNCH) { - return std::make_unique<KioskAutolaunchScreen>( - oobe_ui->GetKioskAutolaunchScreenView(), - base::BindRepeating(&WizardController::OnKioskAutolaunchScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_TERMS_OF_SERVICE) { - return std::make_unique<TermsOfServiceScreen>( - oobe_ui->GetTermsOfServiceScreenView(), - base::BindRepeating(&WizardController::OnTermsOfServiceScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_SYNC_CONSENT) { - return std::make_unique<SyncConsentScreen>( - oobe_ui->GetSyncConsentScreenView(), - base::BindRepeating(&WizardController::OnSyncConsentScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_ARC_TERMS_OF_SERVICE) { - return std::make_unique<ArcTermsOfServiceScreen>( - oobe_ui->GetArcTermsOfServiceScreenView(), - base::BindRepeating(&WizardController::OnArcTermsOfServiceScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_RECOMMEND_APPS) { - return std::make_unique<RecommendAppsScreen>( - oobe_ui->GetRecommendAppsScreenView(), - base::BindRepeating(&WizardController::OnRecommendAppsScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_APP_DOWNLOADING) { - return std::make_unique<AppDownloadingScreen>( - oobe_ui->GetAppDownloadingScreenView(), - base::BindRepeating(&WizardController::OnAppDownloadingScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_WRONG_HWID) { - return std::make_unique<WrongHWIDScreen>( - oobe_ui->GetWrongHWIDScreenView(), - base::BindRepeating(&WizardController::OnWrongHWIDScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_OOBE_HID_DETECTION) { - return std::make_unique<chromeos::HIDDetectionScreen>( - oobe_ui->GetHIDDetectionView(), - base::BindRepeating(&WizardController::OnHidDetectionScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_AUTO_ENROLLMENT_CHECK) { - return std::make_unique<AutoEnrollmentCheckScreen>( - this, oobe_ui->GetAutoEnrollmentCheckScreenView(), - base::BindRepeating(&WizardController::OnAutoEnrollmentCheckScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_DEVICE_DISABLED) { - return std::make_unique<DeviceDisabledScreen>( - oobe_ui->GetDeviceDisabledScreenView()); - } else if (screen == OobeScreen::SCREEN_ENCRYPTION_MIGRATION) { - return std::make_unique<EncryptionMigrationScreen>( - oobe_ui->GetEncryptionMigrationScreenView()); - } else if (screen == OobeScreen::SCREEN_SUPERVISION_TRANSITION) { - return std::make_unique<SupervisionTransitionScreen>( - oobe_ui->GetSupervisionTransitionScreenView(), - base::BindRepeating( - &WizardController::OnSupervisionTransitionScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_UPDATE_REQUIRED) { - return std::make_unique<UpdateRequiredScreen>( - oobe_ui->GetUpdateRequiredScreenView()); - } else if (screen == OobeScreen::SCREEN_ASSISTANT_OPTIN_FLOW) { - return std::make_unique<AssistantOptInFlowScreen>( - oobe_ui->GetAssistantOptInFlowScreenView(), - base::BindRepeating(&WizardController::OnAssistantOptInFlowScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_MULTIDEVICE_SETUP) { - return std::make_unique<MultiDeviceSetupScreen>( - oobe_ui->GetMultiDeviceSetupScreenView(), - base::BindRepeating(&WizardController::OnMultiDeviceSetupScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_DISCOVER) { - return std::make_unique<DiscoverScreen>( - oobe_ui->GetDiscoverScreenView(), - base::BindRepeating(&WizardController::OnDiscoverScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_FINGERPRINT_SETUP) { - return std::make_unique<FingerprintSetupScreen>( - oobe_ui->GetFingerprintSetupScreenView(), - base::BindRepeating(&WizardController::OnFingerprintSetupScreenExit, - weak_factory_.GetWeakPtr())); - } else if (screen == OobeScreen::SCREEN_MARKETING_OPT_IN) { - return std::make_unique<MarketingOptInScreen>( - oobe_ui->GetMarketingOptInScreenView(), - base::BindRepeating(&WizardController::OnMarketingOptInScreenExit, - weak_factory_.GetWeakPtr())); - } - return nullptr; -} - void WizardController::SetCurrentScreenForTesting(BaseScreen* screen) { current_screen_ = screen; } @@ -521,6 +381,128 @@ testing_factory = std::move(factory); } +std::vector<std::unique_ptr<BaseScreen>> WizardController::CreateScreens() { + OobeUI* oobe_ui = GetOobeUI(); + + std::vector<std::unique_ptr<BaseScreen>> result; + + auto append = [&](std::unique_ptr<BaseScreen> screen) { + result.emplace_back(std::move(screen)); + }; + + if (oobe_ui->display_type() == OobeUI::kOobeDisplay) { + append(std::make_unique<WelcomeScreen>( + oobe_ui->GetWelcomeView(), + base::BindRepeating(&WizardController::OnWelcomeScreenExit, + weak_factory_.GetWeakPtr()))); + } + + append(std::make_unique<NetworkScreen>( + oobe_ui->GetNetworkScreenView(), + base::BindRepeating(&WizardController::OnNetworkScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<UpdateScreen>( + this, oobe_ui->GetUpdateView(), + base::BindRepeating(&WizardController::OnUpdateScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<EulaScreen>( + oobe_ui->GetEulaView(), + base::BindRepeating(&WizardController::OnEulaScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<EnrollmentScreen>( + oobe_ui->GetEnrollmentScreenView(), + base::BindRepeating(&WizardController::OnEnrollmentScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<chromeos::ResetScreen>( + this, oobe_ui->GetResetView(), + base::BindRepeating(&WizardController::OnResetScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<chromeos::DemoSetupScreen>( + oobe_ui->GetDemoSetupScreenView(), + base::BindRepeating(&WizardController::OnDemoSetupScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<chromeos::DemoPreferencesScreen>( + oobe_ui->GetDemoPreferencesScreenView(), + base::BindRepeating(&WizardController::OnDemoPreferencesScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<EnableDebuggingScreen>( + oobe_ui->GetEnableDebuggingScreenView(), + base::BindRepeating(&WizardController::OnEnableDebuggingScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<KioskEnableScreen>( + oobe_ui->GetKioskEnableScreenView(), + base::BindRepeating(&WizardController::OnKioskEnableScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<KioskAutolaunchScreen>( + oobe_ui->GetKioskAutolaunchScreenView(), + base::BindRepeating(&WizardController::OnKioskAutolaunchScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<TermsOfServiceScreen>( + oobe_ui->GetTermsOfServiceScreenView(), + base::BindRepeating(&WizardController::OnTermsOfServiceScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<SyncConsentScreen>( + oobe_ui->GetSyncConsentScreenView(), + base::BindRepeating(&WizardController::OnSyncConsentScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<ArcTermsOfServiceScreen>( + oobe_ui->GetArcTermsOfServiceScreenView(), + base::BindRepeating(&WizardController::OnArcTermsOfServiceScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<RecommendAppsScreen>( + oobe_ui->GetRecommendAppsScreenView(), + base::BindRepeating(&WizardController::OnRecommendAppsScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<AppDownloadingScreen>( + oobe_ui->GetAppDownloadingScreenView(), + base::BindRepeating(&WizardController::OnAppDownloadingScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<WrongHWIDScreen>( + oobe_ui->GetWrongHWIDScreenView(), + base::BindRepeating(&WizardController::OnWrongHWIDScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<chromeos::HIDDetectionScreen>( + oobe_ui->GetHIDDetectionView(), + base::BindRepeating(&WizardController::OnHidDetectionScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<AutoEnrollmentCheckScreen>( + this, oobe_ui->GetAutoEnrollmentCheckScreenView(), + base::BindRepeating(&WizardController::OnAutoEnrollmentCheckScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<DeviceDisabledScreen>( + oobe_ui->GetDeviceDisabledScreenView())); + append(std::make_unique<EncryptionMigrationScreen>( + oobe_ui->GetEncryptionMigrationScreenView())); + append(std::make_unique<SupervisionTransitionScreen>( + oobe_ui->GetSupervisionTransitionScreenView(), + base::BindRepeating(&WizardController::OnSupervisionTransitionScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<UpdateRequiredScreen>( + oobe_ui->GetUpdateRequiredScreenView())); + append(std::make_unique<AssistantOptInFlowScreen>( + oobe_ui->GetAssistantOptInFlowScreenView(), + base::BindRepeating(&WizardController::OnAssistantOptInFlowScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<MultiDeviceSetupScreen>( + oobe_ui->GetMultiDeviceSetupScreenView(), + base::BindRepeating(&WizardController::OnMultiDeviceSetupScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<DiscoverScreen>( + oobe_ui->GetDiscoverScreenView(), + base::BindRepeating(&WizardController::OnDiscoverScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<FingerprintSetupScreen>( + oobe_ui->GetFingerprintSetupScreenView(), + base::BindRepeating(&WizardController::OnFingerprintSetupScreenExit, + weak_factory_.GetWeakPtr()))); + append(std::make_unique<MarketingOptInScreen>( + oobe_ui->GetMarketingOptInScreenView(), + base::BindRepeating(&WizardController::OnMarketingOptInScreenExit, + weak_factory_.GetWeakPtr()))); + + return result; +} + void WizardController::ShowWelcomeScreen() { SetCurrentScreen(GetScreen(OobeScreen::SCREEN_OOBE_WELCOME)); }
diff --git a/chrome/browser/chromeos/login/wizard_controller.h b/chrome/browser/chromeos/login/wizard_controller.h index 75996697..267f119 100644 --- a/chrome/browser/chromeos/login/wizard_controller.h +++ b/chrome/browser/chromeos/login/wizard_controller.h
@@ -143,10 +143,6 @@ // Volume percent at which spoken feedback is still audible. static const int kMinAudibleOutputVolumePercent; - // Allocate a given BaseScreen for the given |Screen|. Used by - // |screen_manager_|. - std::unique_ptr<BaseScreen> CreateScreen(OobeScreen screen); - // Set the current screen. For Test use only. void SetCurrentScreenForTesting(BaseScreen* screen); @@ -154,6 +150,9 @@ scoped_refptr<network::SharedURLLoaderFactory> factory); private: + // Create BaseScreen instances. These are owned by |screen_manager_|. + std::vector<std::unique_ptr<BaseScreen>> CreateScreens(); + // Show specific screen. void ShowWelcomeScreen(); void ShowNetworkScreen();
diff --git a/chrome/browser/chromeos/network_change_manager_client.cc b/chrome/browser/chromeos/network_change_manager_client.cc index f64f37f..c3800e7c 100644 --- a/chrome/browser/chromeos/network_change_manager_client.cc +++ b/chrome/browser/chromeos/network_change_manager_client.cc
@@ -12,6 +12,7 @@ #include "chromeos/network/network_state_handler.h" #include "content/public/browser/network_service_instance.h" #include "content/public/common/network_service_util.h" +#include "net/base/network_change_notifier.h" #include "net/base/network_change_notifier_posix.h" #include "services/network/public/mojom/network_service.mojom.h" @@ -19,8 +20,8 @@ NetworkChangeManagerClient::NetworkChangeManagerClient( net::NetworkChangeNotifierPosix* network_change_notifier) - : connection_type_(net::NetworkChangeNotifier::CONNECTION_NONE), - connection_subtype_(net::NetworkChangeNotifier::SUBTYPE_NONE), + : connection_type_(net::NetworkChangeNotifier::GetConnectionType()), + connection_subtype_(net::NetworkChangeNotifier::GetConnectionSubtype()), network_change_notifier_(network_change_notifier) { PowerManagerClient::Get()->AddObserver(this); NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE);
diff --git a/chrome/browser/chromeos/network_change_manager_client.h b/chrome/browser/chromeos/network_change_manager_client.h index 9731798..36cc507f 100644 --- a/chrome/browser/chromeos/network_change_manager_client.h +++ b/chrome/browser/chromeos/network_change_manager_client.h
@@ -42,6 +42,8 @@ friend class NetworkChangeManagerClientUpdateTest; FRIEND_TEST_ALL_PREFIXES(NetworkChangeManagerClientTest, ConnectionTypeFromShill); + FRIEND_TEST_ALL_PREFIXES(NetworkChangeManagerClientTest, + NetworkChangeNotifierConnectionTypeUpdated); void ConnectToNetworkChangeManager(); void ReconnectToNetworkChangeManager();
diff --git a/chrome/browser/chromeos/network_change_manager_client_unittest.cc b/chrome/browser/chromeos/network_change_manager_client_unittest.cc index 23e42a6..a2576eb6 100644 --- a/chrome/browser/chromeos/network_change_manager_client_unittest.cc +++ b/chrome/browser/chromeos/network_change_manager_client_unittest.cc
@@ -12,6 +12,7 @@ #include "base/strings/string_split.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/power/power_manager_client.h" +#include "chromeos/dbus/shill/shill_service_client.h" #include "chromeos/network/network_handler.h" #include "chromeos/network/network_state.h" #include "content/public/test/test_browser_thread_bundle.h" @@ -106,6 +107,43 @@ } } +TEST(NetworkChangeManagerClientTest, + NetworkChangeNotifierConnectionTypeUpdated) { + // Create a NetworkChangeNotifier with a non-NONE connection type. + content::TestBrowserThreadBundle thread_bundle_; + std::unique_ptr<net::NetworkChangeNotifierPosix> network_change_notifier( + static_cast<net::NetworkChangeNotifierPosix*>( + net::NetworkChangeNotifier::Create())); + network_change_notifier->OnConnectionChanged( + net::NetworkChangeNotifier::CONNECTION_UNKNOWN); + EXPECT_EQ(net::NetworkChangeNotifier::CONNECTION_UNKNOWN, + net::NetworkChangeNotifier::GetConnectionType()); + + // Initialize DBus and clear services so NetworkHandler thinks we're offline. + DBusThreadManager::Initialize(); + PowerManagerClient::InitializeFake(); + NetworkHandler::Initialize(); + DBusThreadManager::Get() + ->GetShillServiceClient() + ->GetTestInterface() + ->ClearServices(); + + auto client = std::make_unique<NetworkChangeManagerClient>( + network_change_notifier.get()); + + // NetworkChangeManagerClient should have read the network state from DBus + // and notified NetworkChangeNotifier that we're offline. + EXPECT_EQ(net::NetworkChangeNotifier::CONNECTION_NONE, + client->connection_type_); + EXPECT_EQ(net::NetworkChangeNotifier::CONNECTION_NONE, + net::NetworkChangeNotifier::GetConnectionType()); + + client.reset(); + NetworkHandler::Shutdown(); + PowerManagerClient::Shutdown(); + DBusThreadManager::Shutdown(); +} + class NetworkChangeManagerClientUpdateTest : public testing::Test { protected: NetworkChangeManagerClientUpdateTest() : default_network_("") {}
diff --git a/chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc b/chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc index 265250f..cbd1483 100644 --- a/chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc +++ b/chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc
@@ -1250,6 +1250,16 @@ container.day_configs(), policies); } } + + if (policy.has_device_boot_on_ac()) { + const em::DeviceBootOnAcProto& container(policy.device_boot_on_ac()); + if (container.has_enabled()) { + policies->Set(key::kDeviceBootOnAcEnabled, POLICY_LEVEL_MANDATORY, + POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, + std::make_unique<base::Value>(container.enabled()), + nullptr); + } + } } } // namespace
diff --git a/chrome/browser/chromeos/printing/cups_printers_manager.cc b/chrome/browser/chromeos/printing/cups_printers_manager.cc index 9bd5d3d..19009203 100644 --- a/chrome/browser/chromeos/printing/cups_printers_manager.cc +++ b/chrome/browser/chromeos/printing/cups_printers_manager.cc
@@ -72,7 +72,7 @@ printers_(kNumPrinterClasses), weak_ptr_factory_(this) { // Prime the printer cache with the configured and enterprise printers. - printers_[kConfigured] = synced_printers_manager_->GetConfiguredPrinters(); + printers_[kConfigured] = synced_printers_manager_->GetSavedPrinters(); RebuildConfiguredPrintersIndex(); synced_printers_manager_observer_.Add(synced_printers_manager_); enterprise_printers_are_ready_ = @@ -141,7 +141,7 @@ } // If this is an 'add' instead of just an update, record the event. MaybeRecordInstallation(printer, false); - synced_printers_manager_->UpdateConfiguredPrinter(printer); + synced_printers_manager_->UpdateSavedPrinter(printer); // Note that we will rebuild our lists when we get the observer // callback from |synced_printers_manager_|. } @@ -153,7 +153,7 @@ if (existing) { event_tracker_->RecordPrinterRemoved(*existing); } - synced_printers_manager_->RemoveConfiguredPrinter(printer_id); + synced_printers_manager_->RemoveSavedPrinter(printer_id); // Note that we will rebuild our lists when we get the observer // callback from |synced_printers_manager_|. } @@ -214,9 +214,9 @@ } // SyncedPrintersManager::Observer implementation - void OnConfiguredPrintersChanged() override { + void OnSavedPrintersChanged() override { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_); - printers_[kConfigured] = synced_printers_manager_->GetConfiguredPrinters(); + printers_[kConfigured] = synced_printers_manager_->GetSavedPrinters(); RebuildConfiguredPrintersIndex(); RebuildDetectedLists(); NotifyObservers({kConfigured});
diff --git a/chrome/browser/chromeos/printing/cups_printers_manager_unittest.cc b/chrome/browser/chromeos/printing/cups_printers_manager_unittest.cc index 04ce83d..758e430 100644 --- a/chrome/browser/chromeos/printing/cups_printers_manager_unittest.cc +++ b/chrome/browser/chromeos/printing/cups_printers_manager_unittest.cc
@@ -24,15 +24,15 @@ namespace { // Fake backend for SyncedPrintersManager. This allows us to poke arbitrary -// changes in the configured and enterprise printer lists. +// changes in the saved and enterprise printer lists. class FakeSyncedPrintersManager : public SyncedPrintersManager { public: FakeSyncedPrintersManager() = default; ~FakeSyncedPrintersManager() override = default; // Returns the printers that are saved in preferences. - std::vector<Printer> GetConfiguredPrinters() const override { - return configured_printers_; + std::vector<Printer> GetSavedPrinters() const override { + return saved_printers_; } // Returns printers from enterprise policy. @@ -56,30 +56,29 @@ observers_.RemoveObserver(observer); } - void UpdateConfiguredPrinter(const Printer& printer) override { + void UpdateSavedPrinter(const Printer& printer) override { size_t i; - for (i = 0; i < configured_printers_.size(); ++i) { - if (configured_printers_[i].id() == printer.id()) { - configured_printers_[i] = printer; + for (i = 0; i < saved_printers_.size(); ++i) { + if (saved_printers_[i].id() == printer.id()) { + saved_printers_[i] = printer; break; } } - if (i == configured_printers_.size()) { + if (i == saved_printers_.size()) { // Didn't find it, add it. - configured_printers_.push_back(printer); + saved_printers_.push_back(printer); } for (Observer& observer : observers_) { - observer.OnConfiguredPrintersChanged(); + observer.OnSavedPrintersChanged(); } } - bool RemoveConfiguredPrinter(const std::string& printer_id) override { - for (auto it = configured_printers_.begin(); - it != configured_printers_.end(); ++it) { + bool RemoveSavedPrinter(const std::string& printer_id) override { + for (auto it = saved_printers_.begin(); it != saved_printers_.end(); ++it) { if (it->id() == printer_id) { - configured_printers_.erase(it); + saved_printers_.erase(it); for (Observer& observer : observers_) { - observer.OnConfiguredPrintersChanged(); + observer.OnSavedPrintersChanged(); } return true; } @@ -97,7 +96,7 @@ } PrintersSyncBridge* GetSyncBridge() override { return nullptr; } // Returns the printer with id |printer_id|, or nullptr if no such printer - // exists. Searches both Configured and Enterprise printers. + // exists. Searches both Saved and Enterprise printers. std::unique_ptr<Printer> GetPrinter( const std::string& printer_id) const override { return nullptr; @@ -105,22 +104,22 @@ // Fake manipulation functions. - // Add the given printers to the list of configured printers and + // Add the given printers to the list of saved printers and // notify observers. - void AddConfiguredPrinters(const std::vector<Printer>& printers) { - configured_printers_.insert(configured_printers_.end(), printers.begin(), - printers.end()); + void AddSavedPrinters(const std::vector<Printer>& printers) { + saved_printers_.insert(saved_printers_.end(), printers.begin(), + printers.end()); for (Observer& observer : observers_) { - observer.OnConfiguredPrintersChanged(); + observer.OnSavedPrintersChanged(); } } - // Remove the printers with the given ids from the set of configured printers, + // Remove the printers with the given ids from the set of saved printers, // notify observers. - void RemoveConfiguredPrinters(const std::unordered_set<std::string>& ids) { - RemovePrinters(ids, &configured_printers_); + void RemoveSavedPrinters(const std::unordered_set<std::string>& ids) { + RemovePrinters(ids, &saved_printers_); for (Observer& observer : observers_) { - observer.OnConfiguredPrintersChanged(); + observer.OnSavedPrintersChanged(); } } @@ -155,7 +154,7 @@ } base::ObserverList<SyncedPrintersManager::Observer>::Unchecked observers_; - std::vector<Printer> configured_printers_; + std::vector<Printer> saved_printers_; std::vector<Printer> enterprise_printers_; }; @@ -343,11 +342,10 @@ ExpectPrintersInClassAre(CupsPrintersManager::kEnterprise, {"Foo", "Bar"}); } -// Test that Configured printers from SyncedPrinterManager are +// Test that Saved printers from SyncedPrinterManager are // surfaced appropriately. -TEST_F(CupsPrintersManagerTest, GetConfiguredPrinters) { - synced_printers_manager_.AddConfiguredPrinters( - {Printer("Foo"), Printer("Bar")}); +TEST_F(CupsPrintersManagerTest, GetSavedPrinters) { + synced_printers_manager_.AddSavedPrinters({Printer("Foo"), Printer("Bar")}); scoped_task_environment_.RunUntilIdle(); ExpectPrintersInClassAre(CupsPrintersManager::kConfigured, {"Foo", "Bar"}); } @@ -369,8 +367,7 @@ TEST_F(CupsPrintersManagerTest, GetZeroconfPrinters) { zeroconf_detector_->AddDetections({MakeDiscoveredPrinter("DiscoveredPrinter"), MakeAutomaticPrinter("AutomaticPrinter")}); - synced_printers_manager_.AddConfiguredPrinters( - {Printer("Foo"), Printer("Bar")}); + synced_printers_manager_.AddSavedPrinters({Printer("Foo"), Printer("Bar")}); scoped_task_environment_.RunUntilIdle(); ExpectPrintersInClassAre(CupsPrintersManager::kDiscovered, @@ -417,7 +414,7 @@ // Start with a printer in each class named after the class it's in, except // Enterprise which is not relevant to this test. Printer existing_configured("Configured"); - synced_printers_manager_.AddConfiguredPrinters({existing_configured}); + synced_printers_manager_.AddSavedPrinters({existing_configured}); usb_detector_->AddDetections({MakeDiscoveredPrinter("Discovered")}); zeroconf_detector_->AddDetections({MakeAutomaticPrinter("Automatic")}); scoped_task_environment_.RunUntilIdle(); @@ -471,7 +468,7 @@ // Test that GetPrinter() finds printers in any class, and returns null if // a printer is not found. TEST_F(CupsPrintersManagerTest, GetPrinter) { - synced_printers_manager_.AddConfiguredPrinters({Printer("Configured")}); + synced_printers_manager_.AddSavedPrinters({Printer("Configured")}); synced_printers_manager_.AddEnterprisePrinters({Printer("Enterprise")}); usb_detector_->AddDetections({MakeDiscoveredPrinter("Discovered")}); zeroconf_detector_->AddDetections({MakeAutomaticPrinter("Automatic")}); @@ -492,7 +489,7 @@ // GetPrinters() will only return printers from // |CupsPrintersManager::kEnterprise|. TEST_F(CupsPrintersManagerTest, GetPrintersUserNativePrintersDisabled) { - synced_printers_manager_.AddConfiguredPrinters({Printer("Configured")}); + synced_printers_manager_.AddSavedPrinters({Printer("Configured")}); synced_printers_manager_.AddEnterprisePrinters({Printer("Enterprise")}); scoped_task_environment_.RunUntilIdle(); @@ -517,7 +514,7 @@ // Start by installing a configured printer to be used to test than any // changes made to the printer will not be propogated. Printer existing_configured("Configured"); - synced_printers_manager_.AddConfiguredPrinters({existing_configured}); + synced_printers_manager_.AddSavedPrinters({existing_configured}); usb_detector_->AddDetections({MakeDiscoveredPrinter("Discovered")}); zeroconf_detector_->AddDetections({MakeAutomaticPrinter("Automatic")}); scoped_task_environment_.RunUntilIdle(); @@ -572,7 +569,7 @@ // returns a printer when the given printer id corresponds to an enterprise // printer. Otherwise, it returns nothing. TEST_F(CupsPrintersManagerTest, GetPrinterUserNativePrintersDisabled) { - synced_printers_manager_.AddConfiguredPrinters({Printer("Configured")}); + synced_printers_manager_.AddSavedPrinters({Printer("Configured")}); synced_printers_manager_.AddEnterprisePrinters({Printer("Enterprise")}); scoped_task_environment_.RunUntilIdle();
diff --git a/chrome/browser/chromeos/printing/synced_printers_manager.cc b/chrome/browser/chromeos/printing/synced_printers_manager.cc index a3c5055..1294f32 100644 --- a/chrome/browser/chromeos/printing/synced_printers_manager.cc +++ b/chrome/browser/chromeos/printing/synced_printers_manager.cc
@@ -57,7 +57,7 @@ sync_bridge_->RemoveObserver(this); } - std::vector<Printer> GetConfiguredPrinters() const override { + std::vector<Printer> GetSavedPrinters() const override { // No need to lock here, since sync_bridge_ is thread safe and we don't // touch anything else. std::vector<Printer> printers; @@ -82,12 +82,12 @@ return GetPrinterLocked(printer_id); } - void UpdateConfiguredPrinter(const Printer& printer) override { + void UpdateSavedPrinter(const Printer& printer) override { base::AutoLock l(lock_); - UpdateConfiguredPrinterLocked(printer); + UpdateSavedPrinterLocked(printer); } - bool RemoveConfiguredPrinter(const std::string& printer_id) override { + bool RemoveSavedPrinter(const std::string& printer_id) override { return sync_bridge_->RemovePrinter(printer_id); } @@ -106,7 +106,7 @@ // Register this printer if it's the first time we're using it. if (!IsPrinterRegistered(printer.id())) { - UpdateConfiguredPrinterLocked(printer); + UpdateSavedPrinterLocked(printer); } } @@ -124,8 +124,7 @@ // PrintersSyncBridge::Observer override. void OnPrintersUpdated() override { observers_->Notify( - FROM_HERE, - &SyncedPrintersManager::Observer::OnConfiguredPrintersChanged); + FROM_HERE, &SyncedPrintersManager::Observer::OnSavedPrintersChanged); } // EnterprisePrintersProvider::Observer override @@ -165,7 +164,7 @@ sync_bridge_->HasPrinter(printer_id); } - void UpdateConfiguredPrinterLocked(const Printer& printer_arg) { + void UpdateSavedPrinterLocked(const Printer& printer_arg) { lock_.AssertAcquired(); DCHECK_EQ(Printer::SRC_USER_PREFS, printer_arg.source());
diff --git a/chrome/browser/chromeos/printing/synced_printers_manager.h b/chrome/browser/chromeos/printing/synced_printers_manager.h index 35bf0497..65193fc1 100644 --- a/chrome/browser/chromeos/printing/synced_printers_manager.h +++ b/chrome/browser/chromeos/printing/synced_printers_manager.h
@@ -26,7 +26,7 @@ namespace chromeos { -// Manages information about synced local printers classes (CONFIGURED +// Manages information about synced local printers classes (SAVED // and ENTERPRISE). Provides an interface to a user's printers and // printers provided by policy. User printers are backed by the // PrintersSyncBridge. @@ -36,7 +36,7 @@ public: class Observer { public: - virtual void OnConfiguredPrintersChanged() = 0; + virtual void OnSavedPrintersChanged() = 0; virtual void OnEnterprisePrintersChanged() {} }; @@ -49,25 +49,25 @@ static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); // Returns the printers that are saved in preferences. - virtual std::vector<Printer> GetConfiguredPrinters() const = 0; + virtual std::vector<Printer> GetSavedPrinters() const = 0; // Replaces given vector with vector of printers from enterprise policy. // Returns true if the enterprise policy was loaded and is valid. virtual bool GetEnterprisePrinters(std::vector<Printer>* printers) const = 0; // Returns the printer with id |printer_id|, or nullptr if no such printer - // exists. Searches both Configured and Enterprise printers. + // exists. Searches both Saved and Enterprise printers. virtual std::unique_ptr<Printer> GetPrinter( const std::string& printer_id) const = 0; // Adds or updates a printer in profile preferences. The |printer| is // identified by its id field. Those with an empty id are treated as new // printers. - virtual void UpdateConfiguredPrinter(const Printer& printer) = 0; + virtual void UpdateSavedPrinter(const Printer& printer) = 0; // Remove printer from preferences with the id |printer_id|. Returns true if // the printer was successfully removed. - virtual bool RemoveConfiguredPrinter(const std::string& printer_id) = 0; + virtual bool RemoveSavedPrinter(const std::string& printer_id) = 0; // Attach |observer| for notification of events. |observer| is expected to // live on the same thread (UI) as this object. OnPrinter* methods are @@ -83,9 +83,9 @@ virtual PrintersSyncBridge* GetSyncBridge() = 0; // Registers that the printer was installed in CUPS. If |printer| is not an - // already known printer (either a configured printer or an enterprise + // already known printer (either a saved printer or an enterprise // printer), this will have the side effect of saving |printer| as a - // configured printer. + // saved printer. virtual void PrinterInstalled(const Printer& printer) = 0; // Returns true if |printer| is currently installed in CUPS.
diff --git a/chrome/browser/chromeos/printing/synced_printers_manager_unittest.cc b/chrome/browser/chromeos/printing/synced_printers_manager_unittest.cc index 8332ede..665ebe4 100644 --- a/chrome/browser/chromeos/printing/synced_printers_manager_unittest.cc +++ b/chrome/browser/chromeos/printing/synced_printers_manager_unittest.cc
@@ -67,23 +67,21 @@ observer_.Add(source); } - void OnConfiguredPrintersChanged() override { - configured_printers_ = manager_->GetConfiguredPrinters(); + void OnSavedPrintersChanged() override { + saved_printers_ = manager_->GetSavedPrinters(); } void OnEnterprisePrintersChanged() override { manager_->GetEnterprisePrinters(&enterprise_printers_); } - const std::vector<Printer>& configured_printers() const { - return configured_printers_; - } + const std::vector<Printer>& saved_printers() const { return saved_printers_; } const std::vector<Printer>& enterprise_printers() const { return enterprise_printers_; } private: - std::vector<Printer> configured_printers_; + std::vector<Printer> saved_printers_; std::vector<Printer> enterprise_printers_; ScopedObserver<SyncedPrintersManager, SyncedPrintersManager::Observer> observer_; @@ -134,49 +132,49 @@ TEST_F(SyncedPrintersManagerTest, AddPrinter) { LoggingObserver observer(manager_.get()); - manager_->UpdateConfiguredPrinter(Printer(kTestPrinterId)); + manager_->UpdateSavedPrinter(Printer(kTestPrinterId)); - auto printers = manager_->GetConfiguredPrinters(); + auto printers = manager_->GetSavedPrinters(); ASSERT_EQ(1U, printers.size()); EXPECT_EQ(kTestPrinterId, printers[0].id()); EXPECT_EQ(Printer::Source::SRC_USER_PREFS, printers[0].source()); - ExpectObservedPrinterIdsAre(observer.configured_printers(), {kTestPrinterId}); + ExpectObservedPrinterIdsAre(observer.saved_printers(), {kTestPrinterId}); } TEST_F(SyncedPrintersManagerTest, UpdatePrinterAssignsId) { - manager_->UpdateConfiguredPrinter(Printer()); + manager_->UpdateSavedPrinter(Printer()); - auto printers = manager_->GetConfiguredPrinters(); + auto printers = manager_->GetSavedPrinters(); ASSERT_EQ(1U, printers.size()); EXPECT_FALSE(printers[0].id().empty()); } TEST_F(SyncedPrintersManagerTest, UpdatePrinter) { - manager_->UpdateConfiguredPrinter(Printer(kTestPrinterId)); + manager_->UpdateSavedPrinter(Printer(kTestPrinterId)); Printer updated_printer(kTestPrinterId); updated_printer.set_uri(kTestUri); // Register observer so it only receives the update event. LoggingObserver observer(manager_.get()); - manager_->UpdateConfiguredPrinter(updated_printer); + manager_->UpdateSavedPrinter(updated_printer); - auto printers = manager_->GetConfiguredPrinters(); + auto printers = manager_->GetSavedPrinters(); ASSERT_EQ(1U, printers.size()); EXPECT_EQ(kTestUri, printers[0].uri()); - ExpectObservedPrinterIdsAre(observer.configured_printers(), {kTestPrinterId}); + ExpectObservedPrinterIdsAre(observer.saved_printers(), {kTestPrinterId}); } TEST_F(SyncedPrintersManagerTest, RemovePrinter) { - manager_->UpdateConfiguredPrinter(Printer("OtherUUID")); - manager_->UpdateConfiguredPrinter(Printer(kTestPrinterId)); - manager_->UpdateConfiguredPrinter(Printer()); + manager_->UpdateSavedPrinter(Printer("OtherUUID")); + manager_->UpdateSavedPrinter(Printer(kTestPrinterId)); + manager_->UpdateSavedPrinter(Printer()); - manager_->RemoveConfiguredPrinter(kTestPrinterId); + manager_->RemoveSavedPrinter(kTestPrinterId); - auto printers = manager_->GetConfiguredPrinters(); + auto printers = manager_->GetSavedPrinters(); // One of the remaining ids should be "OtherUUID", the other should have // been automatically generated by the manager. @@ -241,9 +239,9 @@ EXPECT_TRUE(manager_->IsConfigurationCurrent(printer)); } -// Test that PrinterInstalled configures a printer if it doesn't appear in the -// enterprise or configured printer lists. -TEST_F(SyncedPrintersManagerTest, PrinterInstalledConfiguresPrinter) { +// Test that PrinterInstalled saves a printer if it doesn't appear in the +// enterprise or saved printer lists. +TEST_F(SyncedPrintersManagerTest, PrinterInstalledSavesPrinter) { // Set up an enterprise printer. auto value = std::make_unique<base::ListValue>(); value->AppendString(kColorLaserJson); @@ -257,14 +255,14 @@ manager_->GetEnterprisePrinters(&printers); std::string enterprise_id = printers.at(0).id(); - Printer configured(kTestPrinterId); + Printer saved(kTestPrinterId); - // Install a Configured printer - manager_->UpdateConfiguredPrinter(configured); + // Install |saved| printer. + manager_->UpdateSavedPrinter(saved); - // Installing the configured printer should *not* update it. - configured.set_display_name("display name"); - manager_->PrinterInstalled(configured); + // Installing |saved| should *not* update it. + saved.set_display_name("display name"); + manager_->PrinterInstalled(saved); auto found_printer = manager_->GetPrinter(kTestPrinterId); ASSERT_TRUE(found_printer); EXPECT_TRUE(found_printer->display_name().empty()); @@ -272,12 +270,12 @@ // Installing the enterprise printer should *not* generate a configuration // update. manager_->PrinterInstalled(Printer(enterprise_id)); - EXPECT_EQ(1U, manager_->GetConfiguredPrinters().size()); + EXPECT_EQ(1U, manager_->GetSavedPrinters().size()); // Installing a printer we don't know about *should* generate a configuration // update. manager_->PrinterInstalled(Printer(kTestPrinterId2)); - EXPECT_EQ(2U, manager_->GetConfiguredPrinters().size()); + EXPECT_EQ(2U, manager_->GetSavedPrinters().size()); } // Test that we detect that the configuration is stale when any of the relevant
diff --git a/chrome/browser/dom_distiller/dom_distiller_service_factory.cc b/chrome/browser/dom_distiller/dom_distiller_service_factory.cc index 88113cd5..c62e4581 100644 --- a/chrome/browser/dom_distiller/dom_distiller_service_factory.cc +++ b/chrome/browser/dom_distiller/dom_distiller_service_factory.cc
@@ -68,7 +68,7 @@ leveldb_proto::ProtoDatabaseProvider* db_provider = leveldb_proto::ProtoDatabaseProviderFactory::GetForKey( - profile->GetSimpleFactoryKey(), profile->GetPrefs()); + profile->GetProfileKey()); auto db = db_provider->GetDB<ArticleEntry>( leveldb_proto::ProtoDbType::DOM_DISTILLER_STORE, database_dir,
diff --git a/chrome/browser/download/download_service_factory.cc b/chrome/browser/download/download_service_factory.cc index 3a0d446..83053f8 100644 --- a/chrome/browser/download/download_service_factory.cc +++ b/chrome/browser/download/download_service_factory.cc
@@ -108,7 +108,7 @@ SystemNetworkContextManager::GetInstance()->GetSharedURLLoaderFactory(); return download::BuildInMemoryDownloadService( - profile->GetSimpleFactoryKey(), std::move(clients), + profile->GetProfileKey(), std::move(clients), content::GetNetworkConnectionTracker(), base::FilePath(), blob_context_getter, io_task_runner, url_loader_factory); } else { @@ -131,10 +131,10 @@ #endif return download::BuildDownloadService( - context, profile->GetSimpleFactoryKey(), profile->GetPrefs(), + context, profile->GetProfileKey(), profile->GetPrefs(), std::move(clients), content::GetNetworkConnectionTracker(), storage_dir, SimpleDownloadManagerCoordinatorFactory::GetForKey( - profile->GetSimpleFactoryKey(), nullptr), + profile->GetProfileKey()), background_task_runner, std::move(task_scheduler)); } }
diff --git a/chrome/browser/download/simple_download_manager_coordinator_factory.cc b/chrome/browser/download/simple_download_manager_coordinator_factory.cc index 0568468..3160183 100644 --- a/chrome/browser/download/simple_download_manager_coordinator_factory.cc +++ b/chrome/browser/download/simple_download_manager_coordinator_factory.cc
@@ -19,10 +19,9 @@ // static download::SimpleDownloadManagerCoordinator* -SimpleDownloadManagerCoordinatorFactory::GetForKey(SimpleFactoryKey* key, - PrefService* prefs) { +SimpleDownloadManagerCoordinatorFactory::GetForKey(SimpleFactoryKey* key) { return static_cast<download::SimpleDownloadManagerCoordinator*>( - GetInstance()->GetServiceForKey(key, prefs, true)); + GetInstance()->GetServiceForKey(key, true)); } SimpleDownloadManagerCoordinatorFactory:: @@ -35,7 +34,6 @@ std::unique_ptr<KeyedService> SimpleDownloadManagerCoordinatorFactory::BuildServiceInstanceFor( - SimpleFactoryKey* key, - PrefService* prefs) const { + SimpleFactoryKey* key) const { return std::make_unique<download::SimpleDownloadManagerCoordinator>(); }
diff --git a/chrome/browser/download/simple_download_manager_coordinator_factory.h b/chrome/browser/download/simple_download_manager_coordinator_factory.h index cb83720..fc57dc5 100644 --- a/chrome/browser/download/simple_download_manager_coordinator_factory.h +++ b/chrome/browser/download/simple_download_manager_coordinator_factory.h
@@ -11,7 +11,6 @@ #include "components/keyed_service/core/simple_keyed_service_factory.h" class KeyedService; -class PrefService; class SimpleFactoryKey; namespace base { @@ -33,8 +32,7 @@ // Returns SimpleDownloadManagerCoordinator associated with |key|. static download::SimpleDownloadManagerCoordinator* GetForKey( - SimpleFactoryKey* key, - PrefService* prefs); + SimpleFactoryKey* key); private: friend class base::NoDestructor<SimpleDownloadManagerCoordinatorFactory>; @@ -44,8 +42,7 @@ // SimpleKeyedServiceFactory overrides. std::unique_ptr<KeyedService> BuildServiceInstanceFor( - SimpleFactoryKey* key, - PrefService* prefs) const override; + SimpleFactoryKey* key) const override; DISALLOW_COPY_AND_ASSIGN(SimpleDownloadManagerCoordinatorFactory); };
diff --git a/chrome/browser/extensions/api/cast_streaming/performance_test.cc b/chrome/browser/extensions/api/cast_streaming/performance_test.cc index 8d3d46c..bda71aa 100644 --- a/chrome/browser/extensions/api/cast_streaming/performance_test.cc +++ b/chrome/browser/extensions/api/cast_streaming/performance_test.cc
@@ -67,13 +67,14 @@ // long enough to collect sufficient tracing data; and, unfortunately, there's // nothing we can do about that. #define EXPECT_FOR_PERFORMANCE_RUN(expr) \ - do { \ + if (!(expr)) { \ + const char *_out = #expr; \ if (is_full_performance_run()) { \ - EXPECT_TRUE(expr); \ - } else if (!(expr)) { \ - LOG(WARNING) << "Allowing failure: " << #expr; \ + LOG(ERROR) << "Failure: " << _out; \ + } else { \ + LOG(WARNING) << "Allowing failure: " << _out; \ } \ - } while (false) + } enum TestFlags { kSmallWindow = 1 << 2, // Window size: 1 = 800x600, 0 = 2000x1000 @@ -168,7 +169,7 @@ const std::string& modifier, const std::string& trace, const std::string& unit) { - if (num_values_ >= 20) { + if (num_values_ > 0) { perf_test::PrintResultMeanAndError(measurement, modifier, trace, @@ -176,8 +177,7 @@ unit, true); } else { - LOG(ERROR) << "Not enough events (" << num_values_ << ") for " - << measurement << modifier << " " << trace; + LOG(ERROR) << "No events for " << measurement << modifier << " " << trace; } }
diff --git a/chrome/browser/extensions/api/tab_capture/tab_capture_performance_test_base.cc b/chrome/browser/extensions/api/tab_capture/tab_capture_performance_test_base.cc index 7b455d2..fe7bf28a2 100644 --- a/chrome/browser/extensions/api/tab_capture/tab_capture_performance_test_base.cc +++ b/chrome/browser/extensions/api/tab_capture/tab_capture_performance_test_base.cc
@@ -22,6 +22,7 @@ #include "chrome/common/chrome_paths.h" #include "chrome/test/base/tracing.h" #include "chrome/test/base/ui_test_utils.h" +#include "content/public/common/content_features.h" #include "content/public/test/browser_test_utils.h" #include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_system.h" @@ -32,6 +33,7 @@ #include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/http_request.h" #include "net/test/embedded_test_server/http_response.h" +#include "services/service_manager/sandbox/features.h" #include "third_party/zlib/google/compression_utils.h" #include "ui/gl/gl_switches.h" @@ -47,6 +49,15 @@ // Because screen capture is involved, require pixel output. EnablePixelOutput(); + feature_list_.InitWithFeatures( + { + service_manager::features::kAudioServiceSandbox, + features::kAudioServiceAudioStreams, + features::kAudioServiceLaunchOnStartup, + features::kAudioServiceOutOfProcess, + }, + {}); + InProcessBrowserTest::SetUp(); }
diff --git a/chrome/browser/extensions/api/tab_capture/tab_capture_performance_test_base.h b/chrome/browser/extensions/api/tab_capture/tab_capture_performance_test_base.h index 51d0fd4..8a1c7146 100644 --- a/chrome/browser/extensions/api/tab_capture/tab_capture_performance_test_base.h +++ b/chrome/browser/extensions/api/tab_capture/tab_capture_performance_test_base.h
@@ -11,6 +11,7 @@ #include "base/macros.h" #include "base/strings/string_piece.h" +#include "base/test/scoped_feature_list.h" #include "base/test/trace_event_analyzer.h" #include "chrome/test/base/in_process_browser_test.h" @@ -135,6 +136,9 @@ const extensions::Extension* extension_ = nullptr; + // Manages the Audio Service feature set, enabled for these performance tests. + base::test::ScopedFeatureList feature_list_; + DISALLOW_COPY_AND_ASSIGN(TabCapturePerformanceTestBase); };
diff --git a/chrome/browser/extensions/chrome_app_icon_unittest.cc b/chrome/browser/extensions/chrome_app_icon_unittest.cc index 9b8f87e1..58338b7 100644 --- a/chrome/browser/extensions/chrome_app_icon_unittest.cc +++ b/chrome/browser/extensions/chrome_app_icon_unittest.cc
@@ -388,7 +388,6 @@ const gfx::ImageSkia image_before_badging = reference_icon.image_skia(); // Badging should be applied once package is installed. - arc_test.app_instance()->RefreshAppList(); std::vector<arc::mojom::AppInfo> fake_apps = arc_test.fake_apps(); fake_apps[0].package_name = arc_test.fake_packages()[0]->package_name; arc_test.app_instance()->SendRefreshAppList(fake_apps);
diff --git a/chrome/browser/extensions/extension_management.cc b/chrome/browser/extensions/extension_management.cc index eddb080..3e99ca14 100644 --- a/chrome/browser/extensions/extension_management.cc +++ b/chrome/browser/extensions/extension_management.cc
@@ -68,6 +68,8 @@ pref_change_registrar_.Add(pref_names::kAllowedTypes, pref_change_callback); pref_change_registrar_.Add(pref_names::kExtensionManagement, pref_change_callback); + pref_change_registrar_.Add(pref_names::kUninstallBlacklistedExtensions, + pref_change_callback); #if !defined(OS_CHROMEOS) pref_change_registrar_.Add(prefs::kCloudReportingEnabled, pref_change_callback); @@ -308,6 +310,10 @@ return meets_requirement; } +bool ExtensionManagement::ShouldUninstallPolicyBlacklistedExtensions() const { + return pref_service_->GetBoolean(pref_names::kUninstallBlacklistedExtensions); +} + void ExtensionManagement::Refresh() { TRACE_EVENT0("browser,startup", "ExtensionManagement::Refresh"); SCOPED_UMA_HISTOGRAM_TIMER("Extensions.ExtensionManagement_RefreshTime");
diff --git a/chrome/browser/extensions/extension_management.h b/chrome/browser/extensions/extension_management.h index 4f87283..7d7fa1a 100644 --- a/chrome/browser/extensions/extension_management.h +++ b/chrome/browser/extensions/extension_management.h
@@ -169,6 +169,10 @@ bool CheckMinimumVersion(const Extension* extension, std::string* required_version) const; + // Returns true if there is a policy setting that explicitly uninstalls + // blacklisted extensions that are installed + bool ShouldUninstallPolicyBlacklistedExtensions() const; + private: using SettingsIdMap = std::unordered_map<ExtensionId,
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index caeefb2..306d95c 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc
@@ -25,6 +25,7 @@ #include "base/strings/string_tokenizer.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/syslog_logging.h" #include "base/task/post_task.h" #include "base/threading/thread_restrictions.h" #include "base/threading/thread_task_runner_handle.h" @@ -1028,6 +1029,23 @@ if (!to_recheck.ids.empty()) updater_->CheckNow(std::move(to_recheck)); } + + // Check the disabled extensions to see if any should be force uninstalled. + std::vector<ExtensionId> remove_list; + for (const auto& extension : registry_->disabled_extensions()) { + if (system_->management_policy()->ShouldForceUninstall(extension.get(), + nullptr /*error*/)) { + remove_list.push_back(extension->id()); + } + } + for (auto extension_id : remove_list) { + base::string16 error; + if (!UninstallExtension(extension_id, UNINSTALL_REASON_INTERNAL_MANAGEMENT, + &error)) { + SYSLOG(WARNING) << "Extension with id " << extension_id + << " failed to be uninstalled via policy: " << error; + } + } } void ExtensionService::CheckForUpdatesSoon() {
diff --git a/chrome/browser/extensions/standard_management_policy_provider.cc b/chrome/browser/extensions/standard_management_policy_provider.cc index a4e37085..bf49c50 100644 --- a/chrome/browser/extensions/standard_management_policy_provider.cc +++ b/chrome/browser/extensions/standard_management_policy_provider.cc
@@ -199,6 +199,20 @@ return false; } +bool StandardManagementPolicyProvider::ShouldForceUninstall( + const Extension* extension, + base::string16* error) const { + if (!settings_->ShouldUninstallPolicyBlacklistedExtensions()) + return false; + if (UserMayLoad(extension, error)) + return false; + if (settings_->GetInstallationMode(extension) == + ExtensionManagement::INSTALLATION_BLOCKED) { + return true; + } + return false; +} + bool StandardManagementPolicyProvider::ReturnLoadError( const extensions::Extension* extension, base::string16* error) const {
diff --git a/chrome/browser/extensions/standard_management_policy_provider.h b/chrome/browser/extensions/standard_management_policy_provider.h index 0df9511..9b98488 100644 --- a/chrome/browser/extensions/standard_management_policy_provider.h +++ b/chrome/browser/extensions/standard_management_policy_provider.h
@@ -42,6 +42,8 @@ base::string16* error) const override; bool MustRemainInstalled(const Extension* extension, base::string16* error) const override; + bool ShouldForceUninstall(const Extension* extension, + base::string16* error) const override; private: const ExtensionManagement* settings_;
diff --git a/chrome/browser/feature_engagement/tracker_factory.cc b/chrome/browser/feature_engagement/tracker_factory.cc index b54bcc8..044e7c3 100644 --- a/chrome/browser/feature_engagement/tracker_factory.cc +++ b/chrome/browser/feature_engagement/tracker_factory.cc
@@ -53,7 +53,7 @@ leveldb_proto::ProtoDatabaseProvider* db_provider = leveldb_proto::ProtoDatabaseProviderFactory::GetInstance()->GetForKey( - profile->GetSimpleFactoryKey(), profile->GetPrefs()); + profile->GetProfileKey()); return feature_engagement::Tracker::Create( storage_dir, background_task_runner, db_provider); }
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json index a36cd56..a179f4c 100644 --- a/chrome/browser/flag-metadata.json +++ b/chrome/browser/flag-metadata.json
@@ -2356,6 +2356,11 @@ "expiry_milestone": 76 }, { + "name": "ntp-customization-menu-v2", + "owners": ["kmilka", "ramyan"], + "expiry_milestone": 77 + }, + { "name": "oculus-vr", "owners": [ "//device/vr/OWNERS", "xr-dev@chromium.org" ], "expiry_milestone": 76 @@ -2491,6 +2496,11 @@ "expiry_milestone": 76 }, { + "name": "omnibox-suggestion-transparency-options", + "owners": [ "tommycli", "chrome-omnibox-team@google.com" ], + "expiry_milestone": 80 + }, + { "name": "omnibox-tab-switch-suggestions", "owners": [ "krb", "chrome-omnibox-team@google.com" ], "expiry_milestone": 76 @@ -3107,6 +3117,11 @@ "name": "xr-sandbox", "owners": [ "//chrome/services/isolated_xr_device/OWNERS", "xr-dev@chromium.org" ], "expiry_milestone": 76 + }, + { + "name": "enable-streamlined-usb-printer-setup", + "owners": [ "baileyberro" ], + "expiry_milestone": 77 } // This is an alphabetized list; please do your part to keep it organized by
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc index 0a291df..db24541 100644 --- a/chrome/browser/flag_descriptions.cc +++ b/chrome/browser/flag_descriptions.cc
@@ -2709,6 +2709,10 @@ const char kRemoveNtpFakeboxDescription[] = "Do not show the fakebox on the New Tab page."; +const char kNtpCustomizationMenuV2Name[] = "NTP customization menu version 2"; +const char kNtpCustomizationMenuV2Description[] = + "Use the second version of the NTP customization menu."; + const char kEnableWebAuthenticationBleSupportName[] = "Web Authentication API BLE support"; const char kEnableWebAuthenticationBleSupportDescription[] = @@ -2771,6 +2775,13 @@ "Reverse the logic of suggestions that have a tab switch button: Have " "them switch by default, and have the button navigate."; +const char kOmniboxSuggestionTransparencyOptionsName[] = + "Omnibox Suggestion Transparency Options"; +const char kOmniboxSuggestionTransparencyOptionsDescription[] = + "Improves transparency of and control over omnibox suggestions. This " + "includes UI cues (like a clock icon for Search History suggestions), as " + "well as user controls to delete personalized suggestions."; + const char kOmniboxTabSwitchSuggestionsName[] = "Omnibox tab switch suggestions"; const char kOmniboxTabSwitchSuggestionsDescription[] = @@ -3320,6 +3331,12 @@ "Shows quick actions for text " "selections in the context menu."; +const char kStreamlinedUsbPrinterSetupName[] = + "Streamlined USB Printer Setup Flow"; +const char kStreamlinedUsbPrinterSetupDescription[] = + "Automatically sets up capable USB printers when plugged in. Shows a " + "notification with the setup result."; + const char kTetherName[] = "Instant Tethering"; const char kTetherDescription[] = "Enables Instant Tethering. Instant Tethering allows your nearby Google "
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h index 662fd77d..93f2303 100644 --- a/chrome/browser/flag_descriptions.h +++ b/chrome/browser/flag_descriptions.h
@@ -1613,6 +1613,9 @@ extern const char kRemoveNtpFakeboxName[]; extern const char kRemoveNtpFakeboxDescription[]; +extern const char kNtpCustomizationMenuV2Name[]; +extern const char kNtpCustomizationMenuV2Description[]; + extern const char kEnableWebAuthenticationBleSupportName[]; extern const char kEnableWebAuthenticationBleSupportDescription[]; @@ -1646,6 +1649,9 @@ extern const char kOmniboxReverseTabSwitchLogicName[]; extern const char kOmniboxReverseTabSwitchLogicDescription[]; +extern const char kOmniboxSuggestionTransparencyOptionsName[]; +extern const char kOmniboxSuggestionTransparencyOptionsDescription[]; + extern const char kOmniboxTabSwitchSuggestionsName[]; extern const char kOmniboxTabSwitchSuggestionsDescription[]; @@ -2000,6 +2006,9 @@ extern const char kSmartTextSelectionName[]; extern const char kSmartTextSelectionDescription[]; +extern const char kStreamlinedUsbPrinterSetupName[]; +extern const char kStreamlinedUsbPrinterSetupDescription[]; + extern const char kTetherName[]; extern const char kTetherDescription[];
diff --git a/chrome/browser/image_fetcher/image_fetcher_service_factory.cc b/chrome/browser/image_fetcher/image_fetcher_service_factory.cc index 1f294a61..ad2fc5c 100644 --- a/chrome/browser/image_fetcher/image_fetcher_service_factory.cc +++ b/chrome/browser/image_fetcher/image_fetcher_service_factory.cc
@@ -15,6 +15,7 @@ #include "build/build_config.h" #include "chrome/browser/image_fetcher/image_decoder_impl.h" #include "chrome/browser/net/system_network_context_manager.h" +#include "chrome/browser/profiles/profile_key.h" #include "chrome/common/chrome_paths_internal.h" #include "components/image_fetcher/core/cache/image_cache.h" #include "components/image_fetcher/core/cache/image_data_store_disk.h" @@ -44,10 +45,9 @@ // static image_fetcher::ImageFetcherService* ImageFetcherServiceFactory::GetForKey( - SimpleFactoryKey* key, - PrefService* prefs) { + SimpleFactoryKey* key) { return static_cast<image_fetcher::ImageFetcherService*>( - GetInstance()->GetServiceForKey(key, prefs, true)); + GetInstance()->GetServiceForKey(key, true)); } // static @@ -64,8 +64,8 @@ ImageFetcherServiceFactory::~ImageFetcherServiceFactory() = default; std::unique_ptr<KeyedService> -ImageFetcherServiceFactory::BuildServiceInstanceFor(SimpleFactoryKey* key, - PrefService* prefs) const { +ImageFetcherServiceFactory::BuildServiceInstanceFor( + SimpleFactoryKey* key) const { base::FilePath cache_path = GetCachePath(key); scoped_refptr<base::SequencedTaskRunner> task_runner = @@ -75,15 +75,16 @@ auto metadata_store = std::make_unique<image_fetcher::ImageMetadataStoreLevelDB>( - leveldb_proto::ProtoDatabaseProviderFactory::GetForKey(key, prefs), + leveldb_proto::ProtoDatabaseProviderFactory::GetForKey(key), cache_path, task_runner, clock); auto data_store = std::make_unique<image_fetcher::ImageDataStoreDisk>( cache_path, task_runner); + ProfileKey* profile_key = ProfileKey::FromSimpleFactoryKey(key); scoped_refptr<image_fetcher::ImageCache> image_cache = base::MakeRefCounted<image_fetcher::ImageCache>( - std::move(data_store), std::move(metadata_store), prefs, clock, - task_runner); + std::move(data_store), std::move(metadata_store), + profile_key->prefs(), clock, task_runner); scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory = SystemNetworkContextManager::GetInstance()->GetSharedURLLoaderFactory();
diff --git a/chrome/browser/image_fetcher/image_fetcher_service_factory.h b/chrome/browser/image_fetcher/image_fetcher_service_factory.h index 6b1f06c..fbb01a1 100644 --- a/chrome/browser/image_fetcher/image_fetcher_service_factory.h +++ b/chrome/browser/image_fetcher/image_fetcher_service_factory.h
@@ -13,7 +13,6 @@ #include "components/keyed_service/core/simple_keyed_service_factory.h" class SimpleFactoryKey; -class PrefService; namespace image_fetcher { class ImageFetcherService; @@ -25,8 +24,7 @@ // Return the cache path for the given profile. static base::FilePath GetCachePath(SimpleFactoryKey* key); - static image_fetcher::ImageFetcherService* GetForKey(SimpleFactoryKey* key, - PrefService* prefs); + static image_fetcher::ImageFetcherService* GetForKey(SimpleFactoryKey* key); static ImageFetcherServiceFactory* GetInstance(); private: @@ -37,8 +35,7 @@ // SimpleKeyedServiceFactory: std::unique_ptr<KeyedService> BuildServiceInstanceFor( - SimpleFactoryKey* key, - PrefService* prefs) const override; + SimpleFactoryKey* key) const override; SimpleFactoryKey* GetKeyToUse(SimpleFactoryKey* key) const override; DISALLOW_COPY_AND_ASSIGN(ImageFetcherServiceFactory);
diff --git a/chrome/browser/lookalikes/lookalike_url_navigation_throttle.cc b/chrome/browser/lookalikes/lookalike_url_navigation_throttle.cc index 72567b38..37c33b1 100644 --- a/chrome/browser/lookalikes/lookalike_url_navigation_throttle.cc +++ b/chrome/browser/lookalikes/lookalike_url_navigation_throttle.cc
@@ -348,34 +348,36 @@ &match_type)) { return content::NavigationThrottle::PROCEED; } - DCHECK(!matched_domain.empty()); - // matched_domain can be a top domain or an engaged domain. Simply use its - // eTLD+1 as the suggested domain. - // 1. If matched_domain is a top domain: Top domain list already contains - // eTLD+1s only so this works well. - // 2. If matched_domain is an engaged domain and is not an eTLD+1, don't - // suggest it. Otherwise, navigating to googlé.com and having engaged with - // docs.google.com would suggest docs.google.com. - // - // When the navigated and matched domains are not eTLD+1s (e.g. - // docs.googlé.com and docs.google.com), this will suggest google.com instead - // of docs.google.com. This is less than ideal, but has two benefits: - // - Simpler code - // - Fewer suggestions to non-existent domains. E.g. When the navigated domain - // is nonexistent.googlé.com and the matched domain is docs.google.com, we - // will suggest google.com instead of nonexistent.google.com. - const std::string suggested_domain = GetETLDPlusOne(matched_domain); - DCHECK(!suggested_domain.empty()); - - GURL::Replacements replace_host; - replace_host.SetHostStr(suggested_domain); - const GURL suggested_url = url.ReplaceComponents(replace_host); ukm::SourceId source_id = ukm::ConvertToSourceId( navigation_handle()->GetNavigationId(), ukm::SourceIdType::NAVIGATION_ID); if (ShouldDisplayInterstitial(match_type)) { + // matched_domain can be a top domain or an engaged domain. Simply use its + // eTLD+1 as the suggested domain. + // 1. If matched_domain is a top domain: Top domain list already contains + // eTLD+1s only so this works well. + // 2. If matched_domain is an engaged domain and is not an eTLD+1, don't + // suggest it. Otherwise, navigating to googlé.com and having engaged with + // docs.google.com would suggest docs.google.com. + // + // When the navigated and matched domains are not eTLD+1s (e.g. + // docs.googlé.com and docs.google.com), this will suggest google.com + // instead of docs.google.com. This is less than ideal, but has two + // benefits: + // - Simpler code + // - Fewer suggestions to non-existent domains. E.g. When the navigated + // domain is nonexistent.googlé.com and the matched domain is + // docs.google.com, we will suggest google.com instead of + // nonexistent.google.com. + const std::string suggested_domain = GetETLDPlusOne(matched_domain); + DCHECK(!suggested_domain.empty()); + // Drop everything but the parts of the origin. + GURL::Replacements replace_host; + replace_host.SetHostStr(suggested_domain); + const GURL suggested_url = + url.ReplaceComponents(replace_host).GetWithEmptyPath(); return ShowInterstitial(suggested_url, url, source_id, match_type); }
diff --git a/chrome/browser/lookalikes/lookalike_url_navigation_throttle_browsertest.cc b/chrome/browser/lookalikes/lookalike_url_navigation_throttle_browsertest.cc index 922d6704..aa7d14b 100644 --- a/chrome/browser/lookalikes/lookalike_url_navigation_throttle_browsertest.cc +++ b/chrome/browser/lookalikes/lookalike_url_navigation_throttle_browsertest.cc
@@ -199,6 +199,10 @@ return embedded_test_server()->GetURL(hostname, "/title1.html"); } + GURL GetURLWithoutPath(const char* hostname) const { + return GetURL(hostname).GetWithEmptyPath(); + } + GURL GetLongRedirect(const char* via_hostname1, const char* via_hostname2, const char* dest_hostname) const { @@ -407,7 +411,7 @@ base::HistogramTester histograms; const GURL kNavigatedUrl = GetURL("googlé.com"); - const GURL kExpectedSuggestedUrl = GetURL("google.com"); + const GURL kExpectedSuggestedUrl = GetURLWithoutPath("google.com"); // Even if the navigated site has a low engagement score, it should be // considered for lookalike suggestions. SetEngagementScore(browser(), kNavigatedUrl, kLowEngagement); @@ -428,7 +432,7 @@ base::HistogramTester histograms; const GURL kNavigatedUrl = GetURL("аррӏе.com"); - const GURL kExpectedSuggestedUrl = GetURL("apple.com"); + const GURL kExpectedSuggestedUrl = GetURLWithoutPath("apple.com"); // Even if the navigated site has a low engagement score, it should be // considered for lookalike suggestions. SetEngagementScore(browser(), kNavigatedUrl, kLowEngagement); @@ -657,7 +661,7 @@ for (const auto& test_case : kSiteEngagementTestCases) { base::HistogramTester histograms; const GURL kNavigatedUrl = GetURL(test_case.navigated); - const GURL kExpectedSuggestedUrl = GetURL(test_case.suggested); + const GURL kExpectedSuggestedUrl = GetURLWithoutPath(test_case.suggested); // Even if the navigated site has a low engagement score, it should be // considered for lookalike suggestions. @@ -683,7 +687,7 @@ Idn_SiteEngagementAndTopDomain_Match) { base::HistogramTester histograms; const GURL kNavigatedUrl = GetURL("googlé.com"); - const GURL kExpectedSuggestedUrl = GetURL("google.com"); + const GURL kExpectedSuggestedUrl = GetURLWithoutPath("google.com"); SetEngagementScore(browser(), kNavigatedUrl, kLowEngagement); SetEngagementScore(browser(), kExpectedSuggestedUrl, kHighEngagement); @@ -704,7 +708,7 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest, Idn_SiteEngagement_Match_Incognito) { const GURL kNavigatedUrl = GetURL("sité1.com"); - const GURL kEngagedUrl = GetURL("site1.com"); + const GURL kEngagedUrl = GetURLWithoutPath("site1.com"); // Set high engagement scores in the main profile and low engagement scores // in incognito. Main profile should record metrics, incognito shouldn't.
diff --git a/chrome/browser/metrics/bluetooth_available_utility.cc b/chrome/browser/metrics/bluetooth_available_utility.cc index 1f6c2239..e046a5b 100644 --- a/chrome/browser/metrics/bluetooth_available_utility.cc +++ b/chrome/browser/metrics/bluetooth_available_utility.cc
@@ -21,7 +21,7 @@ namespace bluetooth_utility { void ReportAvailability(BluetoothAvailability availability) { - UMA_HISTOGRAM_ENUMERATION("Bluetooth.Availability", availability, + UMA_HISTOGRAM_ENUMERATION("Bluetooth.Availability.v2", availability, BLUETOOTH_AVAILABILITY_COUNT); } @@ -40,15 +40,17 @@ } void ReportBluetoothAvailability() { +#if !defined(OS_MACOSX) && !defined(OS_WIN) && !defined(OS_LINUX) + // This is only relevant for desktop platforms. + return; +#endif + #if defined(OS_MACOSX) // TODO(kenrb): This is separate from other platforms because we get a // little bit of extra information from the Mac-specific code. It might not // be worth having the extra code path, and we should consider whether to // combine them (https://crbug.com/907279). - bluetooth_utility::BluetoothAvailability availability = - bluetooth_utility::GetBluetoothAvailability(); - UMA_HISTOGRAM_ENUMERATION("Bluetooth.Availability", availability, - bluetooth_utility::BLUETOOTH_AVAILABILITY_COUNT); + ReportAvailability(bluetooth_utility::GetBluetoothAvailability()); return; #endif // defined(OS_MACOSX) @@ -69,8 +71,10 @@ return; #endif // defined(OS_LINUX) - if (!device::BluetoothAdapterFactory::Get().IsBluetoothSupported()) + if (!device::BluetoothAdapterFactory::Get().IsBluetoothSupported()) { ReportAvailability(BLUETOOTH_NOT_SUPPORTED); + return; + } device::BluetoothAdapterFactory::Get().GetAdapter( base::BindOnce(&OnGetAdapter));
diff --git a/chrome/browser/notifications/notification_display_service_impl.cc b/chrome/browser/notifications/notification_display_service_impl.cc index 33c8f59e..6d40ef9 100644 --- a/chrome/browser/notifications/notification_display_service_impl.cc +++ b/chrome/browser/notifications/notification_display_service_impl.cc
@@ -31,7 +31,7 @@ #include "chrome/browser/notifications/notification_platform_bridge_message_center.h" #endif -#if defined(OS_LINUX) || defined(OS_MACOSX) +#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_WIN) #include "chrome/browser/send_tab_to_self/desktop_notification_handler.h" #endif @@ -121,7 +121,7 @@ AddNotificationHandler(NotificationHandler::Type::WEB_PERSISTENT, std::make_unique<PersistentNotificationHandler>()); -#if defined(OS_LINUX) || defined(OS_MACOSX) +#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_WIN) AddNotificationHandler( NotificationHandler::Type::SEND_TAB_TO_SELF, std::make_unique<send_tab_to_self::DesktopNotificationHandler>(
diff --git a/chrome/browser/offline_pages/android/offline_page_model_factory.cc b/chrome/browser/offline_pages/android/offline_page_model_factory.cc index 46920ed..d9d82a6 100644 --- a/chrome/browser/offline_pages/android/offline_page_model_factory.cc +++ b/chrome/browser/offline_pages/android/offline_page_model_factory.cc
@@ -18,6 +18,7 @@ #include "chrome/browser/offline_pages/download_archive_manager.h" #include "chrome/browser/offline_pages/fresh_offline_content_observer.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/profiles/profile_key.h" #include "chrome/common/chrome_constants.h" #include "components/keyed_service/core/simple_dependency_manager.h" #include "components/offline_pages/core/model/offline_page_model_taskified.h" @@ -35,22 +36,20 @@ } // static -OfflinePageModel* OfflinePageModelFactory::GetForKey(SimpleFactoryKey* key, - PrefService* prefs) { +OfflinePageModel* OfflinePageModelFactory::GetForKey(SimpleFactoryKey* key) { return static_cast<OfflinePageModel*>( - GetInstance()->GetServiceForKey(key, prefs, /*create=*/true)); + GetInstance()->GetServiceForKey(key, /*create=*/true)); } // static OfflinePageModel* OfflinePageModelFactory::GetForBrowserContext( content::BrowserContext* browser_context) { Profile* profile = Profile::FromBrowserContext(browser_context); - return GetForKey(profile->GetSimpleFactoryKey(), profile->GetPrefs()); + return GetForKey(profile->GetProfileKey()); } std::unique_ptr<KeyedService> OfflinePageModelFactory::BuildServiceInstanceFor( - SimpleFactoryKey* key, - PrefService* prefs) const { + SimpleFactoryKey* key) const { scoped_refptr<base::SequencedTaskRunner> background_task_runner = base::CreateSequencedTaskRunnerWithTraits({base::MayBlock()}); @@ -68,10 +67,12 @@ temporary_archives_dir = temporary_archives_dir.Append(chrome::kOfflinePageArchivesDirname); } + + ProfileKey* profile_key = ProfileKey::FromSimpleFactoryKey(key); std::unique_ptr<ArchiveManager> archive_manager(new DownloadArchiveManager( temporary_archives_dir, persistent_archives_dir, DownloadPrefs::GetDefaultDownloadDirectory(), background_task_runner, - prefs)); + profile_key->prefs())); auto clock = std::make_unique<base::DefaultClock>(); std::unique_ptr<SystemDownloadManager> download_manager(
diff --git a/chrome/browser/offline_pages/android/prefetch_test_bridge.cc b/chrome/browser/offline_pages/android/prefetch_test_bridge.cc index 9223e1d..ad87463 100644 --- a/chrome/browser/offline_pages/android/prefetch_test_bridge.cc +++ b/chrome/browser/offline_pages/android/prefetch_test_bridge.cc
@@ -50,8 +50,7 @@ Profile* profile = ProfileManager::GetLastUsedProfile(); DCHECK(profile); image_fetcher::ImageFetcherService* service = - ImageFetcherServiceFactory::GetForKey(profile->GetSimpleFactoryKey(), - profile->GetPrefs()); + ImageFetcherServiceFactory::GetForKey(profile->GetProfileKey()); DCHECK(service); scoped_refptr<image_fetcher::ImageCache> cache = service->ImageCacheForTesting();
diff --git a/chrome/browser/offline_pages/offline_page_model_factory.h b/chrome/browser/offline_pages/offline_page_model_factory.h index 4b644741..e44f68c56 100644 --- a/chrome/browser/offline_pages/offline_page_model_factory.h +++ b/chrome/browser/offline_pages/offline_page_model_factory.h
@@ -31,10 +31,10 @@ class OfflinePageModelFactory : public SimpleKeyedServiceFactory { public: static OfflinePageModelFactory* GetInstance(); - static OfflinePageModel* GetForKey(SimpleFactoryKey* key, PrefService* prefs); + static OfflinePageModel* GetForKey(SimpleFactoryKey* key); - // Helper method that calls GetForKey(). Extracts the SimpleFactoryKey and - // the PrefService from |browser_context|, which is assumed to be a Profile. + // Helper method that calls GetForKey(). Extracts the SimpleFactoryKey + // from |browser_context|, which is assumed to be a Profile. static OfflinePageModel* GetForBrowserContext( content::BrowserContext* browser_context); @@ -45,8 +45,7 @@ ~OfflinePageModelFactory() override {} std::unique_ptr<KeyedService> BuildServiceInstanceFor( - SimpleFactoryKey* key, - PrefService* prefs) const override; + SimpleFactoryKey* key) const override; DISALLOW_COPY_AND_ASSIGN(OfflinePageModelFactory); };
diff --git a/chrome/browser/offline_pages/offline_page_request_handler_unittest.cc b/chrome/browser/offline_pages/offline_page_request_handler_unittest.cc index 034b020..d4043b42 100644 --- a/chrome/browser/offline_pages/offline_page_request_handler_unittest.cc +++ b/chrome/browser/offline_pages/offline_page_request_handler_unittest.cc
@@ -602,7 +602,7 @@ public_archives_dir_ = public_archives_temp_base_dir_.GetPath().AppendASCII( kPublicOfflineFileDir); OfflinePageModelFactory::GetInstance()->SetTestingFactoryAndUse( - profile()->GetSimpleFactoryKey(), profile()->GetPrefs(), + profile()->GetProfileKey(), base::BindRepeating( &OfflinePageRequestHandlerTestBase::BuildTestOfflinePageModel));
diff --git a/chrome/browser/offline_pages/offline_page_utils_unittest.cc b/chrome/browser/offline_pages/offline_page_utils_unittest.cc index 0630479..fb35003 100644 --- a/chrome/browser/offline_pages/offline_page_utils_unittest.cc +++ b/chrome/browser/offline_pages/offline_page_utils_unittest.cc
@@ -151,7 +151,7 @@ // Set up the factory for testing. OfflinePageModelFactory::GetInstance()->SetTestingFactoryAndUse( - profile_.GetSimpleFactoryKey(), profile_.GetPrefs(), + profile_.GetProfileKey(), base::BindRepeating(&BuildTestOfflinePageModel)); RunUntilIdle();
diff --git a/chrome/browser/offline_pages/prefetch/prefetch_service_factory.cc b/chrome/browser/offline_pages/prefetch/prefetch_service_factory.cc index 3d97262..38710ee 100644 --- a/chrome/browser/offline_pages/prefetch/prefetch_service_factory.cc +++ b/chrome/browser/offline_pages/prefetch/prefetch_service_factory.cc
@@ -112,10 +112,9 @@ suggested_articles_observer = std::make_unique<SuggestedArticlesObserver>(); thumbnail_fetcher = std::make_unique<ThumbnailFetcherImpl>(); } else { - SimpleFactoryKey* simple_factory_key = profile->GetSimpleFactoryKey(); + SimpleFactoryKey* simple_factory_key = profile->GetProfileKey(); image_fetcher::ImageFetcherService* image_fetcher_service = - ImageFetcherServiceFactory::GetForKey(simple_factory_key, - profile->GetPrefs()); + ImageFetcherServiceFactory::GetForKey(simple_factory_key); DCHECK(image_fetcher_service); image_fetcher = image_fetcher_service->GetImageFetcher( image_fetcher::ImageFetcherConfig::kDiskCacheOnly); @@ -141,7 +140,7 @@ auto callback = base::BindOnce(&OnProfileCreated, service); FullBrowserTransitionManager::Get()->RegisterCallbackOnProfileCreation( - profile->GetSimpleFactoryKey(), std::move(callback)); + profile->GetProfileKey(), std::move(callback)); return service; }
diff --git a/chrome/browser/offline_pages/recent_tab_helper_unittest.cc b/chrome/browser/offline_pages/recent_tab_helper_unittest.cc index 2775e346..ae6a2e8 100644 --- a/chrome/browser/offline_pages/recent_tab_helper_unittest.cc +++ b/chrome/browser/offline_pages/recent_tab_helper_unittest.cc
@@ -222,7 +222,7 @@ // Sets up the factories for testing. OfflinePageModelFactory::GetInstance()->SetTestingFactoryAndUse( - profile()->GetSimpleFactoryKey(), profile()->GetPrefs(), + profile()->GetProfileKey(), base::BindRepeating(&BuildTestOfflinePageModel)); RunUntilIdle(); RequestCoordinatorFactory::GetInstance()->SetTestingFactoryAndUse(
diff --git a/chrome/browser/performance_manager/graph/frame_node_impl_unittest.cc b/chrome/browser/performance_manager/graph/frame_node_impl_unittest.cc index 700c4eb2..9e01e6cd 100644 --- a/chrome/browser/performance_manager/graph/frame_node_impl_unittest.cc +++ b/chrome/browser/performance_manager/graph/frame_node_impl_unittest.cc
@@ -38,7 +38,7 @@ TEST_F(FrameNodeImplTest, AddFrameHierarchyBasic) { auto process = CreateNode<ProcessNodeImpl>(); - auto page = CreateNode<PageNodeImpl>(); + auto page = CreateNode<PageNodeImpl>(nullptr /*TEST*/); auto parent_node = CreateNode<FrameNodeImpl>(process.get(), page.get(), nullptr, 0); auto child2_node = CreateNode<FrameNodeImpl>(process.get(), page.get(), @@ -54,7 +54,7 @@ TEST_F(FrameNodeImplTest, Url) { auto process = CreateNode<ProcessNodeImpl>(); - auto page = CreateNode<PageNodeImpl>(); + auto page = CreateNode<PageNodeImpl>(nullptr /*TEST*/); auto frame_node = CreateNode<FrameNodeImpl>(process.get(), page.get(), nullptr, 0); EXPECT_TRUE(frame_node->url().is_empty()); @@ -65,7 +65,7 @@ TEST_F(FrameNodeImplTest, RemoveChildFrame) { auto process = CreateNode<ProcessNodeImpl>(); - auto page = CreateNode<PageNodeImpl>(); + auto page = CreateNode<PageNodeImpl>(nullptr /*TEST*/); auto parent_frame_node = CreateNode<FrameNodeImpl>(process.get(), page.get(), nullptr, 0); auto child_frame_node = CreateNode<FrameNodeImpl>(process.get(), page.get(),
diff --git a/chrome/browser/performance_manager/graph/mock_graphs.cc b/chrome/browser/performance_manager/graph/mock_graphs.cc index 83da70e..a84f57c 100644 --- a/chrome/browser/performance_manager/graph/mock_graphs.cc +++ b/chrome/browser/performance_manager/graph/mock_graphs.cc
@@ -31,7 +31,7 @@ Graph* graph) : system(TestNodeWrapper<SystemNodeImpl>::Create(graph)), process(TestNodeWrapper<TestProcessNodeImpl>::Create(graph)), - page(TestNodeWrapper<PageNodeImpl>::Create(graph)), + page(TestNodeWrapper<PageNodeImpl>::Create(graph, nullptr /*TEST*/)), frame(TestNodeWrapper<FrameNodeImpl>::Create(graph, process.get(), page.get(), @@ -51,7 +51,8 @@ MockMultiplePagesInSingleProcessGraph::MockMultiplePagesInSingleProcessGraph( Graph* graph) : MockSinglePageInSingleProcessGraph(graph), - other_page(TestNodeWrapper<PageNodeImpl>::Create(graph)), + other_page( + TestNodeWrapper<PageNodeImpl>::Create(graph, nullptr /*TEST*/)), other_frame(TestNodeWrapper<FrameNodeImpl>::Create(graph, process.get(), other_page.get(),
diff --git a/chrome/browser/performance_manager/graph/page_node_impl.cc b/chrome/browser/performance_manager/graph/page_node_impl.cc index 9138476b..1fc0f42ac 100644 --- a/chrome/browser/performance_manager/graph/page_node_impl.cc +++ b/chrome/browser/performance_manager/graph/page_node_impl.cc
@@ -42,8 +42,10 @@ } // namespace -PageNodeImpl::PageNodeImpl(Graph* graph) +PageNodeImpl::PageNodeImpl(Graph* graph, + const base::WeakPtr<WebContentsProxy>& weak_contents) : TypedNodeBase(graph), + contents_proxy_(weak_contents), visibility_change_time_(PerformanceManagerClock::NowTicks()) { DETACH_FROM_SEQUENCE(sequence_checker_); } @@ -52,6 +54,10 @@ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); } +const base::WeakPtr<WebContentsProxy>& PageNodeImpl::contents_proxy() const { + return contents_proxy_; +} + void PageNodeImpl::AddFrame(FrameNodeImpl* frame_node) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK(frame_node); @@ -186,6 +192,85 @@ return *main_frame_nodes_.begin(); } +bool PageNodeImpl::is_visible() const { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + return is_visible_.value(); +} + +bool PageNodeImpl::is_loading() const { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + return is_loading_.value(); +} + +ukm::SourceId PageNodeImpl::ukm_source_id() const { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + return ukm_source_id_.value(); +} + +PageNodeImpl::LifecycleState PageNodeImpl::lifecycle_state() const { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + return lifecycle_state_.value(); +} + +const base::flat_set<FrameNodeImpl*>& PageNodeImpl::main_frame_nodes() const { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + return main_frame_nodes_; +} + +base::TimeTicks PageNodeImpl::usage_estimate_time() const { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + return usage_estimate_time_; +} + +base::TimeDelta PageNodeImpl::cumulative_cpu_usage_estimate() const { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + return cumulative_cpu_usage_estimate_; +} + +uint64_t PageNodeImpl::private_footprint_kb_estimate() const { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + return private_footprint_kb_estimate_; +} + +bool PageNodeImpl::page_almost_idle() const { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + return page_almost_idle_.value(); +} + +const GURL& PageNodeImpl::main_frame_url() const { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + return main_frame_url_; +} + +int64_t PageNodeImpl::navigation_id() const { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + return navigation_id_; +} + +void PageNodeImpl::set_usage_estimate_time( + base::TimeTicks usage_estimate_time) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + usage_estimate_time_ = usage_estimate_time; +} + +void PageNodeImpl::set_cumulative_cpu_usage_estimate( + base::TimeDelta cumulative_cpu_usage_estimate) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + cumulative_cpu_usage_estimate_ = cumulative_cpu_usage_estimate; +} + +void PageNodeImpl::set_private_footprint_kb_estimate( + uint64_t private_footprint_kb_estimate) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + private_footprint_kb_estimate_ = private_footprint_kb_estimate; +} + +void PageNodeImpl::set_has_nonempty_beforeunload( + bool has_nonempty_beforeunload) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + has_nonempty_beforeunload_ = has_nonempty_beforeunload; +} + void PageNodeImpl::OnFrameLifecycleStateChanged( FrameNodeImpl* frame_node, resource_coordinator::mojom::LifecycleState old_state) {
diff --git a/chrome/browser/performance_manager/graph/page_node_impl.h b/chrome/browser/performance_manager/graph/page_node_impl.h index 668f7d7..19f6355 100644 --- a/chrome/browser/performance_manager/graph/page_node_impl.h +++ b/chrome/browser/performance_manager/graph/page_node_impl.h
@@ -14,6 +14,7 @@ #include "chrome/browser/performance_manager/graph/node_attached_data.h" #include "chrome/browser/performance_manager/graph/node_base.h" #include "chrome/browser/performance_manager/observers/graph_observer.h" +#include "chrome/browser/performance_manager/web_contents_proxy.h" #include "services/metrics/public/cpp/ukm_source_id.h" #include "url/gurl.h" @@ -30,9 +31,15 @@ return resource_coordinator::CoordinationUnitType::kPage; } - explicit PageNodeImpl(Graph* graph); + explicit PageNodeImpl(Graph* graph, + const base::WeakPtr<WebContentsProxy>& contents_proxy); ~PageNodeImpl() override; + // Returns the web contents associated with this page node. It is valid to + // call this function on any thread but the weak pointer must only be + // dereferenced on the UI thread. + const base::WeakPtr<WebContentsProxy>& contents_proxy() const; + void SetIsLoading(bool is_loading); void SetIsVisible(bool is_visible); void SetUkmSourceId(ukm::SourceId ukm_source_id); @@ -69,43 +76,33 @@ FrameNodeImpl* GetMainFrameNode() const; // Accessors. - bool is_visible() const { return is_visible_.value(); } - bool is_loading() const { return is_loading_.value(); } - ukm::SourceId ukm_source_id() const { return ukm_source_id_.value(); } - LifecycleState lifecycle_state() const { return lifecycle_state_.value(); } - const base::flat_set<FrameNodeImpl*>& main_frame_nodes() const { - return main_frame_nodes_; - } - base::TimeTicks usage_estimate_time() const { return usage_estimate_time_; } - void set_usage_estimate_time(base::TimeTicks usage_estimate_time) { - usage_estimate_time_ = usage_estimate_time; - } - base::TimeDelta cumulative_cpu_usage_estimate() const { - return cumulative_cpu_usage_estimate_; - } - void set_cumulative_cpu_usage_estimate( - base::TimeDelta cumulative_cpu_usage_estimate) { - cumulative_cpu_usage_estimate_ = cumulative_cpu_usage_estimate; - } - uint64_t private_footprint_kb_estimate() const { - return private_footprint_kb_estimate_; - } - void set_private_footprint_kb_estimate( - uint64_t private_footprint_kb_estimate) { - private_footprint_kb_estimate_ = private_footprint_kb_estimate; - } - void set_has_nonempty_beforeunload(bool has_nonempty_beforeunload) { - has_nonempty_beforeunload_ = has_nonempty_beforeunload; - } - bool page_almost_idle() const { return page_almost_idle_.value(); } + bool is_visible() const; + bool is_loading() const; + ukm::SourceId ukm_source_id() const; + LifecycleState lifecycle_state() const; + const base::flat_set<FrameNodeImpl*>& main_frame_nodes() const; + base::TimeTicks usage_estimate_time() const; + base::TimeDelta cumulative_cpu_usage_estimate() const; + uint64_t private_footprint_kb_estimate() const; + bool page_almost_idle() const; + const GURL& main_frame_url() const; + int64_t navigation_id() const; - const GURL& main_frame_url() const { return main_frame_url_; } - int64_t navigation_id() const { return navigation_id_; } + void set_usage_estimate_time(base::TimeTicks usage_estimate_time); + void set_cumulative_cpu_usage_estimate( + base::TimeDelta cumulative_cpu_usage_estimate); + void set_private_footprint_kb_estimate( + uint64_t private_footprint_kb_estimate); + void set_has_nonempty_beforeunload(bool has_nonempty_beforeunload); // Invoked when the state of a frame in this page changes. + // TODO(chrisha): Move this out to a decorator. void OnFrameLifecycleStateChanged(FrameNodeImpl* frame_node, LifecycleState old_state); + // Invoked when a frame belonging to this page changes intervention policy + // values. + // TODO(chrisha): Move this out to a decorator. void OnFrameInterventionPolicyChanged( FrameNodeImpl* frame, resource_coordinator::mojom::PolicyControlledIntervention intervention, @@ -179,6 +176,9 @@ template <typename MapFunction> void ForAllFrameNodes(MapFunction map_function) const; + // A weak pointer to the WebContentsProxy associated with this page. + const base::WeakPtr<WebContentsProxy> contents_proxy_; + // The main frame nodes of this page. There can be more than one main frame // in a page, among other reasons because during main frame navigation, the // pending navigation will coexist with the existing main frame until it's
diff --git a/chrome/browser/performance_manager/graph/page_node_impl_unittest.cc b/chrome/browser/performance_manager/graph/page_node_impl_unittest.cc index 2c6250c..3bbe79e7 100644 --- a/chrome/browser/performance_manager/graph/page_node_impl_unittest.cc +++ b/chrome/browser/performance_manager/graph/page_node_impl_unittest.cc
@@ -40,7 +40,7 @@ TEST_F(PageNodeImplTest, AddFrameBasic) { auto process_node = CreateNode<ProcessNodeImpl>(); - auto page_node = CreateNode<PageNodeImpl>(); + auto page_node = CreateNode<PageNodeImpl>(nullptr /*TEST*/); auto parent_frame = CreateNode<FrameNodeImpl>(process_node.get(), page_node.get(), nullptr, 0); auto child1_frame = CreateNode<FrameNodeImpl>( @@ -54,7 +54,7 @@ TEST_F(PageNodeImplTest, RemoveFrame) { auto process_node = CreateNode<ProcessNodeImpl>(); - auto page_node = CreateNode<PageNodeImpl>(); + auto page_node = CreateNode<PageNodeImpl>(nullptr /*TEST*/); auto frame_node = CreateNode<FrameNodeImpl>(process_node.get(), page_node.get(), nullptr, 0); @@ -227,7 +227,7 @@ TestNodeWrapper<ProcessNodeImpl> process = TestNodeWrapper<ProcessNodeImpl>::Create(mock_graph); TestNodeWrapper<PageNodeImpl> page = - TestNodeWrapper<PageNodeImpl>::Create(mock_graph); + TestNodeWrapper<PageNodeImpl>::Create(mock_graph, nullptr /*TEST*/); // Check the initial values before any frames are added. EXPECT_EQ(0u, page->GetInterventionPolicyFramesReportedForTesting()); @@ -368,7 +368,7 @@ TestNodeWrapper<ProcessNodeImpl> process = TestNodeWrapper<ProcessNodeImpl>::Create(mock_graph); TestNodeWrapper<PageNodeImpl> page = - TestNodeWrapper<PageNodeImpl>::Create(mock_graph); + TestNodeWrapper<PageNodeImpl>::Create(mock_graph, nullptr /*TEST*/); // Create two frames and immediately attach them to the page. TestNodeWrapper<FrameNodeImpl> f0 = TestNodeWrapper<FrameNodeImpl>::Create(
diff --git a/chrome/browser/performance_manager/observers/graph_observer_unittest.cc b/chrome/browser/performance_manager/observers/graph_observer_unittest.cc index 12187ca..45b177e 100644 --- a/chrome/browser/performance_manager/observers/graph_observer_unittest.cc +++ b/chrome/browser/performance_manager/observers/graph_observer_unittest.cc
@@ -53,7 +53,7 @@ { auto process_node = CreateNode<ProcessNodeImpl>(); - auto page_node = CreateNode<PageNodeImpl>(); + auto page_node = CreateNode<PageNodeImpl>(nullptr /*TEST*/); auto root_frame_node = CreateNode<FrameNodeImpl>( process_node.get(), page_node.get(), nullptr, 0); auto frame_node = CreateNode<FrameNodeImpl>(
diff --git a/chrome/browser/performance_manager/observers/metrics_collector_unittest.cc b/chrome/browser/performance_manager/observers/metrics_collector_unittest.cc index 403496e..0290b33 100644 --- a/chrome/browser/performance_manager/observers/metrics_collector_unittest.cc +++ b/chrome/browser/performance_manager/observers/metrics_collector_unittest.cc
@@ -62,7 +62,7 @@ }; TEST_F(MAYBE_MetricsCollectorTest, FromBackgroundedToFirstTitleUpdatedUMA) { - auto page_node = CreateNode<PageNodeImpl>(); + auto page_node = CreateNode<PageNodeImpl>(nullptr /*TEST*/); page_node->OnMainFrameNavigationCommitted(PerformanceManagerClock::NowTicks(), kDummyID, kDummyUrl); @@ -95,7 +95,7 @@ TEST_F(MAYBE_MetricsCollectorTest, FromBackgroundedToFirstTitleUpdatedUMA5MinutesTimeout) { - auto page_node = CreateNode<PageNodeImpl>(); + auto page_node = CreateNode<PageNodeImpl>(nullptr /*TEST*/); page_node->OnMainFrameNavigationCommitted(PerformanceManagerClock::NowTicks(), kDummyID, kDummyUrl); @@ -114,7 +114,7 @@ TEST_F(MAYBE_MetricsCollectorTest, FromBackgroundedToFirstNonPersistentNotificationCreatedUMA) { auto process_node = CreateNode<ProcessNodeImpl>(); - auto page_node = CreateNode<PageNodeImpl>(); + auto page_node = CreateNode<PageNodeImpl>(nullptr /*TEST*/); auto frame_node = CreateNode<FrameNodeImpl>(process_node.get(), page_node.get(), nullptr, 0); @@ -151,7 +151,7 @@ MAYBE_MetricsCollectorTest, FromBackgroundedToFirstNonPersistentNotificationCreatedUMA5MinutesTimeout) { auto process_node = CreateNode<ProcessNodeImpl>(); - auto page_node = CreateNode<PageNodeImpl>(); + auto page_node = CreateNode<PageNodeImpl>(nullptr /*TEST*/); auto frame_node = CreateNode<FrameNodeImpl>(process_node.get(), page_node.get(), nullptr, 0); @@ -170,7 +170,7 @@ } TEST_F(MAYBE_MetricsCollectorTest, FromBackgroundedToFirstFaviconUpdatedUMA) { - auto page_node = CreateNode<PageNodeImpl>(); + auto page_node = CreateNode<PageNodeImpl>(nullptr /*TEST*/); page_node->OnMainFrameNavigationCommitted(PerformanceManagerClock::NowTicks(), kDummyID, kDummyUrl); @@ -203,7 +203,7 @@ TEST_F(MAYBE_MetricsCollectorTest, FromBackgroundedToFirstFaviconUpdatedUMA5MinutesTimeout) { - auto page_node = CreateNode<PageNodeImpl>(); + auto page_node = CreateNode<PageNodeImpl>(nullptr /*TEST*/); page_node->OnMainFrameNavigationCommitted(PerformanceManagerClock::NowTicks(), kDummyID, kDummyUrl); @@ -222,7 +222,7 @@ // Flaky test: https://crbug.com/833028 TEST_F(MAYBE_MetricsCollectorTest, ResponsivenessMetric) { auto process_node = CreateNode<ProcessNodeImpl>(); - auto page_node = CreateNode<PageNodeImpl>(); + auto page_node = CreateNode<PageNodeImpl>(nullptr /*TEST*/); auto frame_node = CreateNode<FrameNodeImpl>(process_node.get(), page_node.get(), nullptr, 0);
diff --git a/chrome/browser/performance_manager/performance_manager.cc b/chrome/browser/performance_manager/performance_manager.cc index 3adea9f..593a0eae 100644 --- a/chrome/browser/performance_manager/performance_manager.cc +++ b/chrome/browser/performance_manager/performance_manager.cc
@@ -101,9 +101,10 @@ parent_frame_node, frame_tree_node_id); } -std::unique_ptr<PageNodeImpl> PerformanceManager::CreatePageNode() { - return CreateNodeImpl<PageNodeImpl>( - base::OnceCallback<void(PageNodeImpl*)>()); +std::unique_ptr<PageNodeImpl> PerformanceManager::CreatePageNode( + const base::WeakPtr<WebContentsProxy>& contents_proxy) { + return CreateNodeImpl<PageNodeImpl>(base::OnceCallback<void(PageNodeImpl*)>(), + contents_proxy); } std::unique_ptr<ProcessNodeImpl> PerformanceManager::CreateProcessNode() {
diff --git a/chrome/browser/performance_manager/performance_manager.h b/chrome/browser/performance_manager/performance_manager.h index 6b3a157..e1861b0 100644 --- a/chrome/browser/performance_manager/performance_manager.h +++ b/chrome/browser/performance_manager/performance_manager.h
@@ -16,6 +16,7 @@ #include "base/sequenced_task_runner.h" #include "chrome/browser/performance_manager/graph/graph.h" #include "chrome/browser/performance_manager/performance_manager.h" +#include "chrome/browser/performance_manager/web_contents_proxy.h" #include "chrome/browser/performance_manager/webui_graph_dump_impl.h" #include "services/resource_coordinator/public/mojom/coordination_unit.mojom.h" #include "services/service_manager/public/cpp/bind_source_info.h" @@ -78,7 +79,8 @@ FrameNodeImpl* parent_frame_node, int frame_tree_node_id, FrameNodeCreationCallback creation_callback); - std::unique_ptr<PageNodeImpl> CreatePageNode(); + std::unique_ptr<PageNodeImpl> CreatePageNode( + const base::WeakPtr<WebContentsProxy>& contents_proxy); std::unique_ptr<ProcessNodeImpl> CreateProcessNode(); // Destroys a node returned from the creation functions above.
diff --git a/chrome/browser/performance_manager/performance_manager_tab_helper.cc b/chrome/browser/performance_manager/performance_manager_tab_helper.cc index fe8cda9..f5fc13e 100644 --- a/chrome/browser/performance_manager/performance_manager_tab_helper.cc +++ b/chrome/browser/performance_manager/performance_manager_tab_helper.cc
@@ -45,7 +45,9 @@ content::WebContents* web_contents) : content::WebContentsObserver(web_contents), performance_manager_(PerformanceManager::GetInstance()), - page_node_(performance_manager_->CreatePageNode()) { + weak_factory_(this) { + page_node_ = performance_manager_->CreatePageNode(weak_factory_.GetWeakPtr()); + // Make sure to set the visibility property when we create // |page_resource_coordinator_|. UpdatePageNodeVisibility(web_contents->GetVisibility()); @@ -219,6 +221,10 @@ std::move(*interface_pipe))); } +content::WebContents* PerformanceManagerTabHelper::GetWebContents() const { + return web_contents(); +} + template <typename Functor, typename NodeType, typename... Args> void PerformanceManagerTabHelper::PostToGraph(const base::Location& from_here, Functor&& functor,
diff --git a/chrome/browser/performance_manager/performance_manager_tab_helper.h b/chrome/browser/performance_manager/performance_manager_tab_helper.h index 4099c1e8..1b12096 100644 --- a/chrome/browser/performance_manager/performance_manager_tab_helper.h +++ b/chrome/browser/performance_manager/performance_manager_tab_helper.h
@@ -11,6 +11,8 @@ #include <vector> #include "base/macros.h" +#include "base/memory/weak_ptr.h" +#include "chrome/browser/performance_manager/web_contents_proxy.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_user_data.h" #include "services/metrics/public/cpp/ukm_source_id.h" @@ -29,7 +31,8 @@ // host to the frame graph entity. class PerformanceManagerTabHelper : public content::WebContentsObserver, - public content::WebContentsUserData<PerformanceManagerTabHelper> { + public content::WebContentsUserData<PerformanceManagerTabHelper>, + public WebContentsProxy { public: // TODO(siggi): Remove this once the PageSignalGenerator has been abolished. static bool GetCoordinationIDForWebContents( @@ -59,10 +62,14 @@ const std::string& interface_name, mojo::ScopedMessagePipeHandle* interface_pipe) override; + // WebContentsProxy overrides. + content::WebContents* GetWebContents() const override; + void SetUkmSourceIdForTesting(ukm::SourceId id) { ukm_source_id_ = id; } private: friend class content::WebContentsUserData<PerformanceManagerTabHelper>; + friend class WebContentsProxy; explicit PerformanceManagerTabHelper(content::WebContents* web_contents); @@ -101,6 +108,8 @@ WEB_CONTENTS_USER_DATA_KEY_DECL(); + base::WeakPtrFactory<PerformanceManagerTabHelper> weak_factory_; + DISALLOW_COPY_AND_ASSIGN(PerformanceManagerTabHelper); };
diff --git a/chrome/browser/performance_manager/performance_manager_test_harness.cc b/chrome/browser/performance_manager/performance_manager_test_harness.cc new file mode 100644 index 0000000..df41d80 --- /dev/null +++ b/chrome/browser/performance_manager/performance_manager_test_harness.cc
@@ -0,0 +1,36 @@ +// 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/performance_manager/performance_manager_test_harness.h" + +#include "chrome/browser/performance_manager/performance_manager_tab_helper.h" + +namespace performance_manager { + +PerformanceManagerTestHarness::PerformanceManagerTestHarness() = default; + +PerformanceManagerTestHarness::~PerformanceManagerTestHarness() = default; + +void PerformanceManagerTestHarness::SetUp() { + Super::SetUp(); + perf_man_ = PerformanceManager::Create(); +} + +void PerformanceManagerTestHarness::TearDown() { + // Have the performance manager destroy itself. + PerformanceManager::Destroy(std::move(perf_man_)); + thread_bundle()->RunUntilIdle(); + + Super::TearDown(); +} + +std::unique_ptr<content::WebContents> +PerformanceManagerTestHarness::CreateTestWebContents() { + std::unique_ptr<content::WebContents> contents = + Super::CreateTestWebContents(); + PerformanceManagerTabHelper::CreateForWebContents(contents.get()); + return contents; +} + +} // namespace performance_manager
diff --git a/chrome/browser/performance_manager/performance_manager_test_harness.h b/chrome/browser/performance_manager/performance_manager_test_harness.h new file mode 100644 index 0000000..6e9442b --- /dev/null +++ b/chrome/browser/performance_manager/performance_manager_test_harness.h
@@ -0,0 +1,41 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_PERFORMANCE_MANAGER_PERFORMANCE_MANAGER_TEST_HARNESS_H_ +#define CHROME_BROWSER_PERFORMANCE_MANAGER_PERFORMANCE_MANAGER_TEST_HARNESS_H_ + +#include "chrome/browser/performance_manager/performance_manager.h" +#include "chrome/test/base/chrome_render_view_host_test_harness.h" +#include "content/public/browser/web_contents.h" + +namespace performance_manager { + +// A test harness that initializes PerformanceManager, plus the entire +// RenderViewHost harness. Allows for creating full WebContents, and their +// accompanying structures in the graph. The task environment is accessed +// via content::RenderViewHostTestHarness::test_bundle(). +class PerformanceManagerTestHarness : public ChromeRenderViewHostTestHarness { + public: + using Super = ChromeRenderViewHostTestHarness; + + PerformanceManagerTestHarness(); + ~PerformanceManagerTestHarness() override; + + void SetUp() override; + void TearDown() override; + + // Creates a test web contents with performance manager tab helpers + // attached. This is a test web contents that can be interacted with + // via WebContentsTester. + std::unique_ptr<content::WebContents> CreateTestWebContents(); + + private: + std::unique_ptr<PerformanceManager> perf_man_; + + DISALLOW_COPY_AND_ASSIGN(PerformanceManagerTestHarness); +}; + +} // namespace performance_manager + +#endif // CHROME_BROWSER_PERFORMANCE_MANAGER_PERFORMANCE_MANAGER_TEST_HARNESS_H_
diff --git a/chrome/browser/performance_manager/performance_manager_unittest.cc b/chrome/browser/performance_manager/performance_manager_unittest.cc index 20e3b491..1c48c18d 100644 --- a/chrome/browser/performance_manager/performance_manager_unittest.cc +++ b/chrome/browser/performance_manager/performance_manager_unittest.cc
@@ -57,7 +57,7 @@ performance_manager()->CreateProcessNode(); EXPECT_NE(nullptr, process_node.get()); std::unique_ptr<PageNodeImpl> page_node = - performance_manager()->CreatePageNode(); + performance_manager()->CreatePageNode(nullptr /*TEST*/); EXPECT_NE(nullptr, page_node.get()); // Create a node of each type. @@ -76,7 +76,7 @@ std::unique_ptr<ProcessNodeImpl> process_node = performance_manager()->CreateProcessNode(); std::unique_ptr<PageNodeImpl> page_node = - performance_manager()->CreatePageNode(); + performance_manager()->CreatePageNode(nullptr /*TEST*/); std::unique_ptr<FrameNodeImpl> parent1_frame = performance_manager()->CreateFrameNode(process_node.get(), @@ -113,7 +113,7 @@ TEST_F(PerformanceManagerTest, CallOnGraph) { // Create a page node for something to target. std::unique_ptr<PageNodeImpl> page_node = - performance_manager()->CreatePageNode(); + performance_manager()->CreatePageNode(nullptr /*TEST*/); PerformanceManager::GraphCallback graph_callback = base::BindLambdaForTesting( [&page_node](Graph* graph) { EXPECT_EQ(page_node->graph(), graph); });
diff --git a/chrome/browser/performance_manager/web_contents_proxy.cc b/chrome/browser/performance_manager/web_contents_proxy.cc new file mode 100644 index 0000000..ec1adda --- /dev/null +++ b/chrome/browser/performance_manager/web_contents_proxy.cc
@@ -0,0 +1,12 @@ +// 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/performance_manager/web_contents_proxy.h" + +namespace performance_manager { + +WebContentsProxy::WebContentsProxy() = default; +WebContentsProxy::~WebContentsProxy() = default; + +} // namespace performance_manager
diff --git a/chrome/browser/performance_manager/web_contents_proxy.h b/chrome/browser/performance_manager/web_contents_proxy.h new file mode 100644 index 0000000..19a38d4 --- /dev/null +++ b/chrome/browser/performance_manager/web_contents_proxy.h
@@ -0,0 +1,35 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_PERFORMANCE_MANAGER_WEB_CONTENTS_PROXY_H_ +#define CHROME_BROWSER_PERFORMANCE_MANAGER_WEB_CONTENTS_PROXY_H_ + +#include "base/macros.h" + +namespace content { +class WebContents; +} // namespace content + +namespace performance_manager { + +// A WebContentsProxy is used to post messages out of the performance manager +// sequence that are bound for a WebContents running on the UI thread. The +// object is bound to the UI thread. A WeakPtr<WebContentsProxy> is effectively +// equivalent to a WeakPtr<WebContents>. +class WebContentsProxy { + public: + WebContentsProxy(); + virtual ~WebContentsProxy(); + + // Allows resolving this proxy to the underlying WebContents. This must only + // be called on the UI thread. + virtual content::WebContents* GetWebContents() const = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(WebContentsProxy); +}; + +} // namespace performance_manager + +#endif // CHROME_BROWSER_PERFORMANCE_MANAGER_WEB_CONTENTS_PROXY_H_
diff --git a/chrome/browser/performance_manager/web_contents_proxy_unittest.cc b/chrome/browser/performance_manager/web_contents_proxy_unittest.cc new file mode 100644 index 0000000..ef82440 --- /dev/null +++ b/chrome/browser/performance_manager/web_contents_proxy_unittest.cc
@@ -0,0 +1,90 @@ +// 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/performance_manager/web_contents_proxy.h" + +#include "base/run_loop.h" +#include "base/task/post_task.h" +#include "base/task/task_traits.h" +#include "base/test/bind_test_util.h" +#include "chrome/browser/performance_manager/graph/page_node_impl.h" +#include "chrome/browser/performance_manager/performance_manager_tab_helper.h" +#include "chrome/browser/performance_manager/performance_manager_test_harness.h" +#include "content/public/browser/browser_task_traits.h" +#include "content/public/browser/browser_thread.h" + +namespace performance_manager { + +class WebContentsProxyTest : public PerformanceManagerTestHarness { + public: + WebContentsProxyTest() {} + ~WebContentsProxyTest() override {} + + void GetContentsViaProxy(bool delete_before_deref); + + private: + DISALLOW_COPY_AND_ASSIGN(WebContentsProxyTest); +}; + +TEST_F(WebContentsProxyTest, EndToEnd) { + std::unique_ptr<content::WebContents> contents = CreateTestWebContents(); + auto* helper = PerformanceManagerTabHelper::FromWebContents(contents.get()); + auto* page_node = helper->page_node(); + content::WebContents* proxy_contents = nullptr; + + auto deref_proxy = base::BindLambdaForTesting( + [&proxy_contents](const base::WeakPtr<WebContentsProxy>& proxy, + base::RepeatingClosure quit_loop) { + proxy_contents = nullptr; + if (proxy) + proxy_contents = proxy.get()->GetWebContents(); + quit_loop.Run(); + }); + + // Bounce over to the PM sequence, retrieve the proxy, bounce back to the UI + // thread, dereference it if possible, and save the returned contents. To be + // fair, it's entirely valid to grab the weak pointer directly on the UI + // thread, as the lifetime of the page node is managed their and the property + // being accessed is thread safe. However, this test aims to simulate what + // would happen with a policy message being posted from the graph. + { + base::RunLoop run_loop; + PerformanceManager::GetInstance()->CallOnGraph( + FROM_HERE, base::BindLambdaForTesting([&run_loop, &deref_proxy, + page_node](Graph* graph) { + base::PostTaskWithTraits( + FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(deref_proxy, page_node->contents_proxy(), + run_loop.QuitClosure())); + })); + run_loop.Run(); + + EXPECT_EQ(contents.get(), proxy_contents); + } + + // Run the same test, but this time destroy the contents prior to + // dereferencing the proxy. + { + base::RunLoop run_loop; + PerformanceManager::GetInstance()->CallOnGraph( + FROM_HERE, + base::BindLambdaForTesting([&contents, &run_loop, &deref_proxy, + page_node](Graph* graph) { + base::PostTaskWithTraits( + FROM_HERE, {content::BrowserThread::UI}, + base::BindLambdaForTesting([&contents]() { contents.reset(); })); + base::PostTaskWithTraits( + FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(deref_proxy, page_node->contents_proxy(), + run_loop.QuitClosure())); + })); + run_loop.Run(); + + // The contents was destroyed on the UI thread prior to dereferencing the + // proxy, so it should return nullptr. + EXPECT_FALSE(proxy_contents); + } +} + +} // namespace performance_manager
diff --git a/chrome/browser/policy/configuration_policy_handler_list_factory.cc b/chrome/browser/policy/configuration_policy_handler_list_factory.cc index cbaf6a0c..b0a4c820 100644 --- a/chrome/browser/policy/configuration_policy_handler_list_factory.cc +++ b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
@@ -462,6 +462,9 @@ { key::kExtensionAllowInsecureUpdates, extensions::pref_names::kInsecureExtensionUpdatesEnabled, base::Value::Type::BOOLEAN }, + { key::kUninstallBlacklistedExtensions, + extensions::pref_names::kUninstallBlacklistedExtensions, + base::Value::Type::BOOLEAN }, #endif // BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(ENABLE_SPELLCHECK)
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc index 391c5e47..e3ea2142 100644 --- a/chrome/browser/policy/policy_browsertest.cc +++ b/chrome/browser/policy/policy_browsertest.cc
@@ -2212,6 +2212,28 @@ EXPECT_TRUE(service->IsExtensionEnabled(bookmark_app->id())); } +// Ensure that when the UninstallBlacklistedExtensions policy is set +// that blacklisted extensions are removed from the device +IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallBlacklistUninstallPolicy) { + EXPECT_TRUE(InstallExtension(kGoodCrxName)); + + extensions::ExtensionService* service = extension_service(); + EXPECT_TRUE(service->GetInstalledExtension(kGoodCrxId)); + + // Now create policy to block all extensions and set a flag to uninstall + // blocked extensions + PolicyMap policies; + policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, + POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, + extensions::ListBuilder().Append("*").Build(), nullptr); + policies.Set(key::kUninstallBlacklistedExtensions, POLICY_LEVEL_MANDATORY, + POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, + std::make_unique<base::Value>(true), nullptr); + UpdateProviderPolicy(policies); + + EXPECT_FALSE(service->GetInstalledExtension(kGoodCrxId)); +} + // Ensure that bookmark apps are not blocked by the ExtensionAllowedTypes // policy. IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionAllowedTypes_BookmarkApp) {
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc index 7caa218..a77eee5 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.cc +++ b/chrome/browser/profiles/off_the_record_profile_impl.cc
@@ -40,6 +40,7 @@ #include "chrome/browser/prefs/in_process_service_factory_factory.h" #include "chrome/browser/prefs/incognito_mode_prefs.h" #include "chrome/browser/prefs/pref_service_syncable_util.h" +#include "chrome/browser/profiles/profile_key.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" @@ -137,11 +138,7 @@ } // namespace OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) - : profile_(real_profile), - start_time_(base::Time::Now()), - key_( - std::make_unique<SimpleFactoryKey>(profile_->GetPath(), - profile_->GetSimpleFactoryKey())) { + : profile_(real_profile), start_time_(base::Time::Now()) { // Must happen before we ask for prefs as prefs needs the connection to the // service manager, which is set up in Initialize. BrowserContext::Initialize(this, profile_->GetPath()); @@ -150,6 +147,10 @@ CreateExtensionPrefStore(profile_, true), InProcessPrefServiceFactoryFactory::GetInstanceForContext(this) ->CreateDelegate()); + + key_ = std::make_unique<ProfileKey>(profile_->GetPath(), prefs_.get(), + profile_->GetProfileKey()); + // Register on BrowserContext. user_prefs::UserPrefs::Set(this, prefs_.get()); } @@ -230,7 +231,7 @@ // ones in the SimpleDependencyManager's graph. DependencyManager::PerformInterlockedTwoPhaseShutdown( BrowserContextDependencyManager::GetInstance(), this, - SimpleDependencyManager::GetInstance(), GetSimpleFactoryKey()); + SimpleDependencyManager::GetInstance(), key_.get()); #if BUILDFLAG(ENABLE_EXTENSIONS) base::PostTaskWithTraits( @@ -551,7 +552,7 @@ return start_time_; } -SimpleFactoryKey* OffTheRecordProfileImpl::GetSimpleFactoryKey() const { +ProfileKey* OffTheRecordProfileImpl::GetProfileKey() const { DCHECK(key_); return key_.get(); }
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.h b/chrome/browser/profiles/off_the_record_profile_impl.h index 1bfa10ef..6e7df3a8 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.h +++ b/chrome/browser/profiles/off_the_record_profile_impl.h
@@ -78,7 +78,7 @@ service_manager::mojom::ServiceRequest request) override; bool IsSameProfile(Profile* profile) override; base::Time GetStartTime() const override; - SimpleFactoryKey* GetSimpleFactoryKey() const override; + ProfileKey* GetProfileKey() const override; base::FilePath last_selected_directory() override; void set_last_selected_directory(const base::FilePath& path) override; bool WasCreatedByVersionOrLater(const std::string& version) override; @@ -156,7 +156,7 @@ // The key to index KeyedService instances created by // SimpleKeyedServiceFactory. - std::unique_ptr<SimpleFactoryKey> key_; + std::unique_ptr<ProfileKey> key_; base::FilePath last_selected_directory_;
diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h index c70a4c0f..18dca5d 100644 --- a/chrome/browser/profiles/profile.h +++ b/chrome/browser/profiles/profile.h
@@ -13,8 +13,8 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "build/build_config.h" +#include "chrome/browser/profiles/profile_key.h" #include "components/domain_reliability/clear_mode.h" -#include "components/keyed_service/core/simple_factory_key.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/content_browser_client.h" #include "services/network/public/mojom/network_service.mojom-forward.h" @@ -223,8 +223,8 @@ virtual base::Time GetStartTime() const = 0; // Returns the key used to index KeyedService instances created by a - // SimpleKeyedServiceFactory. - virtual SimpleFactoryKey* GetSimpleFactoryKey() const = 0; + // SimpleKeyedServiceFactory, more strictly typed as a ProfileKey. + virtual ProfileKey* GetProfileKey() const = 0; // Returns the last directory that was chosen for uploading or opening a file. virtual base::FilePath last_selected_directory() = 0;
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index 8ff2f79..96a2a99 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc
@@ -76,6 +76,7 @@ #include "chrome/browser/profiles/profile_attributes_entry.h" #include "chrome/browser/profiles/profile_attributes_storage.h" #include "chrome/browser/profiles/profile_destroyer.h" +#include "chrome/browser/profiles/profile_key.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_metrics.h" #include "chrome/browser/push_messaging/push_messaging_service_factory.h" @@ -466,7 +467,6 @@ io_data_(this), last_session_exit_type_(EXIT_NORMAL), start_time_(base::Time::Now()), - key_(std::make_unique<SimpleFactoryKey>(GetPath())), delegate_(delegate), reporting_permissions_checker_factory_(this), shared_cors_origin_access_list_( @@ -581,6 +581,8 @@ user_prefs::UserPrefs::Set(this, prefs_.get()); } + key_ = std::make_unique<ProfileKey>(GetPath(), prefs_.get()); + #if defined(OS_CHROMEOS) if (is_regular_profile) { chromeos::AccountManagerFactory* factory = @@ -805,7 +807,7 @@ // ones in the SimpleDependencyManager's graph. DependencyManager::PerformInterlockedTwoPhaseShutdown( BrowserContextDependencyManager::GetInstance(), this, - SimpleDependencyManager::GetInstance(), GetSimpleFactoryKey()); + SimpleDependencyManager::GetInstance(), key_.get()); // This causes the Preferences file to be written to disk. if (prefs_loaded) @@ -1342,7 +1344,7 @@ return start_time_; } -SimpleFactoryKey* ProfileImpl::GetSimpleFactoryKey() const { +ProfileKey* ProfileImpl::GetProfileKey() const { DCHECK(key_); return key_.get(); }
diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h index 3a2fd2e..747735d28 100644 --- a/chrome/browser/profiles/profile_impl.h +++ b/chrome/browser/profiles/profile_impl.h
@@ -146,7 +146,7 @@ scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override; bool IsSameProfile(Profile* profile) override; base::Time GetStartTime() const override; - SimpleFactoryKey* GetSimpleFactoryKey() const override; + ProfileKey* GetProfileKey() const override; base::FilePath last_selected_directory() override; void set_last_selected_directory(const base::FilePath& path) override; GURL GetHomePage() override; @@ -256,7 +256,7 @@ // The key to index KeyedService instances created by // SimpleKeyedServiceFactory. - std::unique_ptr<SimpleFactoryKey> key_; + std::unique_ptr<ProfileKey> key_; #if defined(OS_CHROMEOS) std::unique_ptr<chromeos::Preferences> chromeos_preferences_;
diff --git a/chrome/browser/profiles/profile_key.cc b/chrome/browser/profiles/profile_key.cc new file mode 100644 index 0000000..a2e19adc --- /dev/null +++ b/chrome/browser/profiles/profile_key.cc
@@ -0,0 +1,21 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/profiles/profile_key.h" + +ProfileKey::ProfileKey(const base::FilePath& path, + PrefService* prefs, + ProfileKey* original_key) + : SimpleFactoryKey(path), prefs_(prefs), original_key_(original_key) {} + +ProfileKey::~ProfileKey() = default; + +bool ProfileKey::is_off_the_record() const { + return original_key_ != nullptr; +} + +// static +ProfileKey* ProfileKey::FromSimpleFactoryKey(SimpleFactoryKey* key) { + return key ? static_cast<ProfileKey*>(key) : nullptr; +}
diff --git a/chrome/browser/profiles/profile_key.h b/chrome/browser/profiles/profile_key.h new file mode 100644 index 0000000..b1ec9d6 --- /dev/null +++ b/chrome/browser/profiles/profile_key.h
@@ -0,0 +1,41 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_PROFILES_PROFILE_KEY_H_ +#define CHROME_BROWSER_PROFILES_PROFILE_KEY_H_ + +#include "base/files/file_path.h" +#include "base/macros.h" +#include "components/keyed_service/core/simple_factory_key.h" + +class PrefService; + +// An embryonic Profile with only fields accessible in reduced mode. +// Used as a SimpleFactoryKey. +class ProfileKey : public SimpleFactoryKey { + public: + ProfileKey(const base::FilePath& path, + PrefService* prefs, + ProfileKey* original_key = nullptr); + ~ProfileKey() override; + + // Profile-specific APIs needed in reduced mode: + ProfileKey* original_key() { return original_key_; } + PrefService* prefs() { return prefs_; } + + static ProfileKey* FromSimpleFactoryKey(SimpleFactoryKey* key); + + // SimpleFactoryKey implementation. + bool is_off_the_record() const override; + + private: + PrefService* prefs_; + + // Points to the original (non off-the-record) ProfileKey. + ProfileKey* original_key_ = nullptr; + + DISALLOW_COPY_AND_ASSIGN(ProfileKey); +}; + +#endif // CHROME_BROWSER_PROFILES_PROFILE_KEY_H_
diff --git a/chrome/browser/resources/BUILD.gn b/chrome/browser/resources/BUILD.gn index 496a77f..0c2ed33 100644 --- a/chrome/browser/resources/BUILD.gn +++ b/chrome/browser/resources/BUILD.gn
@@ -23,7 +23,6 @@ "local_ntp:closure_compile", "local_state:closure_compile", "management:closure_compile", - "md_user_manager:closure_compile", "media_router:closure_compile", "ntp4:closure_compile", "omnibox:closure_compile", @@ -32,6 +31,7 @@ "quota_internals:closure_compile", "settings:closure_compile", "signin/dice_sync_confirmation:closure_compile", + "user_manager:closure_compile", "welcome/dice_welcome:closure_compile", "welcome/onboarding_welcome:closure_compile", ]
diff --git a/chrome/browser/resources/chromeos/chromevox/BUILD.gn b/chrome/browser/resources/chromeos/chromevox/BUILD.gn index be13c261..340a44c 100644 --- a/chrome/browser/resources/chromeos/chromevox/BUILD.gn +++ b/chrome/browser/resources/chromeos/chromevox/BUILD.gn
@@ -132,6 +132,7 @@ "cvox2/background/cursors.js", "cvox2/background/custom_automation_event.js", "cvox2/background/desktop_automation_handler.js", + "cvox2/background/download_handler.js", "cvox2/background/earcon_engine.js", "cvox2/background/editing.js", "cvox2/background/event_source.js", @@ -622,6 +623,7 @@ "cvox2/background/braille_command_data_test.extjs", "cvox2/background/color_test.extjs", "cvox2/background/cursors_test.extjs", + "cvox2/background/download_handler_test.extjs", "cvox2/background/editing_test.extjs", "cvox2/background/i_search_test.extjs", "cvox2/background/language_switching_test.extjs",
diff --git a/chrome/browser/resources/chromeos/chromevox/chromevox/background/options.html b/chrome/browser/resources/chromeos/chromevox/chromevox/background/options.html index 0103e57..385f05ee 100644 --- a/chrome/browser/resources/chromeos/chromevox/chromevox/background/options.html +++ b/chrome/browser/resources/chromeos/chromevox/chromevox/background/options.html
@@ -52,6 +52,14 @@ </label> </div> + <div class="option"> + <input id="announceDownloadNotifications" type="checkbox" class="checkbox pref" + name="announceDownloadNotifications"> + <label for="announceDownloadNotifications" class="i18n" msgid="options_announce_download"> + Announce download notifications. + </label> + </div> + <h2 class="i18n description" msgid="options_audio_description" id="audio-description"> When playing audio
diff --git a/chrome/browser/resources/chromeos/chromevox/chromevox/background/prefs.js b/chrome/browser/resources/chromeos/chromevox/chromevox/background/prefs.js index 191b16e..4148f15 100644 --- a/chrome/browser/resources/chromeos/chromevox/chromevox/background/prefs.js +++ b/chrome/browser/resources/chromeos/chromevox/chromevox/background/prefs.js
@@ -62,6 +62,7 @@ */ cvox.ChromeVoxPrefs.DEFAULT_PREFS = { 'active': true, + 'announceDownloadNotifications': true, 'audioStrategy': 'audioNormal', 'autoRead': false, 'brailleCaptions': false,
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js index 5cb13f8..a11ae7a9 100644 --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js
@@ -18,6 +18,7 @@ goog.require('ChromeVoxState'); goog.require('CommandHandler'); goog.require('DesktopAutomationHandler'); +goog.require('DownloadHandler'); goog.require('FindHandler'); goog.require('GestureCommandHandler'); goog.require('LiveRegions'); @@ -149,6 +150,7 @@ CommandHandler.init(); FindHandler.init(); + DownloadHandler.init(); Notifications.onStartup();
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/download_handler.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/download_handler.js new file mode 100644 index 0000000..e774114 --- /dev/null +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/download_handler.js
@@ -0,0 +1,241 @@ +// 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. + +/** + * @fileoverview Listens for download events and provides corresponding + * notifications in ChromeVox. + */ + +goog.provide('DownloadHandler'); + +/** + * Maps download item ID to an object containing its file name and progress + * update function. + * @private {{id: {fileName: string, notifyProgressId: number, time: Date, + * percentComplete: number}}} + */ +DownloadHandler.downloadItemData_ = {}; + +/** + * Threshold value used when determining whether to report an update to user. + * @const {number} + * @private + */ +DownloadHandler.UPDATE_THRESHOLD_ = 100; + +/** + * The limit for the number of results we receive when querying for downloads. + * @const {number} + * @private + */ +DownloadHandler.FILE_LIMIT_ = 20; + +/** + * The time interval, in milliseconds, for calling + * DownloadHandler.notifyProgress. + * @const {number} + * @private + */ +DownloadHandler.INTERVAL_TIME_MILLISECONDS_ = 10000; + +/** + * Performs initialization. Populates downloadItemData_ object and registers + * event listener for chrome.downloads.onChanged events. + */ +DownloadHandler.init = function() { + // Populate downloadItemData_. + // Retrieve 20 most recent downloads sorted by most recent start time. + chrome.downloads.search( + {orderBy: ['-startTime'], limit: DownloadHandler.FILE_LIMIT_}, + function(results) { + if (!results || results.length == 0) + return; + + for (var i = 0; i < results.length; ++i) { + var item = results[i]; + var state = item.state; + if (!state) + continue; + // If download is in progress, start tracking it. + if (state === chrome.downloads.State.IN_PROGRESS) + DownloadHandler.startTrackingDownload(item); + } + }); + + // Note: No event listener for chrome.downloads.onCreated because + // onCreated does not actually correspond to when the download starts; + // it corresponds to when the user clicks the download button, which sometimes + // leads to a screen where the user can decide where to save the download. + + // Fired when any of a DownloadItem's properties, except bytesReceived and + // estimatedEndTime, change. Only contains properties that changed. + chrome.downloads.onChanged.addListener(function(item) { + // The type of notification ChromeVox reports can be inferred based on the + // available properties, as they have been observed to be mutually + // exclusive. + var name = item.filename; + var state = item.state; + var paused = item.paused; + // The item ID is always set no matter what. + var id = item.id; + + var storedItem = DownloadHandler.downloadItemData_[id]; + + // New download if we're not tracking the item and if the filename was + // previously empty. + if (!storedItem && name && (name.previous === '')) { + DownloadHandler.startTrackingDownload(item); + + // Speech and braille output. + var optSubs = [DownloadHandler.downloadItemData_[id].fileName]; + DownloadHandler.speechAndBrailleOutput( + 'download_started', cvox.QueueMode.FLUSH, optSubs); + } else if (state) { + var currentState = state.current; + var msgId = ''; + // Only give notification for COMPLETE and INTERRUPTED. + // IN_PROGRESS notifications are given by notifyProgress function. + if (currentState === chrome.downloads.State.COMPLETE) + msgId = 'download_completed'; + else if (currentState === chrome.downloads.State.INTERRUPTED) + msgId = 'download_stopped'; + else + return; + + var optSubs = [storedItem.fileName]; + clearInterval(storedItem.notifyProgressId); + delete DownloadHandler.downloadItemData_[id]; + // Speech and braille output. + DownloadHandler.speechAndBrailleOutput( + msgId, cvox.QueueMode.FLUSH, optSubs); + } else if (paused) { + // Will be either resumed or paused. + var msgId = 'download_resumed'; + var optSubs = [storedItem.fileName]; + if (paused.current === true) { + // Download paused. + msgId = 'download_paused'; + clearInterval(storedItem.notifyProgressId); + } else { + // Download resumed. + storedItem.notifyProgressId = setInterval( + DownloadHandler.notifyProgress.bind(DownloadHandler, item.id), + 10000); + storedItem.time = Date.now(); + } + // Speech and braille output. + DownloadHandler.speechAndBrailleOutput( + msgId, cvox.QueueMode.FLUSH, optSubs); + } + }); +}; + +/** + * Notifies user of download progress for file. + * @param {number} id The ID of the file we are providing an update for. + */ +DownloadHandler.notifyProgress = function(id) { + chrome.downloads.search({id: id}, function(results) { + if (!results || (results.length != 1)) + return; + // Results should have only one item because IDs are unique. + var updatedItem = results[0]; + var storedItem = DownloadHandler.downloadItemData_[updatedItem.id]; + + var percentComplete = + Math.round((updatedItem.bytesReceived / updatedItem.totalBytes) * 100); + var percentDelta = percentComplete - storedItem.percentComplete; + // Convert time delta from milliseconds to seconds. + var timeDelta = Math.round((Date.now() - storedItem.time) / 1000); + + // Calculate notification score for this download. + // This equation was determined by targeting 30 seconds and 50% complete + // as reasonable milestones before giving an update. + var score = percentDelta + (5 / 3) * timeDelta; + // Only report downloads that have scores above the threshold value. + if (score > DownloadHandler.UPDATE_THRESHOLD_) { + // Update state. + storedItem.time = Date.now(); + storedItem.percentComplete = percentComplete; + + // Determine time remaining and units. + if (!updatedItem.estimatedEndTime) + return; + var endTime = new Date(updatedItem.estimatedEndTime); + var timeRemaining = Math.round((endTime.getTime() - Date.now()) / 1000); + var timeUnit = ''; + + if (!timeRemaining || (timeRemaining < 0)) + return; + else if (timeRemaining < 60) { + // Seconds. Use up until 1 minute remaining. + timeUnit = new goog.i18n.MessageFormat(Msgs.getMsg('seconds')).format({ + COUNT: timeRemaining + }); + } else if (timeRemaining < 3600) { + // Minutes. Use up until 1 hour remaining. + timeRemaining = Math.floor(timeRemaining / 60); + timeUnit = new goog.i18n.MessageFormat(Msgs.getMsg('minutes')).format({ + COUNT: timeRemaining + }); + } else if (timeRemaining < 36000) { + // Hours. Use up until 10 hours remaining. + timeRemaining = Math.floor(timeRemaining / 3600); + timeUnit = new goog.i18n.MessageFormat(Msgs.getMsg('hours')).format({ + COUNT: timeRemaining + }); + } else { + // If 10+ hours remaining, do not report progress. + return; + } + + var optSubs = [ + storedItem.percentComplete, storedItem.fileName, timeRemaining, timeUnit + ]; + DownloadHandler.speechAndBrailleOutput( + 'download_progress', cvox.QueueMode.FLUSH, optSubs); + } + }); +}; + +/** + * Store item data. + * @param{chrome.downloads.DownloadItem} item The download item we want to + * track. + */ +DownloadHandler.startTrackingDownload = function(item) { + var id = item.id; + // Don't add if we are already tracking file. + if (DownloadHandler.downloadItemData_[id]) + return; + + var fullPath = (item.filename.current || item.filename); + var fileName = fullPath.substring(fullPath.lastIndexOf('/') + 1); + var notifyProgressId = setInterval( + DownloadHandler.notifyProgress.bind(DownloadHandler, id), + DownloadHandler.INTERVAL_TIME_MILLISECONDS_); + var percentComplete = 0; + if (item.bytesReceived && item.totalBytes) + percentComplete = Math.round((item.bytesReceived / item.totalBytes) * 100); + + DownloadHandler.downloadItemData_[id] = { + fileName: fileName, + notifyProgressId: notifyProgressId, + time: Date.now(), + percentComplete: percentComplete + }; +}; + +/** + * Output download notification as speech and braille. + * @param{string} msgId The msgId for Output. + * @param{number} queueMode The queue mode. + * @param{Array<string>} optSubs Substitution strings. + */ +DownloadHandler.speechAndBrailleOutput = function(msgId, queueMode, optSubs) { + if (localStorage['announceDownloadNotifications'] == 'true') { + var msg = Msgs.getMsg(msgId, optSubs); + new Output().withString(msg).withQueueMode(queueMode).go(); + } +};
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/download_handler_test.extjs b/chrome/browser/resources/chromeos/chromevox/cvox2/background/download_handler_test.extjs new file mode 100644 index 0000000..a6e9198 --- /dev/null +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/download_handler_test.extjs
@@ -0,0 +1,388 @@ +// 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 test fixture. +GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js']); + +GEN_INCLUDE(['../../testing/fake_objects.js']); +GEN_INCLUDE(['../../testing/mock_feedback.js']); + +/** + * Test fixture for Download_Handler. + * @constructor + * @extends {ChromeVoxE2ETest} + */ +function ChromeVoxDownloadTest() { + ChromeVoxNextE2ETest.call(this); +} + +ChromeVoxDownloadTest.prototype = { + __proto__: ChromeVoxNextE2ETest.prototype, + + addFakeApi: function() { + // Fake out Chrome Downloads API namespace. + chrome.downloads = {}; + chrome.downloads.search = function(query, callback) { + callback([{ + id:query.id, + fileName:'test.pdf', + bytesReceived: 9, + totalBytes: 10, + estimatedEndTime: this.getTimeRemaining(this.timeRemainingUnits), + }]); + }.bind(this); + chrome.downloads.onChanged = new FakeChromeEvent(); + + chrome.downloads.State = { + IN_PROGRESS: 'in_progress', + COMPLETE: 'complete', + INTERRUPTED: 'interrupted' + }; + }, + + /** @override */ + setUp: function() { + window.simulateEvent = this.simulateEvent.bind(this); + }, + + /** + * @return{!MockFeedback} + */ + createMockFeedback: function() { + var mockFeedback = new MockFeedback(this.newCallback(), + this.newCallback.bind(this)); + mockFeedback.install(); + return mockFeedback; + }, + + /** + * Simulates a chrome.downloads.onChanged event with the given parameters. + */ + simulateEvent: function(item) { + return function () { + var listener = chrome.downloads.onChanged.getListener(); + assertNotEquals(null, listener); + listener(item); + }; + }, + + getTimeRemaining: function(units) { + if (!units) + console.error('Must specify time units before calling this function'); + else if (units === 'second'){ + // 1 second. + return new Date(new Date().getTime() + 1000).toISOString(); + } + else if (units === 'seconds') { + // 30 seconds. + return new Date(new Date().getTime() + 30000).toISOString(); + } + else if (units === 'minute') { + // 1 minute. + return new Date(new Date().getTime() + 60000).toISOString(); + } + else if (units === 'minutes') { + // 30 minutes. + return new Date(new Date().getTime() + 1800000).toISOString(); + } + else if (units === 'hour') { + // 1 hour. + return new Date(new Date().getTime() + 3600000).toISOString(); + } + else if (units === 'hours') { + // 3 hours. + return new Date(new Date().getTime() + 10800000).toISOString(); + } + else + console.error('Did not specify a valid unit type'); + }, + + timeRemainingUnits: '', +}; + +TEST_F('ChromeVoxDownloadTest', 'DownloadStartedTest', function() { + localStorage['announceDownloadNotifications'] = 'true'; + this.addFakeApi(); + var mockFeedback = this.createMockFeedback(); + DownloadHandler.init(); + // Simulate download started. + mockFeedback.call(simulateEvent({ + id: 1, + filename: { + current: 'test.pdf', + previous: '' + }, + })); + + mockFeedback.expectSpeech('Download started test.pdf') + .expectBraille('Download started test.pdf', {startIndex:-1, endIndex: -1}) + .replay(); +}); + +TEST_F('ChromeVoxDownloadTest', 'DownloadCompletedTest', function() { + localStorage['announceDownloadNotifications'] = 'true'; + this.addFakeApi(); + var mockFeedback = this.createMockFeedback(); + DownloadHandler.init(); + // Simulate download started. + mockFeedback.call(simulateEvent({ + id: 1, + filename: { + current: 'test.pdf', + previous: '' + } + })); + + // Simulate download completed. + mockFeedback.call(simulateEvent({ + id: 1, + state: { + current: chrome.downloads.State.COMPLETE, + previous: chrome.downloads.State.IN_PROGRESS, + } + })); + + mockFeedback.expectSpeech('Download started test.pdf') + .expectSpeech('Download completed test.pdf') + .expectBraille('Download started test.pdf', {startIndex:-1, endIndex: -1}) + .expectBraille('Download completed test.pdf', {startIndex:-1, endIndex: -1}) + .replay(); +}); + +TEST_F('ChromeVoxDownloadTest', 'DownloadInterruptedTest', function() { + localStorage['announceDownloadNotifications'] = 'true'; + this.addFakeApi(); + var mockFeedback = this.createMockFeedback(); + DownloadHandler.init(); + // Simulate download started. + mockFeedback.call(simulateEvent({ + id: 1, + filename: { + current: 'test.pdf', + previous: '' + } + })); + + // Simulate download interrupted. + mockFeedback.call(simulateEvent({ + id: 1, + state: { + current: chrome.downloads.State.INTERRUPTED, + previous: chrome.downloads.State.IN_PROGRESS, + } + })); + mockFeedback.expectSpeech('Download started test.pdf') + .expectSpeech('Download stopped test.pdf') + .expectBraille('Download started test.pdf', {startIndex:-1, endIndex: -1}) + .expectBraille('Download stopped test.pdf', {startIndex:-1, endIndex: -1}) + .replay(); +}); + +TEST_F('ChromeVoxDownloadTest', 'DownloadPausedTest', function() { + localStorage['announceDownloadNotifications'] = 'true'; + this.addFakeApi(); + var mockFeedback = this.createMockFeedback(); + DownloadHandler.init(); + // Simulate download started. + mockFeedback.call(simulateEvent({ + id: 1, + filename: { + current: 'test.pdf', + previous: '' + } + })); + + // Simulate download paused. + mockFeedback.call(simulateEvent({ + id: 1, + paused: { + current: true, + previous: false, + } + })); + mockFeedback.expectSpeech('Download started test.pdf') + .expectSpeech('Download paused test.pdf') + .expectBraille('Download started test.pdf', {startIndex:-1, endIndex: -1}) + .expectBraille('Download paused test.pdf', {startIndex:-1, endIndex: -1}) + .replay(); +}); + +TEST_F('ChromeVoxDownloadTest', 'DownloadResumedTest', function() { + localStorage['announceDownloadNotifications'] = 'true'; + this.addFakeApi(); + var mockFeedback = this.createMockFeedback(); + DownloadHandler.init(); + // Simulate download started. + mockFeedback.call(simulateEvent({ + id: 1, + filename:{ + current: 'test.pdf', + previous: '' + } + })); + + // Simulate download resumed. + mockFeedback.call(simulateEvent({ + id: 1, + paused:{ + current: false, + previous: true, + } + })); + mockFeedback.expectSpeech('Download started test.pdf') + .expectSpeech('Download resumed test.pdf') + .expectBraille('Download started test.pdf', {startIndex:-1, endIndex: -1}) + .expectBraille('Download resumed test.pdf', {startIndex:-1, endIndex: -1}) + .replay(); +}); + +TEST_F('ChromeVoxDownloadTest', 'DownloadOneSecondRemainingTest', function() { + localStorage['announceDownloadNotifications'] = 'true'; + this.addFakeApi(); + var mockFeedback = this.createMockFeedback(); + DownloadHandler.init(); + DownloadHandler.intervalTimeMilliseconds = 1000; + // Simulate download started. + mockFeedback.call(simulateEvent({ + id: 1, + filename:{ + current: 'test.pdf', + previous: '' + } + })); + + this.timeRemainingUnits = 'second'; + setTimeout(function() { + mockFeedback.expectSpeech('Download started test.pdf') + .expectSpeech('Download 90% complete test.pdf. About 1 second remaining.') + .expectBraille('Download started test.pdf', {startIndex:-1, endIndex: -1}) + .expectBraille('Download 90% complete test.pdf. About 1 second remaining.', {startIndex:-1, endIndex: -1}) + .replay(); + }, 2000); +}); + +TEST_F('ChromeVoxDownloadTest', 'DownloadMultipleSecondsRemainingTest', function() { + localStorage['announceDownloadNotifications'] = 'true'; + this.addFakeApi(); + var mockFeedback = this.createMockFeedback(); + DownloadHandler.init(); + DownloadHandler.intervalTimeMilliseconds = 1000; + // Simulate download started. + mockFeedback.call(simulateEvent({ + id: 1, + filename:{ + current: 'test.pdf', + previous: '' + } + })); + + this.timeRemainingUnits = 'seconds'; + setTimeout(function() { + mockFeedback.expectSpeech('Download started test.pdf') + .expectSpeech('Download 90% complete test.pdf. About 30 seconds remaining.') + .expectBraille('Download started test.pdf', {startIndex:-1, endIndex: -1}) + .expectBraille('Download 90% complete test.pdf. About 30 seconds remaining.', {startIndex:-1, endIndex: -1}) + .replay(); + }, 2000); +}); + +TEST_F('ChromeVoxDownloadTest', 'DownloadOneMinuteRemainingTest', function() { + localStorage['announceDownloadNotifications'] = 'true'; + this.addFakeApi(); + var mockFeedback = this.createMockFeedback(); + DownloadHandler.init(); + DownloadHandler.intervalTimeMilliseconds = 1000; + // Simulate download started. + mockFeedback.call(simulateEvent({ + id: 1, + filename:{ + current: 'test.pdf', + previous: '' + } + })); + + this.timeRemainingUnits = 'minute'; + setTimeout(function() { + mockFeedback.expectSpeech('Download started test.pdf') + .expectSpeech('Download 90% complete test.pdf. About 1 minute remaining.') + .expectBraille('Download started test.pdf', {startIndex:-1, endIndex: -1}) + .expectBraille('Download 90% complete test.pdf. About 1 minute remaining.', {startIndex:-1, endIndex: -1}) + .replay(); + }, 2000); +}); + +TEST_F('ChromeVoxDownloadTest', 'DownloadMultipleMinutesRemainingTest', function() { + localStorage['announceDownloadNotifications'] = 'true'; + this.addFakeApi(); + var mockFeedback = this.createMockFeedback(); + DownloadHandler.init(); + DownloadHandler.intervalTimeMilliseconds = 1000; + // Simulate download started. + mockFeedback.call(simulateEvent({ + id: 1, + filename:{ + current: 'test.pdf', + previous: '' + } + })); + + this.timeRemainingUnits = 'minutes'; + setTimeout(function() { + mockFeedback.expectSpeech('Download started test.pdf') + .expectSpeech('Download 90% complete test.pdf. About 30 minutes remaining.') + .expectBraille('Download started test.pdf', {startIndex:-1, endIndex: -1}) + .expectBraille('Download 90% complete test.pdf. About 30 minutes remaining.', {startIndex:-1, endIndex: -1}) + .replay(); + }, 2000); +}); + +TEST_F('ChromeVoxDownloadTest', 'DownloadOneHourRemainingTest', function() { + localStorage['announceDownloadNotifications'] = 'true'; + this.addFakeApi(); + var mockFeedback = this.createMockFeedback(); + DownloadHandler.init(); + DownloadHandler.intervalTimeMilliseconds = 1000; + // Simulate download started. + mockFeedback.call(simulateEvent({ + id: 1, + filename:{ + current: 'test.pdf', + previous: '' + } + })); + + this.timeRemainingUnits = 'hour'; + setTimeout(function() { + mockFeedback.expectSpeech('Download started test.pdf') + .expectSpeech('Download 90% complete test.pdf. About 1 hour remaining.') + .expectBraille('Download started test.pdf', {startIndex:-1, endIndex: -1}) + .expectBraille('Download 90% complete test.pdf. About 1 hour remaining.', {startIndex:-1, endIndex: -1}) + .replay(); + }, 2000); +}); + +TEST_F('ChromeVoxDownloadTest', 'DownloadMultipleHoursRemainingTest', function() { + localStorage['announceDownloadNotifications'] = 'true'; + this.addFakeApi(); + var mockFeedback = this.createMockFeedback(); + DownloadHandler.init(); + DownloadHandler.intervalTimeMilliseconds = 1000; + // Simulate download started. + mockFeedback.call(simulateEvent({ + id: 1, + filename:{ + current: 'test.pdf', + previous: '' + } + })); + + this.timeRemainingUnits = 'hours'; + setTimeout(function() { + mockFeedback.expectSpeech('Download started test.pdf') + .expectSpeech('Download 90% complete test.pdf. About 3 hours remaining.') + .expectBraille('Download started test.pdf', {startIndex:-1, endIndex: -1}) + .expectBraille('Download 90% complete test.pdf. About 3 hours remaining.', {startIndex:-1, endIndex: -1}) + .replay(); + }, 2000); +});
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js index c2b87c3..4630b46 100644 --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js
@@ -718,9 +718,11 @@ // Chrome automatically calculates these attributes. case 'posInSet': - return node.htmlAttributes['aria-posinset']; + return node.htmlAttributes['aria-posinset'] || + (node.root.role != RoleType.ROOT_WEB_AREA && node.posInSet); case 'setSize': - return node.htmlAttributes['aria-setsize']; + return node.htmlAttributes['aria-setsize'] || + (node.root.role != RoleType.ROOT_WEB_AREA && node.setSize); // These attributes default to false for empty strings. case 'roleDescription':
diff --git a/chrome/browser/resources/chromeos/chromevox/manifest.json.jinja2 b/chrome/browser/resources/chromeos/chromevox/manifest.json.jinja2 index 4997337..17f5ccd9 100644 --- a/chrome/browser/resources/chromeos/chromevox/manifest.json.jinja2 +++ b/chrome/browser/resources/chromeos/chromevox/manifest.json.jinja2
@@ -22,6 +22,7 @@ "clipboardRead", "commands.accessibility", "commandLinePrivate", + "downloads", "experimental", "history", "metricsPrivate",
diff --git a/chrome/browser/resources/chromeos/chromevox/strings/chromevox_strings.grd b/chrome/browser/resources/chromeos/chromevox/strings/chromevox_strings.grd index faf15cc..46f94be 100644 --- a/chrome/browser/resources/chromeos/chromevox/strings/chromevox_strings.grd +++ b/chrome/browser/resources/chromeos/chromevox/strings/chromevox_strings.grd
@@ -3691,6 +3691,37 @@ <message desc="A menulist option in ChromeVox rich text settings to announce rich text" name="IDS_CHROMEVOX_RICH_TEXT_ANNOUNCE"> Announce </message> + + <message desc="An option to announce download notifications." name="IDS_CHROMEVOX_OPTIONS_ANNOUNCE_DOWNLOAD"> + Announce download notifications + </message> + <message desc="Spoken when a download is started" name="IDS_CHROMEVOX_DOWNLOAD_STARTED"> + Download started <ph name="file_name">$1<ex>test.pdf</ex></ph> + </message> + <message desc="Spoken when a download is completed" name="IDS_CHROMEVOX_DOWNLOAD_COMPLETED"> + Download completed <ph name="file_name">$1<ex>test.pdf</ex></ph> + </message> + <message desc="Spoken when a download is stopped" name="IDS_CHROMEVOX_DOWNLOAD_STOPPED"> + Download stopped <ph name="file_name">$1<ex>test.pdf</ex></ph> + </message> + <message desc="Spoken when a download is paused" name="IDS_CHROMEVOX_DOWNLOAD_PAUSED"> + Download paused <ph name="file_name">$1<ex>test.pdf</ex></ph> + </message> + <message desc="Spoken when a download is resumed" name="IDS_CHROMEVOX_DOWNLOAD_RESUMED"> + Download resumed <ph name="file_name">$1<ex>test.pdf</ex></ph> + </message> + <message desc="Spoken to give progress on a current download, specifying percent complete and time remaining." name="IDS_CHROMEVOX_DOWNLOAD_PROGRESS"> + Download <ph name="progress">$1<ex>50</ex></ph>% complete <ph name="file_name">$2<ex>test.pdf</ex></ph>. About <ph name="time">$3<ex>30</ex></ph> <ph name="units">$4<ex>minutes</ex></ph> remaining. + </message> + <message desc="A string to specify time units in seconds." name="IDS_CHROMEVOX_SECONDS"> + {COUNT, plural, =1 {second}other {seconds}} + </message> + <message desc="A string to specify time units in minutes." name="IDS_CHROMEVOX_MINUTES"> + {COUNT, plural, =1 {minute}other {minutes}} + </message> + <message desc="A string to specify time units in hours." name="IDS_CHROMEVOX_HOURS"> + {COUNT, plural, =1 {hour}other {hours}} + </message> </messages> </release> </grit>
diff --git a/chrome/browser/resources/chromeos/login/oobe_eula.html b/chrome/browser/resources/chromeos/login/oobe_eula.html index ddff8a8..9bc2a14 100644 --- a/chrome/browser/resources/chromeos/login/oobe_eula.html +++ b/chrome/browser/resources/chromeos/login/oobe_eula.html
@@ -71,7 +71,7 @@ </cr-toggle> <div id="usageStatsLabelContainer"> <span id="usageStatsLabel" i18n-content="checkboxLogging"></span> - <a id="" href="#" i18n-content="learnMore" + <a id="learn-more" href="#" i18n-content="learnMore" on-tap="onUsageStatsHelpLinkClicked_"> </a> </div> @@ -109,7 +109,7 @@ </div> <div class='password-row layout horizontal'> <div class="flex"></div> - <div>{{password}}</div> + <div id="eula-password">{{password}}</div> <div class="flex"></div> </div> </div>
diff --git a/chrome/browser/resources/chromeos/switch_access/prefs.js b/chrome/browser/resources/chromeos/switch_access/prefs.js index 00a4513..e6f0ab3 100644 --- a/chrome/browser/resources/chromeos/switch_access/prefs.js +++ b/chrome/browser/resources/chromeos/switch_access/prefs.js
@@ -129,21 +129,6 @@ } /** - * Get the value of type 'string' of the preference |key|. Will throw a type - * error if the value of |key| is not 'string'. - * - * @param {string} key - * @return {string} - */ - getStringPref(key) { - const value = this.prefs_[key]; - if (typeof value === 'string') - return value; - else - throw new TypeError('No value of string type for key \'' + key + '\''); - } - - /** * Returns true if |keyCode| is already used to run a command from the * keyboard. *
diff --git a/chrome/browser/resources/chromeos/switch_access/switch_access.js b/chrome/browser/resources/chromeos/switch_access/switch_access.js index c6d1c48..f283c1d 100644 --- a/chrome/browser/resources/chromeos/switch_access/switch_access.js +++ b/chrome/browser/resources/chromeos/switch_access/switch_access.js
@@ -235,18 +235,6 @@ } /** - * Get the value of type 'string' of the preference |key|. Will throw a type - * error if the value of |key| is not 'string'. - * - * @override - * @param {string} key - * @return {string} - */ - getStringPref(key) { - return this.switchAccessPrefs_.getStringPref(key); - } - - /** * Returns true if |keyCode| is already used to run a command from the * keyboard. *
diff --git a/chrome/browser/resources/chromeos/switch_access/switch_access_interface.js b/chrome/browser/resources/chromeos/switch_access/switch_access_interface.js index 54237b8..ffd1ef1f 100644 --- a/chrome/browser/resources/chromeos/switch_access/switch_access_interface.js +++ b/chrome/browser/resources/chromeos/switch_access/switch_access_interface.js
@@ -97,15 +97,6 @@ getNumberPref(key) {} /** - * Get the value of type 'string' of the preference |key|. Will throw a type - * error if the value of |key| is not 'string'. - * - * @param {string} key - * @return {string} - */ - getStringPref(key) {} - - /** * Returns true if |keyCode| is already used to run a command from the * keyboard. *
diff --git a/chrome/browser/resources/downloads/item.html b/chrome/browser/resources/downloads/item.html index ad502b9..d75108d 100644 --- a/chrome/browser/resources/downloads/item.html +++ b/chrome/browser/resources/downloads/item.html
@@ -271,9 +271,9 @@ } </style> - <h3 id="date">[[computeDate_(data.hideDate, - data.sinceString, - data.dateString)]]</h3> + <div id="date">[[computeDate_(data.hideDate, + data.sinceString, + data.dateString)]]</div> <div id="content" on-dragstart="onDragStart_" class$="[[computeClass_(isActive_, isDangerous_, showProgress_)]]"
diff --git a/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-button.html b/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-button.html index f26b52d..c957208 100644 --- a/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-button.html +++ b/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-button.html
@@ -1,9 +1,18 @@ <link rel="import" href="chrome://resources/html/polymer.html"> +<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-fab/paper-fab.html"> <dom-module id="viewer-zoom-button"> <template> <style> + :host { + --translate-x-distance: 132px; + } + + :host([new-print-preview]) { + --translate-x-distance: 96px; + } + #wrapper { transition: transform 250ms; transition-timing-function: cubic-bezier(0, 0, 0.2, 1); @@ -12,12 +21,12 @@ :host([closed]) #wrapper { /* 132px roughly flips the location of the button across the right edge * of the page. */ - transform: translateX(132px); + transform: translateX(var(--translate-x-distance)); transition-timing-function: cubic-bezier(0.4, 0, 1, 1); } :host([show-on-left][closed]) #wrapper { - transform: translateX(-132px); + transform: translateX(calc(-1 * var(--translate-x-distance))); } paper-fab { @@ -31,9 +40,32 @@ overflow: visible; } + :host([new-print-preview]) paper-fab { + --paper-fab-mini: { + height: 24px; + padding: 4px; + width: 24px; + }; + background-color: var(--google-grey-100); + color: var(--google-grey-refresh-700); + } + + :host-context([dark]):host([new-print-preview]) paper-fab { + background-color: var(--google-grey-900); + color: var(--google-grey-200); + } + paper-fab.keyboard-focus { background-color: var(--viewer-icon-ink-color); } + + :host([new-print-preview]) paper-fab.keyboard-focus { + background-color: var(--google-grey-200); + } + + :host-context([dark]):host([new-print-preview]) paper-fab.keyboard-focus { + background-color: var(--google-grey-800); + } </style> <div id="wrapper"> <paper-fab id="button" mini icon="[[visibleIcon_]]" on-click="fireClick"
diff --git a/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-button.js b/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-button.js index 575de5a..e1d750a 100644 --- a/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-button.js +++ b/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-button.js
@@ -26,6 +26,8 @@ delay: {type: Number, observer: 'delayChanged_'}, + newPrintPreview: {type: Boolean, reflectToAttribute: true}, + showOnLeft: {type: Boolean, reflectToAttribute: true}, /**
diff --git a/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.html b/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.html index 24485bb..c117507 100644 --- a/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.html +++ b/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.html
@@ -8,6 +8,7 @@ <template> <style> :host { + --button-position-offset: 48px; bottom: 0; padding: 48px 0; position: fixed; @@ -16,6 +17,10 @@ z-index: 3; } + :host([new-print-preview]) { + --button-position-offset: 24px; + } + :host([show-on-left_]) { left: 0; right: auto; @@ -23,11 +28,11 @@ #zoom-buttons { position: relative; - right: 48px; + right: var(--button-position-offset); } :host([show-on-left_]) #zoom-buttons { - left: 48px; + left: var(--button-position-offset); right: auto; } @@ -47,13 +52,16 @@ </style> <div id="zoom-buttons"> <viewer-zoom-button id="fit-button" on-fabclick="fitToggle" delay="100" + new-print-preview="[[newPrintPreview]]" show-on-left="[[showOnLeft_]]" icons="pdf:fullscreen-exit cr:fullscreen"> </viewer-zoom-button> <viewer-zoom-button id="zoom-in-button" icons="pdf:add" + new-print-preview="[[newPrintPreview]]" show-on-left="[[showOnLeft_]]" on-fabclick="zoomIn" delay="50"></viewer-zoom-button> <viewer-zoom-button id="zoom-out-button" icons="pdf:remove" + new-print-preview="[[newPrintPreview]]" show-on-left="[[showOnLeft_]]" on-fabclick="zoomOut" delay="0"></viewer-zoom-button> </div>
diff --git a/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.js b/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.js index f7a6fb2..fddb5bb 100644 --- a/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.js +++ b/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.js
@@ -11,12 +11,15 @@ is: 'viewer-zoom-toolbar', properties: { - reverse: Boolean, + newPrintPreview: { + type: Boolean, + reflectToAttribute: true, + }, /** @private */ showOnLeft_: { type: Boolean, - computed: 'computeShowOnLeft_(reverse)', + computed: 'computeShowOnLeft_(newPrintPreview)', reflectToAttribute: true, }, @@ -47,7 +50,7 @@ * @private */ computeShowOnLeft_: function() { - return isRTL() !== this.reverse; + return isRTL() !== this.newPrintPreview; }, /**
diff --git a/chrome/browser/resources/pdf/pdf_scripting_api.js b/chrome/browser/resources/pdf/pdf_scripting_api.js index c54e184a5..0ab77f4 100644 --- a/chrome/browser/resources/pdf/pdf_scripting_api.js +++ b/chrome/browser/resources/pdf/pdf_scripting_api.js
@@ -215,6 +215,11 @@ this.sendMessage_({type: 'loadPreviewPage', url: url, index: index}); }, + /** @param {boolean} darkMode Whether the page is in dark mode. */ + darkModeChanged: function(darkMode) { + this.sendMessage_({type: 'darkModeChanged', darkMode: darkMode}); + }, + /** * Select all the text in the document. May only be called after document * load. @@ -296,5 +301,6 @@ iframe.sendKeyEvent = client.sendKeyEvent.bind(client); iframe.scrollPosition = client.scrollPosition.bind(client); iframe.hideToolbars = client.hideToolbars.bind(client); + iframe.darkModeChanged = client.darkModeChanged.bind(client); return iframe; }
diff --git a/chrome/browser/resources/pdf/pdf_viewer.js b/chrome/browser/resources/pdf/pdf_viewer.js index c785024c..942761c0 100644 --- a/chrome/browser/resources/pdf/pdf_viewer.js +++ b/chrome/browser/resources/pdf/pdf_viewer.js
@@ -101,14 +101,20 @@ PDFViewer.TOOLBAR_WINDOW_MIN_HEIGHT = 250; /** - * The light-gray background color used for print preview. + * The background color used for print preview (--google-grey-refresh-300). */ -PDFViewer.LIGHT_BACKGROUND_COLOR = '0xFFCCCCCC'; +PDFViewer.PRINT_PREVIEW_BACKGROUND_COLOR = '0xFFDADCE0'; /** - * The dark-gray background color used for the regular viewer. + * The background color used for print preview when dark mode is enabled + * (--google-grey-refresh-700). */ -PDFViewer.DARK_BACKGROUND_COLOR = '0xFF525659'; +PDFViewer.PRINT_PREVIEW_DARK_BACKGROUND_COLOR = '0xFF5F6368'; + +/** + * The background color used for the regular viewer. + */ +PDFViewer.BACKGROUND_COLOR = '0xFF525659'; /** * Creates a new PDFViewer. There should only be one of these objects per @@ -214,8 +220,7 @@ } this.plugin_.setAttribute('headers', headers); - const backgroundColor = PDFViewer.DARK_BACKGROUND_COLOR; - this.plugin_.setAttribute('background-color', backgroundColor); + this.plugin_.setAttribute('background-color', PDFViewer.BACKGROUND_COLOR); this.plugin_.setAttribute('top-toolbar-height', topToolbarHeight); this.plugin_.setAttribute('javascript', this.javascript_); @@ -737,6 +742,16 @@ } }, + /** @private */ + sendBackgroundColorForPrintPreview_: function() { + this.pluginController_.postMessage({ + type: 'backgroundColorChanged', + backgroundColor: document.documentElement.hasAttribute('dark') ? + PDFViewer.PRINT_PREVIEW_DARK_BACKGROUND_COLOR : + PDFViewer.PRINT_PREVIEW_BACKGROUND_COLOR, + }); + }, + /** * Load a dictionary of translated strings into the UI. Used as a callback for * chrome.resourcesPrivate. @@ -749,13 +764,15 @@ document.documentElement.lang = strings.language; loadTimeData.data = strings; - const reverseZoomToolbar = this.isPrintPreview_ && + const isNewPrintPreview = this.isPrintPreview_ && loadTimeData.getBoolean('newPrintPreviewLayoutEnabled'); - this.reverseZoomToolbar_ = reverseZoomToolbar; - if (reverseZoomToolbar) { + if (isNewPrintPreview) { + this.sendBackgroundColorForPrintPreview_(); this.toolbarManager_.reverseSideToolbar(); } - $('zoom-toolbar').reverse = reverseZoomToolbar; + this.reverseZoomToolbar_ = isNewPrintPreview; + this.zoomToolbar_.newPrintPreview = isNewPrintPreview; + $('toolbar').strings = strings; $('toolbar').pdfAnnotationsEnabled = loadTimeData.getBoolean('pdfAnnotationsEnabled'); @@ -996,6 +1013,12 @@ case 'hideToolbars': this.toolbarManager_.resetKeyboardNavigationAndHideToolbars(); return true; + case 'darkModeChanged': + document.documentElement.toggleAttribute('dark', message.data.darkMode); + if (this.isPrintPreview_) { + this.sendBackgroundColorForPrintPreview_(); + } + return true; case 'scrollPosition': const position = this.viewport_.position; position.y += message.data.y;
diff --git a/chrome/browser/resources/print_preview/new/app.html b/chrome/browser/resources/print_preview/new/app.html index 9214a5b..9a25c3d 100644 --- a/chrome/browser/resources/print_preview/new/app.html +++ b/chrome/browser/resources/print_preview/new/app.html
@@ -45,12 +45,12 @@ #preview-area-container { align-items: center; - background-color: var(--google-grey-200); + background-color: var(--preview-area-background-color); flex: 1; } - :host-context([dark]) #preview-area-container { - background-color: var(--google-grey-400); + :host([new-print-preview-layout_]) #preview-area-container { + background-color: var(--preview-area-background-color-new); } </style> <print-preview-state id="state" state="{{state}}" error="{{error_}}"> @@ -90,6 +90,7 @@ document-modifiable="[[documentSettings_.isModifiable]]" margins="[[margins_]]" page-size="[[pageSize_]]" state="[[state]]" measurement-system="[[measurementSystem_]]" + new-print-preview-layout="[[newPrintPreviewLayout_]]" preview-state="{{previewState_}}" on-preview-start="onPreviewStart_"> </print-preview-preview-area> </div>
diff --git a/chrome/browser/resources/print_preview/new/app.js b/chrome/browser/resources/print_preview/new/app.js index 3a206c9f..079483f9 100644 --- a/chrome/browser/resources/print_preview/new/app.js +++ b/chrome/browser/resources/print_preview/new/app.js
@@ -350,7 +350,7 @@ /** @private */ onPreviewSettingChanged_: function() { if (this.state === print_preview_new.State.READY) { - this.$.previewArea.startPreview(); + this.$.previewArea.startPreview(false); this.startPreviewWhenReady_ = false; } else { this.startPreviewWhenReady_ = true; @@ -361,7 +361,7 @@ onStateChanged_: function() { if (this.state == print_preview_new.State.READY) { if (this.startPreviewWhenReady_) { - this.$.previewArea.startPreview(); + this.$.previewArea.startPreview(false); this.startPreviewWhenReady_ = false; } if (this.isInKioskAutoPrintMode_ || this.printRequested_) {
diff --git a/chrome/browser/resources/print_preview/new/plugin_proxy.js b/chrome/browser/resources/print_preview/new/plugin_proxy.js index 60e1e4f..d813eed 100644 --- a/chrome/browser/resources/print_preview/new/plugin_proxy.js +++ b/chrome/browser/resources/print_preview/new/plugin_proxy.js
@@ -159,6 +159,11 @@ this.plugin_.loadPreviewPage( this.getPreviewUrl_(previewUid, pageIndex), index); } + + /** @param {boolean} darkMode Whether the page is in dark mode. */ + darkModeChanged(darkMode) { + this.plugin_.darkModeChanged(darkMode); + } } /** @type {?print_preview_new.PluginProxy} */
diff --git a/chrome/browser/resources/print_preview/new/preview_area.html b/chrome/browser/resources/print_preview/new/preview_area.html index 01a44d2..a867368 100644 --- a/chrome/browser/resources/print_preview/new/preview_area.html +++ b/chrome/browser/resources/print_preview/new/preview_area.html
@@ -74,7 +74,7 @@ } .preview-area-overlay-layer { - background: var(--google-grey-200); + background: var(--preview-area-background-color); display: flex; flex-direction: column; height: 100%; @@ -91,8 +91,8 @@ z-index: 1; } - :host-context([dark]) .preview-area-overlay-layer { - background: var(--google-grey-400); + :host([new-print-preview-layout]) .preview-area-overlay-layer { + background: var(--preview-area-background-color-new); } .preview-area-overlay-layer.invisible { @@ -109,6 +109,10 @@ position: relative; text-align: center; } + + :host([new-print-preview-layout]) .preview-area-message { + color: var(--cr-primary-text-color); + } </style> <div class$="preview-area-overlay-layer [[getInvisible_(previewState)]]" aria-hidden$="[[getAriaHidden_(previewState)]]">
diff --git a/chrome/browser/resources/print_preview/new/preview_area.js b/chrome/browser/resources/print_preview/new/preview_area.js index dd8b4b9..824883d 100644 --- a/chrome/browser/resources/print_preview/new/preview_area.js +++ b/chrome/browser/resources/print_preview/new/preview_area.js
@@ -45,6 +45,11 @@ /** @type {?print_preview.MeasurementSystem} */ measurementSystem: Object, + newPrintPreviewLayout: { + type: Boolean, + reflectToAttribute: true, + }, + /** @type {!print_preview.Size} */ pageSize: Object, @@ -110,6 +115,10 @@ this.nativeLayer_ = print_preview.NativeLayer.getInstance(); this.addWebUIListener( 'page-preview-ready', this.onPagePreviewReady_.bind(this)); + if (this.newPrintPreviewLayout) { + this.addWebUIListener( + 'dark-mode-changed', this.onDarkModeChanged_.bind(this)); + } this.pluginProxy_ = print_preview_new.PluginProxy.getInstance(); if (!this.pluginProxy_.checkPluginCompatibility(assert( @@ -257,9 +266,12 @@ } }, - /** @private */ - startPreview: function() { - if (!this.hasTicketChanged_() && + /** + * @param {boolean} forceUpdate Whether to force the preview area to update + * regardless of whether the print ticket has changed. + */ + startPreview: function(forceUpdate) { + if (!this.hasTicketChanged_() && !forceUpdate && this.previewState !== print_preview_new.PreviewAreaState.ERROR) { return; } @@ -312,6 +324,10 @@ } this.pluginLoaded_ = false; + if (document.documentElement.hasAttribute('dark') && + this.newPrintPreviewLayout) { + this.pluginProxy_.darkModeChanged(true); + } this.pluginProxy_.resetPrintPreviewMode( previewUid, index, !this.getSettingValue('color'), /** @type {!Array<number>} */ (this.getSettingValue('pages')), @@ -385,6 +401,21 @@ }, /** + * @param {boolean} darkMode Whether the page is now in dark mode. + * @private + */ + onDarkModeChanged_: function(darkMode) { + if (this.pluginProxy_.pluginReady()) { + this.pluginProxy_.darkModeChanged(darkMode); + } + + if (this.previewState === + print_preview_new.PreviewAreaState.DISPLAY_PREVIEW) { + this.startPreview(true); + } + }, + + /** * Processes a keyboard event that could possibly be used to change state of * the preview plugin. * @param {!KeyboardEvent} e Keyboard event to process.
diff --git a/chrome/browser/resources/print_preview/new/print_preview_shared_css.html b/chrome/browser/resources/print_preview/new/print_preview_shared_css.html index 1fd28280..249c00cf 100644 --- a/chrome/browser/resources/print_preview/new/print_preview_shared_css.html +++ b/chrome/browser/resources/print_preview/new/print_preview_shared_css.html
@@ -21,9 +21,13 @@ --cr-form-field-label-height: initial; --cr-form-field-label-line-height: .75rem; --destination-item-height: 32px; + --preview-area-background-color: var(--google-grey-200); + --preview-area-background-color-new: var(--google-grey-refresh-300); } :host-context([dark]) { + --preview-area-background-color: var(--google-grey-400); + --preview-area-background-color-new: var(--google-grey-refresh-700); --print-preview-disabled-label: { opacity: var(--cr-disabled-opacity); }
diff --git a/chrome/browser/resources/settings/chromeos/lazy_load.html b/chrome/browser/resources/settings/chromeos/lazy_load.html index 5971b4e..0505fc5 100644 --- a/chrome/browser/resources/settings/chromeos/lazy_load.html +++ b/chrome/browser/resources/settings/chromeos/lazy_load.html
@@ -1,14 +1,13 @@ <html> <head></head> <body> - <!-- TODO: Add imports here --> + <link rel="import" href="../a11y_page/a11y_page.html"> + <link rel="import" href="../downloads_page/downloads_page.html"> + <link rel="import" href="../languages_page/languages_page.html"> + <link rel="import" href="../printing_page/printing_page.html"> + <link rel="import" href="../privacy_page/privacy_page.html"> + <link rel="import" href="../reset_page/reset_page.html"> - <!-- - TODO(maybelle): Remove dummy script tag once we add in real - elements. This is necessary for the optimized webui build step. - --> -<script> -</script> - + <link rel="import" href="../date_time_page/date_time_page.html"> </body> </html>
diff --git a/chrome/browser/resources/settings/chromeos/os_settings.html b/chrome/browser/resources/settings/chromeos/os_settings.html index 00f57316..6bdd820 100644 --- a/chrome/browser/resources/settings/chromeos/os_settings.html +++ b/chrome/browser/resources/settings/chromeos/os_settings.html
@@ -1,19 +1,36 @@ <!doctype html> -<html> -<!-- TODO(jamescook): Text direction, language, title, etc. --> +<html dir="$i18n{textdirection}" lang="$i18n{language}" class="loading" + $i18n{dark}> <head> <meta charset="utf-8"> - <title>Hello settings!</title> + <title>$i18n{settings}</title> +<if expr="not optimize_webui"> + <base href="chrome://os-settings"> +</if> + <link rel="stylesheet" href="chrome://resources/css/md_colors.css"> + <style> + html { + background: var(--md-background-color); + overflow: hidden; + /* Remove 300ms delay for 'click' event, when using touch interface. */ + touch-action: manipulation; + } + + html.loading::before { + background-color: var(--md-toolbar-color); + border-bottom: var(--md-toolbar-border); + box-sizing: border-box; + content: ''; + display: block; + height: var(--md-toolbar-height); + } + </style> </head> <body> - Hello, settings! - -<!-- - TODO(maybelle): Remove dummy script tag once we add in real elements. - This is necessary for the optimized webui build step. ---> -<script> -</script> - + <settings-ui></settings-ui> + <link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css"> + <link rel="import" href="chrome://resources/html/polymer.html"> + <link rel="import" href="../settings_ui/settings_ui.html"> + <link rel="import" href="chrome://resources/html/dark_mode.html"> </body> </html>
diff --git a/chrome/browser/resources/settings/google_assistant_page/google_assistant_page.html b/chrome/browser/resources/settings/google_assistant_page/google_assistant_page.html index 90d52bf..61c613ff 100644 --- a/chrome/browser/resources/settings/google_assistant_page/google_assistant_page.html +++ b/chrome/browser/resources/settings/google_assistant_page/google_assistant_page.html
@@ -60,7 +60,7 @@ on-settings-boolean-control-change="onEnableHotwordChange_" hidden="[[!hotwordDspAvailable_]]"> </settings-toggle-button> - <div class="settings-box three-line" + <div class="settings-box three-line" id="dsp-hotword-container" hidden="[[hotwordDspAvailable_]]"> <div class="start text-area"> <div class="label">
diff --git a/chrome/browser/resources/settings/os_settings_resources.grd b/chrome/browser/resources/settings/os_settings_resources.grd index fdd1780..b7fb799 100644 --- a/chrome/browser/resources/settings/os_settings_resources.grd +++ b/chrome/browser/resources/settings/os_settings_resources.grd
@@ -12,14 +12,1454 @@ </outputs> <release seq="1"> <structures> - <structure name="IDR_SETTINGS_OS_SETTINGS_HTML" + <structure name="IDR_OS_SETTINGS_A11Y_PAGE_JS" + file="a11y_page/a11y_page.js" + preprocess="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_A11Y_PAGE_HTML" + file="a11y_page/a11y_page.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_MANAGE_A11Y_PAGE_JS" + file="a11y_page/manage_a11y_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MANAGE_A11Y_PAGE_HTML" + file="a11y_page/manage_a11y_page.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_TTS_SUBPAGE_JS" + file="a11y_page/tts_subpage.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_TTS_SUBPAGE_HTML" + file="a11y_page/tts_subpage.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MANIFEST" + file="manifest.json" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ABOUT_PAGE_BROWSER_PROXY_HTML" + file="about_page/about_page_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ABOUT_PAGE_BROWSER_PROXY_JS" + file="about_page/about_page_browser_proxy.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_ABOUT_PAGE_JS" + file="about_page/about_page.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_ABOUT_PAGE_HTML" + file="about_page/about_page.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_CHANNEL_SWITCHER_DIALOG_HTML" + file="about_page/channel_switcher_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CHANNEL_SWITCHER_DIALOG_JS" + file="about_page/channel_switcher_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DETAILED_BUILD_INFO_JS" + file="about_page/detailed_build_info.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DETAILED_BUILD_INFO_HTML" + file="about_page/detailed_build_info.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_UPDATE_WARNING_DIALOG_HTML" + file="about_page/update_warning_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_UPDATE_WARNING_DIALOG_JS" + file="about_page/update_warning_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ADD_SITE_DIALOG_HTML" + file="site_settings/add_site_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ADD_SITE_DIALOG_JS" + file="site_settings/add_site_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ALL_SITES_HTML" + file="site_settings/all_sites.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ALL_SITES_JS" + file="site_settings/all_sites.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_SITE_ENTRY_HTML" + file="site_settings/site_entry.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_ENTRY_JS" + file="site_settings/site_entry.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CATEGORY_DEFAULT_SETTING_HTML" + file="site_settings/category_default_setting.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CATEGORY_DEFAULT_SETTING_JS" + file="site_settings/category_default_setting.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CATEGORY_SETTING_EXCEPTIONS_HTML" + file="site_settings/category_setting_exceptions.html" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_CATEGORY_SETTING_EXCEPTIONS_JS" + file="site_settings/category_setting_exceptions.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CHOOSER_EXCEPTION_LIST_HTML" + file="site_settings/chooser_exception_list.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CHOOSER_EXCEPTION_LIST_JS" + file="site_settings/chooser_exception_list.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CHOOSER_EXCEPTION_LIST_ENTRY_HTML" + file="site_settings/chooser_exception_list_entry.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CHOOSER_EXCEPTION_LIST_ENTRY_JS" + file="site_settings/chooser_exception_list_entry.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CR_SETTINGS_ANIMATED_PAGES_HTML" + file="settings_page/settings_animated_pages.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CR_SETTINGS_ANIMATED_PAGES_JS" + file="settings_page/settings_animated_pages.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_APPEARANCE_BROWSER_PROXY_HTML" + file="appearance_page/appearance_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_APPEARANCE_BROWSER_PROXY_JS" + file="appearance_page/appearance_browser_proxy.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_APPEARANCE_FONTS_PAGE_HTML" + file="appearance_page/appearance_fonts_page.html" + type="chrome_html" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_APPEARANCE_FONTS_PAGE_JS" + file="appearance_page/appearance_fonts_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_APPEARANCE_PAGE_HTML" + file="appearance_page/appearance_page.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_APPEARANCE_PAGE_JS" + file="appearance_page/appearance_page.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_APPEARANCE_HOME_URL_INPUT_HTML" + file="appearance_page/home_url_input.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_APPEARANCE_HOME_URL_INPUT_JS" + file="appearance_page/home_url_input.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_BASIC_PAGE_JS" + file="basic_page/basic_page.js" + preprocess="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_BASIC_PAGE_HTML" + file="basic_page/basic_page.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_EDIT_EXCEPTION_DIALOG_HTML" + file="site_settings/edit_exception_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_EDIT_EXCEPTION_DIALOG_JS" + file="site_settings/edit_exception_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_EXTENSION_CONTROL_BROWSER_PROXY_JS" + file="extension_control_browser_proxy.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_EXTENSION_CONTROL_BROWSER_PROXY_HTML" + file="extension_control_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_FONTS_BROWSER_PROXY_HTML" + file="appearance_page/fonts_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_FONTS_BROWSER_PROXY_JS" + file="appearance_page/fonts_browser_proxy.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_LIFETIME_BROWSER_PROXY_HTML" + file="lifetime_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_LIFETIME_BROWSER_PROXY_JS" + file="lifetime_browser_proxy.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_ON_STARTUP_BROWSER_PROXY_HTML" + file="on_startup_page/on_startup_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ON_STARTUP_BROWSER_PROXY_JS" + file="on_startup_page/on_startup_browser_proxy.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ON_STARTUP_PAGE_HTML" + file="on_startup_page/on_startup_page.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ON_STARTUP_PAGE_JS" + file="on_startup_page/on_startup_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SEARCH_SETTINGS_JS" + file="search_settings.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_STARTUP_URLS_PAGE_HTML" + file="on_startup_page/startup_urls_page.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_STARTUP_URLS_PAGE_JS" + file="on_startup_page/startup_urls_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_STARTUP_URLS_PAGE_BROWSER_PROXY_JS" + file="on_startup_page/startup_urls_page_browser_proxy.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_STARTUP_URLS_PAGE_BROWSER_PROXY_HTML" + file="on_startup_page/startup_urls_page_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_STARTUP_URL_DIALOG_JS" + file="on_startup_page/startup_url_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_STARTUP_URL_DIALOG_HTML" + file="on_startup_page/startup_url_dialog.html" + type="chrome_html" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_STARTUP_URL_ENTRY_JS" + file="on_startup_page/startup_url_entry.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_STARTUP_URL_ENTRY_HTML" + file="on_startup_page/startup_url_entry.html" + type="chrome_html" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_CR_SETTINGS_MAIN_HTML" + file="settings_main/settings_main.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_CR_SETTINGS_MAIN_JS" + file="settings_main/settings_main.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CR_SETTINGS_MENU_HTML" + file="settings_menu/settings_menu.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_CR_SETTINGS_MENU_JS" + file="settings_menu/settings_menu.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CR_SETTINGS_SECTION_HTML" + file="settings_page/settings_section.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CR_SETTINGS_SECTION_JS" + file="settings_page/settings_section.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CR_SETTINGS_SUBPAGE_HTML" + file="settings_page/settings_subpage.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CR_SETTINGS_SUBPAGE_JS" + file="settings_page/settings_subpage.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CR_SETTINGS_PAGE_CSS_HTML" + file="settings_page_css.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CR_SETTINGS_ICONS_CSS_HTML" + file="settings_icons_css.html" + flattenhtml="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MAIN_PAGE_BEHAVIOR_HTML" + file="settings_page/main_page_behavior.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MAIN_PAGE_BEHAVIOR_JS" + file="settings_page/main_page_behavior.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SETTINGS_VARS_CSS_HTML" + file="settings_vars_css.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SETTINGS_SHARED_CSS_HTML" + file="settings_shared_css.html" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_CR_SETTINGS_UI_HTML" + file="settings_ui/settings_ui.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_CR_SETTINGS_UI_JS" + file="settings_ui/settings_ui.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_GLOBAL_SCROLL_TARGET_BEHAVIOR_HTML" + file="global_scroll_target_behavior.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_GLOBAL_SCROLL_TARGET_BEHAVIOR_JS" + file="global_scroll_target_behavior.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CHANGE_PASSWORD_BROWSER_PROXY_HTML" + file="change_password_page/change_password_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CHANGE_PASSWORD_BROWSER_PROXY_JS" + file="change_password_page/change_password_browser_proxy.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CHANGE_PASSWORD_PAGE_HTML" + file="change_password_page/change_password_page.html" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_CHANGE_PASSWORD_PAGE_JS" + file="change_password_page/change_password_page.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_CLEAR_BROWSING_DATA_BROWSER_PROXY_HTML" + file="clear_browsing_data_dialog/clear_browsing_data_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CLEAR_BROWSING_DATA_BROWSER_PROXY_JS" + file="clear_browsing_data_dialog/clear_browsing_data_browser_proxy.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CLEAR_BROWSING_DATA_DIALOG_HTML" + file="clear_browsing_data_dialog/clear_browsing_data_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CLEAR_BROWSING_DATA_DIALOG_JS" + file="clear_browsing_data_dialog/clear_browsing_data_dialog.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_HISTORY_DELETION_DIALOG_HTML" + file="clear_browsing_data_dialog/history_deletion_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_HISTORY_DELETION_DIALOG_JS" + file="clear_browsing_data_dialog/history_deletion_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SECURITY_KEYS_PAGE_HTML" + file="privacy_page/security_keys_subpage.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SECURITY_KEYS_PAGE_JS" + file="privacy_page/security_keys_subpage.js" + type="chrome_html"/> + <structure name="IDR_OS_SETTINGS_SECURITY_KEYS_SET_PIN_DIALOG_HTML" + file="privacy_page/security_keys_set_pin_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SECURITY_KEYS_SET_PIN_DIALOG_JS" + file="privacy_page/security_keys_set_pin_dialog.js" + type="chrome_html"/> + <structure name="IDR_OS_SETTINGS_SECURITY_KEYS_RESET_DIALOG_HTML" + file="privacy_page/security_keys_reset_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SECURITY_KEYS_RESET_DIALOG_JS" + file="privacy_page/security_keys_reset_dialog.js" + type="chrome_html"/> + <structure name="IDR_OS_SETTINGS_SECURITY_KEYS_DIALOG_BROWSER_PROXY_HTML" + file="privacy_page/security_keys_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SECURITY_KEYS_DIALOG_BROWSER_PROXY_JS" + file="privacy_page/security_keys_browser_proxy.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_BOOLEAN_CONTROL_BEHAVIOR_HTML" + file="controls/settings_boolean_control_behavior.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_BOOLEAN_CONTROL_BEHAVIOR_JS" + file="controls/settings_boolean_control_behavior.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_CONTROLLED_BUTTON_JS" + file="controls/controlled_button.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_CONTROLLED_BUTTON_HTML" + file="controls/controlled_button.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_CONTROLLED_RADIO_BUTTON_JS" + file="controls/controlled_radio_button.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_CONTROLLED_RADIO_BUTTON_HTML" + file="controls/controlled_radio_button.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_EXTENSION_CONTROLLED_INDICATOR_JS" + file="controls/extension_controlled_indicator.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_EXTENSION_CONTROLLED_INDICATOR_HTML" + file="controls/extension_controlled_indicator.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_CHECKBOX_HTML" + file="controls/settings_checkbox.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_CHECKBOX_JS" + file="controls/settings_checkbox.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_DROPDOWN_MENU_HTML" + file="controls/settings_dropdown_menu.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_DROPDOWN_MENU_JS" + file="controls/settings_dropdown_menu.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_PASSWORD_PROMPT_DIALOG_JS" + file="controls/password_prompt_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_PASSWORD_PROMPT_DIALOG_HTML" + file="controls/password_prompt_dialog.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_PREF_CONTROL_BEHAVIOR_HTML" + file="controls/pref_control_behavior.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_PREF_CONTROL_BEHAVIOR_JS" + file="controls/pref_control_behavior.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_RADIO_GROUP_HTML" + file="controls/settings_radio_group.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_RADIO_GROUP_JS" + file="controls/settings_radio_group.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_SETTINGS_IDLE_LOAD_HTML" + file="controls/settings_idle_load.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_SETTINGS_IDLE_LOAD_JS" + file="controls/settings_idle_load.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_SLIDER_HTML" + file="controls/settings_slider.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_SLIDER_JS" + file="controls/settings_slider.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_TEXTAREA_HTML" + file="controls/settings_textarea.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_TEXTAREA_JS" + file="controls/settings_textarea.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_TOGGLE_BUTTON_HTML" + file="controls/settings_toggle_button.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONTROLS_TOGGLE_BUTTON_JS" + file="controls/settings_toggle_button.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_COOKIE_INFO_HTML" + file="site_settings/cookie_info.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_COOKIE_INFO_JS" + file="site_settings/cookie_info.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_BROWSER_PROXY_HTML" + file="device_page/device_page_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_BROWSER_PROXY_JS" + file="device_page/device_page_browser_proxy.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_DISPLAY_HTML" + file="device_page/display.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_DISPLAY_JS" + file="device_page/display.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_DISPLAY_LAYOUT_HTML" + file="device_page/display_layout.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_DISPLAY_LAYOUT_JS" + file="device_page/display_layout.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_DISPLAY_OVERSCAN_DIALOG_HTML" + file="device_page/display_overscan_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_DISPLAY_OVERSCAN_DIALOG_JS" + file="device_page/display_overscan_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_DRIVE_CACHE_DIALOG_HTML" + file="device_page/drive_cache_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_DRIVE_CACHE_DIALOG_JS" + file="device_page/drive_cache_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_KEYBOARD_HTML" + file="device_page/keyboard.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_KEYBOARD_JS" + file="device_page/keyboard.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_POWER_HTML" + file="device_page/power.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_POWER_JS" + file="device_page/power.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_STORAGE_HTML" + file="device_page/storage.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_STORAGE_JS" + file="device_page/storage.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_STYLUS_HTML" + file="device_page/stylus.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_STYLUS_JS" + file="device_page/stylus.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_PAGE_HTML" + file="device_page/device_page.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_PAGE_JS" + file="device_page/device_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_POINTERS_HTML" + file="device_page/pointers.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_POINTERS_JS" + file="device_page/pointers.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_DRAG_BEHAVIOR_HTML" + file="device_page/drag_behavior.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_DRAG_BEHAVIOR_JS" + file="device_page/drag_behavior.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_LAYOUT_BEHAVIOR_HTML" + file="device_page/layout_behavior.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_LAYOUT_BEHAVIOR_JS" + file="device_page/layout_behavior.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_NIGHT_LIGHT_SLIDER_HTML" + file="device_page/night_light_slider.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DEVICE_NIGHT_LIGHT_SLIDER_JS" + file="device_page/night_light_slider.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DOWNLOADS_BROWSER_PROXY_HTML" + file="downloads_page/downloads_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DOWNLOADS_BROWSER_PROXY_JS" + file="downloads_page/downloads_browser_proxy.js" + preprocess="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DOWNLOADS_PAGE_HTML" + file="downloads_page/downloads_page.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_DOWNLOADS_PAGE_JS" + file="downloads_page/downloads_page.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_SMB_SHARES_PAGE_HTML" + file="downloads_page/smb_shares_page.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SMB_SHARES_PAGE_JS" + file="downloads_page/smb_shares_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_I18n_SETUP_HTML" + file="i18n_setup.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ICONS" + file="icons.html" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_POWERWASH_DIALOG_HTML" + file="reset_page/powerwash_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_POWERWASH_DIALOG_JS" + file="reset_page/powerwash_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_RESET_PAGE_HTML" + file="reset_page/reset_page.html" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_RESET_PAGE_JS" + file="reset_page/reset_page.js" + preprocess="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_RESET_PROFILE_DIALOG_HTML" + file="reset_page/reset_profile_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_RESET_PROFILE_DIALOG_JS" + file="reset_page/reset_profile_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_RESET_PROFILE_BANNER_HTML" + file="reset_page/reset_profile_banner.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_RESET_PROFILE_BANNER_JS" + file="reset_page/reset_profile_banner.js" + type="chrome_html"/> + <structure name="IDR_OS_SETTINGS_RESET_BROWSER_PROXY_JS" + file="reset_page/reset_browser_proxy.js" + preprocess="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_RESET_BROWSER_PROXY_HTML" + file="reset_page/reset_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_LANGUAGES_HTML" + file="languages_page/languages.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_LANGUAGES_JS" + file="languages_page/languages.js" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_LANGUAGES_BROWSER_PROXY_HTML" + file="languages_page/languages_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_LANGUAGES_BROWSER_PROXY_JS" + file="languages_page/languages_browser_proxy.js" + preprocess="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_LANGUAGES_ADD_LANGUAGES_DIALOG_HTML" + file="languages_page/add_languages_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_LANGUAGES_ADD_LANGUAGES_DIALOG_JS" + file="languages_page/add_languages_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_LANGUAGES_PAGE_HTML" + file="languages_page/languages_page.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_LANGUAGES_PAGE_JS" + file="languages_page/languages_page.js" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_LANGUAGES_MANAGE_INPUT_METHODS_PAGE_HTML" + file="languages_page/manage_input_methods_page.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_LANGUAGES_MANAGE_INPUT_METHODS_PAGE_JS" + file="languages_page/manage_input_methods_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_LANGUAGES_EDIT_DICTIONARY_PAGE_HTML" + file="languages_page/edit_dictionary_page.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_LANGUAGES_EDIT_DICTIONARY_PAGE_JS" + file="languages_page/edit_dictionary_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MEDIA_PICKER_HTML" + file="site_settings/media_picker.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MEDIA_PICKER_JS" + file="site_settings/media_picker.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_AUTOFILL_PAGE_HTML" + file="autofill_page/autofill_page.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_AUTOFILL_PAGE_JS" + file="autofill_page/autofill_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CREDIT_CARD_LIST_HTML" + file="autofill_page/credit_card_list.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CREDIT_CARD_LIST_JS" + file="autofill_page/credit_card_list.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CREDIT_CARD_LIST_ENTRY_HTML" + file="autofill_page/credit_card_list_entry.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CREDIT_CARD_LIST_ENTRY_JS" + file="autofill_page/credit_card_list_entry.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PASSWORDS_SHARED_CSS_HTML" + file="autofill_page/passwords_shared_css.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CREDIT_CARD_EDIT_DIALOG_HTML" + file="autofill_page/credit_card_edit_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CREDIT_CARD_EDIT_DIALOG_JS" + file="autofill_page/credit_card_edit_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_AUTOFILL_SECTION_HTML" + file="autofill_page/autofill_section.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_AUTOFILL_SECTION_JS" + file="autofill_page/autofill_section.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ADDRESS_EDIT_DIALOG_HTML" + file="autofill_page/address_edit_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ADDRESS_EDIT_DIALOG_JS" + file="autofill_page/address_edit_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SHOW_PASSWORD_BEHAVIOR_HTML" + file="autofill_page/show_password_behavior.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SHOW_PASSWORD_BEHAVIOR_JS" + file="autofill_page/show_password_behavior.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PASSWORD_LIST_ITEM_HTML" + file="autofill_page/password_list_item.html" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_PASSWORD_LIST_ITEM_JS" + file="autofill_page/password_list_item.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PASSWORD_MANAGER_PROXY_HTML" + file="autofill_page/password_manager_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PASSWORD_MANAGER_PROXY_JS" + file="autofill_page/password_manager_proxy.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PASSWORDS_SECTION_HTML" + file="autofill_page/passwords_section.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PASSWORDS_SECTION_JS" + file="autofill_page/passwords_section.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_PASSWORD_EDIT_DIALOG_HTML" + file="autofill_page/password_edit_dialog.html" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_PASSWORD_EDIT_DIALOG_JS" + file="autofill_page/password_edit_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PASSWORDS_EXPORT_DIALOG_HTML" + file="autofill_page/passwords_export_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PASSWORDS_EXPORT_DIALOG_JS" + file="autofill_page/passwords_export_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PAYMENTS_SECTION_HTML" + file="autofill_page/payments_section.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PAYMENTS_SECTION_JS" + file="autofill_page/payments_section.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_PAGE_HTML" + file="people_page/people_page.html" + type="chrome_html" + flattenhtml="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_PAGE_JS" + file="people_page/people_page.js" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_PAGE_SIGNOUT_DIALOG_HTML" + file="people_page/signout_dialog.html" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_PAGE_SIGNOUT_DIALOG_JS" + file="people_page/signout_dialog.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_PAGE_PROFILE_INFO_BROWSER_PROXY_HTML" + file="people_page/profile_info_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_PAGE_PROFILE_INFO_BROWSER_PROXY_JS" + file="people_page/profile_info_browser_proxy.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_PAGE_SYNC_BROWSER_PROXY_HTML" + file="people_page/sync_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_PAGE_SYNC_BROWSER_PROXY_JS" + file="people_page/sync_browser_proxy.js" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_PREF_UTIL_HTML" + file="prefs/pref_util.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PREF_UTIL_JS" + file="prefs/pref_util.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PREFS_HTML" + file="prefs/prefs.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PREFS_JS" + file="prefs/prefs.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PREFS_BEHAVIOR_HTML" + file="prefs/prefs_behavior.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PREFS_BEHAVIOR_JS" + file="prefs/prefs_behavior.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PREFS_TYPES_HTML" + file="prefs/prefs_types.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PREFS_TYPES_JS" + file="prefs/prefs_types.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PRINTING_PAGE_HTML" + file="printing_page/printing_page.html" + preprocess="true" + allowexternalscript="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PRINTING_PAGE_JS" + file="printing_page/printing_page.js" + preprocess="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CUPS_PRINTER_SHARED_CSS_HTML" + file="printing_page/cups_printer_shared_css.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CUPS_PRINTING_PAGE_HTML" + file="printing_page/cups_printers.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CUPS_PRINTING_PAGE_JS" + file="printing_page/cups_printers.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CUPS_PRINTERS_BROWSER_PROXY_HTML" + file="printing_page/cups_printers_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CUPS_PRINTERS_BROWSER_PROXY_JS" + file="printing_page/cups_printers_browser_proxy.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CUPS_PRINTERS_LIST_HTML" + file="printing_page/cups_printers_list.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CUPS_PRINTERS_LIST_JS" + file="printing_page/cups_printers_list.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CUPS_EDIT_PRINTER_DIALOG_HTML" + file="printing_page/cups_edit_printer_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CUPS_EDIT_PRINTER_DIALOG_JS" + file="printing_page/cups_edit_printer_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CUPS_ADD_PRINTER_DIALOG_HTML" + file="printing_page/cups_add_printer_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CUPS_ADD_PRINTER_DIALOG_JS" + file="printing_page/cups_add_printer_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CUPS_ADD_PRINTER_DIALOG_ELEMENTS_HTML" + file="printing_page/cups_add_printer_dialog_elements.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CUPS_ADD_PRINTER_DIALOG_ELEMENTS_JS" + file="printing_page/cups_add_printer_dialog_elements.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CUPS_PRINTER_DIALOG_UTIL_HTML" + file="printing_page/cups_printer_dialog_util.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CUPS_PRINTER_DIALOG_UTIL_JS" + file="printing_page/cups_printer_dialog_util.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CLOUD_PRINTING_PAGE_HTML" + file="printing_page/cloud_printers.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CLOUD_PRINTING_PAGE_JS" + file="printing_page/cloud_printers.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_LOCAL_DATA_BROWSER_PROXY_HTML" + file="site_settings/local_data_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_LOCAL_DATA_BROWSER_PROXY_JS" + file="site_settings/local_data_browser_proxy.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_OPEN_WINDOW_PROXY_HTML" + file="open_window_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_OPEN_WINDOW_PROXY_JS" + file="open_window_proxy.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PAGE_VISIBILITY_HTML" + file="page_visibility.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PAGE_VISIBILITY_JS" + file="page_visibility.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_PDF_DOCUMENTS_HTML" + file="site_settings/pdf_documents.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PDF_DOCUMENTS_JS" + file="site_settings/pdf_documents.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PERSONALIZATION_OPTIONS_HTML" + file="privacy_page/personalization_options.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_PERSONALIZATION_OPTIONS_JS" + file="privacy_page/personalization_options.js" + preprocess="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PRIVACY_PAGE_HTML" + file="privacy_page/privacy_page.html" + type="chrome_html" + flattenhtml="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_PRIVACY_PAGE_JS" + file="privacy_page/privacy_page.js" + preprocess="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PRIVACY_PAGE_BROWSER_PROXY_HTML" + file="privacy_page/privacy_page_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PRIVACY_PAGE_BROWSER_PROXY_JS" + file="privacy_page/privacy_page_browser_proxy.js" + preprocess="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PROTOCOL_HANDLERS_HTML" + file="site_settings/protocol_handlers.html" + preprocess="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PROTOCOL_HANDLERS_JS" + file="site_settings/protocol_handlers.js" + preprocess="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ROUTE_HTML" + file="route.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ROUTE_JS" + file="route.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_SITE_FAVICON_HTML" + file="site_favicon.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_FAVICON_JS" + file="site_favicon.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_DATA_HTML" + file="site_settings/site_data.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_DATA_JS" + file="site_settings/site_data.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_DATA_DETAILS_SUBPAGE_HTML" + file="site_settings/site_data_details_subpage.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_DATA_DETAILS_SUBPAGE_JS" + file="site_settings/site_data_details_subpage.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_DATA_ENTRY_HTML" + file="site_settings/site_data_entry.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_DATA_ENTRY_JS" + file="site_settings/site_data_entry.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_LIST_HTML" + file="site_settings/site_list.html" + preprocess="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_LIST_JS" + file="site_settings/site_list.js" + preprocess="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_LIST_ENTRY_HTML" + file="site_settings/site_list_entry.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_LIST_ENTRY_JS" + file="site_settings/site_list_entry.js" + preprocess="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_SETTINGS_BEHAVIOR_HTML" + file="site_settings/site_settings_behavior.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_SETTINGS_BEHAVIOR_JS" + file="site_settings/site_settings_behavior.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_CONSTANTS_JS" + file="site_settings/constants.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CONSTANTS_HTML" + file="site_settings/constants.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_SETTINGS_PAGE_HTML" + file="site_settings_page/site_settings_page.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_SETTINGS_PAGE_JS" + file="site_settings_page/site_settings_page.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_SITE_SETTINGS_PREFS_BROWSER_PROXY_HTML" + file="site_settings/site_settings_prefs_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_SETTINGS_PREFS_BROWSER_PROXY_JS" + file="site_settings/site_settings_prefs_browser_proxy.js" + preprocess="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_DETAILS_HTML" + file="site_settings/site_details.html" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_SITE_DETAILS_JS" + file="site_settings/site_details.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_SITE_DETAILS_PERMISSION_HTML" + file="site_settings/site_details_permission.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SITE_DETAILS_PERMISSION_JS" + file="site_settings/site_details_permission.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_SEARCH_ENGINES_PAGE_SEARCH_ENGINE_DIALOG_JS" + file="search_engines_page/search_engine_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SEARCH_ENGINES_PAGE_SEARCH_ENGINE_DIALOG_HTML" + file="search_engines_page/search_engine_dialog.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_SEARCH_ENGINES_PAGE_SEARCH_ENGINE_ENTRY_JS" + file="search_engines_page/search_engine_entry.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SEARCH_ENGINES_PAGE_SEARCH_ENGINE_ENTRY_HTML" + file="search_engines_page/search_engine_entry.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_SEARCH_ENGINES_PAGE_SEARCH_ENGINE_ENTRY_CSS_HTML" + file="search_engines_page/search_engine_entry_css.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SEARCH_ENGINES_PAGE_OMNIBOX_EXTENSION_ENTRY_JS" + file="search_engines_page/omnibox_extension_entry.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SEARCH_ENGINES_PAGE_OMNIBOX_EXTENSION_ENTRY_HTML" + file="search_engines_page/omnibox_extension_entry.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_SEARCH_ENGINES_PAGE_SEARCH_ENGINES_LIST_JS" + file="search_engines_page/search_engines_list.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SEARCH_ENGINES_PAGE_SEARCH_ENGINES_LIST_HTML" + file="search_engines_page/search_engines_list.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_SEARCH_ENGINES_PAGE_SEARCH_ENGINES_PAGE_JS" + file="search_engines_page/search_engines_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SEARCH_ENGINES_PAGE_SEARCH_ENGINES_PAGE_HTML" + file="search_engines_page/search_engines_page.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_SEARCH_ENGINES_BROWSER_PROXY_JS" + file="search_engines_page/search_engines_browser_proxy.js" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_SEARCH_ENGINES_BROWSER_PROXY_HTML" + file="search_engines_page/search_engines_browser_proxy.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_GOOGLE_ASSISTANT_PAGE_GOOGLE_ASSISTANT_PAGE_JS" + file="google_assistant_page/google_assistant_page.js" + type="chrome_html" + allowexternalscript="true"/> + <structure name="IDR_OS_SETTINGS_GOOGLE_ASSISTANT_PAGE_GOOGLE_ASSISTANT_PAGE_HTML" + file="google_assistant_page/google_assistant_page.html" + type="chrome_html" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_GOOGLE_ASSISTANT_PAGE_GOOGLE_ASSISTANT_BROWSER_PROXY_JS" + file="google_assistant_page/google_assistant_browser_proxy.js" + type="chrome_html" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_GOOGLE_ASSISTANT_PAGE_GOOGLE_ASSISTANT_BROWSER_PROXY_HTML" + file="google_assistant_page/google_assistant_browser_proxy.html" + type="chrome_html" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_SEARCH_PAGE_JS" + file="search_page/search_page.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_SEARCH_PAGE_HTML" + file="search_page/search_page.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_SYNC_CONTROLS_JS" + file="people_page/sync_controls.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_SYNC_CONTROLS_HTML" + file="people_page/sync_controls.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_SYNC_PAGE_JS" + file="people_page/sync_page.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_SYNC_PAGE_HTML" + file="people_page/sync_page.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_SYSTEM_PAGE_BROWSER_PROXY_HTML" + file="system_page/system_page_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SYSTEM_PAGE_BROWSER_PROXY" + file="system_page/system_page_browser_proxy.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SYSTEM_PAGE_HTML" + file="system_page/system_page.html" + preprocess="true" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SYSTEM_PAGE_JS" + file="system_page/system_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_SETTINGS_HTML" preprocess="true" file="chromeos/os_settings.html" type="chrome_html" /> - <structure name="IDR_SETTINGS_OS_LAZY_LOAD_HTML" + <structure name="IDR_OS_SETTINGS_LAZY_LOAD_HTML" preprocess="true" file="chromeos/lazy_load.html" type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_WEBSITE_USAGE_PRIVATE_API_HTML" + file="site_settings/website_usage_private_api.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_WEBSITE_USAGE_PRIVATE_API_JS" + file="site_settings/website_usage_private_api.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ZOOM_LEVELS_HTML" + file="site_settings/zoom_levels.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ZOOM_LEVELS_JS" + file="site_settings/zoom_levels.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ANDROID_APPS_PAGE_HTML" + file="android_apps_page/android_apps_page.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ANDROID_APPS_PAGE_JS" + file="android_apps_page/android_apps_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ANDROID_APPS_SUBPAGE_HTML" + file="android_apps_page/android_apps_subpage.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ANDROID_APPS_SUBPAGE_JS" + file="android_apps_page/android_apps_subpage.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ANDROID_APPS_BROWSER_PROXY_JS" + file="android_apps_page/android_apps_browser_proxy.js" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_ANDROID_APPS_BROWSER_PROXY_HTML" + file="android_apps_page/android_apps_browser_proxy.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_CROSTINI_PAGE_HTML" + file="crostini_page/crostini_page.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CROSTINI_PAGE_JS" + file="crostini_page/crostini_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CROSTINI_SUBPAGE_HTML" + file="crostini_page/crostini_subpage.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CROSTINI_SUBPAGE_JS" + file="crostini_page/crostini_subpage.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CROSTINI_EXPORT_IMPORT_HTML" + file="crostini_page/crostini_export_import.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CROSTINI_EXPORT_IMPORT_JS" + file="crostini_page/crostini_export_import.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CROSTINI_SHARED_PATHS_HTML" + file="crostini_page/crostini_shared_paths.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CROSTINI_SHARED_PATHS_JS" + file="crostini_page/crostini_shared_paths.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_HTML" + file="crostini_page/crostini_shared_usb_devices.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_JS" + file="crostini_page/crostini_shared_usb_devices.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_CROSTINI_BROWSER_PROXY_JS" + file="crostini_page/crostini_browser_proxy.js" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_CROSTINI_BROWSER_PROXY_HTML" + file="crostini_page/crostini_browser_proxy.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_KIOSK_NEXT_SHELL_PAGE_HTML" + file="kiosk_next_shell_page/kiosk_next_shell_page.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_KIOSK_NEXT_SHELL_PAGE_JS" + file="kiosk_next_shell_page/kiosk_next_shell_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_KIOSK_NEXT_SHELL_CONFIRMATION_DIALOG_HTML" + file="kiosk_next_shell_page/kiosk_next_shell_confirmation_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_KIOSK_NEXT_SHELL_CONFIRMATION_DIALOG_JS" + file="kiosk_next_shell_page/kiosk_next_shell_confirmation_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_BLUETOOTH_DEVICE_LIST_ITEM_HTML" + file="bluetooth_page/bluetooth_device_list_item.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_BLUETOOTH_DEVICE_LIST_ITEM_JS" + file="bluetooth_page/bluetooth_device_list_item.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_BLUETOOTH_PAGE_HTML" + file="bluetooth_page/bluetooth_page.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_BLUETOOTH_PAGE_JS" + file="bluetooth_page/bluetooth_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_BLUETOOTH_SUBPAGE_HTML" + file="bluetooth_page/bluetooth_subpage.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_BLUETOOTH_SUBPAGE_JS" + file="bluetooth_page/bluetooth_subpage.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DATE_TIME_PAGE_HTML" + file="date_time_page/date_time_page.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DATE_TIME_PAGE_JS" + file="date_time_page/date_time_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DATE_TIME_TYPES_HTML" + file="date_time_page/date_time_types.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_DATE_TIME_TYPES_JS" + file="date_time_page/date_time_types.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_TIMEZONE_SELECTOR_HTML" + file="date_time_page/timezone_selector.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_TIMEZONE_SELECTOR_JS" + file="date_time_page/timezone_selector.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_TIMEZONE_SUBPAGE_HTML" + file="date_time_page/timezone_subpage.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_TIMEZONE_SUBPAGE_JS" + file="date_time_page/timezone_subpage.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_INTERNET_CONFIG_HTML" + file="internet_page/internet_config.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_INTERNET_CONFIG_JS" + file="internet_page/internet_config.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_INTERNET_DETAIL_PAGE_HTML" + file="internet_page/internet_detail_page.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_INTERNET_DETAIL_PAGE_JS" + file="internet_page/internet_detail_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_INTERNET_KNOWN_NETWORKS_PAGE_HTML" + file="internet_page/internet_known_networks_page.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_INTERNET_KNOWN_NETWORKS_PAGE_JS" + file="internet_page/internet_known_networks_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_INTERNET_PAGE_BROWSER_PROXY_HTML" + file="internet_page/internet_page_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_INTERNET_PAGE_BROWSER_PROXY_JS" + file="internet_page/internet_page_browser_proxy.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_INTERNET_PAGE_HTML" + file="internet_page/internet_page.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_INTERNET_PAGE_JS" + file="internet_page/internet_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_INTERNET_SHARED_CSS_HTML" + file="internet_page/internet_shared_css.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_INTERNET_SUBPAGE_HTML" + file="internet_page/internet_subpage.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_INTERNET_SUBPAGE_JS" + file="internet_page/internet_subpage.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_BROWSER_PROXY_HTML" + file="multidevice_page/multidevice_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_BROWSER_PROXY_JS" + file="multidevice_page/multidevice_browser_proxy.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_CONSTANTS_HTML" + file="multidevice_page/multidevice_constants.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_CONSTANTS_JS" + file="multidevice_page/multidevice_constants.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_FEATURE_BEHAVIOR_HTML" + file="multidevice_page/multidevice_feature_behavior.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_FEATURE_BEHAVIOR_JS" + file="multidevice_page/multidevice_feature_behavior.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_FEATURE_ITEM_HTML" + file="multidevice_page/multidevice_feature_item.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_FEATURE_ITEM_JS" + file="multidevice_page/multidevice_feature_item.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_FEATURE_TOGGLE_HTML" + file="multidevice_page/multidevice_feature_toggle.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_FEATURE_TOGGLE_JS" + file="multidevice_page/multidevice_feature_toggle.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_PAGE_HTML" + file="multidevice_page/multidevice_page.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_PAGE_JS" + file="multidevice_page/multidevice_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_RADIO_BUTTON_HTML" + file="multidevice_page/multidevice_radio_button.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_RADIO_BUTTON_JS" + file="multidevice_page/multidevice_radio_button.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_SMARTLOCK_SUBPAGE_HTML" + file="multidevice_page/multidevice_smartlock_subpage.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_SMARTLOCK_SUBPAGE_JS" + file="multidevice_page/multidevice_smartlock_subpage.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_SUBPAGE_HTML" + file="multidevice_page/multidevice_subpage.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_SUBPAGE_JS" + file="multidevice_page/multidevice_subpage.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_TETHER_ITEM_HTML" + file="multidevice_page/multidevice_tether_item.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_MULTIDEVICE_TETHER_ITEM_JS" + file="multidevice_page/multidevice_tether_item.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_NETWORK_PROXY_SECTION_HTML" + file="internet_page/network_proxy_section.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_NETWORK_PROXY_SECTION_JS" + file="internet_page/network_proxy_section.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_NETWORK_SUMMARY_HTML" + file="internet_page/network_summary.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_NETWORK_SUMMARY_JS" + file="internet_page/network_summary.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_NETWORK_SUMMARY_ITEM_HTML" + file="internet_page/network_summary_item.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_NETWORK_SUMMARY_ITEM_JS" + file="internet_page/network_summary_item.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_TETHER_CONNECTION_DIALOG_HTML" + file="internet_page/tether_connection_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_TETHER_CONNECTION_DIALOG_JS" + file="internet_page/tether_connection_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_PAGE_ACCOUNT_MANAGER_HTML" + file="people_page/account_manager.html" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_PAGE_ACCOUNT_MANAGER_JS" + file="people_page/account_manager.js" + type="chrome_html" + preprocess="true" /> + <structure + name="IDR_OS_SETTINGS_PEOPLE_PAGE_ACCOUNT_MANAGER_BROWSER_PROXY_HTML" + file="people_page/account_manager_browser_proxy.html" + type="chrome_html" + preprocess="true" /> + <structure + name="IDR_OS_SETTINGS_PEOPLE_PAGE_ACCOUNT_MANAGER_BROWSER_PROXY_JS" + file="people_page/account_manager_browser_proxy.js" + type="chrome_html" + preprocess="true" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_PAGE_CHANGE_PICTURE_HTML" + file="people_page/change_picture.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_PAGE_CHANGE_PICTURE_JS" + file="people_page/change_picture.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_CHANGE_PICTURE_BROWSER_PROXY_JS" + file="people_page/change_picture_browser_proxy.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_CHANGE_PICTURE_BROWSER_PROXY_HTML" + file="people_page/change_picture_browser_proxy.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_LOCK_SCREEN_PASSWORD_PROMPT_DIALOG_JS" + file="people_page/lock_screen_password_prompt_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_LOCK_SCREEN_PASSWORD_PROMPT_DIALOG_HTML" + file="people_page/lock_screen_password_prompt_dialog.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_LOCK_SCREEN_JS" + file="people_page/lock_screen.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_LOCK_SCREEN_HTML" + file="people_page/lock_screen.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_LOCK_STATE_BEHAVIOR_JS" + file="people_page/lock_state_behavior.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_LOCK_STATE_BEHAVIOR_HTML" + file="people_page/lock_state_behavior.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_SETUP_PIN_DIALOG_JS" + file="people_page/setup_pin_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_SETUP_PIN_DIALOG_HTML" + file="people_page/setup_pin_dialog.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_FINGERPRINT_LIST_JS" + file="people_page/fingerprint_list.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_FINGERPRINT_LIST_HTML" + file="people_page/fingerprint_list.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_SETUP_FINGERPRINT_DIALOG_JS" + file="people_page/setup_fingerprint_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_SETUP_FINGERPRINT_DIALOG_HTML" + file="people_page/setup_fingerprint_dialog.html" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_FINGERPRINT_BROWSER_PROXY_JS" + file="people_page/fingerprint_browser_proxy.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_PEOPLE_FINGERPRINT_BROWSER_PROXY_HTML" + file="people_page/fingerprint_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_SETTINGS_PLUGIN_VM_PAGE_HTML" + file="plugin_vm_page/plugin_vm_page.html" + type="chrome_html" /> + <structure name="IDR_SETTINGS_PLUGIN_VM_PAGE_JS" + file="plugin_vm_page/plugin_vm_page.js" + type="chrome_html" /> + <structure name="IDR_SETTINGS_PLUGIN_VM_SUBPAGE_HTML" + file="plugin_vm_page/plugin_vm_subpage.html" + type="chrome_html" /> + <structure name="IDR_SETTINGS_PLUGIN_VM_SUBPAGE_JS" + file="plugin_vm_page/plugin_vm_subpage.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_USERS_PAGE_ADD_USER_DIALOG_JS" + file="people_page/users_add_user_dialog.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_USERS_PAGE_ADD_USER_DIALOG_HTML" + file="people_page/users_add_user_dialog.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_USERS_PAGE_USER_LIST_JS" + file="people_page/user_list.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_USERS_PAGE_USER_LIST_HTML" + file="people_page/user_list.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> + <structure name="IDR_OS_SETTINGS_USERS_PAGE_JS" + file="people_page/users_page.js" + type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_USERS_PAGE_HTML" + file="people_page/users_page.html" + type="chrome_html" + preprocess="true" + allowexternalscript="true" /> </structures> </release> </grit>
diff --git a/chrome/browser/resources/settings/os_settings_resources_vulcanized.grd b/chrome/browser/resources/settings/os_settings_resources_vulcanized.grd index 56bab64..93e5894 100644 --- a/chrome/browser/resources/settings/os_settings_resources_vulcanized.grd +++ b/chrome/browser/resources/settings/os_settings_resources_vulcanized.grd
@@ -12,13 +12,47 @@ </outputs> <release seq="1"> <includes> - <include name="IDR_OS_MD_SETTINGS_VULCANIZED_HTML" file="${root_gen_dir}\chrome\browser\resources\settings\chromeos\vulcanized.html" use_base_dir="false" flattenhtml="true" allowexternalscript="true" type="BINDATA" compress="gzip" /> - <include name="IDR_OS_MD_SETTINGS_VULCANIZED_P2_HTML" file="${root_gen_dir}\chrome\browser\resources\settings\chromeos\vulcanized.p2.html" use_base_dir="false" flattenhtml="true" allowexternalscript="true" type="BINDATA" compress="gzip" /> - <include name="IDR_OS_MD_SETTINGS_CRISPER_JS" file="${root_gen_dir}\chrome\browser\resources\settings\chromeos\crisper.js" use_base_dir="false" flattenhtml="true" type="BINDATA" compress="gzip" /> - <include name="IDR_OS_MD_SETTINGS_LAZY_LOAD_VULCANIZED_HTML" file="${root_gen_dir}\chrome\browser\resources\settings\chromeos\lazy_load.vulcanized.html" use_base_dir="false" flattenhtml="true" allowexternalscript="true" type="BINDATA" compress="gzip" /> - <include name="IDR_OS_MD_SETTINGS_LAZY_LOAD_VULCANIZED_P2_HTML" file="${root_gen_dir}\chrome\browser\resources\settings\chromeos\lazy_load.vulcanized.p2.html" use_base_dir="false" flattenhtml="true" allowexternalscript="true" type="BINDATA" compress="gzip" /> - <include name="IDR_OS_MD_SETTINGS_LAZY_LOAD_CRISPER_JS" file="${root_gen_dir}\chrome\browser\resources\settings\chromeos\lazy_load.crisper.js" use_base_dir="false" flattenhtml="true" type="BINDATA" compress="gzip" /> - <include name="IDR_OS_MD_SETTINGS_MANIFEST" file="manifest.json" type="BINDATA" compress="gzip" /> + <include name="IDR_OS_SETTINGS_VULCANIZED_HTML" + file="${root_gen_dir}\chrome\browser\resources\settings\chromeos\vulcanized.html" + use_base_dir="false" + flattenhtml="true" + allowexternalscript="true" + type="BINDATA" + compress="gzip" /> + <include name="IDR_OS_SETTINGS_VULCANIZED_P2_HTML" + file="${root_gen_dir}\chrome\browser\resources\settings\chromeos\vulcanized.p2.html" + use_base_dir="false" + flattenhtml="true" + allowexternalscript="true" + type="BINDATA" + compress="gzip" /> + <include name="IDR_OS_SETTINGS_CRISPER_JS" + file="${root_gen_dir}\chrome\browser\resources\settings\chromeos\crisper.js" + use_base_dir="false" + flattenhtml="true" + type="BINDATA" + compress="gzip" /> + <include name="IDR_OS_SETTINGS_LAZY_LOAD_VULCANIZED_HTML" + file="${root_gen_dir}\chrome\browser\resources\settings\chromeos\lazy_load.vulcanized.html" + use_base_dir="false" + flattenhtml="true" + allowexternalscript="true" + type="BINDATA" + compress="gzip" /> + <include name="IDR_OS_SETTINGS_LAZY_LOAD_VULCANIZED_P2_HTML" + file="${root_gen_dir}\chrome\browser\resources\settings\chromeos\lazy_load.vulcanized.p2.html" + use_base_dir="false" + flattenhtml="true" + allowexternalscript="true" + type="BINDATA" + compress="gzip" /> + <include name="IDR_OS_SETTINGS_LAZY_LOAD_CRISPER_JS" + file="${root_gen_dir}\chrome\browser\resources\settings\chromeos\lazy_load.crisper.js" + use_base_dir="false" + flattenhtml="true" + type="BINDATA" + compress="gzip" /> + <include name="IDR_OS_SETTINGS_MANIFEST" file="manifest.json" type="BINDATA" compress="gzip" /> </includes> </release> </grit>
diff --git a/chrome/browser/resources/md_user_manager/BUILD.gn b/chrome/browser/resources/user_manager/BUILD.gn similarity index 100% rename from chrome/browser/resources/md_user_manager/BUILD.gn rename to chrome/browser/resources/user_manager/BUILD.gn
diff --git a/chrome/browser/resources/md_user_manager/OWNERS b/chrome/browser/resources/user_manager/OWNERS similarity index 100% rename from chrome/browser/resources/md_user_manager/OWNERS rename to chrome/browser/resources/user_manager/OWNERS
diff --git a/chrome/browser/resources/md_user_manager/control_bar.html b/chrome/browser/resources/user_manager/control_bar.html similarity index 100% rename from chrome/browser/resources/md_user_manager/control_bar.html rename to chrome/browser/resources/user_manager/control_bar.html
diff --git a/chrome/browser/resources/md_user_manager/control_bar.js b/chrome/browser/resources/user_manager/control_bar.js similarity index 100% rename from chrome/browser/resources/md_user_manager/control_bar.js rename to chrome/browser/resources/user_manager/control_bar.js
diff --git a/chrome/browser/resources/md_user_manager/create_profile.html b/chrome/browser/resources/user_manager/create_profile.html similarity index 100% rename from chrome/browser/resources/md_user_manager/create_profile.html rename to chrome/browser/resources/user_manager/create_profile.html
diff --git a/chrome/browser/resources/md_user_manager/create_profile.js b/chrome/browser/resources/user_manager/create_profile.js similarity index 100% rename from chrome/browser/resources/md_user_manager/create_profile.js rename to chrome/browser/resources/user_manager/create_profile.js
diff --git a/chrome/browser/resources/md_user_manager/error_dialog.html b/chrome/browser/resources/user_manager/error_dialog.html similarity index 100% rename from chrome/browser/resources/md_user_manager/error_dialog.html rename to chrome/browser/resources/user_manager/error_dialog.html
diff --git a/chrome/browser/resources/md_user_manager/error_dialog.js b/chrome/browser/resources/user_manager/error_dialog.js similarity index 100% rename from chrome/browser/resources/md_user_manager/error_dialog.js rename to chrome/browser/resources/user_manager/error_dialog.js
diff --git a/chrome/browser/resources/md_user_manager/profile_browser_proxy.html b/chrome/browser/resources/user_manager/profile_browser_proxy.html similarity index 100% rename from chrome/browser/resources/md_user_manager/profile_browser_proxy.html rename to chrome/browser/resources/user_manager/profile_browser_proxy.html
diff --git a/chrome/browser/resources/md_user_manager/profile_browser_proxy.js b/chrome/browser/resources/user_manager/profile_browser_proxy.js similarity index 100% rename from chrome/browser/resources/md_user_manager/profile_browser_proxy.js rename to chrome/browser/resources/user_manager/profile_browser_proxy.js
diff --git a/chrome/browser/resources/md_user_manager/shared_styles.html b/chrome/browser/resources/user_manager/shared_styles.html similarity index 100% rename from chrome/browser/resources/md_user_manager/shared_styles.html rename to chrome/browser/resources/user_manager/shared_styles.html
diff --git a/chrome/browser/resources/md_user_manager/strings.html b/chrome/browser/resources/user_manager/strings.html similarity index 100% rename from chrome/browser/resources/md_user_manager/strings.html rename to chrome/browser/resources/user_manager/strings.html
diff --git a/chrome/browser/resources/md_user_manager/user_manager.html b/chrome/browser/resources/user_manager/user_manager.html similarity index 100% rename from chrome/browser/resources/md_user_manager/user_manager.html rename to chrome/browser/resources/user_manager/user_manager.html
diff --git a/chrome/browser/resources/md_user_manager/user_manager.js b/chrome/browser/resources/user_manager/user_manager.js similarity index 100% rename from chrome/browser/resources/md_user_manager/user_manager.js rename to chrome/browser/resources/user_manager/user_manager.js
diff --git a/chrome/browser/resources/md_user_manager/user_manager_pages.html b/chrome/browser/resources/user_manager/user_manager_pages.html similarity index 100% rename from chrome/browser/resources/md_user_manager/user_manager_pages.html rename to chrome/browser/resources/user_manager/user_manager_pages.html
diff --git a/chrome/browser/resources/md_user_manager/user_manager_pages.js b/chrome/browser/resources/user_manager/user_manager_pages.js similarity index 100% rename from chrome/browser/resources/md_user_manager/user_manager_pages.js rename to chrome/browser/resources/user_manager/user_manager_pages.js
diff --git a/chrome/browser/resources/md_user_manager/user_manager_tutorial.html b/chrome/browser/resources/user_manager/user_manager_tutorial.html similarity index 100% rename from chrome/browser/resources/md_user_manager/user_manager_tutorial.html rename to chrome/browser/resources/user_manager/user_manager_tutorial.html
diff --git a/chrome/browser/resources/md_user_manager/user_manager_tutorial.js b/chrome/browser/resources/user_manager/user_manager_tutorial.js similarity index 100% rename from chrome/browser/resources/md_user_manager/user_manager_tutorial.js rename to chrome/browser/resources/user_manager/user_manager_tutorial.js
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/BUILD.gn b/chrome/browser/resources/welcome/onboarding_welcome/BUILD.gn index 7e37a64..426c6d0 100644 --- a/chrome/browser/resources/welcome/onboarding_welcome/BUILD.gn +++ b/chrome/browser/resources/welcome/onboarding_welcome/BUILD.gn
@@ -7,7 +7,6 @@ group("closure_compile") { deps = [ ":welcome_files", - "./email:closure_compile", "./google_apps:closure_compile", "./ntp_background:closure_compile", "./set_as_default:closure_compile", @@ -42,7 +41,6 @@ ":navigation_behavior", ":signin_view_proxy", ":welcome_browser_proxy", - "./email/:email_app_proxy", ] } @@ -67,6 +65,7 @@ "./shared:bookmark_proxy", "./shared:nux_types", "//ui/webui/resources/cr_elements/cr_view_manager:cr_view_manager", + "//ui/webui/resources/js:load_time_data", "//ui/webui/resources/js:promise_resolver", ] }
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/email/BUILD.gn b/chrome/browser/resources/welcome/onboarding_welcome/email/BUILD.gn deleted file mode 100644 index 15c354b..0000000 --- a/chrome/browser/resources/welcome/onboarding_welcome/email/BUILD.gn +++ /dev/null
@@ -1,34 +0,0 @@ -# Copyright 2018 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//third_party/closure_compiler/compile_js.gni") - -js_type_check("closure_compile") { - deps = [ - ":nux_email", - ] -} - -js_library("nux_email") { - deps = [ - ":email_app_proxy", - "../:navigation_behavior", - "../shared:app_chooser", - "../shared:nux_types", - ] -} - -js_library("email_app_proxy") { - deps = [ - "../shared:app_proxy", - "../shared:nux_types", - "//ui/webui/resources/js:cr", - "//ui/webui/resources/js:load_time_data", - ] - externs_list = [ - "$externs_path/chrome_extensions.js", - "$externs_path/chrome_send.js", - "$externs_path/metrics_private.js", - ] -}
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/email/email_app_proxy.html b/chrome/browser/resources/welcome/onboarding_welcome/email/email_app_proxy.html deleted file mode 100644 index 3dc5c92b..0000000 --- a/chrome/browser/resources/welcome/onboarding_welcome/email/email_app_proxy.html +++ /dev/null
@@ -1,4 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="chrome://welcome/shared/i18n_setup.html"> -<link rel="import" href="chrome://welcome/shared/module_metrics_proxy.html"> -<script src="email_app_proxy.js"></script>
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/email/email_app_proxy.js b/chrome/browser/resources/welcome/onboarding_welcome/email/email_app_proxy.js deleted file mode 100644 index d0bc4e52..0000000 --- a/chrome/browser/resources/welcome/onboarding_welcome/email/email_app_proxy.js +++ /dev/null
@@ -1,31 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -cr.define('nux', function() { - /** @implements {nux.AppProxy} */ - class EmailAppProxyImpl { - /** @override */ - cacheBookmarkIcon(emailProviderId) { - chrome.send('cacheEmailIcon', [emailProviderId]); - } - - /** @override */ - getAppList() { - return cr.sendWithPromise('getEmailList'); - } - - /** @override */ - recordProviderSelected(providerId) { - chrome.metricsPrivate.recordEnumerationValue( - 'FirstRun.NewUserExperience.EmailProvidersSelection', providerId, - loadTimeData.getInteger('email_providers_enum_count')); - } - } - - cr.addSingletonGetter(EmailAppProxyImpl); - - return { - EmailAppProxyImpl: EmailAppProxyImpl, - }; -});
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/email/nux_email.html b/chrome/browser/resources/welcome/onboarding_welcome/email/nux_email.html deleted file mode 100644 index 70c4455..0000000 --- a/chrome/browser/resources/welcome/onboarding_welcome/email/nux_email.html +++ /dev/null
@@ -1,45 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="../navigation_behavior.html"> -<link rel="import" href="../shared/app_chooser.html"> -<link rel="import" href="email_app_proxy.html"> - -<dom-module id="nux-email"> - <template> - <style> - .email-ask { - text-align: center; - } - - .email-logo { - content: url(../images/module_icons/email_light.svg); - height: 38px; - margin: auto; - margin-bottom: 16px; - width: 42px; - } - - :host-context([dark]) .email-logo { - content: url(../images/module_icons/email_dark.svg); - } - - h1 { - color: var(--cr-primary-text-color); - font-size: 1.5rem; - font-weight: 500; - margin: 0; - margin-bottom: 48px; - outline: none; - } - </style> - <div class="email-ask"> - <div class="email-logo" alt=""></div> - <h1 tabindex="-1">$i18n{emailProviderTitle}</h1> - <app-chooser id="emailChooser" indicator-model="[[indicatorModel]]" - single-select> - </app-chooser> - </div> - </template> - <script src="nux_email.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/email/nux_email.js b/chrome/browser/resources/welcome/onboarding_welcome/email/nux_email.js deleted file mode 100644 index 8dabf5e1..0000000 --- a/chrome/browser/resources/welcome/onboarding_welcome/email/nux_email.js +++ /dev/null
@@ -1,33 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -Polymer({ - is: 'nux-email', - - behaviors: [welcome.NavigationBehavior], - - properties: { - /** @type {nux.stepIndicatorModel} */ - indicatorModel: Object, - }, - - /** @override */ - ready: function() { - this.$.emailChooser.appProxy = nux.EmailAppProxyImpl.getInstance(); - this.$.emailChooser.metricsManager = - new nux.ModuleMetricsManager(nux.EmailMetricsProxyImpl.getInstance()); - }, - - onRouteEnter: function() { - this.$.emailChooser.onRouteEnter(); - }, - - onRouteExit: function() { - this.$.emailChooser.onRouteExit(); - }, - - onRouteUnload: function() { - this.$.emailChooser.onRouteUnload(); - }, -});
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/images/aol_1x.png b/chrome/browser/resources/welcome/onboarding_welcome/images/aol_1x.png deleted file mode 100644 index 566cf211..0000000 --- a/chrome/browser/resources/welcome/onboarding_welcome/images/aol_1x.png +++ /dev/null Binary files differ
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/images/aol_2x.png b/chrome/browser/resources/welcome/onboarding_welcome/images/aol_2x.png deleted file mode 100644 index a316bf9..0000000 --- a/chrome/browser/resources/welcome/onboarding_welcome/images/aol_2x.png +++ /dev/null Binary files differ
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/images/icloud_1x.png b/chrome/browser/resources/welcome/onboarding_welcome/images/icloud_1x.png deleted file mode 100644 index f3f7538..0000000 --- a/chrome/browser/resources/welcome/onboarding_welcome/images/icloud_1x.png +++ /dev/null Binary files differ
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/images/icloud_2x.png b/chrome/browser/resources/welcome/onboarding_welcome/images/icloud_2x.png deleted file mode 100644 index a01c37d..0000000 --- a/chrome/browser/resources/welcome/onboarding_welcome/images/icloud_2x.png +++ /dev/null Binary files differ
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/images/module_icons/email_dark.svg b/chrome/browser/resources/welcome/onboarding_welcome/images/module_icons/email_dark.svg deleted file mode 100644 index f6eac4f..0000000 --- a/chrome/browser/resources/welcome/onboarding_welcome/images/module_icons/email_dark.svg +++ /dev/null
@@ -1 +0,0 @@ -<svg width="46" height="39" xmlns="http://www.w3.org/2000/svg"><g transform="translate(-2 -2)" fill="none" fill-rule="evenodd"><circle fill="#90CFA3" cx="9.764" cy="38.785" r="2"/><path d="M34.998 27.443l11.433-.565a1.157 1.157 0 0 1 1.156 1.16 1.142 1.142 0 0 1-.127.514L42.284 38.58a1.174 1.174 0 0 1-1.977.163L34.05 29.28a1.144 1.144 0 0 1 .247-1.611c.203-.148.45-.227.701-.226z" fill="#EE675C" style="mix-blend-mode:screen"/><path d="M37.43 13.118H16.097a2.663 2.663 0 0 0-2.653 2.667l-.014 16c0 1.466 1.2 2.666 2.667 2.666H37.43c1.467 0 2.667-1.2 2.667-2.666v-16c0-1.467-1.2-2.667-2.667-2.667zm0 5.333l-10.666 6.667-10.667-6.667v-2.666l10.667 6.666 10.666-6.666v2.666z" fill="#8AB4F8" fill-rule="nonzero"/><path style="mix-blend-mode:multiply" d="M10.764 7.785h32v32h-32z"/><path d="M7.356 5.426c4.903-4.184 12.016-3.946 16.689.284.464.42 1.274 1.412-.187 2.658L7.085 22.678c-1.324 1.13-1.914.198-2.203-.255C1.42 16.985 2.38 9.671 7.356 5.426z" fill="#FDD663" style="mix-blend-mode:screen"/></g></svg> \ No newline at end of file
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/images/module_icons/email_light.svg b/chrome/browser/resources/welcome/onboarding_welcome/images/module_icons/email_light.svg deleted file mode 100644 index bb7b52ab..0000000 --- a/chrome/browser/resources/welcome/onboarding_welcome/images/module_icons/email_light.svg +++ /dev/null
@@ -1 +0,0 @@ -<svg width="46" height="39" xmlns="http://www.w3.org/2000/svg"><g transform="translate(-2 -2)" fill="none" fill-rule="evenodd"><circle fill="#31A753" cx="9.764" cy="38.785" r="2"/><path d="M34.998 27.443l11.433-.565a1.157 1.157 0 0 1 1.156 1.16 1.142 1.142 0 0 1-.127.514L42.284 38.58a1.174 1.174 0 0 1-1.977.163L34.05 29.28a1.144 1.144 0 0 1 .247-1.611c.203-.148.45-.227.701-.226z" fill="#E74133" style="mix-blend-mode:multiply"/><path d="M37.43 13.118H16.097a2.663 2.663 0 0 0-2.653 2.667l-.014 16c0 1.466 1.2 2.666 2.667 2.666H37.43c1.467 0 2.667-1.2 2.667-2.666v-16c0-1.467-1.2-2.667-2.667-2.667zm0 5.333l-10.666 6.667-10.667-6.667v-2.666l10.667 6.666 10.666-6.666v2.666z" fill="#1A73E8" fill-rule="nonzero"/><path style="mix-blend-mode:multiply" d="M10.764 7.785h32v32h-32z"/><path d="M7.356 5.426c4.903-4.184 12.016-3.946 16.689.284.464.42 1.274 1.412-.187 2.658L7.085 22.678c-1.324 1.13-1.914.198-2.203-.255C1.42 16.985 2.38 9.671 7.356 5.426z" fill="#FACF4C" style="mix-blend-mode:multiply"/></g></svg> \ No newline at end of file
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/images/outlook_1x.png b/chrome/browser/resources/welcome/onboarding_welcome/images/outlook_1x.png deleted file mode 100644 index 0c9bed6..0000000 --- a/chrome/browser/resources/welcome/onboarding_welcome/images/outlook_1x.png +++ /dev/null Binary files differ
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/images/outlook_2x.png b/chrome/browser/resources/welcome/onboarding_welcome/images/outlook_2x.png deleted file mode 100644 index ffa7774b..0000000 --- a/chrome/browser/resources/welcome/onboarding_welcome/images/outlook_2x.png +++ /dev/null Binary files differ
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/images/yahoo_1x.png b/chrome/browser/resources/welcome/onboarding_welcome/images/yahoo_1x.png deleted file mode 100644 index 3b0dcd4..0000000 --- a/chrome/browser/resources/welcome/onboarding_welcome/images/yahoo_1x.png +++ /dev/null Binary files differ
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/images/yahoo_2x.png b/chrome/browser/resources/welcome/onboarding_welcome/images/yahoo_2x.png deleted file mode 100644 index 1abc74d..0000000 --- a/chrome/browser/resources/welcome/onboarding_welcome/images/yahoo_2x.png +++ /dev/null Binary files differ
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/landing_view.html b/chrome/browser/resources/welcome/onboarding_welcome/landing_view.html index 648e986f..9d4cc6d 100644 --- a/chrome/browser/resources/welcome/onboarding_welcome/landing_view.html +++ b/chrome/browser/resources/welcome/onboarding_welcome/landing_view.html
@@ -13,19 +13,29 @@ <dom-module id="landing-view"> <template> <style - include="paper-button-style action-link-style splash-pages-shared-css"> + include="animations paper-button-style action-link-style + splash-pages-shared-css"> + onboarding-background { + --animation-delay: 275ms; + } + h1 { outline: none; } + + .action-button, + .action-link { + --animation-delay: 150ms; + } </style> <div id="container"> - <onboarding-background></onboarding-background> - <h2>$i18n{landingDescription}</h2> - <h1 tabindex="-1">$i18n{landingTitle}</h1> - <paper-button class="action-button" on-click="onNewUserClick_"> + <onboarding-background class="fade-in"></onboarding-background> + <h2 class="fade-in">$i18n{landingDescription}</h2> + <h1 class="fade-in" tabindex="-1">$i18n{landingTitle}</h1> + <paper-button class="action-button fade-in" on-click="onNewUserClick_"> $i18n{landingNewUser} </paper-button> - <button class="action-link" on-click="onExistingUserClick_"> + <button class="action-link fade-in" on-click="onExistingUserClick_"> $i18n{landingExistingUser} </button> </div>
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/ntp_background/nux_ntp_background.html b/chrome/browser/resources/welcome/onboarding_welcome/ntp_background/nux_ntp_background.html index 87a747d..96b0b41 100644 --- a/chrome/browser/resources/welcome/onboarding_welcome/ntp_background/nux_ntp_background.html +++ b/chrome/browser/resources/welcome/onboarding_welcome/ntp_background/nux_ntp_background.html
@@ -9,6 +9,7 @@ <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"> <link rel="import" href="../navigation_behavior.html"> +<link rel="import" href="../shared/animations_css.html"> <link rel="import" href="../shared/chooser_shared_css.html"> <link rel="import" href="../shared/i18n_setup.html"> <link rel="import" href="../shared/module_metrics_proxy.html"> @@ -17,7 +18,7 @@ <dom-module id="nux-ntp-background"> <template> - <style include="chooser-shared-css paper-button-style"> + <style include="animations chooser-shared-css paper-button-style"> :host { text-align: center; } @@ -178,7 +179,7 @@ <div class="ntp-background-logo"></div> <h1 tabindex="-1">$i18n{ntpBackgroundDescription}</h1> - <div class="ntp-backgrounds-grid"> + <div class="ntp-backgrounds-grid slide-in"> <template is="dom-repeat" items="[[backgrounds_]]"> <button active$="[[isSelectedBackground_(item, selectedBackground_)]]"
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/onboarding_welcome_resources.grd b/chrome/browser/resources/welcome/onboarding_welcome/onboarding_welcome_resources.grd index 174bf93..3f2f0ba 100644 --- a/chrome/browser/resources/welcome/onboarding_welcome/onboarding_welcome_resources.grd +++ b/chrome/browser/resources/welcome/onboarding_welcome/onboarding_welcome_resources.grd
@@ -14,36 +14,12 @@ </outputs> <release seq="1"> <includes> - <include name="IDR_NUX_EMAIL_AOL_1X" - file="images/aol_1x.png" - type="BINDATA"/> - <include name="IDR_NUX_EMAIL_AOL_2X" - file="images/aol_2x.png" - type="BINDATA" /> <include name="IDR_NUX_EMAIL_GMAIL_1X" file="images/gmail_1x.png" type="BINDATA" /> <include name="IDR_NUX_EMAIL_GMAIL_2X" file="images/gmail_2x.png" type="BINDATA" /> - <include name="IDR_NUX_EMAIL_ICLOUD_1X" - file="images/icloud_1x.png" - type="BINDATA" /> - <include name="IDR_NUX_EMAIL_ICLOUD_2X" - file="images/icloud_2x.png" - type="BINDATA" /> - <include name="IDR_NUX_EMAIL_OUTLOOK_1X" - file="images/outlook_1x.png" - type="BINDATA" /> - <include name="IDR_NUX_EMAIL_OUTLOOK_2X" - file="images/outlook_2x.png" - type="BINDATA" /> - <include name="IDR_NUX_EMAIL_YAHOO_1X" - file="images/yahoo_1x.png" - type="BINDATA" /> - <include name="IDR_NUX_EMAIL_YAHOO_2X" - file="images/yahoo_2x.png" - type="BINDATA" /> <include name="IDR_NUX_GOOGLE_APPS_CHROME_STORE_1X" file="images/chrome_store_1x.png" type="BINDATA" /> @@ -74,14 +50,6 @@ <include name="IDR_NUX_GOOGLE_APPS_YOUTUBE_2X" file="images/youtube_2x.png" type="BINDATA" /> - <include name="IDR_NUX_MODULE_ICONS_EMAIL_DARK" - file="images/module_icons/email_dark.svg" - compress="gzip" - type="BINDATA" /> - <include name="IDR_NUX_MODULE_ICONS_EMAIL_LIGHT" - file="images/module_icons/email_light.svg" - compress="gzip" - type="BINDATA" /> <include name="IDR_NUX_MODULE_ICONS_GOOGLE_DARK" file="images/module_icons/google_dark.svg" compress="gzip" @@ -205,6 +173,10 @@ file="shared/action_link_style_css.html" compress="gzip" type="chrome_html" /> + <structure name="IDR_WELCOME_ONBOARDING_WELCOME_SHARED_ANIMATIONS_CSS" + file="shared/animations_css.html" + compress="gzip" + type="chrome_html" /> <structure name="IDR_WELCOME_ONBOARDING_WELCOME_SHARED_BOOKMARK_PROXY_HTML" file="shared/bookmark_proxy.html" compress="gzip" @@ -307,24 +279,6 @@ compress="gzip" preprocess="true"/> - <!-- NUX Email--> - <structure name="IDR_EMAIL_APP_PROXY_HTML" - file="email/email_app_proxy.html" - compress="gzip" - type="chrome_html" /> - <structure name="IDR_EMAIL_APP_PROXY_JS" - file="email/email_app_proxy.js" - compress="gzip" - type="chrome_html" /> - <structure name="IDR_NUX_EMAIL_HTML" - file="email/nux_email.html" - compress="gzip" - type="chrome_html" /> - <structure name="IDR_NUX_EMAIL_JS" - file="email/nux_email.js" - compress="gzip" - type="chrome_html" /> - <!-- NUX Google apps--> <structure name="IDR_NUX_GOOGLE_APPS_HTML" file="google_apps/nux_google_apps.html"
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/set_as_default/nux_set_as_default.html b/chrome/browser/resources/welcome/onboarding_welcome/set_as_default/nux_set_as_default.html index aca9698..306a4e3 100644 --- a/chrome/browser/resources/welcome/onboarding_welcome/set_as_default/nux_set_as_default.html +++ b/chrome/browser/resources/welcome/onboarding_welcome/set_as_default/nux_set_as_default.html
@@ -5,6 +5,7 @@ <link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html"> <link rel="import" href="../navigation_behavior.html"> +<link rel="import" href="../shared/animations_css.html"> <link rel="import" href="../shared/i18n_setup.html"> <link rel="import" href="../shared/step_indicator.html"> <link rel="import" href="nux_set_as_default_proxy.html"> @@ -15,7 +16,7 @@ <dom-module id="nux-set-as-default"> <template> - <style include="paper-button-style"> + <style include="animations paper-button-style"> .container { text-align: center; } @@ -81,7 +82,7 @@ <div class="logo"></div> <h1 tabindex="-1">$i18n{setDefaultHeader}</h1> <h2>$i18n{setDefaultSubHeader}</h2> - <div class="illustration" aria-hidden="true"></div> + <div class="illustration slide-in" aria-hidden="true"></div> <div class="button-bar"> <paper-button id="decline-button" on-click="onDeclineClick_"> $i18n{setDefaultSkip}
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/shared/animations_css.html b/chrome/browser/resources/welcome/onboarding_welcome/shared/animations_css.html new file mode 100644 index 0000000..c79bd54 --- /dev/null +++ b/chrome/browser/resources/welcome/onboarding_welcome/shared/animations_css.html
@@ -0,0 +1,39 @@ +<link rel="import" href="chrome://resources/html/polymer.html"> + +<dom-module id="animations"> + <template> + <style> + @keyframes fade-in { + 0% { opacity: 0; } + 100% { opacity: 1; } + } + + @keyframes slide-in { + 0% { transform: translateX(var(--slide-in-length, 40px)); } + 100% { transform: translateX(0); } + } + + .fade-in { + animation-delay: var(--animation-delay, 0); + animation-duration: 200ms; + animation-fill-mode: forwards; + animation-name: fade-in; + animation-timing-function: ease-in; + opacity: 0; + } + + .slide-in { + animation-delay: var(--animation-delay, 0); + animation-duration: 200ms; + animation-fill-mode: forwards; + animation-name: slide-in; + animation-timing-function: ease; + transform: translateX(30px); + } + + :host-context(html[dir='rtl']) .slide-in { + --slide-in-length: -40px; + } + </style> + </template> +</dom-module>
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 11a9b56..398b4ec 100644 --- a/chrome/browser/resources/welcome/onboarding_welcome/shared/app_chooser.html +++ b/chrome/browser/resources/welcome/onboarding_welcome/shared/app_chooser.html
@@ -10,6 +10,7 @@ <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"> <link rel="import" href="../navigation_behavior.html"> +<link rel="import" href="animations_css.html"> <link rel="import" href="bookmark_proxy.html"> <link rel="import" href="chooser_shared_css.html"> <link rel="import" href="i18n_setup.html"> @@ -18,7 +19,7 @@ <dom-module id="app-chooser"> <template> - <style include="chooser-shared-css paper-button-style"> + <style include="animations chooser-shared-css paper-button-style"> :host { display: block; white-space: nowrap; @@ -174,18 +175,20 @@ } </style> - <template is="dom-repeat" items="[[appList_]]"> - <button active$="[[item.selected]]" - aria-pressed$="[[getAriaPressed_(item.selected)]]" - on-click="onAppClick_" on-pointerdown="onAppPointerDown_" - on-keyup="onAppKeyUp_" class="option"> - <div class="option-icon-shadow"> - <div class$="[[item.icon]] option-icon"></div> - </div> - <div class="option-name">[[item.name]]</div> - <iron-icon icon="cr:check"></iron-icon> - </button> - </template> + <div class="slide-in"> + <template is="dom-repeat" items="[[appList_]]"> + <button active$="[[item.selected]]" + aria-pressed$="[[getAriaPressed_(item.selected)]]" + on-click="onAppClick_" on-pointerdown="onAppPointerDown_" + on-keyup="onAppKeyUp_" class="option"> + <div class="option-icon-shadow"> + <div class$="[[item.icon]] option-icon"></div> + </div> + <div class="option-name">[[item.name]]</div> + <iron-icon icon="cr:check"></iron-icon> + </button> + </template> + </div> <div class="button-bar"> <paper-button id="noThanksButton" on-click="onNoThanksClicked_">
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/shared/module_metrics_proxy.js b/chrome/browser/resources/welcome/onboarding_welcome/shared/module_metrics_proxy.js index 4340878..159a187 100644 --- a/chrome/browser/resources/welcome/onboarding_welcome/shared/module_metrics_proxy.js +++ b/chrome/browser/resources/welcome/onboarding_welcome/shared/module_metrics_proxy.js
@@ -196,37 +196,6 @@ }; }); -// This is done outside |cr.define| because the closure compiler wants a fully -// qualified name for |nux.ModuleMetricsProxyImpl|. -nux.EmailMetricsProxyImpl = class extends nux.ModuleMetricsProxyImpl { - constructor() { - /** - * NuxEmailProvidersInteractions enum. - * These values are persisted to logs and should not be renumbered or - * re-used. - * See tools/metrics/histograms/enums.xml. - * @enum {number} - */ - const NuxEmailProvidersInteractions = { - PageShown: 0, - DidNothingAndNavigatedAway: 1, - DidNothingAndChoseSkip: 2, - ChoseAnOptionAndNavigatedAway: 3, - ChoseAnOptionAndChoseSkip: 4, - ChoseAnOptionAndChoseNext: 5, - ClickedDisabledNextButtonAndNavigatedAway: 6, - ClickedDisabledNextButtonAndChoseSkip: 7, - ClickedDisabledNextButtonAndChoseNext: 8, - DidNothingAndChoseNext: 9, - NavigatedAwayThroughBrowserHistory: 10, - }; - - super( - 'FirstRun.NewUserExperience.EmailProvidersInteraction', - NuxEmailProvidersInteractions); - } -}; - nux.GoogleAppsMetricsProxyImpl = class extends nux.ModuleMetricsProxyImpl { constructor() { /** @@ -290,6 +259,5 @@ } }; -cr.addSingletonGetter(nux.EmailMetricsProxyImpl); cr.addSingletonGetter(nux.GoogleAppsMetricsProxyImpl); cr.addSingletonGetter(nux.NtpBackgroundMetricsProxyImpl);
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/signin_view.html b/chrome/browser/resources/welcome/onboarding_welcome/signin_view.html index 101786f..42e8387 100644 --- a/chrome/browser/resources/welcome/onboarding_welcome/signin_view.html +++ b/chrome/browser/resources/welcome/onboarding_welcome/signin_view.html
@@ -3,9 +3,9 @@ <link rel="import" href="chrome://resources/cr_elements/paper_button_style_css.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html"> -<link rel="import" href="email/email_app_proxy.html"> <link rel="import" href="navigation_behavior.html"> <link rel="import" href="shared/action_link_style_css.html"> +<link rel="import" href="shared/animations_css.html"> <link rel="import" href="shared/i18n_setup.html"> <link rel="import" href="shared/onboarding_background.html"> <link rel="import" href="shared/splash_pages_shared_css.html"> @@ -15,13 +15,18 @@ <dom-module id="signin-view"> <template> <style - include="paper-button-style action-link-style splash-pages-shared-css"> + include="animations paper-button-style action-link-style + splash-pages-shared-css"> + onboarding-background { + --animation-delay: 150ms; + } + h1 { outline: none; } </style> <div id="container"> - <onboarding-background></onboarding-background> + <onboarding-background class="fade-in"></onboarding-background> <h2>$i18n{signInSubHeader}</h2> <h1 tabindex="-1">$i18n{signInHeader}</h1> <paper-button class="action-button" on-click="onSignInClick_">
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/welcome_app.html b/chrome/browser/resources/welcome/onboarding_welcome/welcome_app.html index 93a454f..cda34d4 100644 --- a/chrome/browser/resources/welcome/onboarding_welcome/welcome_app.html +++ b/chrome/browser/resources/welcome/onboarding_welcome/welcome_app.html
@@ -5,7 +5,6 @@ <link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html"> <link rel="import" href="chrome://resources/html/promise_resolver.html"> <link rel="import" href="google_apps/nux_google_apps.html"> -<link rel="import" href="email/nux_email.html"> <link rel="import" href="landing_view.html"> <link rel="import" href="navigation_behavior.html"> <link rel="import" href="ntp_background/nux_ntp_background.html"> @@ -25,8 +24,8 @@ min-height: 100vh; } - #viewManager :-webkit-any(nux-email, - nux-google-apps, nux-ntp-background, nux-set-as-default) { + #viewManager :-webkit-any(nux-google-apps, nux-ntp-background, + nux-set-as-default) { /* Override cr-view-manager's default styling for view. */ bottom: initial; left: initial;
diff --git a/chrome/browser/resources/welcome/onboarding_welcome/welcome_app.js b/chrome/browser/resources/welcome/onboarding_welcome/welcome_app.js index 0303723..dc1a8e9 100644 --- a/chrome/browser/resources/welcome/onboarding_welcome/welcome_app.js +++ b/chrome/browser/resources/welcome/onboarding_welcome/welcome_app.js
@@ -17,8 +17,7 @@ * @const {!Set<string>} */ const MODULES_WHITELIST = new Set([ - 'nux-email', 'nux-google-apps', 'nux-ntp-background', 'nux-set-as-default', - 'signin-view' + 'nux-google-apps', 'nux-ntp-background', 'nux-set-as-default', 'signin-view' ]); /** @@ -26,9 +25,8 @@ * added. * @const {!Set<string>} */ -const MODULES_NEEDING_INDICATOR = new Set([ - 'nux-email', 'nux-google-apps', 'nux-ntp-background', 'nux-set-as-default' -]); +const MODULES_NEEDING_INDICATOR = + new Set(['nux-google-apps', 'nux-ntp-background', 'nux-set-as-default']); Polymer({ is: 'welcome-app', @@ -134,10 +132,10 @@ return canSetDefault; } - if (module == 'nux-email') { - // Show email module in en-US only until email recommendations - // for other locales is figured out. - return navigator.language == 'en-US'; + if (!MODULES_WHITELIST.has(module)) { + // Makes sure the module specified by the feature configuration is + // whitelisted. + return false; } return true; @@ -149,10 +147,6 @@ let indicatorActiveCount = 0; modules.forEach((elementTagName, index) => { - // Makes sure the module specified by the feature configuration is - // whitelisted. - assert(MODULES_WHITELIST.has(elementTagName)); - const element = document.createElement(elementTagName); element.id = 'step-' + (index + 1); element.setAttribute('slot', 'view');
diff --git a/chrome/browser/search/ntp_features.cc b/chrome/browser/search/ntp_features.cc index d70cdc3..de86b97 100644 --- a/chrome/browser/search/ntp_features.cc +++ b/chrome/browser/search/ntp_features.cc
@@ -9,6 +9,10 @@ namespace features { +// If enabled, the user will see the second version of the customization picker. +const base::Feature kNtpCustomizationMenuV2{"NtpCustomizationMenuV2", + base::FEATURE_DISABLED_BY_DEFAULT}; + // If enabled, the user will see Doodles on the New Tab Page. const base::Feature kDoodlesOnLocalNtp{"DoodlesOnLocalNtp", base::FEATURE_ENABLED_BY_DEFAULT};
diff --git a/chrome/browser/search/ntp_features.h b/chrome/browser/search/ntp_features.h index 61aa533..6e84003 100644 --- a/chrome/browser/search/ntp_features.h +++ b/chrome/browser/search/ntp_features.h
@@ -12,6 +12,7 @@ // The features should be documented alongside the definition of their values in // the .cc file. +extern const base::Feature kNtpCustomizationMenuV2; extern const base::Feature kDoodlesOnLocalNtp; extern const base::Feature kPromosOnLocalNtp; extern const base::Feature kRemoveNtpFakebox;
diff --git a/chrome/browser/send_tab_to_self/receiving_ui_handler_registry.cc b/chrome/browser/send_tab_to_self/receiving_ui_handler_registry.cc index 1ad569aa..77ea4b2 100644 --- a/chrome/browser/send_tab_to_self/receiving_ui_handler_registry.cc +++ b/chrome/browser/send_tab_to_self/receiving_ui_handler_registry.cc
@@ -11,7 +11,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/send_tab_to_self/receiving_ui_handler.h" -#if defined(OS_LINUX) || defined(OS_MACOSX) +#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_WIN) #include "chrome/browser/send_tab_to_self/desktop_notification_handler.h" #endif @@ -32,7 +32,7 @@ // Instantiates all the handlers relevant to this platform. void ReceivingUiHandlerRegistry::InstantiatePlatformSpecificHandlers( Profile* profile) { -#if defined(OS_LINUX) || defined(OS_MACOSX) +#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_WIN) applicable_handlers_.push_back( std::make_unique<send_tab_to_self::DesktopNotificationHandler>(profile)); #elif defined(OS_ANDROID)
diff --git a/chrome/browser/sync/test/integration/printers_helper.cc b/chrome/browser/sync/test/integration/printers_helper.cc index 1a7c58e..3d09f898 100644 --- a/chrome/browser/sync/test/integration/printers_helper.cc +++ b/chrome/browser/sync/test/integration/printers_helper.cc
@@ -74,18 +74,18 @@ void AddPrinter(chromeos::SyncedPrintersManager* manager, const chromeos::Printer& printer) { - manager->UpdateConfiguredPrinter(printer); + manager->UpdateSavedPrinter(printer); } void RemovePrinter(chromeos::SyncedPrintersManager* manager, int index) { chromeos::Printer testPrinter(CreateTestPrinter(index)); - manager->RemoveConfiguredPrinter(testPrinter.id()); + manager->RemoveSavedPrinter(testPrinter.id()); } bool EditPrinterDescription(chromeos::SyncedPrintersManager* manager, int index, const std::string& description) { - PrinterList printers = manager->GetConfiguredPrinters(); + PrinterList printers = manager->GetSavedPrinters(); std::string printer_id = PrinterId(index); auto found = std::find_if(printers.begin(), printers.end(), @@ -97,7 +97,7 @@ return false; found->set_description(description); - manager->UpdateConfiguredPrinter(*found); + manager->UpdateSavedPrinter(*found); return true; } @@ -136,17 +136,17 @@ } int GetVerifierPrinterCount() { - return GetVerifierPrinterStore()->GetConfiguredPrinters().size(); + return GetVerifierPrinterStore()->GetSavedPrinters().size(); } int GetPrinterCount(int index) { - return GetPrinterStore(index)->GetConfiguredPrinters().size(); + return GetPrinterStore(index)->GetSavedPrinters().size(); } bool AllProfilesContainSamePrinters() { - auto reference_printers = GetPrinterStore(0)->GetConfiguredPrinters(); + auto reference_printers = GetPrinterStore(0)->GetSavedPrinters(); for (int i = 1; i < test()->num_clients(); ++i) { - auto printers = GetPrinterStore(i)->GetConfiguredPrinters(); + auto printers = GetPrinterStore(i)->GetSavedPrinters(); if (!ListsContainTheSamePrinters(reference_printers, printers)) { VLOG(1) << "Printers in client [" << i << "] don't match client 0"; return false; @@ -158,8 +158,8 @@ bool ProfileContainsSamePrintersAsVerifier(int index) { return ListsContainTheSamePrinters( - GetVerifierPrinterStore()->GetConfiguredPrinters(), - GetPrinterStore(index)->GetConfiguredPrinters()); + GetVerifierPrinterStore()->GetSavedPrinters(), + GetPrinterStore(index)->GetSavedPrinters()); } PrintersMatchChecker::PrintersMatchChecker()
diff --git a/chrome/browser/sync/test/integration/two_client_printers_sync_test.cc b/chrome/browser/sync/test/integration/two_client_printers_sync_test.cc index 2b68a49..2ab8b2cc 100644 --- a/chrome/browser/sync/test/integration/two_client_printers_sync_test.cc +++ b/chrome/browser/sync/test/integration/two_client_printers_sync_test.cc
@@ -107,7 +107,7 @@ ASSERT_TRUE(PrintersMatchChecker().Wait()); EXPECT_EQ(2, GetPrinterCount(0)); EXPECT_EQ(updated_description, - GetPrinterStore(1)->GetConfiguredPrinters()[0].description()); + GetPrinterStore(1)->GetSavedPrinters()[0].description()); } IN_PROC_BROWSER_TEST_F(TwoClientPrintersSyncTest, ConflictResolution) { @@ -140,9 +140,9 @@ // due to lack of a strong consistency model on the server). ProfileSyncServiceHarness::AwaitQuiescence({GetClient(1)}); - ASSERT_EQ(GetPrinterStore(0)->GetConfiguredPrinters()[0].description(), + ASSERT_EQ(GetPrinterStore(0)->GetSavedPrinters()[0].description(), kLatestDescription); - ASSERT_EQ(GetPrinterStore(1)->GetConfiguredPrinters()[0].description(), + ASSERT_EQ(GetPrinterStore(1)->GetSavedPrinters()[0].description(), kOverwrittenDescription); // Client 0 goes online, which results in a conflict (local wins). @@ -151,9 +151,9 @@ // Run tasks until the most recent update has been applied to all stores. ASSERT_TRUE(PrintersMatchChecker().Wait()); - EXPECT_EQ(GetPrinterStore(0)->GetConfiguredPrinters()[0].description(), + EXPECT_EQ(GetPrinterStore(0)->GetSavedPrinters()[0].description(), kLatestDescription); - EXPECT_EQ(GetPrinterStore(1)->GetConfiguredPrinters()[0].description(), + EXPECT_EQ(GetPrinterStore(1)->GetSavedPrinters()[0].description(), kLatestDescription); } @@ -189,9 +189,9 @@ // involved. ASSERT_TRUE(PrintersMatchChecker().Wait()); - EXPECT_EQ(GetPrinterStore(0)->GetConfiguredPrinters()[0].description(), + EXPECT_EQ(GetPrinterStore(0)->GetSavedPrinters()[0].description(), kLatestDescription); - EXPECT_EQ(GetPrinterStore(1)->GetConfiguredPrinters()[0].description(), + EXPECT_EQ(GetPrinterStore(1)->GetSavedPrinters()[0].description(), kLatestDescription); }
diff --git a/chrome/browser/transition_manager/full_browser_transition_manager.cc b/chrome/browser/transition_manager/full_browser_transition_manager.cc index 39f5e8b..4eb4f04 100644 --- a/chrome/browser/transition_manager/full_browser_transition_manager.cc +++ b/chrome/browser/transition_manager/full_browser_transition_manager.cc
@@ -34,7 +34,7 @@ void FullBrowserTransitionManager::OnProfileCreated(Profile* profile) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - SimpleFactoryKey* key = profile->GetSimpleFactoryKey(); + SimpleFactoryKey* key = profile->GetProfileKey(); DCHECK(!base::ContainsKey(simple_key_to_profile_, key)); // Register the mapping so that it can be used if deferred callbacks are added @@ -52,7 +52,7 @@ void FullBrowserTransitionManager::OnProfileDestroyed(Profile* profile) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - SimpleFactoryKey* key = profile->GetSimpleFactoryKey(); + SimpleFactoryKey* key = profile->GetProfileKey(); simple_key_to_profile_.erase(key); on_profile_creation_callbacks_.erase(key); }
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index e69ebb0..5e9f59e 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn
@@ -1931,8 +1931,6 @@ "webui/settings/system_handler.h", "webui/signin/inline_login_handler_impl.cc", "webui/signin/inline_login_handler_impl.h", - "webui/signin/md_user_manager_ui.cc", - "webui/signin/md_user_manager_ui.h", "webui/signin/signin_create_profile_handler.cc", "webui/signin/signin_create_profile_handler.h", "webui/signin/signin_email_confirmation_dialog.cc", @@ -1953,16 +1951,14 @@ "webui/signin/sync_confirmation_ui.h", "webui/signin/user_manager_screen_handler.cc", "webui/signin/user_manager_screen_handler.h", + "webui/signin/user_manager_ui.cc", + "webui/signin/user_manager_ui.h", "webui/welcome/nux/bookmark_handler.cc", "webui/welcome/nux/bookmark_handler.h", "webui/welcome/nux/bookmark_item.cc", "webui/welcome/nux/bookmark_item.h", "webui/welcome/nux/constants.cc", "webui/welcome/nux/constants.h", - "webui/welcome/nux/email_handler.cc", - "webui/welcome/nux/email_handler.h", - "webui/welcome/nux/email_providers_list.cc", - "webui/welcome/nux/email_providers_list.h", "webui/welcome/nux/google_apps_handler.cc", "webui/welcome/nux/google_apps_handler.h", "webui/welcome/nux/ntp_background_fetcher.cc",
diff --git a/chrome/browser/ui/app_list/app_context_menu_unittest.cc b/chrome/browser/ui/app_list/app_context_menu_unittest.cc index bf14261..f6ea1fe 100644 --- a/chrome/browser/ui/app_list/app_context_menu_unittest.cc +++ b/chrome/browser/ui/app_list/app_context_menu_unittest.cc
@@ -320,7 +320,6 @@ const std::string app_id = ArcAppTest::GetAppId(app_info); controller()->SetAppPinnable(app_id, AppListControllerDelegate::PIN_EDITABLE); - arc_test.app_instance()->RefreshAppList(); arc_test.app_instance()->SendRefreshAppList(arc_test.fake_apps()); ArcAppItem item(profile(), nullptr, nullptr, app_id, std::string()); @@ -409,7 +408,6 @@ } // Uninstall all apps. - arc_test.app_instance()->RefreshAppList(); arc_test.app_instance()->SendRefreshAppList( std::vector<arc::mojom::AppInfo>()); controller()->SetAppOpen(app_id, false); @@ -485,7 +483,6 @@ ArcAppTest arc_test; arc_test.SetUp(profile()); - arc_test.app_instance()->RefreshAppList(); arc_test.app_instance()->SendRefreshAppList(arc_test.fake_apps()); { @@ -528,7 +525,6 @@ arc::mojom::AppInfo app = arc_test.fake_apps()[0]; app.suspended = true; - arc_test.app_instance()->RefreshAppList(); arc_test.app_instance()->SendRefreshAppList({app}); const std::string app_id = ArcAppTest::GetAppId(app);
diff --git a/chrome/browser/ui/app_list/arc/arc_app_unittest.cc b/chrome/browser/ui/app_list/arc/arc_app_unittest.cc index a8a34e5..40ccc87 100644 --- a/chrome/browser/ui/app_list/arc/arc_app_unittest.cc +++ b/chrome/browser/ui/app_list/arc/arc_app_unittest.cc
@@ -406,7 +406,6 @@ bool ready) { ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); ASSERT_NE(nullptr, prefs); - std::vector<std::string> ids = prefs->GetAppIds(); EXPECT_EQ(ids.size(), GetArcItemCount()); @@ -572,7 +571,6 @@ ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); DCHECK(prefs); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList({app}); auto package = CreatePackage(app.package_name); package->package_version = package_version; @@ -684,7 +682,6 @@ app.activity = arc::kPlayStoreActivity; app.sticky = GetParam() != ArcState::ARC_WITHOUT_PLAY_STORE; - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList({app}); } @@ -745,17 +742,8 @@ ValidateHavePackages(fake_packages()); } -TEST_P(ArcAppModelBuilderTest, RefreshAllOnReady) { - // There should already have been one call, when the interface was - // registered. - EXPECT_EQ(1, app_instance()->refresh_app_list_count()); - app_instance()->RefreshAppList(); - EXPECT_EQ(2, app_instance()->refresh_app_list_count()); -} - TEST_P(ArcAppModelBuilderTest, RefreshAllFillsContent) { ValidateHaveApps({}); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(fake_apps()); ValidateHaveApps(fake_apps()); } @@ -794,21 +782,18 @@ TEST_P(ArcAppModelBuilderTest, RefreshAllPreservesShortcut) { ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(fake_apps()); ValidateHaveApps(fake_apps()); app_instance()->SendInstallShortcuts(fake_shortcuts()); ValidateHaveAppsAndShortcuts(fake_apps(), fake_shortcuts()); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(fake_apps()); ValidateHaveAppsAndShortcuts(fake_apps(), fake_shortcuts()); } TEST_P(ArcAppModelBuilderTest, MultipleRefreshAll) { ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); - app_instance()->RefreshAppList(); // Send info about all fake apps except last. std::vector<arc::mojom::AppInfo> apps1(fake_apps().begin(), fake_apps().end() - 1); @@ -842,7 +827,6 @@ ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); ASSERT_NE(nullptr, prefs); - app_instance()->RefreshAppList(); EXPECT_EQ(0u, GetArcItemCount()); EXPECT_EQ(0u, prefs->GetAppIds().size()); @@ -872,7 +856,6 @@ ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); ASSERT_NE(nullptr, prefs); - app_instance()->RefreshAppList(); EXPECT_EQ(0u, GetArcItemCount()); EXPECT_EQ(0u, prefs->GetAppIds().size()); @@ -893,7 +876,6 @@ // Refreshing app list makes apps available. arc_test()->RestartArcInstance(); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>()); EXPECT_EQ(ids, prefs->GetAppIds()); ValidateShortcutReadyState(fake_shortcuts(), true); @@ -1002,7 +984,6 @@ apps[2].suspended = true; - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(apps); // Simulate item activate. @@ -1040,7 +1021,6 @@ // Disable attempts to dismiss app launcher view. ChromeAppListItem::OverrideAppListControllerDelegateForTesting(controller()); - app_instance()->RefreshAppList(); app_instance()->SendInstallShortcuts(fake_shortcuts()); // Simulate item activate. @@ -1077,7 +1057,6 @@ // Make sure we are on UI thread. ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(fake_apps()); // Validate that no icon exists at the beginning and request icon for @@ -1193,7 +1172,6 @@ const std::string app_id = ArcAppTest::GetAppId(fake_apps()[0]); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList({fake_apps()[0]}); // Number of requests per size in pixels. @@ -1227,7 +1205,6 @@ // Make sure we are on UI thread. ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( fake_apps().begin(), fake_apps().begin() + 1)); const arc::mojom::AppInfo& app = fake_apps()[0]; @@ -1278,7 +1255,6 @@ base::RunLoop().RunUntilIdle(); EXPECT_FALSE(IsIconCreated(prefs, app_id, scale_factor)); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( fake_apps().begin(), fake_apps().begin() + 1)); const base::FilePath app_path = prefs->GetAppPath(app_id); @@ -1300,7 +1276,6 @@ // Make sure we are on UI thread. ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); ASSERT_GE(fake_apps().size(), 3U); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( fake_apps().begin(), fake_apps().begin() + 3)); const arc::mojom::AppInfo& app1 = fake_apps()[0]; @@ -1363,7 +1338,6 @@ const std::string app_id = ArcAppTest::GetAppId(fake_apps()[0]); EXPECT_FALSE(prefs->GetApp(app_id)); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(fake_apps()); std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); @@ -1404,7 +1378,6 @@ EXPECT_CALL(observer, OnAppNameUpdated(testing::_, testing::_)).Times(0); EXPECT_CALL(observer, OnAppLastLaunchTimeUpdated(testing::_)).Times(0); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList({app}); // On Opt-out ARC app instance is disconnected first and only then @@ -1465,7 +1438,6 @@ // Send info about all fake apps except last. std::vector<arc::mojom::AppInfo> apps1(fake_apps().begin(), fake_apps().end() - 1); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(apps1); // Model has refreshed apps. ValidateHaveApps(apps1); @@ -1479,7 +1451,6 @@ EXPECT_EQ(apps1.size(), GetArcItemCount()); // Now refresh old apps with new one. - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(fake_apps()); ValidateHaveApps(fake_apps()); EXPECT_EQ(fake_apps().size(), GetArcItemCount()); @@ -1494,7 +1465,6 @@ // Register one app first. const arc::mojom::AppInfo& app = fake_apps()[0]; const std::string app_id = ArcAppTest::GetAppId(app); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList({app}); // We will wait for default apps manually once observer is set. @@ -1814,7 +1784,6 @@ ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); ASSERT_NE(nullptr, prefs); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( fake_apps().begin(), fake_apps().begin() + 1)); content::RunAllTasksUntilIdle(); @@ -1904,7 +1873,6 @@ profile(), app_list::AppListConfig::instance().grid_icon_dimension(), &delegate); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList({app}); content::RunAllTasksUntilIdle(); @@ -1953,7 +1921,6 @@ app_instance()->set_icon_response_type( arc::FakeAppInstance::IconResponseType::ICON_RESPONSE_SEND_BAD); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( fake_apps().begin(), fake_apps().begin() + 1)); content::RunAllTasksUntilIdle(); @@ -2013,7 +1980,6 @@ ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); ASSERT_NE(nullptr, prefs); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( fake_apps().begin(), fake_apps().begin() + 1)); @@ -2234,7 +2200,6 @@ EXPECT_FALSE(launcher.app_launched()); // Register app, however it is suspended. - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList({app}); EXPECT_FALSE(launcher.app_launched()); EXPECT_TRUE(app_instance()->launch_requests().empty()); @@ -2254,7 +2219,6 @@ ASSERT_NE(nullptr, prefs); ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); - app_instance()->RefreshAppList(); // Send all except first. std::vector<arc::mojom::AppInfo> apps(fake_apps().begin() + 1, fake_apps().end()); @@ -2292,7 +2256,6 @@ // Adding package is required to safely call SendPackageUninstalled. AddPackage(CreatePackage(test_package_name)); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(apps1); app_instance()->SendInstallShortcuts(shortcuts); @@ -2355,7 +2318,6 @@ AddPackage(package); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(apps); // Send a task for non-existing lauchable app. That would register new runtime @@ -2412,7 +2374,6 @@ ValidateHaveApps(fake_default_apps()); // Start normal apps. We should have apps from 2 subsets. - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(fake_apps()); std::vector<arc::mojom::AppInfo> all_apps = fake_default_apps(); @@ -2625,7 +2586,6 @@ EXPECT_FALSE(launcher1.app_launched()); EXPECT_TRUE(launcher2.app_launched()); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(fake_default_apps()); // Default apps are ready now and it is expected that first app was launched // now. @@ -2640,7 +2600,6 @@ const std::vector<arc::mojom::AppInfo> empty_app_list; - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(empty_app_list); std::vector<arc::mojom::AppInfo> expected_apps(fake_default_apps()); @@ -2670,7 +2629,6 @@ app.name = "Play Store"; app.package_name = arc::kPlayStorePackage; app.activity = arc::kPlayStoreActivity; - app_instance()->RefreshAppList(); std::vector<arc::mojom::AppInfo> only_play_store({app}); app_instance()->SendRefreshAppList(only_play_store); @@ -2693,7 +2651,6 @@ ValidateHaveApps(fake_default_apps()); - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList(empty_app_list); ValidateHaveApps(fake_default_apps());
diff --git a/chrome/browser/ui/app_list/search/arc/arc_app_reinstall_search_provider_unittest.cc b/chrome/browser/ui/app_list/search/arc/arc_app_reinstall_search_provider_unittest.cc index d9d1211c..7c59112 100644 --- a/chrome/browser/ui/app_list/search/arc/arc_app_reinstall_search_provider_unittest.cc +++ b/chrome/browser/ui/app_list/search/arc/arc_app_reinstall_search_provider_unittest.cc
@@ -62,7 +62,6 @@ app.package_name = arc::kPlayStorePackage; app.activity = arc::kPlayStoreActivity; - app_instance()->RefreshAppList(); app_instance()->SendRefreshAppList({app}); }
diff --git a/chrome/browser/ui/app_list/search/tests/app_search_provider_unittest.cc b/chrome/browser/ui/app_list/search/tests/app_search_provider_unittest.cc index 7b8a5ee..6cc5c94 100644 --- a/chrome/browser/ui/app_list/search/tests/app_search_provider_unittest.cc +++ b/chrome/browser/ui/app_list/search/tests/app_search_provider_unittest.cc
@@ -249,7 +249,6 @@ TEST_F(AppSearchProviderTest, Basic) { arc_test().SetUp(profile()); - arc_test().app_instance()->RefreshAppList(); std::vector<arc::mojom::AppInfo> arc_apps(arc_test().fake_apps().begin(), arc_test().fake_apps().begin() + 2); arc_test().app_instance()->SendRefreshAppList(arc_apps); @@ -335,7 +334,6 @@ TEST_F(AppSearchProviderTest, InstallUninstallArc) { arc_test().SetUp(profile()); std::vector<arc::mojom::AppInfo> arc_apps; - arc_test().app_instance()->RefreshAppList(); arc_test().app_instance()->SendRefreshAppList(arc_apps); // Allow async callbacks to run. @@ -347,7 +345,6 @@ EXPECT_EQ("", RunQuery("fapp0")); arc_apps.push_back(arc_test().fake_apps()[0]); - arc_test().app_instance()->RefreshAppList(); arc_test().app_instance()->SendRefreshAppList(arc_apps); // Allow async callbacks to run. @@ -357,7 +354,6 @@ EXPECT_FALSE(results().empty()); arc_apps.clear(); - arc_test().app_instance()->RefreshAppList(); arc_test().app_instance()->SendRefreshAppList(arc_apps); // Allow async callbacks to run.
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc index f66e8dd..1be1b7d8 100644 --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc
@@ -979,7 +979,6 @@ } void SendListOfArcApps() { - arc_test_.app_instance()->RefreshAppList(); arc_test_.app_instance()->SendRefreshAppList(arc_test_.fake_apps()); } @@ -988,7 +987,6 @@ } void UninstallArcApps() { - arc_test_.app_instance()->RefreshAppList(); arc_test_.app_instance()->SendRefreshAppList( std::vector<arc::mojom::AppInfo>()); } @@ -2049,7 +2047,6 @@ const std::string app_id = ArcAppTest::GetAppId(app); // Register app first. - arc_test_.app_instance()->RefreshAppList(); arc_test_.app_instance()->SendRefreshAppList({app}); arc_test_.StopArcInstance(); @@ -2064,7 +2061,6 @@ // Send app with suspended state. app.suspended = true; - arc_test_.app_instance()->RefreshAppList(); arc_test_.app_instance()->SendRefreshAppList({app}); // Controler automatically closed.
diff --git a/chrome/browser/ui/ash/launcher/launcher_context_menu_unittest.cc b/chrome/browser/ui/ash/launcher/launcher_context_menu_unittest.cc index 8e0f362..8fc5ad0c 100644 --- a/chrome/browser/ui/ash/launcher/launcher_context_menu_unittest.cc +++ b/chrome/browser/ui/ash/launcher/launcher_context_menu_unittest.cc
@@ -227,7 +227,6 @@ // Verifies context menu and app menu items for ARC app. TEST_F(LauncherContextMenuTest, ArcLauncherMenusCheck) { - arc_test().app_instance()->RefreshAppList(); arc_test().app_instance()->SendRefreshAppList( std::vector<arc::mojom::AppInfo>(arc_test().fake_apps().begin(), arc_test().fake_apps().begin() + 1)); @@ -357,7 +356,6 @@ TEST_F(LauncherContextMenuTest, ArcLauncherSuspendAppMenu) { arc::mojom::AppInfo app = arc_test().fake_apps()[0]; app.suspended = true; - arc_test().app_instance()->RefreshAppList(); arc_test().app_instance()->SendRefreshAppList({app}); const std::string app_id = ArcAppTest::GetAppId(app); @@ -382,7 +380,6 @@ } TEST_F(LauncherContextMenuTest, ArcDeferredLauncherContextMenuItemCheck) { - arc_test().app_instance()->RefreshAppList(); arc_test().app_instance()->SendRefreshAppList( std::vector<arc::mojom::AppInfo>(arc_test().fake_apps().begin(), arc_test().fake_apps().begin() + 2)); @@ -448,7 +445,6 @@ // adding a context menu option ensure that you have added the enum to // tools/metrics/enums.xml and that you haven't modified the order of the // existing enums. - arc_test().app_instance()->RefreshAppList(); arc_test().app_instance()->SendRefreshAppList( std::vector<arc::mojom::AppInfo>(arc_test().fake_apps().begin(), arc_test().fake_apps().begin() + 1));
diff --git a/chrome/browser/ui/ash/launcher_animations_interactive_uitest.cc b/chrome/browser/ui/ash/launcher_animations_interactive_uitest.cc index 632e8373..8b351ad 100644 --- a/chrome/browser/ui/ash/launcher_animations_interactive_uitest.cc +++ b/chrome/browser/ui/ash/launcher_animations_interactive_uitest.cc
@@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "ash/public/interfaces/app_list_view.mojom.h" #include "base/bind.h" #include "base/macros.h" #include "base/run_loop.h" @@ -52,8 +53,7 @@ { base::RunLoop waiter; shell_test_api->WaitForLauncherAnimationState( - ash::mojom::LauncherAnimationState::kFullscreenAllApps, - waiter.QuitClosure()); + ash::mojom::AppListViewState::kFullscreenAllApps, waiter.QuitClosure()); ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH, /*control=*/false, /*shift=*/true, @@ -64,7 +64,7 @@ { base::RunLoop waiter; shell_test_api->WaitForLauncherAnimationState( - ash::mojom::LauncherAnimationState::kClosed, waiter.QuitClosure()); + ash::mojom::AppListViewState::kClosed, waiter.QuitClosure()); ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH, /*control=*/false, /*shift=*/true, @@ -84,7 +84,7 @@ { base::RunLoop waiter; shell_test_api->WaitForLauncherAnimationState( - ash::mojom::LauncherAnimationState::kPeeking, waiter.QuitClosure()); + ash::mojom::AppListViewState::kPeeking, waiter.QuitClosure()); ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH, /*control=*/false, /*shift=*/false, @@ -95,7 +95,7 @@ { base::RunLoop waiter; shell_test_api->WaitForLauncherAnimationState( - ash::mojom::LauncherAnimationState::kClosed, waiter.QuitClosure()); + ash::mojom::AppListViewState::kClosed, waiter.QuitClosure()); ui_controls::SendKeyPress(browser_window, ui::VKEY_BROWSER_SEARCH, /*control=*/false, /*shift=*/false,
diff --git a/chrome/browser/ui/autofill/payments/save_card_bubble_controller_impl.h b/chrome/browser/ui/autofill/payments/save_card_bubble_controller_impl.h index 186d4a5..126ebf9 100644 --- a/chrome/browser/ui/autofill/payments/save_card_bubble_controller_impl.h +++ b/chrome/browser/ui/autofill/payments/save_card_bubble_controller_impl.h
@@ -48,6 +48,8 @@ // bubble; otherwise, only the omnibox icon is displayed. // If |options.has_non_focusable_field| is true, the save is triggered by a // form that has non_focusable fields. + // If |options.from_dynamic_change_form| is true, the save is triggered by a + // dynamic change form. void OfferLocalSave( const CreditCard& card, AutofillClient::SaveCreditCardOptions options, @@ -65,6 +67,8 @@ // offer-to-save bubble; otherwise, only the omnibox icon is displayed. // If |options.has_non_focusable_field| is true, the save is triggered by a // form that has non-focusable fields. + // If |options.from_dynamic_change_form| is true, the save is triggered by a + // dynamic change form. void OfferUploadSave( const CreditCard& card, std::unique_ptr<base::DictionaryValue> legal_message,
diff --git a/chrome/browser/ui/autofill/payments/save_card_bubble_controller_impl_unittest.cc b/chrome/browser/ui/autofill/payments/save_card_bubble_controller_impl_unittest.cc index b531f2b5..42ada4e3 100644 --- a/chrome/browser/ui/autofill/payments/save_card_bubble_controller_impl_unittest.cc +++ b/chrome/browser/ui/autofill/payments/save_card_bubble_controller_impl_unittest.cc
@@ -234,6 +234,22 @@ } TEST_F(SaveCardBubbleControllerImplTest, + Metrics_Local_Reshows_FromDynamicChangeForm_ShowBubble) { + ShowLocalBubble(/*card=*/nullptr, AutofillClient::SaveCreditCardOptions() + .with_from_dynamic_change_form(true) + .with_show_prompt()); + + base::HistogramTester histogram_tester; + CloseAndReshowBubble(); + + EXPECT_THAT( + histogram_tester.GetAllSamples( + "Autofill.SaveCreditCardPrompt.Local.Reshows.FromDynamicChangeForm"), + ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1), + Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1))); +} + +TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_Reshows_FromNonFocusableForm_ShowBubble) { ShowLocalBubble(/*card=*/nullptr, AutofillClient::SaveCreditCardOptions() .with_has_non_focusable_field(true) @@ -261,6 +277,20 @@ } TEST_F(SaveCardBubbleControllerImplTest, + Metrics_Upload_FirstShow_DynamicChange_ShowBubble) { + base::HistogramTester histogram_tester; + ShowUploadBubble(AutofillClient::SaveCreditCardOptions() + .with_from_dynamic_change_form(true) + .with_show_prompt()); + + EXPECT_THAT( + histogram_tester.GetAllSamples("Autofill.SaveCreditCardPrompt.Upload." + "FirstShow.FromDynamicChangeForm"), + ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1), + Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1))); +} + +TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_FirstShow_FromNonFocusableForm_ShowBubble) { base::HistogramTester histogram_tester; ShowUploadBubble(AutofillClient::SaveCreditCardOptions() @@ -331,6 +361,22 @@ } TEST_F(SaveCardBubbleControllerImplTest, + Metrics_Upload_Reshows_FromDynamicChangeForm_ShowBubble) { + ShowUploadBubble(AutofillClient::SaveCreditCardOptions() + .with_from_dynamic_change_form(true) + .with_show_prompt()); + + base::HistogramTester histogram_tester; + CloseAndReshowBubble(); + + EXPECT_THAT( + histogram_tester.GetAllSamples("Autofill.SaveCreditCardPrompt.Upload." + "Reshows.FromDynamicChangeForm"), + ElementsAre(Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1), + Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOWN, 1))); +} + +TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_Reshows_RequestingCardholderName_ShowBubble) { ShowUploadBubble(AutofillClient::SaveCreditCardOptions() .with_should_request_name_from_user(true) @@ -392,6 +438,20 @@ } TEST_F(SaveCardBubbleControllerImplTest, + Metrics_Local_FirstShow_FromDynamicChangeForm_SaveButton) { + ShowLocalBubble(/*card=*/nullptr, AutofillClient::SaveCreditCardOptions() + .with_from_dynamic_change_form(true) + .with_show_prompt()); + base::HistogramTester histogram_tester; + ClickSaveButton(); + controller()->OnBubbleClosed(); + + histogram_tester.ExpectUniqueSample( + "Autofill.SaveCreditCardPrompt.Local.FirstShow.FromDynamicChangeForm", + AutofillMetrics::SAVE_CARD_PROMPT_END_ACCEPTED, 1); +} + +TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_FirstShow_FromNonFocusableForm_SaveButton) { ShowLocalBubble(/*card=*/nullptr, AutofillClient::SaveCreditCardOptions() .with_has_non_focusable_field(true) @@ -480,6 +540,37 @@ } TEST_F(SaveCardBubbleControllerImplTest, + Metrics_Local_Reshows_FromDynamicChangeForm_SaveButton) { + ShowLocalBubble(/*card=*/nullptr, AutofillClient::SaveCreditCardOptions() + .with_from_dynamic_change_form(true) + .with_show_prompt()); + CloseAndReshowBubble(); + + base::HistogramTester histogram_tester; + ClickSaveButton(); + controller()->OnBubbleClosed(); + + histogram_tester.ExpectUniqueSample( + "Autofill.SaveCreditCardPrompt.Local.Reshows.FromDynamicChangeForm", + AutofillMetrics::SAVE_CARD_PROMPT_END_ACCEPTED, 1); +} + +TEST_F(SaveCardBubbleControllerImplTest, + Metrics_Upload_FirstShow_FromDynamicChangeForm_SaveButton) { + ShowUploadBubble(AutofillClient::SaveCreditCardOptions() + .with_from_dynamic_change_form(true) + .with_show_prompt()); + + base::HistogramTester histogram_tester; + ClickSaveButton(); + controller()->OnBubbleClosed(); + + histogram_tester.ExpectUniqueSample( + "Autofill.SaveCreditCardPrompt.Upload.FirstShow.FromDynamicChangeForm", + AutofillMetrics::SAVE_CARD_PROMPT_END_ACCEPTED, 1); +} + +TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_Reshows_RequestingCardholderName_SaveButton) { ShowUploadBubble(AutofillClient::SaveCreditCardOptions() .with_should_request_name_from_user(true) @@ -512,6 +603,23 @@ } TEST_F(SaveCardBubbleControllerImplTest, + Metrics_Upload_Reshows_FromDynamicChangeForm_SaveButton) { + ShowUploadBubble(AutofillClient::SaveCreditCardOptions() + .with_from_dynamic_change_form(true) + .with_show_prompt()); + + CloseAndReshowBubble(); + + base::HistogramTester histogram_tester; + ClickSaveButton(); + controller()->OnBubbleClosed(); + + histogram_tester.ExpectUniqueSample( + "Autofill.SaveCreditCardPrompt.Upload.Reshows.FromDynamicChangeForm", + AutofillMetrics::SAVE_CARD_PROMPT_END_ACCEPTED, 1); +} + +TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_Reshows_FromNonFocusableForm_SaveButton) { ShowUploadBubble(AutofillClient::SaveCreditCardOptions() .with_has_non_focusable_field(true) @@ -721,6 +829,34 @@ } TEST_F(SaveCardBubbleControllerImplTest, + Metrics_Local_FirstShow_FromDynamicChangeForm_NavigateWhileShowing) { + ShowLocalBubble(/*card=*/nullptr, AutofillClient::SaveCreditCardOptions() + .with_from_dynamic_change_form(true) + .with_show_prompt()); + + base::HistogramTester histogram_tester; + // The bubble should still stick around for up to + // kCardBubbleSurviveNavigationTime (5 seconds) regardless of navigation. + // Start by waiting for 3 seconds, simulating navigation, and ensuring the + // bubble has not changed. + test_clock_.Advance(base::TimeDelta::FromSeconds(3)); + + controller()->SimulateNavigation(); + + histogram_tester.ExpectTotalCount( + "Autofill.SaveCreditCardPrompt.Local.FirstShow", 0); + + // Wait 3 more seconds (6 total); bubble should go away on next navigation. + test_clock_.Advance(base::TimeDelta::FromSeconds(3)); + + controller()->SimulateNavigation(); + + histogram_tester.ExpectUniqueSample( + "Autofill.SaveCreditCardPrompt.Local.FirstShow.FromDynamicChangeForm", + AutofillMetrics::SAVE_CARD_PROMPT_END_NAVIGATION_SHOWING, 1); +} + +TEST_F(SaveCardBubbleControllerImplTest, Metrics_Local_FirstShow_FromNonFocusableForm_NavigateWhileShowing) { ShowLocalBubble(/*card=*/nullptr, AutofillClient::SaveCreditCardOptions() .with_has_non_focusable_field(true) @@ -829,6 +965,34 @@ } TEST_F(SaveCardBubbleControllerImplTest, + Metrics_Upload_FirstShow_FromDynamicChangeForm_NavigateWhileShowing) { + ShowUploadBubble(AutofillClient::SaveCreditCardOptions() + .with_from_dynamic_change_form(true) + .with_show_prompt()); + base::HistogramTester histogram_tester; + // The bubble should still stick around for up to + // kCardBubbleSurviveNavigationTime (5 seconds) regardless of navigation. + // Start by waiting for 3 seconds, simulating navigation, and ensuring the + // bubble has not changed. + test_clock_.Advance(base::TimeDelta::FromSeconds(3)); + + controller()->SimulateNavigation(); + + histogram_tester.ExpectTotalCount( + "Autofill.SaveCreditCardPrompt.Upload.FirstShow.FromDynamicChangeForm", + 0); + + // Wait 3 more seconds (6 total); bubble should go away on next navigation. + test_clock_.Advance(base::TimeDelta::FromSeconds(3)); + + controller()->SimulateNavigation(); + + histogram_tester.ExpectUniqueSample( + "Autofill.SaveCreditCardPrompt.Upload.FirstShow.FromDynamicChangeForm", + AutofillMetrics::SAVE_CARD_PROMPT_END_NAVIGATION_SHOWING, 1); +} + +TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_FirstShow_RequestingCardholderName_NavigateWhileShowing) { ShowUploadBubble(AutofillClient::SaveCreditCardOptions() .with_should_request_name_from_user(true) @@ -1037,6 +1201,40 @@ } TEST_F(SaveCardBubbleControllerImplTest, + Metrics_Local_FirstShow_FromDynamicChangeForm_NavigateWhileHidden) { + ShowLocalBubble(/*card=*/nullptr, AutofillClient::SaveCreditCardOptions() + .with_from_dynamic_change_form(true) + .with_show_prompt()); + + base::HistogramTester histogram_tester; + controller()->OnBubbleClosed(); + // Fake-navigate after bubble has been visible for a long time. + test_clock_.Advance(base::TimeDelta::FromMinutes(1)); + controller()->SimulateNavigation(); + + histogram_tester.ExpectUniqueSample( + "Autofill.SaveCreditCardPrompt.Local.FirstShow.FromDynamicChangeForm", + AutofillMetrics::SAVE_CARD_PROMPT_END_NAVIGATION_HIDDEN, 1); +} + +TEST_F(SaveCardBubbleControllerImplTest, + Metrics_Upload_FirstShow_FromDynamicChangeForm_NavigateWhileHidden) { + ShowUploadBubble(AutofillClient::SaveCreditCardOptions() + .with_from_dynamic_change_form(true) + .with_show_prompt()); + + base::HistogramTester histogram_tester; + controller()->OnBubbleClosed(); + // Fake-navigate after bubble has been visible for a long time. + test_clock_.Advance(base::TimeDelta::FromMinutes(1)); + controller()->SimulateNavigation(); + + histogram_tester.ExpectUniqueSample( + "Autofill.SaveCreditCardPrompt.Upload.FirstShow.FromDynamicChangeForm", + AutofillMetrics::SAVE_CARD_PROMPT_END_NAVIGATION_HIDDEN, 1); +} + +TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_FirstShow_FromNonFocusableForm_NavigateWhileHidden) { ShowUploadBubble(AutofillClient::SaveCreditCardOptions() .with_has_non_focusable_field(true) @@ -1104,6 +1302,25 @@ } TEST_F(SaveCardBubbleControllerImplTest, + Metrics_Upload_Reshows_FromDynamicChangeForm_NavigateWhileHidden) { + ShowUploadBubble(AutofillClient::SaveCreditCardOptions() + .with_from_dynamic_change_form(true) + .with_show_prompt()); + + CloseAndReshowBubble(); + + base::HistogramTester histogram_tester; + controller()->OnBubbleClosed(); + // Fake-navigate after bubble has been visible for a long time. + test_clock_.Advance(base::TimeDelta::FromMinutes(1)); + controller()->SimulateNavigation(); + + histogram_tester.ExpectUniqueSample( + "Autofill.SaveCreditCardPrompt.Upload.Reshows.FromDynamicChangeForm", + AutofillMetrics::SAVE_CARD_PROMPT_END_NAVIGATION_HIDDEN, 1); +} + +TEST_F(SaveCardBubbleControllerImplTest, Metrics_Upload_Reshows_FromNonFocusableForm_NavigateWhileHidden) { ShowUploadBubble(AutofillClient::SaveCreditCardOptions() .with_has_non_focusable_field(true)
diff --git a/chrome/browser/ui/tab_helpers.cc b/chrome/browser/ui/tab_helpers.cc index a2c8e8f..529b0c9 100644 --- a/chrome/browser/ui/tab_helpers.cc +++ b/chrome/browser/ui/tab_helpers.cc
@@ -218,8 +218,8 @@ Profile* profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); download::DownloadNavigationObserver::CreateForWebContents( - web_contents, download::NavigationMonitorFactory::GetForKey( - profile->GetSimpleFactoryKey())); + web_contents, + download::NavigationMonitorFactory::GetForKey(profile->GetProfileKey())); history::WebContentsTopSitesObserver::CreateForWebContents( web_contents, TopSitesFactory::GetForProfile(profile).get()); HistoryTabHelper::CreateForWebContents(web_contents);
diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc index 72021cd..f2ea054 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
@@ -189,10 +189,10 @@ #include "chrome/browser/ui/sync/sync_promo_ui.h" #include "chrome/browser/ui/webui/browser_switcher/browser_switch_ui.h" #include "chrome/browser/ui/webui/signin/inline_login_ui.h" -#include "chrome/browser/ui/webui/signin/md_user_manager_ui.h" #include "chrome/browser/ui/webui/signin/signin_email_confirmation_ui.h" #include "chrome/browser/ui/webui/signin/signin_error_ui.h" #include "chrome/browser/ui/webui/signin/sync_confirmation_ui.h" +#include "chrome/browser/ui/webui/signin/user_manager_ui.h" #include "chrome/browser/ui/webui/welcome/welcome_ui.h" #endif @@ -593,7 +593,7 @@ #endif // defined(OS_ANDROID) #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) if (url.host_piece() == chrome::kChromeUIMdUserManagerHost) - return &NewWebUI<MDUserManagerUI>; + return &NewWebUI<UserManagerUI>; if (url.host_piece() == chrome::kChromeUISigninErrorHost && (!profile->IsOffTheRecord() || profile->GetOriginalProfile()->IsSystemProfile()))
diff --git a/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.cc b/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.cc index b083f92..59935e5c 100644 --- a/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.cc +++ b/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.cc
@@ -4,178 +4,238 @@ #include "chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h" -#include <memory> +#include <stddef.h> -#include "ash/public/cpp/ash_features.h" -#include "ash/public/cpp/stylus_utils.h" -#include "chrome/browser/chromeos/android_sms/android_sms_app_manager.h" -#include "chrome/browser/chromeos/android_sms/android_sms_service_factory.h" -#include "chrome/browser/chromeos/arc/arc_util.h" -#include "chrome/browser/chromeos/crostini/crostini_util.h" -#include "chrome/browser/chromeos/login/demo_mode/demo_session.h" -#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h" -#include "chrome/browser/chromeos/multidevice_setup/multidevice_setup_client_factory.h" -#include "chrome/browser/chromeos/plugin_vm/plugin_vm_util.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/webui/chromeos/smb_shares/smb_handler.h" -#include "chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h" -#include "chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h" -#include "chrome/browser/ui/webui/settings/chromeos/crostini_handler.h" -#include "chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h" -#include "chrome/browser/ui/webui/settings/chromeos/date_time_handler.h" -#include "chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h" -#include "chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.h" -#include "chrome/browser/ui/webui/settings/chromeos/device_power_handler.h" -#include "chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h" -#include "chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h" -#include "chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h" -#include "chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.h" -#include "chrome/browser/ui/webui/settings/chromeos/internet_handler.h" -#include "chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h" -#include "chrome/browser/ui/webui/settings/tts_handler.h" +#include <memory> +#include <string> +#include <utility> +#include <vector> + +#include "ash/public/cpp/resources/grit/ash_public_unscaled_resources.h" +#include "base/metrics/histogram_macros.h" +#include "build/build_config.h" +#include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" +#include "chrome/browser/ui/webui/certificates_handler.h" +#include "chrome/browser/ui/webui/dark_mode_handler.h" +#include "chrome/browser/ui/webui/managed_ui_handler.h" +#include "chrome/browser/ui/webui/metrics_handler.h" +#include "chrome/browser/ui/webui/settings/about_handler.h" +#include "chrome/browser/ui/webui/settings/accessibility_main_handler.h" +#include "chrome/browser/ui/webui/settings/appearance_handler.h" +#include "chrome/browser/ui/webui/settings/browser_lifetime_handler.h" +#include "chrome/browser/ui/webui/settings/downloads_handler.h" +#include "chrome/browser/ui/webui/settings/extension_control_handler.h" +#include "chrome/browser/ui/webui/settings/font_handler.h" +#include "chrome/browser/ui/webui/settings/languages_handler.h" +#include "chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.h" +#include "chrome/browser/ui/webui/settings/md_settings_ui.h" +#include "chrome/browser/ui/webui/settings/on_startup_handler.h" +#include "chrome/browser/ui/webui/settings/people_handler.h" +#include "chrome/browser/ui/webui/settings/profile_info_handler.h" +#include "chrome/browser/ui/webui/settings/protocol_handlers_handler.h" +#include "chrome/browser/ui/webui/settings/reset_settings_handler.h" +#include "chrome/browser/ui/webui/settings/search_engines_handler.h" +#include "chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h" +#include "chrome/browser/ui/webui/settings/settings_cookies_view_handler.h" +#include "chrome/browser/ui/webui/settings/settings_import_data_handler.h" +#include "chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.h" +#include "chrome/browser/ui/webui/settings/settings_security_key_handler.h" +#include "chrome/browser/ui/webui/settings/settings_startup_pages_handler.h" +#include "chrome/browser/ui/webui/settings/site_settings_handler.h" +#include "chrome/browser/web_applications/system_web_app_manager.h" +#include "chrome/common/pref_names.h" #include "chrome/common/webui_url_constants.h" #include "chrome/grit/browser_resources.h" #include "chrome/grit/os_settings_resources.h" #include "chrome/grit/os_settings_resources_map.h" -#include "chromeos/constants/chromeos_features.h" -#include "chromeos/constants/chromeos_switches.h" -#include "chromeos/services/multidevice_setup/public/cpp/prefs.h" -#include "components/arc/arc_util.h" -#include "content/public/browser/web_ui.h" +#include "components/password_manager/core/common/password_manager_features.h" +#include "components/pref_registry/pref_registry_syncable.h" +#include "components/unified_consent/feature.h" +#include "content/public/browser/navigation_handle.h" #include "content/public/browser/web_ui_data_source.h" -#include "ui/base/ui_base_features.h" +#include "content/public/common/content_features.h" + +#if defined(FULL_SAFE_BROWSING) +#include "chrome/browser/safe_browsing/chrome_password_protection_service.h" +#include "chrome/browser/ui/webui/settings/change_password_handler.h" +#endif namespace chromeos { namespace settings { +// static +void OSSettingsUI::RegisterProfilePrefs( + user_prefs::PrefRegistrySyncable* registry) { + registry->RegisterBooleanPref(::prefs::kImportDialogAutofillFormData, true); + registry->RegisterBooleanPref(::prefs::kImportDialogBookmarks, true); + registry->RegisterBooleanPref(::prefs::kImportDialogHistory, true); + registry->RegisterBooleanPref(::prefs::kImportDialogSavedPasswords, true); + registry->RegisterBooleanPref(::prefs::kImportDialogSearchEngine, true); +} + OSSettingsUI::OSSettingsUI(content::WebUI* web_ui) - : content::WebUIController(web_ui) { -#if !BUILDFLAG(OPTIMIZE_WEBUI) + : content::WebUIController(web_ui), + WebContentsObserver(web_ui->GetWebContents()) { Profile* profile = Profile::FromWebUI(web_ui); content::WebUIDataSource* html_source = content::WebUIDataSource::Create(chrome::kChromeUIOSSettingsHost); - InitWebUIHandlers(profile, web_ui, html_source); + ::settings::MdSettingsUI::InitOSWebUIHandlers(profile, web_ui, html_source); - html_source->SetDefaultResource(IDR_SETTINGS_OS_SETTINGS_HTML); +#if BUILDFLAG(OPTIMIZE_WEBUI) + std::vector<std::string> exclude_from_gzip; +#endif - content::WebUIDataSource::Add(profile, html_source); -#endif //! BUILDFLAG(OPTIMIZE_WEBUI) + AddSettingsPageUIHandler( + std::make_unique<::settings::AppearanceHandler>(web_ui)); - // TODO(maybelle): Add optimized build +#if defined(USE_NSS_CERTS) + AddSettingsPageUIHandler( + std::make_unique<certificate_manager::CertificatesHandler>()); +#elif defined(OS_WIN) || defined(OS_MACOSX) + AddSettingsPageUIHandler(std::make_unique<NativeCertificatesHandler>()); +#endif // defined(USE_NSS_CERTS) + + AddSettingsPageUIHandler( + std::make_unique<::settings::AccessibilityMainHandler>()); + AddSettingsPageUIHandler( + std::make_unique<::settings::BrowserLifetimeHandler>()); + AddSettingsPageUIHandler( + std::make_unique<::settings::ClearBrowsingDataHandler>(web_ui)); + AddSettingsPageUIHandler(std::make_unique<::settings::CookiesViewHandler>()); + AddSettingsPageUIHandler( + std::make_unique<::settings::DownloadsHandler>(profile)); + AddSettingsPageUIHandler( + std::make_unique<::settings::ExtensionControlHandler>()); + AddSettingsPageUIHandler(std::make_unique<::settings::FontHandler>(web_ui)); + AddSettingsPageUIHandler(std::make_unique<::settings::ImportDataHandler>()); + AddSettingsPageUIHandler( + std::make_unique<::settings::LanguagesHandler>(web_ui)); + AddSettingsPageUIHandler( + std::make_unique<::settings::MediaDevicesSelectionHandler>(profile)); + AddSettingsPageUIHandler( + std::make_unique<::settings::OnStartupHandler>(profile)); + AddSettingsPageUIHandler( + std::make_unique<::settings::PeopleHandler>(profile)); + AddSettingsPageUIHandler( + std::make_unique<::settings::ProfileInfoHandler>(profile)); + AddSettingsPageUIHandler( + std::make_unique<::settings::ProtocolHandlersHandler>()); + AddSettingsPageUIHandler( + std::make_unique<::settings::SearchEnginesHandler>(profile)); + AddSettingsPageUIHandler( + std::make_unique<::settings::SiteSettingsHandler>(profile)); + AddSettingsPageUIHandler( + std::make_unique<::settings::StartupPagesHandler>(web_ui)); + AddSettingsPageUIHandler(std::make_unique<::settings::SecurityKeysHandler>()); + + bool password_protection_available = false; +#if defined(FULL_SAFE_BROWSING) + safe_browsing::ChromePasswordProtectionService* password_protection = + safe_browsing::ChromePasswordProtectionService:: + GetPasswordProtectionService(profile); + password_protection_available = !!password_protection; + if (password_protection) { + AddSettingsPageUIHandler( + std::make_unique<::settings::ChangePasswordHandler>( + profile, password_protection)); + } +#endif + + html_source->AddBoolean("passwordProtectionAvailable", + password_protection_available); + + html_source->AddBoolean("unifiedConsentEnabled", + unified_consent::IsUnifiedConsentFeatureEnabled()); + + html_source->AddBoolean( + "navigateToGooglePasswordManager", + ShouldManagePasswordsinGooglePasswordManager(profile)); + + html_source->AddBoolean("showImportPasswords", + base::FeatureList::IsEnabled( + password_manager::features::kPasswordImport)); + + AddSettingsPageUIHandler( + base::WrapUnique(::settings::AboutHandler::Create(html_source, profile))); + AddSettingsPageUIHandler(base::WrapUnique( + ::settings::ResetSettingsHandler::Create(html_source, profile))); + + // Add the metrics handler to write uma stats. + web_ui->AddMessageHandler(std::make_unique<MetricsHandler>()); + + // Add the System Web App resources for Settings. + // TODO(jamescook|calamity): Migrate to chromeos::settings::OSSettingsUI. + if (web_app::SystemWebAppManager::IsEnabled()) { + html_source->AddResourcePath("icon-192.png", IDR_SETTINGS_LOGO_192); + html_source->AddResourcePath("pwa.html", IDR_PWA_HTML); +#if BUILDFLAG(OPTIMIZE_WEBUI) + exclude_from_gzip.push_back("icon-192.png"); + exclude_from_gzip.push_back("pwa.html"); +#endif // BUILDFLAG(OPTIMIZE_WEBUI) + } + +#if BUILDFLAG(OPTIMIZE_WEBUI) + const bool use_polymer_2 = + base::FeatureList::IsEnabled(::features::kWebUIPolymer2); + html_source->AddResourcePath("crisper.js", IDR_OS_SETTINGS_CRISPER_JS); + html_source->AddResourcePath("lazy_load.crisper.js", + IDR_OS_SETTINGS_LAZY_LOAD_CRISPER_JS); + html_source->AddResourcePath( + "lazy_load.html", use_polymer_2 + ? IDR_OS_SETTINGS_LAZY_LOAD_VULCANIZED_P2_HTML + : IDR_OS_SETTINGS_LAZY_LOAD_VULCANIZED_HTML); + html_source->SetDefaultResource(use_polymer_2 + ? IDR_OS_SETTINGS_VULCANIZED_P2_HTML + : IDR_OS_SETTINGS_VULCANIZED_HTML); + html_source->UseGzip(base::BindRepeating( + [](const std::vector<std::string>& excluded_paths, + const std::string& path) { + return !base::ContainsValue(excluded_paths, path); + }, + std::move(exclude_from_gzip))); + html_source->AddResourcePath("manifest.json", IDR_OS_SETTINGS_MANIFEST); +#else + // Add all settings resources. + for (size_t i = 0; i < kOsSettingsResourcesSize; ++i) { + html_source->AddResourcePath(kOsSettingsResources[i].name, + kOsSettingsResources[i].value); + } + html_source->SetDefaultResource(IDR_OS_SETTINGS_SETTINGS_HTML); +#endif + + ::settings::AddLocalizedStrings(html_source, profile); + + DarkModeHandler::Initialize(web_ui, html_source); + ManagedUIHandler::Initialize(web_ui, html_source); + + content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), + html_source); } -OSSettingsUI::~OSSettingsUI() = default; +OSSettingsUI::~OSSettingsUI() {} -// static -void OSSettingsUI::InitWebUIHandlers(Profile* profile, - content::WebUI* web_ui, - content::WebUIDataSource* html_source) { - web_ui->AddMessageHandler(std::make_unique<AccessibilityHandler>(web_ui)); - web_ui->AddMessageHandler(std::make_unique<AndroidAppsHandler>(profile)); - if (crostini::IsCrostiniUIAllowedForProfile(profile, - false /* check_policy */)) { - web_ui->AddMessageHandler(std::make_unique<CrostiniHandler>(profile)); - } - web_ui->AddMessageHandler(CupsPrintersHandler::Create(web_ui)); - web_ui->AddMessageHandler( - base::WrapUnique(DateTimeHandler::Create(html_source))); - web_ui->AddMessageHandler(std::make_unique<FingerprintHandler>(profile)); - if (chromeos::switches::IsAssistantEnabled()) { - web_ui->AddMessageHandler( - std::make_unique<GoogleAssistantHandler>(profile)); - } - web_ui->AddMessageHandler(std::make_unique<KeyboardHandler>()); - web_ui->AddMessageHandler(std::make_unique<PointerHandler>()); - web_ui->AddMessageHandler(std::make_unique<StorageHandler>(profile)); - web_ui->AddMessageHandler(std::make_unique<StylusHandler>()); - web_ui->AddMessageHandler(std::make_unique<InternetHandler>(profile)); - web_ui->AddMessageHandler(std::make_unique<::settings::TtsHandler>()); - web_ui->AddMessageHandler( - std::make_unique<chromeos::smb_dialog::SmbHandler>(profile)); +void OSSettingsUI::AddSettingsPageUIHandler( + std::unique_ptr<content::WebUIMessageHandler> handler) { + DCHECK(handler); + web_ui()->AddMessageHandler(std::move(handler)); +} - if (!profile->IsGuestSession()) { - chromeos::android_sms::AndroidSmsService* android_sms_service = - chromeos::android_sms::AndroidSmsServiceFactory::GetForBrowserContext( - profile); - web_ui->AddMessageHandler(std::make_unique<MultideviceHandler>( - profile->GetPrefs(), - chromeos::multidevice_setup::MultiDeviceSetupClientFactory:: - GetForProfile(profile), - android_sms_service - ? android_sms_service->android_sms_pairing_state_tracker() - : nullptr, - android_sms_service ? android_sms_service->android_sms_app_manager() - : nullptr)); - } +void OSSettingsUI::DidStartNavigation( + content::NavigationHandle* navigation_handle) { + if (navigation_handle->IsSameDocument()) + return; - html_source->AddBoolean( - "multideviceAllowedByPolicy", - chromeos::multidevice_setup::AreAnyMultiDeviceFeaturesAllowed( - profile->GetPrefs())); - html_source->AddBoolean( - "quickUnlockEnabled", - chromeos::quick_unlock::IsPinEnabled(profile->GetPrefs())); - html_source->AddBoolean( - "quickUnlockDisabledByPolicy", - chromeos::quick_unlock::IsPinDisabledByPolicy(profile->GetPrefs())); - const bool fingerprint_unlock_enabled = - chromeos::quick_unlock::IsFingerprintEnabled(profile); - html_source->AddBoolean("fingerprintUnlockEnabled", - fingerprint_unlock_enabled); - if (fingerprint_unlock_enabled) { - html_source->AddBoolean( - "isFingerprintReaderOnKeyboard", - chromeos::quick_unlock::IsFingerprintReaderOnKeyboard()); - } - html_source->AddBoolean("lockScreenNotificationsEnabled", - ash::features::IsLockScreenNotificationsEnabled()); - html_source->AddBoolean( - "lockScreenHideSensitiveNotificationsSupported", - ash::features::IsLockScreenHideSensitiveNotificationsSupported()); - html_source->AddBoolean("showTechnologyBadge", - !ash::features::IsSeparateNetworkIconsEnabled()); - html_source->AddBoolean("hasInternalStylus", - ash::stylus_utils::HasInternalStylus()); + load_start_time_ = base::Time::Now(); +} - html_source->AddBoolean( - "showKioskNextShell", - base::FeatureList::IsEnabled(ash::features::kKioskNextShell)); +void OSSettingsUI::DocumentLoadedInFrame( + content::RenderFrameHost* render_frame_host) { + // TODO(crbug/950007): Create new load histograms +} - html_source->AddBoolean("showCrostini", - crostini::IsCrostiniUIAllowedForProfile( - profile, false /* check_policy */)); - - html_source->AddBoolean("allowCrostini", - crostini::IsCrostiniUIAllowedForProfile(profile)); - - html_source->AddBoolean("showPluginVm", - plugin_vm::IsPluginVmEnabled(profile)); - - html_source->AddBoolean("isDemoSession", - chromeos::DemoSession::IsDeviceInDemoMode()); - - html_source->AddBoolean("assistantEnabled", - chromeos::switches::IsAssistantEnabled()); - - // We have 2 variants of Android apps settings. Default case, when the Play - // Store app exists we show expandable section that allows as to - // enable/disable the Play Store and link to Android settings which is - // available once settings app is registered in the system. - // For AOSP images we don't have the Play Store app. In last case we Android - // apps settings consists only from root link to Android settings and only - // visible once settings app is registered. - html_source->AddBoolean("androidAppsVisible", - arc::IsArcAllowedForProfile(profile)); - html_source->AddBoolean("havePlayStoreApp", arc::IsPlayStoreAvailable()); - - // TODO(mash): Support Chrome power settings in Mash. https://crbug.com/644348 - bool enable_power_settings = !::features::IsMultiProcessMash(); - html_source->AddBoolean("enablePowerSettings", enable_power_settings); - if (enable_power_settings) { - web_ui->AddMessageHandler( - std::make_unique<PowerHandler>(profile->GetPrefs())); - } +void OSSettingsUI::DocumentOnLoadCompletedInMainFrame() { + // TODO(crbug/950007): Create new load histograms } } // namespace settings
diff --git a/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h b/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h index 5a71248..d62bbfa 100644 --- a/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h +++ b/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h
@@ -1,4 +1,4 @@ -// Copyright 2019 The Chromium Authors. All rights reserved. +// Copyright (c) 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. @@ -6,30 +6,43 @@ #define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_OS_SETTINGS_UI_H_ #include "base/macros.h" +#include "base/time/time.h" +#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_ui_controller.h" -class Profile; - namespace content { -class WebUI; -class WebUIDataSource; -} // namespace content +class WebUIMessageHandler; +} + +namespace user_prefs { +class PrefRegistrySyncable; +} namespace chromeos { namespace settings { -// The WebUI handler for chrome://os-settings. -class OSSettingsUI : public content::WebUIController { +// The WebUI handler for chrome://settings. +class OSSettingsUI : public content::WebUIController, + public content::WebContentsObserver { public: + static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); + explicit OSSettingsUI(content::WebUI* web_ui); ~OSSettingsUI() override; - // Initializes the WebUI message handlers for OS-specific settings. - static void InitWebUIHandlers(Profile* profile, - content::WebUI* web_ui, - content::WebUIDataSource* html_source); + // content::WebContentsObserver: + void DidStartNavigation( + content::NavigationHandle* navigation_handle) override; + void DocumentLoadedInFrame( + content::RenderFrameHost* render_frame_host) override; + void DocumentOnLoadCompletedInMainFrame() override; private: + void AddSettingsPageUIHandler( + std::unique_ptr<content::WebUIMessageHandler> handler); + + base::Time load_start_time_; + DISALLOW_COPY_AND_ASSIGN(OSSettingsUI); };
diff --git a/chrome/browser/ui/webui/settings/md_settings_ui.cc b/chrome/browser/ui/webui/settings/md_settings_ui.cc index aab2166..47183b8 100644 --- a/chrome/browser/ui/webui/settings/md_settings_ui.cc +++ b/chrome/browser/ui/webui/settings/md_settings_ui.cc
@@ -73,22 +73,51 @@ #if defined(OS_WIN) || defined(OS_CHROMEOS) #include "chrome/browser/ui/webui/settings/languages_handler.h" +#include "chrome/browser/ui/webui/settings/tts_handler.h" #endif // defined(OS_WIN) || defined(OS_CHROMEOS) #if defined(OS_CHROMEOS) #include "ash/public/cpp/resources/grit/ash_public_unscaled_resources.h" +#include "ash/public/cpp/stylus_utils.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/account_manager/account_manager_util.h" +#include "chrome/browser/chromeos/android_sms/android_sms_app_manager.h" +#include "chrome/browser/chromeos/android_sms/android_sms_service_factory.h" +#include "chrome/browser/chromeos/arc/arc_util.h" +#include "chrome/browser/chromeos/crostini/crostini_util.h" +#include "chrome/browser/chromeos/login/demo_mode/demo_session.h" +#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h" +#include "chrome/browser/chromeos/multidevice_setup/multidevice_setup_client_factory.h" +#include "chrome/browser/chromeos/plugin_vm/plugin_vm_util.h" +#include "chrome/browser/ui/webui/chromeos/smb_shares/smb_handler.h" +#include "chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h" +#include "chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h" -#include "chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h" +#include "chrome/browser/ui/webui/settings/chromeos/crostini_handler.h" +#include "chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h" +#include "chrome/browser/ui/webui/settings/chromeos/date_time_handler.h" +#include "chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h" +#include "chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.h" +#include "chrome/browser/ui/webui/settings/chromeos/device_power_handler.h" +#include "chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h" +#include "chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h" +#include "chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h" +#include "chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.h" +#include "chrome/browser/ui/webui/settings/chromeos/internet_handler.h" +#include "chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h" #include "chrome/browser/web_applications/system_web_app_manager.h" #include "chrome/common/chrome_switches.h" #include "chrome/grit/browser_resources.h" #include "chromeos/components/account_manager/account_manager.h" #include "chromeos/components/account_manager/account_manager_factory.h" +#include "chromeos/constants/chromeos_features.h" #include "chromeos/constants/chromeos_pref_names.h" +#include "chromeos/constants/chromeos_switches.h" +#include "chromeos/services/multidevice_setup/public/cpp/prefs.h" +#include "components/arc/arc_util.h" #include "components/prefs/pref_service.h" +#include "ui/base/ui_base_features.h" #include "ui/chromeos/resources/grit/ui_chromeos_resources.h" #else // !defined(OS_CHROMEOS) #include "chrome/browser/signin/account_consistency_mode_manager.h" @@ -174,10 +203,9 @@ AddSettingsPageUIHandler(std::make_unique<SecurityKeysHandler>()); #if defined(OS_CHROMEOS) - // TODO: Remove this when SplitSettings is the default and there are no - // Chrome OS settings in the browser settings page. - chromeos::settings::OSSettingsUI::InitWebUIHandlers(profile, web_ui, - html_source); + // TODO(950007): Remove this when SplitSettings is the default and there are + // no Chrome OS settings in the browser settings page. + InitOSWebUIHandlers(profile, web_ui, html_source); // TODO(jamescook): Sort out how account management is split between Chrome OS // and browser settings. @@ -243,7 +271,7 @@ html_source->AddBoolean( "diceEnabled", AccountConsistencyModeManager::IsDiceEnabledForProfile(profile)); -#endif // defined(OS_CHROMEOS) +#endif // !defined(OS_CHROMEOS) html_source->AddBoolean("unifiedConsentEnabled", unified_consent::IsUnifiedConsentFeatureEnabled()); @@ -344,4 +372,129 @@ base::Time::Now() - load_start_time_); } +#if defined(OS_CHROMEOS) +// static +void MdSettingsUI::InitOSWebUIHandlers(Profile* profile, + content::WebUI* web_ui, + content::WebUIDataSource* html_source) { + web_ui->AddMessageHandler( + std::make_unique<chromeos::settings::AccessibilityHandler>(web_ui)); + web_ui->AddMessageHandler( + std::make_unique<chromeos::settings::AndroidAppsHandler>(profile)); + if (crostini::IsCrostiniUIAllowedForProfile(profile, + false /* check_policy */)) { + web_ui->AddMessageHandler( + std::make_unique<chromeos::settings::CrostiniHandler>(profile)); + } + web_ui->AddMessageHandler( + chromeos::settings::CupsPrintersHandler::Create(web_ui)); + web_ui->AddMessageHandler(base::WrapUnique( + chromeos::settings::DateTimeHandler::Create(html_source))); + web_ui->AddMessageHandler( + std::make_unique<chromeos::settings::FingerprintHandler>(profile)); + if (chromeos::switches::IsAssistantEnabled()) { + web_ui->AddMessageHandler( + std::make_unique<chromeos::settings::GoogleAssistantHandler>(profile)); + } + web_ui->AddMessageHandler( + std::make_unique<chromeos::settings::KeyboardHandler>()); + web_ui->AddMessageHandler( + std::make_unique<chromeos::settings::PointerHandler>()); + web_ui->AddMessageHandler( + std::make_unique<chromeos::settings::StorageHandler>(profile)); + web_ui->AddMessageHandler( + std::make_unique<chromeos::settings::StylusHandler>()); + web_ui->AddMessageHandler( + std::make_unique<chromeos::settings::InternetHandler>(profile)); + web_ui->AddMessageHandler(std::make_unique<TtsHandler>()); + web_ui->AddMessageHandler( + std::make_unique<chromeos::smb_dialog::SmbHandler>(profile)); + + if (!profile->IsGuestSession()) { + chromeos::android_sms::AndroidSmsService* android_sms_service = + chromeos::android_sms::AndroidSmsServiceFactory::GetForBrowserContext( + profile); + web_ui->AddMessageHandler( + std::make_unique<chromeos::settings::MultideviceHandler>( + profile->GetPrefs(), + chromeos::multidevice_setup::MultiDeviceSetupClientFactory:: + GetForProfile(profile), + android_sms_service + ? android_sms_service->android_sms_pairing_state_tracker() + : nullptr, + android_sms_service ? android_sms_service->android_sms_app_manager() + : nullptr)); + } + + html_source->AddBoolean( + "multideviceAllowedByPolicy", + chromeos::multidevice_setup::AreAnyMultiDeviceFeaturesAllowed( + profile->GetPrefs())); + html_source->AddBoolean( + "quickUnlockEnabled", + chromeos::quick_unlock::IsPinEnabled(profile->GetPrefs())); + html_source->AddBoolean( + "quickUnlockDisabledByPolicy", + chromeos::quick_unlock::IsPinDisabledByPolicy(profile->GetPrefs())); + const bool fingerprint_unlock_enabled = + chromeos::quick_unlock::IsFingerprintEnabled(profile); + html_source->AddBoolean("fingerprintUnlockEnabled", + fingerprint_unlock_enabled); + if (fingerprint_unlock_enabled) { + html_source->AddBoolean( + "isFingerprintReaderOnKeyboard", + chromeos::quick_unlock::IsFingerprintReaderOnKeyboard()); + } + html_source->AddBoolean("lockScreenNotificationsEnabled", + ash::features::IsLockScreenNotificationsEnabled()); + html_source->AddBoolean( + "lockScreenHideSensitiveNotificationsSupported", + ash::features::IsLockScreenHideSensitiveNotificationsSupported()); + html_source->AddBoolean("showTechnologyBadge", + !ash::features::IsSeparateNetworkIconsEnabled()); + html_source->AddBoolean("hasInternalStylus", + ash::stylus_utils::HasInternalStylus()); + + html_source->AddBoolean( + "showKioskNextShell", + base::FeatureList::IsEnabled(ash::features::kKioskNextShell)); + + html_source->AddBoolean("showCrostini", + crostini::IsCrostiniUIAllowedForProfile( + profile, false /* check_policy */)); + + html_source->AddBoolean("allowCrostini", + crostini::IsCrostiniUIAllowedForProfile(profile)); + + html_source->AddBoolean("showPluginVm", + plugin_vm::IsPluginVmEnabled(profile)); + + html_source->AddBoolean("isDemoSession", + chromeos::DemoSession::IsDeviceInDemoMode()); + + html_source->AddBoolean("assistantEnabled", + chromeos::switches::IsAssistantEnabled()); + + // We have 2 variants of Android apps settings. Default case, when the Play + // Store app exists we show expandable section that allows as to + // enable/disable the Play Store and link to Android settings which is + // available once settings app is registered in the system. + // For AOSP images we don't have the Play Store app. In last case we Android + // apps settings consists only from root link to Android settings and only + // visible once settings app is registered. + html_source->AddBoolean("androidAppsVisible", + arc::IsArcAllowedForProfile(profile)); + html_source->AddBoolean("havePlayStoreApp", arc::IsPlayStoreAvailable()); + + // TODO(mash): Support Chrome power settings in Mash. https://crbug.com/644348 + bool enable_power_settings = !::features::IsMultiProcessMash(); + html_source->AddBoolean("enablePowerSettings", enable_power_settings); + if (enable_power_settings) { + web_ui->AddMessageHandler( + std::make_unique<chromeos::settings::PowerHandler>( + profile->GetPrefs())); + } +} +#endif // defined(OS_CHROMEOS) + } // namespace settings
diff --git a/chrome/browser/ui/webui/settings/md_settings_ui.h b/chrome/browser/ui/webui/settings/md_settings_ui.h index 3aa5270..73df051 100644 --- a/chrome/browser/ui/webui/settings/md_settings_ui.h +++ b/chrome/browser/ui/webui/settings/md_settings_ui.h
@@ -7,10 +7,14 @@ #include "base/macros.h" #include "base/time/time.h" +#include "chrome/browser/profiles/profile.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_ui_controller.h" +class Profile; + namespace content { +class WebUIDataSource; class WebUIMessageHandler; } @@ -29,6 +33,13 @@ explicit MdSettingsUI(content::WebUI* web_ui); ~MdSettingsUI() override; +#if defined(OS_CHROMEOS) + // Initializes the WebUI message handlers for OS-specific settings. + static void InitOSWebUIHandlers(Profile* profile, + content::WebUI* web_ui, + content::WebUIDataSource* html_source); +#endif // defined(OS_CHROMEOS) + // content::WebContentsObserver: void DidStartNavigation( content::NavigationHandle* navigation_handle) override;
diff --git a/chrome/browser/ui/webui/signin/md_user_manager_ui.cc b/chrome/browser/ui/webui/signin/user_manager_ui.cc similarity index 67% rename from chrome/browser/ui/webui/signin/md_user_manager_ui.cc rename to chrome/browser/ui/webui/signin/user_manager_ui.cc index 7c65f834..5b44baee 100644 --- a/chrome/browser/ui/webui/signin/md_user_manager_ui.cc +++ b/chrome/browser/ui/webui/signin/user_manager_ui.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/signin/md_user_manager_ui.h" +#include "chrome/browser/ui/webui/signin/user_manager_ui.h" #include <memory> #include <string> @@ -27,8 +27,7 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/base/webui/web_ui_util.h" -MDUserManagerUI::MDUserManagerUI(content::WebUI* web_ui) - : WebUIController(web_ui) { +UserManagerUI::UserManagerUI(content::WebUI* web_ui) : WebUIController(web_ui) { auto signin_create_profile_handler = std::make_unique<SigninCreateProfileHandler>(); signin_create_profile_handler_ = signin_create_profile_handler.get(); @@ -44,17 +43,17 @@ Profile* profile = Profile::FromWebUI(web_ui); // Set up the chrome://md-user-manager/ source. - auto* md_user_source = CreateUIDataSource(localized_strings); - DarkModeHandler::Initialize(web_ui, md_user_source); - content::WebUIDataSource::Add(profile, md_user_source); + auto* user_source = CreateUIDataSource(localized_strings); + DarkModeHandler::Initialize(web_ui, user_source); + content::WebUIDataSource::Add(profile, user_source); // Set up the chrome://theme/ source content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile)); } -MDUserManagerUI::~MDUserManagerUI() {} +UserManagerUI::~UserManagerUI() {} -content::WebUIDataSource* MDUserManagerUI::CreateUIDataSource( +content::WebUIDataSource* UserManagerUI::CreateUIDataSource( const base::DictionaryValue& localized_strings) { content::WebUIDataSource* source = content::WebUIDataSource::Create(chrome::kChromeUIMdUserManagerHost); @@ -66,35 +65,34 @@ source->SetJsonPath("strings.js"); - source->AddResourcePath("control_bar.html", IDR_MD_CONTROL_BAR_HTML); - source->AddResourcePath("control_bar.js", IDR_MD_CONTROL_BAR_JS); - source->AddResourcePath("create_profile.html", IDR_MD_CREATE_PROFILE_HTML); - source->AddResourcePath("create_profile.js", IDR_MD_CREATE_PROFILE_JS); - source->AddResourcePath("error_dialog.html", IDR_MD_ERROR_DIALOG_HTML); - source->AddResourcePath("error_dialog.js", IDR_MD_ERROR_DIALOG_JS); + source->AddResourcePath("control_bar.html", IDR_CONTROL_BAR_HTML); + source->AddResourcePath("control_bar.js", IDR_CONTROL_BAR_JS); + source->AddResourcePath("create_profile.html", IDR_CREATE_PROFILE_HTML); + source->AddResourcePath("create_profile.js", IDR_CREATE_PROFILE_JS); + source->AddResourcePath("error_dialog.html", IDR_ERROR_DIALOG_HTML); + source->AddResourcePath("error_dialog.js", IDR_ERROR_DIALOG_JS); source->AddResourcePath("profile_browser_proxy.html", - IDR_MD_PROFILE_BROWSER_PROXY_HTML); + IDR_PROFILE_BROWSER_PROXY_HTML); source->AddResourcePath("profile_browser_proxy.js", - IDR_MD_PROFILE_BROWSER_PROXY_JS); + IDR_PROFILE_BROWSER_PROXY_JS); source->AddResourcePath("shared_styles.html", - IDR_MD_USER_MANAGER_SHARED_STYLES_HTML); - source->AddResourcePath("strings.html", IDR_MD_USER_MANAGER_STRINGS_HTML); - source->AddResourcePath("user_manager.js", IDR_MD_USER_MANAGER_JS); + IDR_USER_MANAGER_SHARED_STYLES_HTML); + source->AddResourcePath("strings.html", IDR_USER_MANAGER_STRINGS_HTML); + source->AddResourcePath("user_manager.js", IDR_USER_MANAGER_JS); source->AddResourcePath("user_manager_pages.html", - IDR_MD_USER_MANAGER_PAGES_HTML); - source->AddResourcePath("user_manager_pages.js", - IDR_MD_USER_MANAGER_PAGES_JS); + IDR_USER_MANAGER_PAGES_HTML); + source->AddResourcePath("user_manager_pages.js", IDR_USER_MANAGER_PAGES_JS); source->AddResourcePath("user_manager_tutorial.html", - IDR_MD_USER_MANAGER_TUTORIAL_HTML); + IDR_USER_MANAGER_TUTORIAL_HTML); source->AddResourcePath("user_manager_tutorial.js", - IDR_MD_USER_MANAGER_TUTORIAL_JS); + IDR_USER_MANAGER_TUTORIAL_JS); - source->SetDefaultResource(IDR_MD_USER_MANAGER_HTML); + source->SetDefaultResource(IDR_USER_MANAGER_HTML); return source; } -void MDUserManagerUI::GetLocalizedStrings( +void UserManagerUI::GetLocalizedStrings( base::DictionaryValue* localized_strings) { user_manager_screen_handler_->GetLocalizedValues(localized_strings); signin_create_profile_handler_->GetLocalizedValues(localized_strings);
diff --git a/chrome/browser/ui/webui/signin/md_user_manager_ui.h b/chrome/browser/ui/webui/signin/user_manager_ui.h similarity index 68% rename from chrome/browser/ui/webui/signin/md_user_manager_ui.h rename to chrome/browser/ui/webui/signin/user_manager_ui.h index 14c875d1..3a346cf 100644 --- a/chrome/browser/ui/webui/signin/md_user_manager_ui.h +++ b/chrome/browser/ui/webui/signin/user_manager_ui.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_MD_USER_MANAGER_UI_H_ -#define CHROME_BROWSER_UI_WEBUI_SIGNIN_MD_USER_MANAGER_UI_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_UI_H_ +#define CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_UI_H_ #include "base/macros.h" #include "content/public/browser/web_ui_controller.h" @@ -19,10 +19,10 @@ } // A WebUI dialog to display available users. -class MDUserManagerUI : public content::WebUIController { +class UserManagerUI : public content::WebUIController { public: - explicit MDUserManagerUI(content::WebUI* web_ui); - ~MDUserManagerUI() override; + explicit UserManagerUI(content::WebUI* web_ui); + ~UserManagerUI() override; private: content::WebUIDataSource* CreateUIDataSource( @@ -32,7 +32,7 @@ SigninCreateProfileHandler* signin_create_profile_handler_ = nullptr; UserManagerScreenHandler* user_manager_screen_handler_ = nullptr; - DISALLOW_COPY_AND_ASSIGN(MDUserManagerUI); + DISALLOW_COPY_AND_ASSIGN(UserManagerUI); }; -#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_MD_USER_MANAGER_UI_H_ +#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_UI_H_
diff --git a/chrome/browser/ui/webui/welcome/nux/constants.cc b/chrome/browser/ui/webui/welcome/nux/constants.cc index fec9cc9..8b488fc 100644 --- a/chrome/browser/ui/webui/welcome/nux/constants.cc +++ b/chrome/browser/ui/webui/welcome/nux/constants.cc
@@ -14,7 +14,7 @@ // nux-ntp-background should not be added here until we can guarantee that // kUseGoogleLocalNtp is enabled const char kDefaultNewUserModules[] = - "nux-google-apps,nux-email,nux-set-as-default,signin-view"; + "nux-google-apps,nux-set-as-default,signin-view"; const char kDefaultReturningUserModules[] = "nux-set-as-default"; // The value of these FeatureParam values should be a comma-delimited list
diff --git a/chrome/browser/ui/webui/welcome/nux/constants.h b/chrome/browser/ui/webui/welcome/nux/constants.h index e79cd970..b57b0dd 100644 --- a/chrome/browser/ui/webui/welcome/nux/constants.h +++ b/chrome/browser/ui/webui/welcome/nux/constants.h
@@ -21,7 +21,6 @@ extern const base::FeatureParam<std::string> kNuxOnboardingNewUserModules; extern const base::FeatureParam<std::string> kNuxOnboardingReturningUserModules; -extern const base::FeatureParam<bool> kNuxOnboardingShowEmailInterstitial; } // namespace nux
diff --git a/chrome/browser/ui/webui/welcome/nux/email_handler.cc b/chrome/browser/ui/webui/welcome/nux/email_handler.cc deleted file mode 100644 index b88bcb9..0000000 --- a/chrome/browser/ui/webui/welcome/nux/email_handler.cc +++ /dev/null
@@ -1,92 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/webui/welcome/nux/email_handler.h" - -#include "base/bind.h" -#include "base/metrics/field_trial_params.h" -#include "base/metrics/histogram_macros.h" -#include "base/stl_util.h" -#include "base/strings/utf_string_conversions.h" -#include "chrome/browser/favicon/favicon_service_factory.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/webui/welcome/nux/bookmark_item.h" -#include "chrome/browser/ui/webui/welcome/nux/email_providers_list.h" -#include "chrome/grit/generated_resources.h" -#include "chrome/grit/onboarding_welcome_resources.h" -#include "components/country_codes/country_codes.h" -#include "components/favicon/core/favicon_service.h" -#include "components/grit/components_resources.h" -#include "components/grit/components_scaled_resources.h" -#include "components/strings/grit/components_strings.h" -#include "content/public/browser/web_contents.h" -#include "content/public/browser/web_ui.h" -#include "content/public/browser/web_ui_data_source.h" -#include "ui/base/resource/resource_bundle.h" - -namespace nux { - -const char* kEmailInteractionHistogram = - "FirstRun.NewUserExperience.EmailInteraction"; - -constexpr const int kEmailIconSize = 48; // Pixels. - -EmailHandler::EmailHandler() - : email_providers_(GetCurrentCountryEmailProviders()) {} - -EmailHandler::~EmailHandler() {} - -void EmailHandler::RegisterMessages() { - web_ui()->RegisterMessageCallback( - "cacheEmailIcon", base::BindRepeating(&EmailHandler::HandleCacheEmailIcon, - base::Unretained(this))); - - web_ui()->RegisterMessageCallback( - "getEmailList", base::BindRepeating(&EmailHandler::HandleGetEmailList, - base::Unretained(this))); -} - -void EmailHandler::HandleCacheEmailIcon(const base::ListValue* args) { - int emailId; - args->GetInteger(0, &emailId); - - const BookmarkItem* selectedEmail = NULL; - for (const auto& provider : email_providers_) { - if (provider.id == emailId) { - selectedEmail = &provider; - break; - } - } - CHECK(selectedEmail); // WebUI should not be able to pass non-existent ID. - - // Preload the favicon cache with Chrome-bundled images. Otherwise, the - // pre-populated bookmarks don't have favicons and look bad. Favicons are - // updated automatically when a user visits a site. - GURL app_url = GURL(selectedEmail->url); - FaviconServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()), - ServiceAccessType::EXPLICIT_ACCESS) - ->MergeFavicon( - app_url, app_url, favicon_base::IconType::kFavicon, - ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - selectedEmail->icon), - gfx::Size(kEmailIconSize, kEmailIconSize)); -} - -void EmailHandler::HandleGetEmailList(const base::ListValue* args) { - AllowJavascript(); - CHECK_EQ(1U, args->GetSize()); - const base::Value* callback_id; - CHECK(args->Get(0, &callback_id)); - ResolveJavascriptCallback(*callback_id, - BookmarkItemsToListValue(email_providers_)); -} - -void EmailHandler::AddSources(content::WebUIDataSource* html_source) { - // Add constants to loadtime data - html_source->AddInteger("email_providers_enum_count", - GetNumberOfEmailProviders()); - html_source->SetJsonPath("strings.js"); -} - -} // namespace nux
diff --git a/chrome/browser/ui/webui/welcome/nux/email_handler.h b/chrome/browser/ui/webui/welcome/nux/email_handler.h deleted file mode 100644 index 926790d..0000000 --- a/chrome/browser/ui/webui/welcome/nux/email_handler.h +++ /dev/null
@@ -1,56 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_EMAIL_HANDLER_H_ -#define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_EMAIL_HANDLER_H_ - -#include <vector> - -#include "base/macros.h" -#include "base/values.h" -#include "content/public/browser/web_ui_message_handler.h" - -namespace content { -class WebUIDataSource; -} // namespace content - -namespace nux { - -struct BookmarkItem; - -extern const char* kEmailInteractionHistogram; - -// These values are persisted to logs. Entries should not be renumbered and -// numeric values should never be reused. -enum class EmailInteraction { - kPromptShown = 0, - kNoThanks = 1, - kGetStarted = 2, - kCount, -}; - -class EmailHandler : public content::WebUIMessageHandler { - public: - EmailHandler(); - ~EmailHandler() override; - - // WebUIMessageHandler: - void RegisterMessages() override; - - // Callbacks for JS APIs. - void HandleCacheEmailIcon(const base::ListValue* args); - void HandleGetEmailList(const base::ListValue* args); - - // Adds webui sources. - static void AddSources(content::WebUIDataSource* html_source); - - private: - const std::vector<BookmarkItem> email_providers_; - - DISALLOW_COPY_AND_ASSIGN(EmailHandler); -}; - -} // namespace nux - -#endif // CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_EMAIL_HANDLER_H_
diff --git a/chrome/browser/ui/webui/welcome/nux/email_providers_list.cc b/chrome/browser/ui/webui/welcome/nux/email_providers_list.cc deleted file mode 100644 index 62d6c1b..0000000 --- a/chrome/browser/ui/webui/welcome/nux/email_providers_list.cc +++ /dev/null
@@ -1,68 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/webui/welcome/nux/email_providers_list.h" - -#include "chrome/browser/ui/webui/welcome/nux/bookmark_item.h" -#include "chrome/grit/onboarding_welcome_resources.h" -#include "components/country_codes/country_codes.h" - -namespace nux { - -// These values are persisted to logs. Entries should not be renumbered and -// numeric values should never be reused. -enum class EmailProviders { - kGmail = 0, - kYahoo = 1, - kOutlook = 2, - kAol = 3, - kiCloud = 4, - kCount, -}; - -std::vector<BookmarkItem> GetCurrentCountryEmailProviders() { - switch (country_codes::GetCurrentCountryID()) { - case country_codes::CountryCharsToCountryID('U', 'S'): { - return { - {static_cast<int>(EmailProviders::kGmail), "Gmail", "gmail", - "https://accounts.google.com/b/0/AddMailService", - IDR_NUX_EMAIL_GMAIL_1X}, - {static_cast<int>(EmailProviders::kYahoo), "Yahoo", "yahoo", - "https://mail.yahoo.com", IDR_NUX_EMAIL_YAHOO_1X}, - {static_cast<int>(EmailProviders::kOutlook), "Outlook", "outlook", - "https://login.live.com/login.srf?", IDR_NUX_EMAIL_OUTLOOK_1X}, - {static_cast<int>(EmailProviders::kAol), "AOL", "aol", - "https://mail.aol.com", IDR_NUX_EMAIL_AOL_1X}, - {static_cast<int>(EmailProviders::kiCloud), "iCloud", "icloud", - "https://www.icloud.com/mail", IDR_NUX_EMAIL_ICLOUD_1X}, - }; - } - - // TODO(hcarmona/johntlee): define all supported countries here. - - default: { - // TODO(hcarmona/johntlee): examine if we want these US providers as - // default. - return { - {static_cast<int>(EmailProviders::kGmail), "Gmail", "gmail", - "https://accounts.google.com/b/0/AddMailService", - IDR_NUX_EMAIL_GMAIL_1X}, - {static_cast<int>(EmailProviders::kYahoo), "Yahoo", "yahoo", - "https://mail.yahoo.com", IDR_NUX_EMAIL_YAHOO_1X}, - {static_cast<int>(EmailProviders::kOutlook), "Outlook", "outlook", - "https://login.live.com/login.srf?", IDR_NUX_EMAIL_OUTLOOK_1X}, - {static_cast<int>(EmailProviders::kAol), "AOL", "aol", - "https://mail.aol.com", IDR_NUX_EMAIL_AOL_1X}, - {static_cast<int>(EmailProviders::kiCloud), "iCloud", "icloud", - "https://www.icloud.com/mail", IDR_NUX_EMAIL_ICLOUD_1X}, - }; - } - } -} - -int GetNumberOfEmailProviders() { - return static_cast<int>(EmailProviders::kCount); -} - -} // namespace nux
diff --git a/chrome/browser/ui/webui/welcome/nux/email_providers_list.h b/chrome/browser/ui/webui/welcome/nux/email_providers_list.h deleted file mode 100644 index e50eed8..0000000 --- a/chrome/browser/ui/webui/welcome/nux/email_providers_list.h +++ /dev/null
@@ -1,21 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_EMAIL_PROVIDERS_LIST_H_ -#define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_EMAIL_PROVIDERS_LIST_H_ - -#include <vector> - -#include "chrome/browser/ui/webui/welcome/nux/bookmark_item.h" - -namespace nux { - -std::vector<BookmarkItem> GetCurrentCountryEmailProviders(); - -// Function to avoid exposing enum only for count. -int GetNumberOfEmailProviders(); - -} // namespace nux - -#endif // CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_EMAIL_PROVIDERS_LIST_H_
diff --git a/chrome/browser/ui/webui/welcome/nux_helper.cc b/chrome/browser/ui/webui/welcome/nux_helper.cc index 980426a..037f9120 100644 --- a/chrome/browser/ui/webui/welcome/nux_helper.cc +++ b/chrome/browser/ui/webui/welcome/nux_helper.cc
@@ -35,7 +35,7 @@ // chrome/browser/resources/welcome/onboarding_welcome/welcome_app.js const base::FeatureParam<std::string> kNuxOnboardingForceEnabledNewUserModules = {&kNuxOnboardingForceEnabled, "new-user-modules", - "nux-google-apps,nux-email,nux-ntp-background,nux-set-as-default," + "nux-google-apps,nux-ntp-background,nux-set-as-default," "signin-view"}; const base::FeatureParam<std::string> kNuxOnboardingForceEnabledReturningUserModules = {
diff --git a/chrome/browser/ui/webui/welcome/nux_helper.h b/chrome/browser/ui/webui/welcome/nux_helper.h index a56ae37d..74a940ad 100644 --- a/chrome/browser/ui/webui/welcome/nux_helper.h +++ b/chrome/browser/ui/webui/welcome/nux_helper.h
@@ -24,8 +24,6 @@ kNuxOnboardingForceEnabledNewUserModules; extern const base::FeatureParam<std::string> kNuxOnboardingForceEnabledReturningUserModules; -extern const base::FeatureParam<bool> - kNuxOnboardingForceEnabledShowEmailInterstitial; // Get the group for users who onboard in this experiment. // Groups are:
diff --git a/chrome/browser/ui/webui/welcome/welcome_ui.cc b/chrome/browser/ui/webui/welcome/welcome_ui.cc index 75a9e94..cf4b938 100644 --- a/chrome/browser/ui/webui/welcome/welcome_ui.cc +++ b/chrome/browser/ui/webui/welcome/welcome_ui.cc
@@ -15,7 +15,6 @@ #include "chrome/browser/ui/webui/localized_string.h" #include "chrome/browser/ui/webui/welcome/nux/bookmark_handler.h" #include "chrome/browser/ui/webui/welcome/nux/constants.h" -#include "chrome/browser/ui/webui/welcome/nux/email_handler.h" #include "chrome/browser/ui/webui/welcome/nux/google_apps_handler.h" #include "chrome/browser/ui/webui/welcome/nux/ntp_background_handler.h" #include "chrome/browser/ui/webui/welcome/nux/set_as_default_handler.h" @@ -102,9 +101,6 @@ {"signInSubHeader", IDS_ONBOARDING_WELCOME_SIGNIN_VIEW_SUB_HEADER}, {"signIn", IDS_ONBOARDING_WELCOME_SIGNIN_VIEW_SIGNIN}, - // Email provider module strings. - {"emailProviderTitle", IDS_ONBOARDING_WELCOME_NUX_EMAIL_TITLE}, - // Google apps module strings. {"googleAppsDescription", IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_DESCRIPTION}, @@ -199,10 +195,6 @@ web_ui->AddMessageHandler( std::make_unique<nux::BookmarkHandler>(profile->GetPrefs())); - // Add email provider bookmarking onboarding module. - web_ui->AddMessageHandler(std::make_unique<nux::EmailHandler>()); - nux::EmailHandler::AddSources(html_source); - // Add google apps bookmarking onboarding module. web_ui->AddMessageHandler(std::make_unique<nux::GoogleAppsHandler>()); @@ -225,6 +217,7 @@ base::BindRepeating(&HandleRequestCallback, weak_ptr_factory_.GetWeakPtr())); html_source->UseGzip(base::BindRepeating(&WelcomeUI::IsGzipped)); + html_source->SetJsonPath("strings.js"); } else if (kIsBranded && AccountConsistencyModeManager::IsDiceEnabledForProfile(profile)) { // Use special layout if the application is branded and DICE is enabled.
diff --git a/chrome/common/chrome_features.cc b/chrome/common/chrome_features.cc index 15d1434b..56ee17b 100644 --- a/chrome/common/chrome_features.cc +++ b/chrome/common/chrome_features.cc
@@ -604,6 +604,10 @@ "SSLCommittedInterstitials", base::FEATURE_ENABLED_BY_DEFAULT}; #if defined(OS_CHROMEOS) +// Enables or disables automatic setup of USB printers. +const base::Feature kStreamlinedUsbPrinterSetup{ + "StreamlinedUsbPrinterSetup", base::FEATURE_DISABLED_BY_DEFAULT}; + // Enables or disables the ability to add a Samba Share to the Files app const base::Feature kNativeSmb{"NativeSmb", base::FEATURE_ENABLED_BY_DEFAULT}; #endif // defined(OS_CHROMEOS)
diff --git a/chrome/common/chrome_features.h b/chrome/common/chrome_features.h index e0b27f1..a090b50 100644 --- a/chrome/common/chrome_features.h +++ b/chrome/common/chrome_features.h
@@ -371,6 +371,8 @@ extern const base::Feature kSSLCommittedInterstitials; #if defined(OS_CHROMEOS) +COMPONENT_EXPORT(CHROME_FEATURES) +extern const base::Feature kStreamlinedUsbPrinterSetup; COMPONENT_EXPORT(CHROME_FEATURES) extern const base::Feature kNativeSmb; #endif
diff --git a/chrome/common/extensions/api/_api_features.json b/chrome/common/extensions/api/_api_features.json index e60cde8e..c52e6aaf 100644 --- a/chrome/common/extensions/api/_api_features.json +++ b/chrome/common/extensions/api/_api_features.json
@@ -104,6 +104,9 @@ "channel": "stable", "contexts": ["webui"], "matches": [ + // TODO(maybelle): Audit and remove chrome://settings or + // chrome://os-settings as appropriate + "chrome://os-settings/*", "chrome://settings/*" ] }], @@ -535,6 +538,9 @@ "channel": "stable", "contexts": ["webui"], "matches": [ + // TODO(maybelle): Audit and remove chrome://settings or + // chrome://os-settings as appropriate + "chrome://os-settings/*", "chrome://settings/*" ] }], @@ -549,6 +555,9 @@ "channel": "stable", "contexts": ["webui"], "matches": [ + // TODO(maybelle): Audit and remove chrome://settings or + // chrome://os-settings as appropriate + "chrome://os-settings/*", "chrome://settings/*" ] }], @@ -609,6 +618,9 @@ "channel": "stable", "contexts": ["webui"], "matches": [ + // TODO(maybelle): Audit and remove chrome://settings or + // chrome://os-settings as appropriate + "chrome://os-settings/*", "chrome://settings/*" ] }], @@ -651,6 +663,9 @@ "contexts": ["webui"], "matches": [ "chrome://multidevice-setup/*", + // TODO(maybelle): Audit and remove chrome://settings or + // chrome://os-settings as appropriate + "chrome://os-settings/*", "chrome://settings/*", "chrome://oobe/*" ], @@ -685,6 +700,9 @@ "channel": "stable", "contexts": ["webui"], "matches": [ + // TODO(maybelle): Audit and remove chrome://settings or + // chrome://os-settings as appropriate + "chrome://os-settings/*", "chrome://settings/*" ] }], @@ -739,6 +757,9 @@ "channel": "stable", "contexts": ["webui"], "matches": [ + // TODO(maybelle): Audit and remove chrome://settings or + // chrome://os-settings as appropriate + "chrome://os-settings/*", "chrome://settings/*" ] }],
diff --git a/chrome/common/service_process_util_mac_unittest.mm b/chrome/common/service_process_util_mac_unittest.mm index 1e16505..ca8ec46 100644 --- a/chrome/common/service_process_util_mac_unittest.mm +++ b/chrome/common/service_process_util_mac_unittest.mm
@@ -8,6 +8,7 @@ #include "base/bind.h" #include "base/command_line.h" +#include "base/feature_list.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" @@ -21,6 +22,7 @@ #include "base/threading/thread.h" #include "chrome/common/mac/launchd.h" #include "chrome/common/mac/mock_launchd.h" +#include "mojo/public/cpp/platform/features.h" #include "testing/gtest/include/gtest/gtest.h" class ServiceProcessStateFileManipulationTest : public ::testing::Test { @@ -48,8 +50,12 @@ ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); ASSERT_TRUE(MockLaunchd::MakeABundle(GetTempDirPath(), "Test", &bundle_path_, &executable_path_)); + // If using a Mach Mojo channel, set up MockLaunchd as a service. + bool as_service = + base::FeatureList::IsEnabled(mojo::features::kMojoChannelMac); mock_launchd_.reset(new MockLaunchd(executable_path_, loop_.task_runner(), - run_loop_.QuitClosure(), false, false)); + run_loop_.QuitClosure(), false, + as_service)); scoped_launchd_instance_.reset( new Launchd::ScopedInstance(mock_launchd_.get())); ASSERT_TRUE(service_process_state_.Initialize());
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index ebdd8d55..657a8c07 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn
@@ -2789,7 +2789,10 @@ "../browser/performance_manager/observers/metrics_collector_unittest.cc", "../browser/performance_manager/observers/page_signal_generator_impl_unittest.cc", "../browser/performance_manager/observers/working_set_trimmer_win_unittest.cc", + "../browser/performance_manager/performance_manager_test_harness.cc", + "../browser/performance_manager/performance_manager_test_harness.h", "../browser/performance_manager/performance_manager_unittest.cc", + "../browser/performance_manager/web_contents_proxy_unittest.cc", "../browser/performance_manager/webui_graph_dump_impl_unittest.cc", "../browser/performance_monitor/metric_evaluator_helper_win_unittest.cc", "../browser/performance_monitor/system_monitor_unittest.cc",
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc index de64448b..232b4ef 100644 --- a/chrome/test/base/testing_profile.cc +++ b/chrome/test/base/testing_profile.cc
@@ -45,6 +45,7 @@ #include "chrome/browser/prefs/pref_service_syncable_util.h" #include "chrome/browser/prerender/prerender_manager.h" #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" +#include "chrome/browser/profiles/profile_key.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/storage_partition_descriptor.h" #include "chrome/browser/search_engines/template_url_fetcher_factory.h" @@ -386,12 +387,6 @@ profile_manager->GetSystemProfilePath()); } - if (IsOffTheRecord()) - key_ = std::make_unique<SimpleFactoryKey>( - original_profile_->GetPath(), original_profile_->GetSimpleFactoryKey()); - else - key_ = std::make_unique<SimpleFactoryKey>(profile_path_); - BrowserContext::Initialize(this, profile_path_); #if defined(OS_ANDROID) @@ -429,6 +424,14 @@ else CreateTestingPrefService(); + if (IsOffTheRecord()) { + key_ = + std::make_unique<ProfileKey>(original_profile_->GetPath(), prefs_.get(), + original_profile_->GetProfileKey()); + } else { + key_ = std::make_unique<ProfileKey>(profile_path_, prefs_.get()); + } + if (!base::PathExists(profile_path_)) base::CreateDirectory(profile_path_); @@ -489,7 +492,7 @@ // Prefs for incognito profiles are set in CreateIncognitoPrefService() by // simulating ProfileImpl::GetOffTheRecordPrefs(). - SimpleFactoryKey* key = GetSimpleFactoryKey(); + SimpleFactoryKey* key = GetProfileKey(); if (!IsOffTheRecord()) { DCHECK(!original_profile_); user_prefs::PrefRegistrySyncable* pref_registry = @@ -546,7 +549,7 @@ // ones in the SimpleDependencyManager's graph. DependencyManager::PerformInterlockedTwoPhaseShutdown( browser_context_dependency_manager_, this, simple_dependency_manager_, - GetSimpleFactoryKey()); + key_.get()); if (host_content_settings_map_.get()) host_content_settings_map_->ShutdownOnUIThread(); @@ -612,7 +615,7 @@ } #if BUILDFLAG(ENABLE_OFFLINE_PAGES) offline_pages::OfflinePageModelFactory::GetInstance()->SetTestingFactory( - GetSimpleFactoryKey(), base::BindRepeating(&BuildOfflinePageModel)); + GetProfileKey(), base::BindRepeating(&BuildOfflinePageModel)); #endif ManagedBookmarkServiceFactory::GetInstance()->SetTestingFactory( this, ManagedBookmarkServiceFactory::GetDefaultFactory()); @@ -910,7 +913,7 @@ return start_time_; } -SimpleFactoryKey* TestingProfile::GetSimpleFactoryKey() const { +ProfileKey* TestingProfile::GetProfileKey() const { DCHECK(key_); return key_.get(); }
diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h index a0e56f8..a8abc82 100644 --- a/chrome/test/base/testing_profile.h +++ b/chrome/test/base/testing_profile.h
@@ -332,7 +332,7 @@ } bool IsSameProfile(Profile* profile) override; base::Time GetStartTime() const override; - SimpleFactoryKey* GetSimpleFactoryKey() const override; + ProfileKey* GetProfileKey() const override; base::FilePath last_selected_directory() override; void set_last_selected_directory(const base::FilePath& path) override; bool WasCreatedByVersionOrLater(const std::string& version) override; @@ -379,7 +379,7 @@ // The key to index KeyedService instances created by // SimpleKeyedServiceFactory. - std::unique_ptr<SimpleFactoryKey> key_; + std::unique_ptr<ProfileKey> key_; std::unique_ptr<sync_preferences::PrefServiceSyncable> prefs_; // ref only for right type, lifecycle is managed by prefs_
diff --git a/chrome/test/chromedriver/server/http_handler.cc b/chrome/test/chromedriver/server/http_handler.cc index 3c4bcd30..0d7d791 100644 --- a/chrome/test/chromedriver/server/http_handler.cc +++ b/chrome/test/chromedriver/server/http_handler.cc
@@ -1059,6 +1059,9 @@ case kInvalidSelector: response.reset(new net::HttpServerResponseInfo(net::HTTP_BAD_REQUEST)); break; + case kInvalidSessionId: + response.reset(new net::HttpServerResponseInfo(net::HTTP_NOT_FOUND)); + break; case kJavaScriptError: response.reset( new net::HttpServerResponseInfo(net::HTTP_INTERNAL_SERVER_ERROR)); @@ -1126,7 +1129,6 @@ case kNoSuchExecutionContext: response.reset(new net::HttpServerResponseInfo(net::HTTP_BAD_REQUEST)); break; - case kInvalidSessionId: case kChromeNotReachable: case kDisconnected: case kForbidden:
diff --git a/chrome/test/data/extensions/api_test/help_app/manifest.json b/chrome/test/data/extensions/api_test/help_app/manifest.json new file mode 100644 index 0000000..5b9d0ef --- /dev/null +++ b/chrome/test/data/extensions/api_test/help_app/manifest.json
@@ -0,0 +1,8 @@ +{ + "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuCAA3/rQ/X5xUBc2DhjXGB7U0Fn6memyWN5u3XYc1QzNdKodI5hmqVRi6yVePzmQuSdsA2M7wG0enGkg7qfQKNydcHPM7z/J0GEmSqzadrtz5QzWN2JemkIB3ilB7gO1RcyEluuHDhepCbVCwIr3VbguaaoatW4zYndqgC9mNOF5M73G44s6GkCunNcHtUaleaRiwt12y+WZsKIfRW90ijyESlSOEmGVhWwMld9SnAJv/P7apNr2HfQR4Bemriu02ypAPuJQ6zpvK+DRFdXu1bb7gOuN10+zPCjrt8SLs79rZ974bA56gAqUjDf3kLtJiHXMavCPUf3Fs1mvpzKTJwIDAQAB", + "name": "Help", + "version": "4.0", + "description" : "Test Chrome OS Help", + "manifest_version": 2, + "incognito" : "split" +}
diff --git a/chrome/test/data/extensions/api_test/help_app/oobe.html b/chrome/test/data/extensions/api_test/help_app/oobe.html new file mode 100644 index 0000000..058b00e --- /dev/null +++ b/chrome/test/data/extensions/api_test/help_app/oobe.html
@@ -0,0 +1,9 @@ +<!DOCTYPE html> +<html> +<head> +<title>Fake Help App</title> +</head> +<body> + In official builds this shows help pages. +</body> +</html>
diff --git a/chrome/test/data/policy/policy_test_cases.json b/chrome/test/data/policy/policy_test_cases.json index 0e20df0..bcbb5e3 100644 --- a/chrome/test/data/policy/policy_test_cases.json +++ b/chrome/test/data/policy/policy_test_cases.json
@@ -1137,6 +1137,18 @@ ] }, + "UninstallBlacklistedExtensions": { + "os": ["win", "linux", "mac", "chromeos"], + "test_policy": { "UninstallBlacklistedExtensions": true }, + "pref_mappings": [ + { "pref": "extensions.remove_blacklisted", + "indicator_tests": [ + { "policy": { "UninstallBlacklistedExtensions": true } } + ] + } + ] + }, + "ExtensionSettings": { "os": ["win", "linux", "mac", "chromeos"], "test_policy": {
diff --git a/chrome/test/data/webui/BUILD.gn b/chrome/test/data/webui/BUILD.gn index 2a97ce9..d29ee18f 100644 --- a/chrome/test/data/webui/BUILD.gn +++ b/chrome/test/data/webui/BUILD.gn
@@ -104,10 +104,10 @@ ] } else { sources += [ - "md_user_manager/user_manager_browsertest.js", "settings/a11y/manage_profile_a11y_test.js", "settings/a11y/sign_out_a11y_test.js", "signin/signin_browsertest.js", + "user_manager/user_manager_browsertest.js", "welcome/onboarding_welcome_browsertest.js", ] }
diff --git a/chrome/test/data/webui/downloads/manager_tests.js b/chrome/test/data/webui/downloads/manager_tests.js index 195131b..329d5a33e 100644 --- a/chrome/test/data/webui/downloads/manager_tests.js +++ b/chrome/test/data/webui/downloads/manager_tests.js
@@ -44,7 +44,7 @@ const countDates = () => { const items = manager.shadowRoot.querySelectorAll('downloads-item'); return Array.from(items).reduce((soFar, item) => { - return item.$$('h3[id=date]:not(:empty)') ? soFar + 1 : soFar; + return item.$$('div[id=date]:not(:empty)') ? soFar + 1 : soFar; }, 0); };
diff --git a/chrome/test/data/webui/media_router/media_router_elements_browsertest.js b/chrome/test/data/webui/media_router/media_router_elements_browsertest.js index 9542f01..9cfb6a5 100644 --- a/chrome/test/data/webui/media_router/media_router_elements_browsertest.js +++ b/chrome/test/data/webui/media_router/media_router_elements_browsertest.js
@@ -155,8 +155,18 @@ mocha.run(); }); +// Disabling on chromeos due to flaky test. +// https://crbug.com/945198 +GEN('#if defined(OS_CHROMEOS)'); +GEN('#define MAYBE_MediaRouterContainerSearchPart1 \\'); +GEN(' DISABLED_MediaRouterContainerSearchPart1'); +GEN('#else'); +GEN('#define MAYBE_MediaRouterContainerSearchPart1 \\'); +GEN(' MediaRouterContainerSearchPart1'); +GEN('#endif'); + TEST_F( - 'MediaRouterElementsBrowserTest', 'MediaRouterContainerSearchPart1', + 'MediaRouterElementsBrowserTest', 'MAYBE_MediaRouterContainerSearchPart1', function() { media_router_container_search.registerTestsPart1(); mocha.run();
diff --git a/chrome/test/data/webui/print_preview/plugin_stub.js b/chrome/test/data/webui/print_preview/plugin_stub.js index 420673c6..09676cf 100644 --- a/chrome/test/data/webui/print_preview/plugin_stub.js +++ b/chrome/test/data/webui/print_preview/plugin_stub.js
@@ -89,6 +89,8 @@ this.loadCallback_(true); } } + + darkModeChanged(darkMode) {} } return {PDFPluginStub: PDFPluginStub};
diff --git a/chrome/test/data/webui/settings/google_assistant_page_test.js b/chrome/test/data/webui/settings/google_assistant_page_test.js index ae4b60a..91a54a6e 100644 --- a/chrome/test/data/webui/settings/google_assistant_page_test.js +++ b/chrome/test/data/webui/settings/google_assistant_page_test.js
@@ -42,6 +42,7 @@ loadTimeData.overrideValues({ enableAssistant: true, voiceMatchEnabled: true, + hotwordDspAvailable: true, }); }); @@ -51,10 +52,6 @@ PolymerTest.clearBody(); - loadTimeData.overrideValues({ - enableAssistant: true, - }); - const prefElement = document.createElement('settings-prefs'); document.body.appendChild(prefElement); @@ -97,7 +94,7 @@ Polymer.dom.flush(); assertTrue(button.checked); assertTrue( - page.getPref('settings.voice_interaction.context.enabled.value'), true); + page.getPref('settings.voice_interaction.context.enabled.value')); }); test('toggleAssistantHotword', function() { @@ -115,10 +112,56 @@ Polymer.dom.flush(); assertTrue(button.checked); assertTrue( - page.getPref('settings.voice_interaction.hotword.enabled.value'), true); + page.getPref('settings.voice_interaction.hotword.enabled.value')); return browserProxy.whenCalled('syncVoiceModelStatus'); }); + test('hotwordToggleVisibility', function() { + let button = page.$$('#google-assistant-hotword-enable'); + assertFalse(!!button); + + page.setPrefValue('settings.voice_interaction.enabled', true); + Polymer.dom.flush(); + + button = page.$$('#google-assistant-hotword-enable'); + assertTrue(!!button); + assertFalse(button.hasAttribute('hidden')); + }); + + test('hotwordToggleEnabled', function() { + let button = page.$$('#google-assistant-hotword-enable'); + assertFalse(!!button); + + page.setPrefValue('settings.voice_interaction.enabled', true); + + page.set('prefs.settings.voice_interaction.hotword.enabled', { + enforcement: chrome.settingsPrivate.Enforcement.RECOMMENDED, + value: true, + }); + + Polymer.dom.flush(); + button = page.$$('#dsp-hotword-state'); + assertTrue(!!button); + assertFalse(button.hasAttribute('disabled')); + }); + + test('hotwordToggleDisabled', function() { + let button = page.$$('#google-assistant-hotword-enable'); + assertFalse(!!button); + + page.setPrefValue('settings.voice_interaction.enabled', true); + + page.set('prefs.settings.voice_interaction.hotword.enabled', { + enforcement: chrome.settingsPrivate.Enforcement.ENFORCED, + value: true, + }); + + Polymer.dom.flush(); + button = page.$$('#dsp-hotword-state'); + assertTrue(!!button); + assertTrue(button.hasAttribute('disabled')); + }); + test('tapOnRetrainVoiceModel', function() { let button = page.$$('#retrain-voice-model'); assertFalse(!!button); @@ -193,8 +236,7 @@ Polymer.dom.flush(); assertTrue(button.checked); assertTrue( - page.getPref('settings.voice_interaction.notification.enabled.value'), - true); + page.getPref('settings.voice_interaction.notification.enabled.value')); }); test('toggleAssistantLaunchWithMicOpen', function() { @@ -212,8 +254,7 @@ Polymer.dom.flush(); assertTrue(button.checked); assertTrue( - page.getPref('settings.voice_interaction.launch_with_mic_open.value'), - true); + page.getPref('settings.voice_interaction.launch_with_mic_open.value')); }); test('tapOnAssistantSettings', function() { @@ -242,6 +283,7 @@ Polymer.dom.flush(); dropdown = page.$$('#dsp-hotword-state'); + assertTrue(!!dropdown); assertFalse(dropdown.hasAttribute('disabled')); }); @@ -258,7 +300,187 @@ Polymer.dom.flush(); dropdown = page.$$('#dsp-hotword-state'); + assertTrue(!!dropdown); assertTrue(dropdown.hasAttribute('disabled')); }); + test('dspHotwordDropdownVisibility', function() { + let dropdown = page.$$('#dsp-hotword-container'); + assertFalse(!!dropdown); + + page.setPrefValue('settings.voice_interaction.enabled', true); + Polymer.dom.flush(); + + dropdown = page.$$('#dsp-hotword-container'); + assertTrue(!!dropdown); + assertTrue(dropdown.hasAttribute('hidden')); + }); +}); + +suite('GoogleAssistantHandlerWihtNoDspHotword', function() { + /** @type {SettingsGoogleAssistantPageElement} */ + let page = null; + + /** @type {?TestGoogleAssistantBrowserProxy} */ + let browserProxy = null; + + suiteSetup(function() { + loadTimeData.overrideValues({ + enableAssistant: true, + voiceMatchEnabled: true, + hotwordDspAvailable: false, + }); + }); + + setup(function() { + browserProxy = new TestGoogleAssistantBrowserProxy(); + settings.GoogleAssistantBrowserProxyImpl.instance_ = browserProxy; + + PolymerTest.clearBody(); + + const prefElement = document.createElement('settings-prefs'); + document.body.appendChild(prefElement); + + return CrSettingsPrefs.initialized.then(function() { + page = document.createElement('settings-google-assistant-page'); + page.prefs = prefElement.prefs; + document.body.appendChild(page); + }); + }); + + teardown(function() { + page.remove(); + }); + + /** + * @param {!HTMLElement} select + * @param {!value} string + */ + function selectValue(select, value) { + select.value = value; + select.dispatchEvent(new CustomEvent('change')); + Polymer.dom.flush(); + } + + test('hotwordToggleVisibilityWihtNoDspHotword', function() { + let button = page.$$('#google-assistant-hotword-enable'); + assertFalse(!!button); + + page.setPrefValue('settings.voice_interaction.enabled', true); + Polymer.dom.flush(); + + button = page.$$('#google-assistant-hotword-enable'); + assertTrue(!!button); + assertTrue(button.hasAttribute('hidden')); + }); + + test('dspHotwordDropdownVisibilityWihtNoDspHotword', function() { + let container = page.$$('#dsp-hotword-container'); + assertFalse(!!container); + + page.setPrefValue('settings.voice_interaction.enabled', true); + loadTimeData.overrideValues({ + hotwordDspAvailable: true, + }); + Polymer.dom.flush(); + + container = page.$$('#dsp-hotword-container'); + assertFalse(container.hasAttribute('hidden')); + }); + + test('dspHotwordDropdownSelection', function() { + let dropdown = page.$$('#dsp-hotword-state'); + assertFalse(!!dropdown); + + page.setPrefValue('settings.voice_interaction.enabled', true); + Polymer.dom.flush(); + + dropdown = page.$$('#dsp-hotword-state'); + assertTrue(!!dropdown); + assertFalse(dropdown.disabled); + + selectValue(dropdown, DspHotwordState.DEFAULT_ON); + Polymer.dom.flush(); + assertTrue( + page.getPref('settings.voice_interaction.hotword.enabled.value')); + assertFalse( + page.getPref('settings.voice_interaction.hotword.always_on.value')); + + selectValue(dropdown, DspHotwordState.ALWAYS_ON); + Polymer.dom.flush(); + assertTrue( + page.getPref('settings.voice_interaction.hotword.enabled.value')); + assertTrue( + page.getPref('settings.voice_interaction.hotword.always_on.value')); + + selectValue(dropdown, DspHotwordState.OFF); + Polymer.dom.flush(); + assertFalse( + page.getPref('settings.voice_interaction.hotword.enabled.value')); + assertFalse( + page.getPref('settings.voice_interaction.hotword.always_on.value')); + }); + + test('dspHotwordDropdownStatus', function() { + let dropdown = page.$$('#dsp-hotword-state'); + assertFalse(!!dropdown); + + page.setPrefValue('settings.voice_interaction.enabled', true); + Polymer.dom.flush(); + + dropdown = page.$$('#dsp-hotword-state'); + assertTrue(!!dropdown); + assertFalse(dropdown.disabled); + + page.setPrefValue('settings.voice_interaction.hotword.enabled', true); + page.setPrefValue('settings.voice_interaction.hotword.always_on', false); + Polymer.dom.flush(); + assertEquals(Number(dropdown.value), DspHotwordState.DEFAULT_ON); + + page.setPrefValue('settings.voice_interaction.hotword.enabled', true); + page.setPrefValue('settings.voice_interaction.hotword.always_on', true); + Polymer.dom.flush(); + assertEquals(Number(dropdown.value), DspHotwordState.ALWAYS_ON); + + page.setPrefValue('settings.voice_interaction.hotword.enabled', false); + page.setPrefValue('settings.voice_interaction.hotword.always_on', false); + Polymer.dom.flush(); + assertEquals(Number(dropdown.value), DspHotwordState.OFF); + }); + + test('dspHotwordDropdownDefaultOnSync', function() { + let dropdown = page.$$('#dsp-hotword-state'); + assertFalse(!!dropdown); + + page.setPrefValue('settings.voice_interaction.enabled', true); + Polymer.dom.flush(); + + dropdown = page.$$('#dsp-hotword-state'); + assertTrue(!!dropdown); + assertFalse(dropdown.disabled); + selectValue(dropdown, DspHotwordState.OFF); + Polymer.dom.flush(); + + selectValue(dropdown, DspHotwordState.DEFAULT_ON); + Polymer.dom.flush(); + return browserProxy.whenCalled('syncVoiceModelStatus'); + }); + + test('dspHotwordDropdownAlwaysOnSync', function() { + let dropdown = page.$$('#dsp-hotword-state'); + assertFalse(!!dropdown); + + page.setPrefValue('settings.voice_interaction.enabled', true); + Polymer.dom.flush(); + + dropdown = page.$$('#dsp-hotword-state'); + assertTrue(!!dropdown); + assertFalse(dropdown.disabled); + selectValue(dropdown, DspHotwordState.OFF); + Polymer.dom.flush(); + + selectValue(dropdown, DspHotwordState.ALWAYS_ON); + Polymer.dom.flush(); + return browserProxy.whenCalled('syncVoiceModelStatus'); + }); });
diff --git a/chrome/test/data/webui/md_user_manager/.eslintrc.js b/chrome/test/data/webui/user_manager/.eslintrc.js similarity index 100% rename from chrome/test/data/webui/md_user_manager/.eslintrc.js rename to chrome/test/data/webui/user_manager/.eslintrc.js
diff --git a/chrome/test/data/webui/md_user_manager/control_bar_tests.js b/chrome/test/data/webui/user_manager/control_bar_tests.js similarity index 99% rename from chrome/test/data/webui/md_user_manager/control_bar_tests.js rename to chrome/test/data/webui/user_manager/control_bar_tests.js index a7fae10..aed811e 100644 --- a/chrome/test/data/webui/md_user_manager/control_bar_tests.js +++ b/chrome/test/data/webui/user_manager/control_bar_tests.js
@@ -139,7 +139,6 @@ MockInteractions.tap(controlBarElement.$.launchGuest); return browserProxy.whenCalled('launchGuestUser'); }); - }); }
diff --git a/chrome/test/data/webui/md_user_manager/create_profile_tests.js b/chrome/test/data/webui/user_manager/create_profile_tests.js similarity index 98% rename from chrome/test/data/webui/md_user_manager/create_profile_tests.js rename to chrome/test/data/webui/user_manager/create_profile_tests.js index acd1409..47b560d 100644 --- a/chrome/test/data/webui/md_user_manager/create_profile_tests.js +++ b/chrome/test/data/webui/user_manager/create_profile_tests.js
@@ -25,8 +25,7 @@ signin.ProfileBrowserProxyImpl.instance_ = browserProxy; browserProxy.setDefaultProfileInfo({name: 'profile name'}); browserProxy.setIcons([ - {url: 'icon1.png', label: 'icon1'}, - {url: 'icon2.png', label: 'icon2'} + {url: 'icon1.png', label: 'icon1'}, {url: 'icon2.png', label: 'icon2'} ]); createProfileElement = createElement();
diff --git a/chrome/test/data/webui/md_user_manager/test_profile_browser_proxy.js b/chrome/test/data/webui/user_manager/test_profile_browser_proxy.js similarity index 100% rename from chrome/test/data/webui/md_user_manager/test_profile_browser_proxy.js rename to chrome/test/data/webui/user_manager/test_profile_browser_proxy.js
diff --git a/chrome/test/data/webui/md_user_manager/user_manager_browsertest.js b/chrome/test/data/webui/user_manager/user_manager_browsertest.js similarity index 94% rename from chrome/test/data/webui/md_user_manager/user_manager_browsertest.js rename to chrome/test/data/webui/user_manager/user_manager_browsertest.js index 54db1ba..4e92b851 100644 --- a/chrome/test/data/webui/md_user_manager/user_manager_browsertest.js +++ b/chrome/test/data/webui/user_manager/user_manager_browsertest.js
@@ -4,7 +4,7 @@ /** @fileoverview Tests for the Material Design user manager page. */ -/** @const {string} Path to root from chrome/test/data/webui/md_user_manager/ */ +/** @const {string} Path to root from chrome/test/data/webui/user_manager/ */ const ROOT_PATH = '../../../../../'; // Polymer BrowserTest fixture.
diff --git a/chrome/test/data/webui/md_user_manager/user_manager_pages_tests.js b/chrome/test/data/webui/user_manager/user_manager_pages_tests.js similarity index 100% rename from chrome/test/data/webui/md_user_manager/user_manager_pages_tests.js rename to chrome/test/data/webui/user_manager/user_manager_pages_tests.js
diff --git a/chrome/test/data/webui/welcome/email_chooser_test.js b/chrome/test/data/webui/welcome/email_chooser_test.js deleted file mode 100644 index 4f4daa1..0000000 --- a/chrome/test/data/webui/welcome/email_chooser_test.js +++ /dev/null
@@ -1,130 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -cr.define('onboarding_welcome_email_chooser', function() { - suite('EmailChooserTest', function() { - const emails = [ - { - id: 0, - name: 'Gmail', - icon: 'gmail', - url: 'http://www.gmail.com', - }, - { - id: 1, - name: 'Yahoo', - icon: 'yahoo', - url: 'http://mail.yahoo.com', - } - ]; - - /** @type {nux.NuxEmailProxy} */ - let testEmailBrowserProxy; - - /** @type {nux.ModuleMetricsProxy} */ - let testEmailMetricsProxy; - - /** @type {nux.BookmarkProxy} */ - let testBookmarkBrowserProxy; - - /** @type {EmailChooserElement} */ - let testElement; - - setup(async function() { - testEmailBrowserProxy = new TestNuxEmailProxy(); - testEmailMetricsProxy = new TestMetricsProxy(); - testBookmarkBrowserProxy = new TestBookmarkProxy(); - nux.BookmarkProxyImpl.instance_ = testBookmarkBrowserProxy; - // Reset w/ new proxy for test. - nux.BookmarkBarManager.instance_ = new nux.BookmarkBarManager(); - - testEmailBrowserProxy.setEmailList(emails); - - PolymerTest.clearBody(); - testElement = document.createElement('app-chooser'); - document.body.appendChild(testElement); - testElement.singleSelect = true; // Only allow selecting one email. - testElement.appProxy = testEmailBrowserProxy; - testElement.metricsManager = - new nux.ModuleMetricsManager(testEmailMetricsProxy); - // Simulate nux-email's onRouteEnter call. - testElement.onRouteEnter(); - await testEmailMetricsProxy.whenCalled('recordPageShown'); - await testEmailBrowserProxy.whenCalled('getAppList'); - }); - - teardown(function() { - testElement.remove(); - }); - - test('test email chooser options', async function() { - const options = testElement.shadowRoot.querySelectorAll('.option'); - assertEquals(2, options.length); - - // First option is default selected and action button should be enabled. - assertEquals(testElement.$$('.option[active]'), options[0]); - assertFalse(testElement.$$('.action-button').disabled); - - options[0].click(); - - assertEquals( - 1, await testBookmarkBrowserProxy.whenCalled('removeBookmark')); - - assertFalse(!!testElement.$$('.option[active]')); - assertTrue(testElement.$$('.action-button').disabled); - - // Click second option, it should be selected. - testBookmarkBrowserProxy.reset(); - options[1].click(); - - assertDeepEquals( - { - title: emails[1].name, - url: emails[1].url, - parentId: '1', - }, - await testBookmarkBrowserProxy.whenCalled('addBookmark')); - - assertEquals(testElement.$$('.option[active]'), options[1]); - assertFalse(testElement.$$('.action-button').disabled); - - // Click second option again, it should be deselected and action - // button should be disabled. - testBookmarkBrowserProxy.reset(); - options[1].click(); - - assertEquals( - 2, await testBookmarkBrowserProxy.whenCalled('removeBookmark')); - - assertFalse(!!testElement.$$('.option[active]')); - assertTrue(testElement.$$('.action-button').disabled); - }); - - test('test email chooser skip button', async function() { - const options = testElement.shadowRoot.querySelectorAll('.option'); - testElement.wasBookmarkBarShownOnInit_ = true; - - // First option should be selected and action button should be enabled. - testElement.$.noThanksButton.click(); - - await testEmailMetricsProxy.whenCalled('recordDidNothingAndChoseSkip'); - assertEquals( - 1, await testBookmarkBrowserProxy.whenCalled('removeBookmark')); - assertEquals( - true, await testBookmarkBrowserProxy.whenCalled('toggleBookmarkBar')); - }); - - test('test email chooser next button', async function() { - const options = testElement.shadowRoot.querySelectorAll('.option'); - testElement.wasBookmarkBarShownOnInit_ = true; - - // First option should be selected and action button should be enabled. - testElement.$$('.action-button').click(); - - await testEmailMetricsProxy.whenCalled('recordDidNothingAndChoseNext'); - assertEquals( - 0, await testEmailBrowserProxy.whenCalled('recordProviderSelected')); - }); - }); -});
diff --git a/chrome/test/data/webui/welcome/module_metrics_test.js b/chrome/test/data/webui/welcome/module_metrics_test.js index d012d7a2..9ca564b8 100644 --- a/chrome/test/data/webui/welcome/module_metrics_test.js +++ b/chrome/test/data/webui/welcome/module_metrics_test.js
@@ -19,10 +19,6 @@ return testMetricsProxy.whenCalled('recordPageShown'); }); - teardown(function() { - nux.EmailMetricsProxyImpl.instance_ = null; - }); - test('do nothing, click skip', function() { testMetricsManager.recordNoThanks(); return testMetricsProxy.whenCalled('recordDidNothingAndChoseSkip');
diff --git a/chrome/test/data/webui/welcome/onboarding_welcome_browsertest.js b/chrome/test/data/webui/welcome/onboarding_welcome_browsertest.js index 8633b077..48095d3 100644 --- a/chrome/test/data/webui/welcome/onboarding_welcome_browsertest.js +++ b/chrome/test/data/webui/welcome/onboarding_welcome_browsertest.js
@@ -54,27 +54,6 @@ mocha.run(); }); -OnboardingWelcomeEmailChooserTest = class extends OnboardingWelcomeBrowserTest { - /** @override */ - get browsePreload() { - return 'chrome://welcome/shared/app_chooser.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - 'email_chooser_test.js', - 'test_nux_email_proxy.js', - 'test_metrics_proxy.js', - 'test_bookmark_proxy.js', - ]); - } -}; - -TEST_F('OnboardingWelcomeEmailChooserTest', 'All', function() { - mocha.run(); -}); - OnboardingWelcomeWelcomeAppTest = class extends OnboardingWelcomeBrowserTest { /** @override */ get browsePreload() { @@ -107,7 +86,6 @@ get extraLibraries() { return super.extraLibraries.concat([ 'signin_view_test.js', - 'test_nux_email_proxy.js', 'test_welcome_browser_proxy.js', ]); }
diff --git a/chrome/test/data/webui/welcome/signin_view_test.js b/chrome/test/data/webui/welcome/signin_view_test.js index 19da9497..6499430 100644 --- a/chrome/test/data/webui/welcome/signin_view_test.js +++ b/chrome/test/data/webui/welcome/signin_view_test.js
@@ -11,16 +11,10 @@ /** @type {welcome.WelcomeBrowserProxy} */ let testWelcomeBrowserProxy; - /** @type {nux.NuxEmailProxy} */ - let testEmailBrowserProxy; - setup(function() { testWelcomeBrowserProxy = new TestWelcomeBrowserProxy(); welcome.WelcomeBrowserProxyImpl.instance_ = testWelcomeBrowserProxy; - testEmailBrowserProxy = new TestNuxEmailProxy(); - nux.EmailAppProxyImpl.instance_ = testEmailBrowserProxy; - PolymerTest.clearBody(); testElement = document.createElement('signin-view'); document.body.appendChild(testElement);
diff --git a/chrome/test/data/webui/welcome/test_email_interstitial_proxy.js b/chrome/test/data/webui/welcome/test_email_interstitial_proxy.js deleted file mode 100644 index 374a1ae2..0000000 --- a/chrome/test/data/webui/welcome/test_email_interstitial_proxy.js +++ /dev/null
@@ -1,35 +0,0 @@ -// Copyright 2019 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -/** @implements {nux.EmailInterstitialProxy} */ -class TestEmailInterstititalProxy extends TestBrowserProxy { - constructor() { - super([ - 'recordPageShown', - 'recordNavigatedAway', - 'recordSkip', - 'recordNext', - ]); - } - - /** @override */ - recordPageShown() { - this.methodCalled('recordPageShown'); - } - - /** @override */ - recordNavigatedAway() { - this.methodCalled('recordNavigatedAway'); - } - - /** @override */ - recordSkip() { - this.methodCalled('recordSkip'); - } - - /** @override */ - recordNext() { - this.methodCalled('recordNext'); - } -}
diff --git a/chrome/test/data/webui/welcome/test_nux_email_proxy.js b/chrome/test/data/webui/welcome/test_nux_email_proxy.js deleted file mode 100644 index c72ded3..0000000 --- a/chrome/test/data/webui/welcome/test_nux_email_proxy.js +++ /dev/null
@@ -1,38 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -/** @implements {nux.AppProxy} */ -class TestNuxEmailProxy extends TestBrowserProxy { - constructor() { - super([ - 'cacheBookmarkIcon', - 'getAppList', - 'recordProviderSelected', - ]); - - /** @private {!Array<!nux.BookmarkListItem>} */ - this.emailList_ = []; - } - - /** @override */ - getAppList() { - this.methodCalled('getAppList'); - return Promise.resolve(this.emailList_); - } - - /** @override */ - cacheBookmarkIcon() { - this.methodCalled('cacheBookmarkIcon'); - } - - /** @override */ - recordProviderSelected(providerId) { - this.methodCalled('recordProviderSelected', providerId); - } - - /** @param {!Array<!nux.BookmarkListItem>} emailList */ - setEmailList(emailList) { - this.emailList_ = emailList; - } -}
diff --git a/chrome/test/data/webui/welcome/welcome_app_test.js b/chrome/test/data/webui/welcome/welcome_app_test.js index 680e29e..bb284d77 100644 --- a/chrome/test/data/webui/welcome/welcome_app_test.js +++ b/chrome/test/data/webui/welcome/welcome_app_test.js
@@ -73,10 +73,9 @@ welcome.navigateTo(welcome.Routes.NEW_USER, 1); return test_util.waitForRenderOrTimeout0(testElement).then(() => { const views = testElement.shadowRoot.querySelectorAll('[slot=view]'); - assertEquals(views.length, 6); + assertEquals(views.length, 5); ['LANDING-VIEW', 'NUX-GOOGLE-APPS', - 'NUX-EMAIL', 'NUX-NTP-BACKGROUND', 'NUX-SET-AS-DEFAULT', 'SIGNIN-VIEW', @@ -91,10 +90,9 @@ welcome.navigateTo(welcome.Routes.NEW_USER, 1); return test_util.waitForRenderOrTimeout0(testElement).then(() => { const views = testElement.shadowRoot.querySelectorAll('[slot=view]'); - assertEquals(views.length, 5); + assertEquals(views.length, 4); ['LANDING-VIEW', 'NUX-GOOGLE-APPS', - 'NUX-EMAIL', 'NUX-NTP-BACKGROUND', 'SIGNIN-VIEW', ].forEach((expectedView, ix) => {
diff --git a/chromeos/dbus/cryptohome/fake_cryptohome_client.cc b/chromeos/dbus/cryptohome/fake_cryptohome_client.cc index 587fcafb..2e108ca 100644 --- a/chromeos/dbus/cryptohome/fake_cryptohome_client.cc +++ b/chromeos/dbus/cryptohome/fake_cryptohome_client.cc
@@ -47,6 +47,9 @@ } // namespace +// static +constexpr char FakeCryptohomeClient::kStubTpmPassword[] = "Stub-TPM-password"; + FakeCryptohomeClient::FakeCryptohomeClient() : service_is_available_(true), remove_firmware_management_parameters_from_tpm_call_count_(0), @@ -184,7 +187,6 @@ void FakeCryptohomeClient::TpmGetPassword( DBusMethodCallback<std::string> callback) { - constexpr char kStubTpmPassword[] = "Stub-TPM-password"; base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::BindOnce(std::move(callback), std::string(kStubTpmPassword)));
diff --git a/chromeos/dbus/cryptohome/fake_cryptohome_client.h b/chromeos/dbus/cryptohome/fake_cryptohome_client.h index 982127e..e28d25d8 100644 --- a/chromeos/dbus/cryptohome/fake_cryptohome_client.h +++ b/chromeos/dbus/cryptohome/fake_cryptohome_client.h
@@ -36,6 +36,9 @@ // Checks that a FakeCryptohome instance was initialized and returns it. static FakeCryptohomeClient* Get(); + // Expose stub password for tests. + static const char kStubTpmPassword[]; + // CryptohomeClient overrides void AddObserver(Observer* observer) override; void RemoveObserver(Observer* observer) override;
diff --git a/chromeos/services/assistant/assistant_manager_service_impl.cc b/chromeos/services/assistant/assistant_manager_service_impl.cc index 2f722fc..d967af7 100644 --- a/chromeos/services/assistant/assistant_manager_service_impl.cc +++ b/chromeos/services/assistant/assistant_manager_service_impl.cc
@@ -315,6 +315,16 @@ assistant_screenshot_); } +void AssistantManagerServiceImpl::StartEditReminderInteraction( + const std::string& client_id) { + const std::string interaction = CreateEditReminderInteraction(client_id); + assistant_client::VoicelessOptions voiceless_options; + + voiceless_options.is_user_initiated = true; + assistant_manager_internal_->SendVoicelessInteraction( + interaction, std::string(), voiceless_options, [](auto) {}); +} + void AssistantManagerServiceImpl::StartMetalayerInteraction( const gfx::Rect& region) { if (!IsScreenContextAllowed(service_->assistant_state()))
diff --git a/chromeos/services/assistant/assistant_manager_service_impl.h b/chromeos/services/assistant/assistant_manager_service_impl.h index 7844a03..efa3d84 100644 --- a/chromeos/services/assistant/assistant_manager_service_impl.h +++ b/chromeos/services/assistant/assistant_manager_service_impl.h
@@ -115,6 +115,7 @@ // mojom::Assistant overrides: void StartCachedScreenContextInteraction() override; + void StartEditReminderInteraction(const std::string& client_id) override; void StartMetalayerInteraction(const gfx::Rect& region) override; void StartTextInteraction(const std::string& query, bool allow_tts) override; void StartVoiceInteraction() override;
diff --git a/chromeos/services/assistant/chromium_http_connection.cc b/chromeos/services/assistant/chromium_http_connection.cc index 36afbed..1b396e9 100644 --- a/chromeos/services/assistant/chromium_http_connection.cc +++ b/chromeos/services/assistant/chromium_http_connection.cc
@@ -70,14 +70,7 @@ } void ChromiumHttpConnection::SetRequest(const std::string& url, Method method) { - task_runner_->PostTask( - FROM_HERE, base::BindOnce(&ChromiumHttpConnection::SetRequestOnTaskRunner, - this, url, method)); -} - -void ChromiumHttpConnection::SetRequestOnTaskRunner(const std::string& url, - Method method) { - DCHECK(task_runner_->RunsTasksInCurrentSequence()); + ENSURE_MAIN_THREAD(&ChromiumHttpConnection::SetRequest, url, method); DCHECK_EQ(state_, State::NEW); url_ = GURL(url); method_ = method; @@ -85,14 +78,7 @@ void ChromiumHttpConnection::AddHeader(const std::string& name, const std::string& value) { - task_runner_->PostTask( - FROM_HERE, base::BindOnce(&ChromiumHttpConnection::AddHeaderOnTaskRunner, - this, name, value)); -} - -void ChromiumHttpConnection::AddHeaderOnTaskRunner(const std::string& name, - const std::string& value) { - DCHECK(task_runner_->RunsTasksInCurrentSequence()); + ENSURE_MAIN_THREAD(&ChromiumHttpConnection::AddHeader, name, value); DCHECK_EQ(state_, State::NEW); // From https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2: // "Multiple message-header fields with the same field-name MAY be present in @@ -111,16 +97,8 @@ void ChromiumHttpConnection::SetUploadContent(const std::string& content, const std::string& content_type) { - task_runner_->PostTask( - FROM_HERE, - base::BindOnce(&ChromiumHttpConnection::SetUploadContentOnTaskRunner, - this, content, content_type)); -} - -void ChromiumHttpConnection::SetUploadContentOnTaskRunner( - const std::string& content, - const std::string& content_type) { - DCHECK(task_runner_->RunsTasksInCurrentSequence()); + ENSURE_MAIN_THREAD(&ChromiumHttpConnection::SetUploadContent, content, + content_type); DCHECK_EQ(state_, State::NEW); upload_content_ = content; upload_content_type_ = content_type; @@ -129,16 +107,8 @@ void ChromiumHttpConnection::SetChunkedUploadContentType( const std::string& content_type) { - task_runner_->PostTask( - FROM_HERE, - base::BindOnce( - &ChromiumHttpConnection::SetChunkedUploadContentTypeOnTaskRunner, - this, content_type)); -} - -void ChromiumHttpConnection::SetChunkedUploadContentTypeOnTaskRunner( - const std::string& content_type) { - DCHECK(task_runner_->RunsTasksInCurrentSequence()); + ENSURE_MAIN_THREAD(&ChromiumHttpConnection::SetChunkedUploadContentType, + content_type); DCHECK_EQ(state_, State::NEW); upload_content_ = ""; upload_content_type_ = ""; @@ -151,27 +121,15 @@ } void ChromiumHttpConnection::EnablePartialResults() { - task_runner_->PostTask( - FROM_HERE, - base::BindOnce(&ChromiumHttpConnection::EnablePartialResultsOnTaskRunner, - this)); -} - -void ChromiumHttpConnection::EnablePartialResultsOnTaskRunner() { - DCHECK(task_runner_->RunsTasksInCurrentSequence()); + ENSURE_MAIN_THREAD(&ChromiumHttpConnection::EnablePartialResults); DCHECK_EQ(state_, State::NEW); handle_partial_response_ = true; } void ChromiumHttpConnection::Start() { VLOG(2) << "Requested to start connection"; - task_runner_->PostTask( - FROM_HERE, - base::BindOnce(&ChromiumHttpConnection::StartOnTaskRunner, this)); -} -void ChromiumHttpConnection::StartOnTaskRunner() { - DCHECK(task_runner_->RunsTasksInCurrentSequence()); + ENSURE_MAIN_THREAD(&ChromiumHttpConnection::Start); DCHECK_EQ(state_, State::NEW); state_ = State::STARTED; @@ -238,13 +196,8 @@ void ChromiumHttpConnection::Close() { VLOG(2) << "Requesting to close connection object"; - task_runner_->PostTask( - FROM_HERE, - base::BindOnce(&ChromiumHttpConnection::CloseOnTaskRunner, this)); -} -void ChromiumHttpConnection::CloseOnTaskRunner() { - DCHECK(task_runner_->RunsTasksInCurrentSequence()); + ENSURE_MAIN_THREAD(&ChromiumHttpConnection::Close); if (state_ == State::DESTROYED) return; @@ -257,6 +210,28 @@ Release(); } +void ChromiumHttpConnection::UploadData(const std::string& data, + bool is_last_chunk) { + ENSURE_MAIN_THREAD(&ChromiumHttpConnection::UploadData, data, is_last_chunk); + if (state_ != State::STARTED) + return; + + upload_body_ += data; + + upload_body_size_ += data.size(); + if (is_last_chunk) { + // Send size before the rest of the body. While it doesn't matter much, if + // the other side receives the size before the last chunk, which Mojo does + // not guarantee, some protocols can merge the data and the last chunk + // itself into a single frame. + has_last_chunk_ = is_last_chunk; + if (get_size_callback_) + std::move(get_size_callback_).Run(net::OK, upload_body_size_); + } + + SendData(); +} + void ChromiumHttpConnection::GetSize(GetSizeCallback get_size_callback) { if (has_last_chunk_) std::move(get_size_callback).Run(net::OK, upload_body_size_); @@ -371,35 +346,6 @@ SendData(); } -void ChromiumHttpConnection::UploadData(const std::string& data, - bool is_last_chunk) { - task_runner_->PostTask( - FROM_HERE, base::BindOnce(&ChromiumHttpConnection::UploadDataOnTaskRunner, - this, data, is_last_chunk)); -} - -void ChromiumHttpConnection::UploadDataOnTaskRunner(const std::string& data, - bool is_last_chunk) { - DCHECK(task_runner_->RunsTasksInCurrentSequence()); - if (state_ != State::STARTED) - return; - - upload_body_ += data; - - upload_body_size_ += data.size(); - if (is_last_chunk) { - // Send size before the rest of the body. While it doesn't matter much, if - // the other side receives the size before the last chunk, which Mojo does - // not guarantee, some protocols can merge the data and the last chunk - // itself into a single frame. - has_last_chunk_ = is_last_chunk; - if (get_size_callback_) - std::move(get_size_callback_).Run(net::OK, upload_body_size_); - } - - SendData(); -} - void ChromiumHttpConnection::OnURLLoadComplete( std::unique_ptr<std::string> response_body) { DCHECK(!handle_partial_response_);
diff --git a/chromeos/services/assistant/chromium_http_connection.h b/chromeos/services/assistant/chromium_http_connection.h index d0d06f7d..26dc85d 100644 --- a/chromeos/services/assistant/chromium_http_connection.h +++ b/chromeos/services/assistant/chromium_http_connection.h
@@ -55,16 +55,16 @@ void Close() override; void UploadData(const std::string& data, bool is_last_chunk) override; + // network::mojom::ChunkedDataPipeGetter implementation: + void GetSize(GetSizeCallback get_size_callback) override; + void StartReading(mojo::ScopedDataPipeProducerHandle pipe) override; + // network::SimpleURLLoaderStreamConsumer implementation: void OnDataReceived(base::StringPiece string_piece, base::OnceClosure resume) override; void OnComplete(bool success) override; void OnRetry(base::OnceClosure start_retry) override; - // network::mojom::ChunkedDataPipeGetter implementation: - void GetSize(GetSizeCallback get_size_callback) override; - void StartReading(mojo::ScopedDataPipeProducerHandle pipe) override; - protected: ~ChromiumHttpConnection() override; @@ -78,26 +78,15 @@ DESTROYED, }; - // HttpConnection methods, re-scheduled on |task_runner|: - void SetRequestOnTaskRunner(const std::string& url, Method method); - void AddHeaderOnTaskRunner(const std::string& name, const std::string& value); - void SetUploadContentOnTaskRunner(const std::string& content, - const std::string& content_type); - void SetChunkedUploadContentTypeOnTaskRunner(const std::string& content_type); - void EnablePartialResultsOnTaskRunner(); - void StartOnTaskRunner(); - void CloseOnTaskRunner(); - void UploadDataOnTaskRunner(const std::string& data, bool is_last_chunk); - - // URL loader completion callback. - void OnURLLoadComplete(std::unique_ptr<std::string> response_body); - // Send more chunked upload data. void SendData(); // |upload_pipe_| can now receive more data. void OnUploadPipeWriteable(MojoResult unused); + // URL loader completion callback. + void OnURLLoadComplete(std::unique_ptr<std::string> response_body); + Delegate* const delegate_; scoped_refptr<base::SequencedTaskRunner> task_runner_; State state_ = State::NEW;
diff --git a/chromeos/services/assistant/fake_assistant_manager_service_impl.cc b/chromeos/services/assistant/fake_assistant_manager_service_impl.cc index 0e41d26..948858a 100644 --- a/chromeos/services/assistant/fake_assistant_manager_service_impl.cc +++ b/chromeos/services/assistant/fake_assistant_manager_service_impl.cc
@@ -48,6 +48,9 @@ void FakeAssistantManagerServiceImpl::StartCachedScreenContextInteraction() {} +void FakeAssistantManagerServiceImpl::StartEditReminderInteraction( + const std::string& client_id) {} + void FakeAssistantManagerServiceImpl::StartMetalayerInteraction( const gfx::Rect& region) {}
diff --git a/chromeos/services/assistant/fake_assistant_manager_service_impl.h b/chromeos/services/assistant/fake_assistant_manager_service_impl.h index 5732897..7e263ba 100644 --- a/chromeos/services/assistant/fake_assistant_manager_service_impl.h +++ b/chromeos/services/assistant/fake_assistant_manager_service_impl.h
@@ -40,6 +40,7 @@ // mojom::Assistant overrides: void StartCachedScreenContextInteraction() override; + void StartEditReminderInteraction(const std::string& client_id) override; void StartMetalayerInteraction(const gfx::Rect& region) override; void StartTextInteraction(const std::string& query, bool allow_tts) override; void StartVoiceInteraction() override;
diff --git a/chromeos/services/assistant/public/mojom/assistant.mojom b/chromeos/services/assistant/public/mojom/assistant.mojom index 8e8ccd6e..3037cce50 100644 --- a/chromeos/services/assistant/public/mojom/assistant.mojom +++ b/chromeos/services/assistant/public/mojom/assistant.mojom
@@ -18,6 +18,12 @@ // without having first cached screen context (see CacheScreenContext()). StartCachedScreenContextInteraction(); + // Starts an interaction to edit the reminder uniquely identified by + // |client_id|. In response to the request, LibAssistant will initiate + // a user facing interaction with the context pre-populated with details + // to edit the specified reminder. + StartEditReminderInteraction(string client_id); + // Starts a metalayer interaction for the selected screen |region|. Results // related to the selected region will be returned through the // |AssistantInteractionSubscriber| interface to registered subscribers.
diff --git a/chromeos/services/assistant/test_support/mock_assistant.h b/chromeos/services/assistant/test_support/mock_assistant.h index eade08c..5f5493f 100644 --- a/chromeos/services/assistant/test_support/mock_assistant.h +++ b/chromeos/services/assistant/test_support/mock_assistant.h
@@ -23,6 +23,8 @@ MOCK_METHOD0(StartCachedScreenContextInteraction, void()); + MOCK_METHOD1(StartEditReminderInteraction, void(const std::string&)); + MOCK_METHOD1(StartMetalayerInteraction, void(const gfx::Rect&)); MOCK_METHOD2(StartTextInteraction, void(const std::string&, bool));
diff --git a/chromeos/services/device_sync/proto/BUILD.gn b/chromeos/services/device_sync/proto/BUILD.gn index ec6c42d..b9bbbec 100644 --- a/chromeos/services/device_sync/proto/BUILD.gn +++ b/chromeos/services/device_sync/proto/BUILD.gn
@@ -10,6 +10,7 @@ "cryptauth_better_together_feature_metadata.proto", "cryptauth_client_app_metadata.proto", "cryptauth_common.proto", + "cryptauth_devicesync.proto", "cryptauth_directive.proto", "cryptauth_enrollment.proto", "securemessage.proto",
diff --git a/chromeos/services/device_sync/proto/cryptauth_devicesync.proto b/chromeos/services/device_sync/proto/cryptauth_devicesync.proto new file mode 100644 index 0000000..57c7f5d --- /dev/null +++ b/chromeos/services/device_sync/proto/cryptauth_devicesync.proto
@@ -0,0 +1,238 @@ +// 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. + +// Contains the request and response messages used in the CryptAuth v2 +// DeviceSync protocol. Specifically, +// +// -- SyncMetadata -- +// * Request: The device sends its metadata to CryptAuth, most of it encrypted +// with the (alleged) group public key. The device also sends what it thinks +// is the group public key. +// * Response: If CryptAuth can confirm that the device is in possession of the +// correct group public key, then CryptAuth returns metadata for the user's +// devices in the DeviceSync group. The group public key and/or the +// encrypted group private key might also be returned. +// +// -- ShareGroupPrivateKey -- +// * Request: The device shares the group private key by encrypting it with the +// public key of the user's other devices. These encrypted keys are +// persisted by CryptAuth for the other devices to retrieve as necessary. +// * Response: Trivial +// +// -- BatchNotifyGroupDevices -- +// * Request: The client sends a list of the devices that it wants to tickle via +// a GCM message. +// * Response: Trivial +// +// -- BatchGetFeatureStatuses -- +// * Request: The client queries CryptAuth for the state of features on the +// user's devices, for example, whether or not Magic Tether is enabled on +// any of the user's phones. +// * Response: The query results. +// +// -- BatchSetFeatureStatuses -- +// * Request: The client requests CryptAuth to set the state of various features +// for the user's devices. Optionally, features can be enabled exclusively, +// meaning enabled on one device and disabled on all others. +// * Response: Trivial +syntax = "proto3"; + +package cryptauthv2; + +option optimize_for = LITE_RUNTIME; + +import "cryptauth_common.proto"; +import "cryptauth_directive.proto"; + +// A common context for requests. +message RequestContext { + // The group name. + // A device can join multiple groups. Each group will be identified by a + // unique name. + // The device should have previously enrolled a public key with this name with + // the server, using the Enrollment API. + // The key material associated with the key of this name is used by other + // devices in the group to communicate securely with this device. + string group = 1; + + // Common metadata about this request. + ClientMetadata client_metadata = 2; + + // Device identifier. + string device_id = 3; + + // Used to authenticate device_id. + string device_id_token = 4; +} + +// Requests from a client to sync its metadata and receive encrypted copy of +// other metadata updated since its last sync. +message SyncMetadataRequest { + // The context of this request. + RequestContext context = 1; + + // Public key material intended for group use. Will either be created by the + // device upon first joining, or will be existing group public key in its + // possession. + // May be discarded if device is joining an existing group that already has a + // group key pair. + bytes group_public_key = 3; + + // Device's metadata encrypted with the given group public key. + bytes encrypted_metadata = 4; + + // Set to true if the device needs the group's private key. + bool need_group_private_key = 5; + + // Used to obtain only updated metadata, since the last request. + // If not set, all metadata will be sent. + bytes freshness_token = 6; +} + +// One device's metadata, containing an identifier for the particular device, +// along with its encrypted metadata. +message DeviceMetadataPacket { + // Device identifier. + string device_id = 1; + + // This device's metadata, encrypted with the group's private key. + bytes encrypted_metadata = 2; + + // Indicates that the associated device needs the group's private key. + bool need_group_private_key = 3; + + // The associated device's public key, to be used with + // EncryptedGroupPrivateKey below. + bytes device_public_key = 4; + + // A name known to the server or which was assigned by the user to the device. + string device_name = 5; +} + +// Response from server with any new devices' encrypted metadata and public key. +message SyncMetadataResponse { + // Collection of encrypted metadata from devices that have been updated since + // last provided refresh_token. All metadata if none was provided. + repeated DeviceMetadataPacket encrypted_metadata = 1; + + // Public key associated with the group, used to encrypt all metadata. + // May be different than key received in the request. + // If not set, the server is indicating a new group key pair must be created + // by this device. + bytes group_public_key = 2; + + // An encrypted group private key that contains device public key used for + // encryption. Encrypted with the public key of the device. + EncryptedGroupPrivateKey encrypted_group_private_key = 3; + + // Updated freshness token from the server. + // Use this value in subsequent requests, to obtain only data updated since + // the last request. + bytes freshness_token = 4; + + // The updated client-specific directives. + ClientDirective client_directive = 5; +} + +// Encrypted group private key, including identifiers for both sender and +// recipient devices. +message EncryptedGroupPrivateKey { + // Identifier for device receiving group private key. + string recipient_device_id = 1; + + // Identifier for device sending group private key. + string sender_device_id = 2; + + // Group private key, encrypted with the public key of the recipient device. + bytes encrypted_private_key = 3; + + // Hash of the group public key used to encrypt this device’s metadata. + int64 group_public_key_hash = 7; +} + +// Share the group's private key with another device. +message ShareGroupPrivateKeyRequest { + // The context of this request. + RequestContext context = 1; + + // A collection of encrypted group private keys, each identified with the + // device public key of both the sender and the recipient. + repeated EncryptedGroupPrivateKey encrypted_group_private_keys = 2; +} + +// The server's response to sharing the group's private key. +message ShareGroupPrivateKeyResponse {} + +// Allows a device, which is part of the group, notify another group device. +// This allows setup to work, e.g. by letting the other device know it needs to +// turn on the bluetooth radio. +message BatchNotifyGroupDevicesRequest { + // The context of this request. + RequestContext context = 1; + + // Group devices to notify. + repeated string notify_device_ids = 2; + + // Target service & feature type to specify in the notification. + TargetService target_service = 3; + // Feature type. + string feature_type = 4; +} + +// Response to BatchNotifyGroupDevices. +message BatchNotifyGroupDevicesResponse {} + +// Requests feature enabled/disabled statuses per device in the group. +message BatchGetFeatureStatusesRequest { + // The context of this request. + RequestContext context = 1; + + // Which devices to query. + // Leave unset if all group devices should be queried. + repeated string device_ids = 2; + + // Which feature types to query. + repeated string feature_types = 3; +} + +// Enabled/disabled status of a single device. +message DeviceFeatureStatus { + // Enabled/disabled status of a named feature. + message FeatureStatus { + // Feature type name. + string feature_type = 1; + + // If the feature is enabled. + bool enabled = 2; + } + + // Device identifier. + string device_id = 1; + + // The status of features associated with this device. + repeated FeatureStatus feature_statuses = 2; +} + +// Response to BatchGetFeatureStatuses. +message BatchGetFeatureStatusesResponse { + // The status of all queried group devices. + // Only the requested devices and requested features will be populated. + repeated DeviceFeatureStatus device_feature_statuses = 1; +} + +// Sets feature types enable/disable statuses per device in the group. +message BatchSetFeatureStatusesRequest { + // The context of this request. + RequestContext context = 1; + + // The feature statuses to set for specific devices. + repeated DeviceFeatureStatus device_feature_statuses = 2; + + // Set to true to disable all group devices other than the specified device. + // This can only be used with a single device and only when enabling features. + bool enable_exclusively = 3; +} + +// Response to BatchSetFeatureStatuses. +message BatchSetFeatureStatusesResponse {}
diff --git a/components/BUILD.gn b/components/BUILD.gn index b06476f..a6239ba 100644 --- a/components/BUILD.gn +++ b/components/BUILD.gn
@@ -565,6 +565,7 @@ # a MANUAL component_browsertest. sources += [ "dom_distiller/standalone/content_extractor_browsertest.cc" ] deps += [ + "//components/keyed_service/core:test_support", "//components/leveldb_proto", "//components/leveldb_proto/content:factory", "//components/prefs:test_support",
diff --git a/components/arc/common/app.mojom b/components/arc/common/app.mojom index 8864e87..a453b9d2 100644 --- a/components/arc/common/app.mojom +++ b/components/arc/common/app.mojom
@@ -351,7 +351,7 @@ // TODO(lhchavez): Migrate all request/response messages to Mojo. // Next method ID: 34 -// Deprecated method IDs: 3, 13 +// Deprecated method IDs: 2, 3, 13 interface AppInstance { // DEPRECATED: Please use Init@21 instead. InitDeprecated@0(AppHost host_ptr); @@ -393,12 +393,6 @@ // string. See Intent.toUri(). [MinVersion=23] LaunchIntent@19(string intent_uri, int64 display_id); - // Sends a request to ARC to refresh a list of ARC apps. - // OnRefreshAppsList is expected in response to this message. However, - // response may not be sent if ARC is not ready yet (boot completed event is - // not received). - RefreshAppList@2(); - // Sends a request for the ARC shortcut icon of a given resource id and // |pixel_size|. [MinVersion=36] RequestAppIcon@27(string package_name,
diff --git a/components/arc/test/fake_app_instance.cc b/components/arc/test/fake_app_instance.cc index 0eec2f2c..84cd13c 100644 --- a/components/arc/test/fake_app_instance.cc +++ b/components/arc/test/fake_app_instance.cc
@@ -51,17 +51,10 @@ } void FakeAppInstance::Init(mojom::AppHostPtr host_ptr, InitCallback callback) { - // ARC app instance calls RefreshAppList after Init() successfully. Call - // RefreshAppList() here to keep the same behavior. - RefreshAppList(); host_ = std::move(host_ptr); std::move(callback).Run(); } -void FakeAppInstance::RefreshAppList() { - ++refresh_app_list_count_; -} - void FakeAppInstance::LaunchAppDeprecated( const std::string& package_name, const std::string& activity,
diff --git a/components/arc/test/fake_app_instance.h b/components/arc/test/fake_app_instance.h index 8825833..dfb720d 100644 --- a/components/arc/test/fake_app_instance.h +++ b/components/arc/test/fake_app_instance.h
@@ -88,7 +88,6 @@ // mojom::AppInstance overrides: void InitDeprecated(mojom::AppHostPtr host_ptr) override; void Init(mojom::AppHostPtr host_ptr, InitCallback callback) override; - void RefreshAppList() override; void LaunchAppDeprecated(const std::string& package_name, const std::string& activity, const base::Optional<gfx::Rect>& dimension) override; @@ -202,8 +201,6 @@ bool app_icon, std::string* png_data_as_string); - int refresh_app_list_count() const { return refresh_app_list_count_; } - int start_pai_request_count() const { return start_pai_request_count_; } int start_fast_app_reinstall_request_count() const { @@ -252,8 +249,6 @@ using TaskIdToInfo = std::map<int32_t, std::unique_ptr<Request>>; // Mojo endpoints. mojom::AppHost* app_host_; - // Number of RefreshAppList calls. - int refresh_app_list_count_ = 0; // Number of requests to start PAI flows. int start_pai_request_count_ = 0; // Response for PAI flow state;
diff --git a/components/autofill/core/browser/autofill_client.h b/components/autofill/core/browser/autofill_client.h index af8a204..a60e5f6 100644 --- a/components/autofill/core/browser/autofill_client.h +++ b/components/autofill/core/browser/autofill_client.h
@@ -125,6 +125,11 @@ // Used for options of upload prompt. struct SaveCreditCardOptions { + SaveCreditCardOptions& with_from_dynamic_change_form(bool b) { + from_dynamic_change_form = b; + return *this; + } + SaveCreditCardOptions& with_has_non_focusable_field(bool b) { has_non_focusable_field = b; return *this; @@ -146,6 +151,7 @@ return *this; } + bool from_dynamic_change_form = false; bool has_non_focusable_field = false; bool should_request_name_from_user = false; bool should_request_expiration_date_from_user = false;
diff --git a/components/autofill/core/browser/autofill_handler.cc b/components/autofill/core/browser/autofill_handler.cc index 1841e22..f0af93b 100644 --- a/components/autofill/core/browser/autofill_handler.cc +++ b/components/autofill/core/browser/autofill_handler.cc
@@ -287,6 +287,10 @@ /*only_server_and_autofill_state=*/true); if (observer_for_testing_) observer_for_testing_->OnFormParsed(); + + if (form_structure.get()->value_from_dynamic_change_form()) { + value_from_dynamic_change_form_ = true; + } } form_structure->DetermineHeuristicTypes();
diff --git a/components/autofill/core/browser/autofill_handler.h b/components/autofill/core/browser/autofill_handler.h index d144b54ef..b1744e8 100644 --- a/components/autofill/core/browser/autofill_handler.h +++ b/components/autofill/core/browser/autofill_handler.h
@@ -201,6 +201,8 @@ const FormStructure* cached_form, FormStructure** parsed_form_structure); + bool value_from_dynamic_change_form_ = false; + AutofillDriver* driver() { return driver_; } FormStructureMap* mutable_form_structures() { return &form_structures_; }
diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc index 8fd455c5..94a84dc 100644 --- a/components/autofill/core/browser/autofill_manager.cc +++ b/components/autofill/core/browser/autofill_manager.cc
@@ -1513,6 +1513,10 @@ submitted_form->RetrieveFromCache(*cached_submitted_form, /*should_keep_cached_value=*/false, /*only_server_and_autofill_state=*/false); + if (value_from_dynamic_change_form_) { + submitted_form->set_value_from_dynamic_change_form(true); + } + return submitted_form; }
diff --git a/components/autofill/core/browser/autofill_metrics.cc b/components/autofill/core/browser/autofill_metrics.cc index 6ed7b554..42cce6b0 100644 --- a/components/autofill/core/browser/autofill_metrics.cc +++ b/components/autofill/core/browser/autofill_metrics.cc
@@ -684,6 +684,12 @@ metric, NUM_INFO_BAR_METRICS); } + if (options.from_dynamic_change_form) { + base::UmaHistogramEnumeration( + "Autofill.CreditCardInfoBar" + destination + ".FromDynamicChangeForm", + metric, NUM_INFO_BAR_METRICS); + } + if (options.has_non_focusable_field) { base::UmaHistogramEnumeration( "Autofill.CreditCardInfoBar" + destination + ".FromNonFocusableForm", @@ -746,6 +752,11 @@ metric_with_destination_and_show + ".FromNonFocusableForm", metric, NUM_SAVE_CARD_PROMPT_METRICS); } + if (options.from_dynamic_change_form) { + base::UmaHistogramEnumeration( + metric_with_destination_and_show + ".FromDynamicChangeForm", metric, + NUM_SAVE_CARD_PROMPT_METRICS); + } base::UmaHistogramEnumeration( metric_with_destination_and_show + PreviousSaveCreditCardPromptUserDecisionToString(
diff --git a/components/autofill/core/browser/autofill_metrics.h b/components/autofill/core/browser/autofill_metrics.h index 61bd92c..5202cbb 100644 --- a/components/autofill/core/browser/autofill_metrics.h +++ b/components/autofill/core/browser/autofill_metrics.h
@@ -116,6 +116,9 @@ UPLOAD_OFFERED_FROM_NON_FOCUSABLE_FIELD = 1 << 15, // The card does not satisfy any of the ranges of supported BIN ranges. UPLOAD_NOT_OFFERED_UNSUPPORTED_BIN_RANGE = 1 << 16, + // All the required conditions were satisfied even though the form is + // dynamic changed. + UPLOAD_OFFERED_FROM_DYNAMIC_CHANGE_FORM = 1 << 17, // Update |kNumCardUploadDecisionMetrics| when adding new enum here. }; @@ -1240,7 +1243,7 @@ private: static void Log(AutocompleteEvent event); - static const int kNumCardUploadDecisionMetrics = 17; + static const int kNumCardUploadDecisionMetrics = 18; DISALLOW_IMPLICIT_CONSTRUCTORS(AutofillMetrics); };
diff --git a/components/autofill/core/browser/form_data_importer.cc b/components/autofill/core/browser/form_data_importer.cc index acc03e5..cd52e5f 100644 --- a/components/autofill/core/browser/form_data_importer.cc +++ b/components/autofill/core/browser/form_data_importer.cc
@@ -178,7 +178,8 @@ imported_credit_card_record_type_ == ImportedCreditCardRecordType::NEW_CARD); credit_card_save_manager_->AttemptToOfferCardUploadSave( - submitted_form, has_non_focusable_field_, *imported_credit_card, + submitted_form, from_dynamic_change_form_, has_non_focusable_field_, + *imported_credit_card, /*uploading_local_card=*/imported_credit_card_record_type_ == ImportedCreditCardRecordType::LOCAL_CARD); } else { @@ -186,7 +187,8 @@ DCHECK(imported_credit_card_record_type_ == ImportedCreditCardRecordType::NEW_CARD); credit_card_save_manager_->AttemptToOfferCardLocalSave( - has_non_focusable_field_, *imported_credit_card); + from_dynamic_change_form_, has_non_focusable_field_, + *imported_credit_card); } } @@ -509,6 +511,8 @@ if (field_type.group() != CREDIT_CARD) continue; + if (form.value_from_dynamic_change_form()) + from_dynamic_change_form_ = true; if (!field->is_focusable) has_non_focusable_field_ = true;
diff --git a/components/autofill/core/browser/form_data_importer.h b/components/autofill/core/browser/form_data_importer.h index be28615..9678400 100644 --- a/components/autofill/core/browser/form_data_importer.h +++ b/components/autofill/core/browser/form_data_importer.h
@@ -120,6 +120,9 @@ CreditCard ExtractCreditCardFromForm(const FormStructure& form, bool* hasDuplicateFieldType); + // Whether a dynamic change form is imported. + bool from_dynamic_change_form_ = false; + // Whether the form imported has non-focusable fields after user entered // information into it. bool has_non_focusable_field_ = false;
diff --git a/components/autofill/core/browser/form_structure.cc b/components/autofill/core/browser/form_structure.cc index 08281b2..4f7abcc1 100644 --- a/components/autofill/core/browser/form_structure.cc +++ b/components/autofill/core/browser/form_structure.cc
@@ -933,6 +933,7 @@ base::FeatureList::IsEnabled( features::kAutofillImportDynamicForms)) { field->value = cached_field->second->value; + value_from_dynamic_change_form_ = true; } else if (field->value == cached_field->second->value) { // From the perspective of learning user data, text fields containing // default values are equivalent to empty fields.
diff --git a/components/autofill/core/browser/form_structure.h b/components/autofill/core/browser/form_structure.h index 102920d9..bd2a619 100644 --- a/components/autofill/core/browser/form_structure.h +++ b/components/autofill/core/browser/form_structure.h
@@ -327,6 +327,14 @@ page_language_ = std::move(language); } + bool value_from_dynamic_change_form() const { + return value_from_dynamic_change_form_; + } + + void set_value_from_dynamic_change_form(bool v) { + value_from_dynamic_change_form_ = v; + } + private: friend class AutofillMergeTest; friend class FormStructureTest; @@ -583,6 +591,8 @@ // form/field metadata. bool is_rich_query_enabled_ = false; + bool value_from_dynamic_change_form_ = false; + DISALLOW_COPY_AND_ASSIGN(FormStructure); };
diff --git a/components/autofill/core/browser/payments/credit_card_save_manager.cc b/components/autofill/core/browser/payments/credit_card_save_manager.cc index 6705980..b3505c6 100644 --- a/components/autofill/core/browser/payments/credit_card_save_manager.cc +++ b/components/autofill/core/browser/payments/credit_card_save_manager.cc
@@ -102,11 +102,13 @@ CreditCardSaveManager::~CreditCardSaveManager() {} void CreditCardSaveManager::AttemptToOfferCardLocalSave( + bool from_dynamic_change_form, bool has_non_focusable_field, const CreditCard& card) { local_card_save_candidate_ = card; show_save_prompt_ = base::nullopt; has_non_focusable_field_ = has_non_focusable_field; + from_dynamic_change_form_ = from_dynamic_change_form; // Query the Autofill StrikeDatabase on if we should pop up the // offer-to-save prompt for this card. @@ -131,6 +133,7 @@ void CreditCardSaveManager::AttemptToOfferCardUploadSave( const FormStructure& submitted_form, + bool from_dynamic_change_form, bool has_non_focusable_field, const CreditCard& card, const bool uploading_local_card) { @@ -159,6 +162,7 @@ found_cvc_value_in_non_cvc_field_ = false; has_non_focusable_field_ = has_non_focusable_field; + from_dynamic_change_form_ = from_dynamic_change_form; for (const auto& field : submitted_form) { const bool is_valid_cvc = IsValidCreditCardSecurityCode( @@ -188,7 +192,10 @@ upload_decision_metrics_ |= AutofillMetrics::UPLOAD_OFFERED_FROM_NON_FOCUSABLE_FIELD; } - + if (submitted_form.value_from_dynamic_change_form()) { + upload_decision_metrics_ |= + AutofillMetrics::UPLOAD_OFFERED_FROM_DYNAMIC_CHANGE_FORM; + } if (upload_request_.cvc.empty()) { // Apply the CVC decision to |upload_decision_metrics_| to denote a problem // was found. @@ -445,7 +452,8 @@ features::kAutofillDoNotUploadSaveUnsupportedCards) && !supported_card_bin_ranges.empty() && !IsCreditCardSupported(supported_card_bin_ranges)) { - AttemptToOfferCardLocalSave(has_non_focusable_field_, + AttemptToOfferCardLocalSave(from_dynamic_change_form_, + has_non_focusable_field_, upload_request_.card); upload_decision_metrics_ |= AutofillMetrics::UPLOAD_NOT_OFFERED_UNSUPPORTED_BIN_RANGE; @@ -485,7 +493,8 @@ upload_request_.detected_values & DetectedValue::POSTAL_CODE && upload_request_.detected_values & DetectedValue::CVC; if (found_name_and_postal_code_and_cvc && !uploading_local_card_) { - AttemptToOfferCardLocalSave(has_non_focusable_field_, + AttemptToOfferCardLocalSave(from_dynamic_change_form_, + has_non_focusable_field_, upload_request_.card); } upload_decision_metrics_ |= @@ -539,6 +548,7 @@ client_->ConfirmSaveCreditCardToCloud( upload_request_.card, std::move(legal_message_), AutofillClient::SaveCreditCardOptions() + .with_from_dynamic_change_form(from_dynamic_change_form_) .with_has_non_focusable_field(has_non_focusable_field_) .with_should_request_name_from_user(should_request_name_from_user_) .with_should_request_expiration_date_from_user(
diff --git a/components/autofill/core/browser/payments/credit_card_save_manager.h b/components/autofill/core/browser/payments/credit_card_save_manager.h index 44444215..3319c5f 100644 --- a/components/autofill/core/browser/payments/credit_card_save_manager.h +++ b/components/autofill/core/browser/payments/credit_card_save_manager.h
@@ -97,15 +97,21 @@ // Begins the process to offer local credit card save to the user. // If |has_non_focusable_field| is true, the save is triggered by a form that // has non_focusable fields. - void AttemptToOfferCardLocalSave(bool has_non_focusable_field, + // If |from_dynamic_change_form| is true, the save is triggered by a dynamic + // change form. + void AttemptToOfferCardLocalSave(bool from_dynamic_change_form, + bool has_non_focusable_field, const CreditCard& card); // Begins the process to offer upload credit card save to the user if the // imported card passes all requirements and Google Payments approves. // If |has_non_focusable_field| is true, the save is triggered by a form that // has non-focusable fields. if |uploading_local_card| is true, the card being - // offered for upload is already a local card on the device. + // offered for upload is already a local card on the device. If + // |from_dynamic_change_form| is true, the save is triggered by a dynamic + // change form. void AttemptToOfferCardUploadSave(const FormStructure& submitted_form, + bool from_dynamic_change_form, bool has_non_focusable_field, const CreditCard& card, const bool uploading_local_card); @@ -335,6 +341,10 @@ // |is_focusable| is false. bool has_non_focusable_field_ = false; + // |from_dynamic_change_form_| is |true| values imported from dynamic change + // form. + bool from_dynamic_change_form_ = false; + // The origin of the top level frame from which a form is uploaded. url::Origin pending_upload_request_origin_;
diff --git a/components/content_capture/browser/content_capture_receiver.cc b/components/content_capture/browser/content_capture_receiver.cc index 7af8b37..327b209 100644 --- a/components/content_capture/browser/content_capture_receiver.cc +++ b/components/content_capture/browser/content_capture_receiver.cc
@@ -6,6 +6,7 @@ #include <utility> +#include "base/strings/utf_string_conversions.h" #include "components/content_capture/browser/content_capture_receiver_manager.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/web_contents.h" @@ -36,8 +37,12 @@ if (first_data) { // The session id of this frame isn't changed for new document navigation, // so the previous session should be terminated. - if (frame_content_capture_data_.id != 0) + // The parent frame might be captured after child, we need to check if url + // is changed, otherwise the child frame's session will be removed. + if (frame_content_capture_data_.id != 0 && + frame_content_capture_data_.value != data.value) { manager->DidRemoveSession(this); + } frame_content_capture_data_.id = id_; // Copies everything except id and children. @@ -90,4 +95,22 @@ return content_capture_sender_; } +const ContentCaptureData& ContentCaptureReceiver::GetFrameContentCaptureData() { + base::string16 url = base::UTF8ToUTF16(rfh_->GetLastCommittedURL().spec()); + if (url != frame_content_capture_data_.value) { + if (frame_content_capture_data_.id != 0) { + auto* manager = ContentCaptureReceiverManager::FromWebContents( + content::WebContents::FromRenderFrameHost(rfh_)); + manager->DidRemoveSession(this); + } + + frame_content_capture_data_.id = id_; + frame_content_capture_data_.value = url; + const base::Optional<gfx::Size>& size = rfh_->GetFrameSize(); + if (size.has_value()) + frame_content_capture_data_.bounds = gfx::Rect(size.value()); + } + return frame_content_capture_data_; +} + } // namespace content_capture
diff --git a/components/content_capture/browser/content_capture_receiver.h b/components/content_capture/browser/content_capture_receiver.h index a615bfce..f3a6522 100644 --- a/components/content_capture/browser/content_capture_receiver.h +++ b/components/content_capture/browser/content_capture_receiver.h
@@ -39,9 +39,7 @@ content::RenderFrameHost* rfh() const { return rfh_; } // Return ContentCaptureData of the associated frame. - const ContentCaptureData& frame_content_capture_data() const { - return frame_content_capture_data_; - } + const ContentCaptureData& GetFrameContentCaptureData(); private: const mojom::ContentCaptureSenderAssociatedPtr& GetContentCaptureSender();
diff --git a/components/content_capture/browser/content_capture_receiver_manager.cc b/components/content_capture/browser/content_capture_receiver_manager.cc index 6c8577e..353ef88 100644 --- a/components/content_capture/browser/content_capture_receiver_manager.cc +++ b/components/content_capture/browser/content_capture_receiver_manager.cc
@@ -97,8 +97,8 @@ const ContentCaptureData& data) { // The root of |data| is frame, we need get its ancestor only. ContentCaptureSession parent_session; - BuildContentCaptureSession(*content_capture_receiver, - true /* ancestor_only */, &parent_session); + BuildContentCaptureSession(content_capture_receiver, true /* ancestor_only */, + &parent_session); DidCaptureContent(parent_session, data); } @@ -108,7 +108,7 @@ ContentCaptureSession session; // The |data| is a list of text content id, the session should include // |content_capture_receiver| associated frame. - BuildContentCaptureSession(*content_capture_receiver, + BuildContentCaptureSession(content_capture_receiver, false /* ancestor_only */, &session); DidRemoveContent(session, data); } @@ -118,19 +118,19 @@ ContentCaptureSession session; // The session should include the removed frame that the // |content_capture_receiver| associated with. - BuildContentCaptureSession(*content_capture_receiver, + BuildContentCaptureSession(content_capture_receiver, false /* ancestor_only */, &session); DidRemoveSession(session); } void ContentCaptureReceiverManager::BuildContentCaptureSession( - const ContentCaptureReceiver& content_capture_receiver, + ContentCaptureReceiver* content_capture_receiver, bool ancestor_only, ContentCaptureSession* session) { if (!ancestor_only) - session->push_back(content_capture_receiver.frame_content_capture_data()); + session->push_back(content_capture_receiver->GetFrameContentCaptureData()); - content::RenderFrameHost* rfh = content_capture_receiver.rfh()->GetParent(); + content::RenderFrameHost* rfh = content_capture_receiver->rfh()->GetParent(); while (rfh) { ContentCaptureReceiver* receiver = ContentCaptureReceiverForFrame(rfh); // TODO(michaelbai): Only creates ContentCaptureReceiver here, clean up the @@ -139,7 +139,7 @@ RenderFrameCreated(rfh); receiver = ContentCaptureReceiverForFrame(rfh); } - session->push_back(receiver->frame_content_capture_data()); + session->push_back(receiver->GetFrameContentCaptureData()); rfh = receiver->rfh()->GetParent(); } }
diff --git a/components/content_capture/browser/content_capture_receiver_manager.h b/components/content_capture/browser/content_capture_receiver_manager.h index a4b903d..2e16c4d 100644 --- a/components/content_capture/browser/content_capture_receiver_manager.h +++ b/components/content_capture/browser/content_capture_receiver_manager.h
@@ -76,7 +76,7 @@ // Builds ContentCaptureSession and returns in |session|, |ancestor_only| // specifies if only ancestor should be returned in |session|. void BuildContentCaptureSession( - const ContentCaptureReceiver& content_capture_receiver, + ContentCaptureReceiver* content_capture_receiver, bool ancestor_only, ContentCaptureSession* session);
diff --git a/components/content_capture/browser/content_capture_receiver_test.cc b/components/content_capture/browser/content_capture_receiver_test.cc index 15c2793..1a0b35f 100644 --- a/components/content_capture/browser/content_capture_receiver_test.cc +++ b/components/content_capture/browser/content_capture_receiver_test.cc
@@ -18,6 +18,9 @@ namespace content_capture { namespace { +static const char kMainFrameUrl[] = "http://foo.com/main.html"; +static const char kChildFrameUrl[] = "http://foo.org/child.html"; + // Fake ContentCaptureSender to call ContentCaptureReceiver mojom interface. class FakeContentCaptureSender { public: @@ -104,7 +107,7 @@ ContentCaptureReceiverManager::FromWebContents(web_contents())); // This needed to keep the WebContentsObserverSanityChecker checks happy for // when AppendChild is called. - NavigateAndCommit(GURL("about:blank")); + NavigateAndCommit(GURL(kMainFrameUrl)); content_capture_sender_ = std::make_unique<FakeContentCaptureSender>(); main_frame_ = web_contents()->GetMainFrame(); // Binds sender with receiver. @@ -117,10 +120,10 @@ child.value = base::ASCIIToUTF16("Hello"); child.bounds = gfx::Rect(5, 5, 5, 5); // No need to set id in sender. - test_data_.value = base::ASCIIToUTF16("http://foo.com/bar"); + test_data_.value = base::ASCIIToUTF16(kMainFrameUrl); test_data_.bounds = gfx::Rect(10, 10); test_data_.children.push_back(child); - test_data2_.value = base::ASCIIToUTF16("http://foo.org/bar"); + test_data2_.value = base::ASCIIToUTF16(kChildFrameUrl); test_data2_.bounds = gfx::Rect(10, 10); test_data2_.children.push_back(child); // Update to test_data_. @@ -129,11 +132,16 @@ child2.id = 3; child2.value = base::ASCIIToUTF16("World"); child2.bounds = gfx::Rect(5, 10, 5, 5); - test_data_update_.value = base::ASCIIToUTF16("http://foo.com/bar"); + test_data_update_.value = base::ASCIIToUTF16(kMainFrameUrl); test_data_update_.bounds = gfx::Rect(10, 10); test_data_update_.children.push_back(child2); } + void NavigateMainFrame(const GURL& url) { + NavigateAndCommit(url); + main_frame_ = web_contents()->GetMainFrame(); + } + void SetupChildFrame() { child_content_capture_sender_ = std::make_unique<FakeContentCaptureSender>(); @@ -197,6 +205,7 @@ EXPECT_EQ(expected[i].id, result[i].id); EXPECT_EQ(expected[i].value, result[i].value); EXPECT_EQ(expected[i].bounds, result[i].bounds); + EXPECT_TRUE(result[i].children.empty()); } } @@ -347,6 +356,42 @@ content_capture_receiver_manager_helper()->captured_data()); } +TEST_F(ContentCaptureReceiverTest, ChildFrameCaptureContentFirst) { + // Simulate add child frame. + SetupChildFrame(); + // Simulate to capture the content from child frame. + DidCaptureContentForChildFrame(test_data2(), true /* first_data */); + // Verifies that the parent_session was set correctly. + EXPECT_FALSE( + content_capture_receiver_manager_helper()->parent_session().empty()); + + ContentCaptureData data = GetExpectedTestData(true /* main_frame */); + // Currently, there is no way to fake frame size, set it to 0. + data.bounds = gfx::Rect(); + std::vector<ContentCaptureData> expected{data}; + + VerifySession(expected, + content_capture_receiver_manager_helper()->parent_session()); + EXPECT_TRUE( + content_capture_receiver_manager_helper()->removed_session().empty()); + // Verifies that we receive the correct content from child frame. + EXPECT_EQ(GetExpectedTestData2(false /* main_frame */), + content_capture_receiver_manager_helper()->captured_data()); + + // When main frame navigates to another URL, the parent session will change. + NavigateMainFrame(GURL(kChildFrameUrl)); + SetupChildFrame(); + DidCaptureContentForChildFrame(test_data2(), true /* first_data */); + + data = GetExpectedTestData2(true /* main_frame */); + // Currently, there is no way to fake frame size, set it to 0. + data.bounds = gfx::Rect(); + expected.clear(); + expected.push_back(data); + VerifySession(expected, + content_capture_receiver_manager_helper()->parent_session()); +} + class ContentCaptureReceiverMultipleFrameTest : public ContentCaptureReceiverTest { public:
diff --git a/components/content_settings/core/browser/host_content_settings_map.cc b/components/content_settings/core/browser/host_content_settings_map.cc index e0aaecc7..bec96ef 100644 --- a/components/content_settings/core/browser/host_content_settings_map.cc +++ b/components/content_settings/core/browser/host_content_settings_map.cc
@@ -68,8 +68,8 @@ {"policy", content_settings::SETTING_SOURCE_POLICY}, {"supervised_user", content_settings::SETTING_SOURCE_SUPERVISED}, {"extension", content_settings::SETTING_SOURCE_EXTENSION}, - // TODO(peconn): Create a SETTING_SOURCE_WEBAPP. - {"installed_webapp_provider", content_settings::SETTING_SOURCE_POLICY}, + {"installed_webapp_provider", + content_settings::SETTING_SOURCE_INSTALLED_WEBAPP}, {"notification_android", content_settings::SETTING_SOURCE_USER}, {"ephemeral", content_settings::SETTING_SOURCE_USER}, {"preference", content_settings::SETTING_SOURCE_USER},
diff --git a/components/content_settings/core/common/content_settings.h b/components/content_settings/core/common/content_settings.h index fb162fc..0565046 100644 --- a/components/content_settings/core/common/content_settings.h +++ b/components/content_settings/core/common/content_settings.h
@@ -92,6 +92,7 @@ SETTING_SOURCE_USER, SETTING_SOURCE_WHITELIST, SETTING_SOURCE_SUPERVISED, + SETTING_SOURCE_INSTALLED_WEBAPP, }; // |SettingInfo| provides meta data for content setting values. |source|
diff --git a/components/dom_distiller/standalone/content_extractor_browsertest.cc b/components/dom_distiller/standalone/content_extractor_browsertest.cc index 1a5c1100..fbcdff4 100644 --- a/components/dom_distiller/standalone/content_extractor_browsertest.cc +++ b/components/dom_distiller/standalone/content_extractor_browsertest.cc
@@ -32,7 +32,7 @@ #include "components/dom_distiller/core/proto/distilled_article.pb.h" #include "components/dom_distiller/core/proto/distilled_page.pb.h" #include "components/dom_distiller/core/task_tracker.h" -#include "components/keyed_service/core/simple_factory_key.h" +#include "components/keyed_service/core/test_simple_factory_key.h" #include "components/leveldb_proto/content/proto_database_provider_factory.h" #include "components/leveldb_proto/public/proto_database.h" #include "components/leveldb_proto/public/proto_database_provider.h" @@ -139,7 +139,7 @@ DistilledPagePrefs::RegisterProfilePrefs(pref_service->registry()); auto* db_provider = - leveldb_proto::ProtoDatabaseProviderFactory::GetForKey(key, pref_service); + leveldb_proto::ProtoDatabaseProviderFactory::GetForKey(key); // TODO(cjhopman): use an in-memory database instead of an on-disk one with // temporary directory. @@ -357,7 +357,8 @@ command_line, &file_to_url_map); content::BrowserContext* context = shell()->web_contents()->GetBrowserContext(); - key_ = std::make_unique<SimpleFactoryKey>(context->GetPath()); + key_ = std::make_unique<TestSimpleFactoryKey>(context->GetPath(), + context->IsOffTheRecord()); pref_service_ = std::make_unique<sync_preferences::TestingPrefServiceSyncable>();
diff --git a/components/download/content/factory/download_service_factory_helper.cc b/components/download/content/factory/download_service_factory_helper.cc index 255017b1..720653b 100644 --- a/components/download/content/factory/download_service_factory_helper.cc +++ b/components/download/content/factory/download_service_factory_helper.cc
@@ -113,8 +113,8 @@ auto entry_db_storage_dir = storage_dir.Append(kEntryDBStorageDir); leveldb_proto::ProtoDatabaseProvider* db_provider = - leveldb_proto::ProtoDatabaseProviderFactory::GetForKey(simple_factory_key, - prefs); + leveldb_proto::ProtoDatabaseProviderFactory::GetForKey( + simple_factory_key); auto entry_db = db_provider->GetDB<protodb::Entry>( leveldb_proto::ProtoDbType::DOWNLOAD_STORE, entry_db_storage_dir, background_task_runner);
diff --git a/components/download/content/factory/navigation_monitor_factory.cc b/components/download/content/factory/navigation_monitor_factory.cc index f3bded4..f351090f9 100644 --- a/components/download/content/factory/navigation_monitor_factory.cc +++ b/components/download/content/factory/navigation_monitor_factory.cc
@@ -18,7 +18,7 @@ download::NavigationMonitor* NavigationMonitorFactory::GetForKey( SimpleFactoryKey* key) { return static_cast<download::NavigationMonitor*>( - GetInstance()->GetServiceForKey(key, /*prefs=*/nullptr, true)); + GetInstance()->GetServiceForKey(key, true)); } NavigationMonitorFactory::NavigationMonitorFactory() @@ -28,8 +28,7 @@ NavigationMonitorFactory::~NavigationMonitorFactory() = default; std::unique_ptr<KeyedService> NavigationMonitorFactory::BuildServiceInstanceFor( - SimpleFactoryKey* key, - PrefService* prefs) const { + SimpleFactoryKey* key) const { return std::make_unique<NavigationMonitorImpl>(); }
diff --git a/components/download/content/factory/navigation_monitor_factory.h b/components/download/content/factory/navigation_monitor_factory.h index df58847..354909b 100644 --- a/components/download/content/factory/navigation_monitor_factory.h +++ b/components/download/content/factory/navigation_monitor_factory.h
@@ -29,8 +29,7 @@ // SimpleKeyedServiceFactory implementation. std::unique_ptr<KeyedService> BuildServiceInstanceFor( - SimpleFactoryKey* key, - PrefService* prefs) const override; + SimpleFactoryKey* key) const override; SimpleFactoryKey* GetKeyToUse(SimpleFactoryKey* key) const override; DISALLOW_COPY_AND_ASSIGN(NavigationMonitorFactory);
diff --git a/components/gwp_asan/client/guarded_page_allocator.cc b/components/gwp_asan/client/guarded_page_allocator.cc index ac78538..455d3594 100644 --- a/components/gwp_asan/client/guarded_page_allocator.cc +++ b/components/gwp_asan/client/guarded_page_allocator.cc
@@ -176,19 +176,17 @@ const uintptr_t addr = reinterpret_cast<uintptr_t>(ptr); AllocatorState::SlotIdx slot = state_.AddrToSlot(state_.GetPageAddr(addr)); AllocatorState::MetadataIdx metadata_idx = slot_to_metadata_idx_[slot]; +#if !defined(OS_MACOSX) CHECK_LT(metadata_idx, state_.num_metadata); - if (addr != metadata_[metadata_idx].alloc_ptr) { - // TODO(https://crbug.com/946736): Temporary code to help debug a macOS - // crash that happens when malloc_size() is called with what appears to be - // an invalid allocation address. - static crash_reporter::CrashKeyString<64> gpa_crash_key("crbug-946736"); - gpa_crash_key.Set( - base::StringPrintf("%zx %zx", addr, metadata_[metadata_idx].alloc_ptr)); - uintptr_t nearest_guard_page = - state_.GetPageAddr(state_.GetNearestValidPage(addr)) - 1; - *reinterpret_cast<char*>(nearest_guard_page) = 0; - CHECK(false); - } + CHECK_EQ(addr, metadata_[metadata_idx].alloc_ptr); +#else + // macOS core libraries call malloc_size() inside an allocation. The macOS + // malloc_size() returns 0 when the pointer is not recognized. + // https://crbug.com/946736 + if (metadata_idx == AllocatorState::kInvalidMetadataIdx || + addr != metadata_[metadata_idx].alloc_ptr) + return 0; +#endif return metadata_[metadata_idx].alloc_size; }
diff --git a/components/gwp_asan/client/guarded_page_allocator_unittest.cc b/components/gwp_asan/client/guarded_page_allocator_unittest.cc index d4d82bc..b7a6268f 100644 --- a/components/gwp_asan/client/guarded_page_allocator_unittest.cc +++ b/components/gwp_asan/client/guarded_page_allocator_unittest.cc
@@ -13,6 +13,7 @@ #include "base/process/process_metrics.h" #include "base/test/gtest_util.h" #include "base/threading/simple_thread.h" +#include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" namespace gwp_asan { @@ -90,6 +91,16 @@ EXPECT_FALSE(gpa_.PointerIsMine(malloc_ptr.get())); } +TEST_F(GuardedPageAllocatorTest, GetRequestedSize) { + void* buf = gpa_.Allocate(100); + EXPECT_EQ(gpa_.GetRequestedSize(buf), 100U); +#if !defined(OS_MACOSX) + EXPECT_DEATH({ gpa_.GetRequestedSize((char*)buf + 1); }, ""); +#else + EXPECT_EQ(gpa_.GetRequestedSize((char*)buf + 1), 0U); +#endif +} + TEST_F(GuardedPageAllocatorTest, LeftAlignedAllocation) { char* buf = GetAlignedAllocation(true, 16); ASSERT_NE(buf, nullptr);
diff --git a/components/keyed_service/content/browser_context_keyed_service_factory.cc b/components/keyed_service/content/browser_context_keyed_service_factory.cc index 415aa7a7..19046586 100644 --- a/components/keyed_service/content/browser_context_keyed_service_factory.cc +++ b/components/keyed_service/content/browser_context_keyed_service_factory.cc
@@ -34,7 +34,7 @@ TestingFactory testing_factory) { DCHECK(testing_factory); return KeyedServiceFactory::SetTestingFactoryAndUse( - context, nullptr /* side_parameter */, + context, base::BindRepeating( [](const TestingFactory& testing_factory, void* context) { return testing_factory.Run( @@ -54,8 +54,7 @@ KeyedService* BrowserContextKeyedServiceFactory::GetServiceForBrowserContext( content::BrowserContext* context, bool create) { - return KeyedServiceFactory::GetServiceForContext( - context, nullptr /* side_parameter */, create); + return KeyedServiceFactory::GetServiceForContext(context, create); } content::BrowserContext* @@ -92,8 +91,7 @@ std::unique_ptr<KeyedService> BrowserContextKeyedServiceFactory::BuildServiceInstanceFor( - void* context, - void* side_parameter) const { + void* context) const { // TODO(isherman): The wrapped BuildServiceInstanceFor() should return a // scoped_ptr as well. return base::WrapUnique( @@ -127,6 +125,5 @@ } void BrowserContextKeyedServiceFactory::CreateServiceNow(void* context) { - KeyedServiceFactory::GetServiceForContext(context, - nullptr /* side_parameter */, true); + KeyedServiceFactory::GetServiceForContext(context, true); }
diff --git a/components/keyed_service/content/browser_context_keyed_service_factory.h b/components/keyed_service/content/browser_context_keyed_service_factory.h index e6ec079b..1df7c684 100644 --- a/components/keyed_service/content/browser_context_keyed_service_factory.h +++ b/components/keyed_service/content/browser_context_keyed_service_factory.h
@@ -122,8 +122,7 @@ // KeyedServiceFactory: std::unique_ptr<KeyedService> BuildServiceInstanceFor( - void* context, - void* side_parameter) const final; + void* context) const final; bool IsOffTheRecord(void* context) const final; // KeyedServiceBaseFactory:
diff --git a/components/keyed_service/content/refcounted_browser_context_keyed_service_factory.cc b/components/keyed_service/content/refcounted_browser_context_keyed_service_factory.cc index 9cd0663..3158079 100644 --- a/components/keyed_service/content/refcounted_browser_context_keyed_service_factory.cc +++ b/components/keyed_service/content/refcounted_browser_context_keyed_service_factory.cc
@@ -32,7 +32,7 @@ TestingFactory testing_factory) { DCHECK(testing_factory); return RefcountedKeyedServiceFactory::SetTestingFactoryAndUse( - context, nullptr /* side_parameter */, + context, base::BindRepeating( [](const TestingFactory& testing_factory, void* context) { return testing_factory.Run( @@ -55,8 +55,7 @@ RefcountedBrowserContextKeyedServiceFactory::GetServiceForBrowserContext( content::BrowserContext* context, bool create) { - return RefcountedKeyedServiceFactory::GetServiceForContext( - context, nullptr /* side_parameter */, create); + return RefcountedKeyedServiceFactory::GetServiceForContext(context, create); } content::BrowserContext* @@ -94,8 +93,7 @@ scoped_refptr<RefcountedKeyedService> RefcountedBrowserContextKeyedServiceFactory::BuildServiceInstanceFor( - void* context, - void* side_parameter) const { + void* context) const { return BuildServiceInstanceFor( static_cast<content::BrowserContext*>(context)); }
diff --git a/components/keyed_service/content/refcounted_browser_context_keyed_service_factory.h b/components/keyed_service/content/refcounted_browser_context_keyed_service_factory.h index 0e9090cc..46283ece 100644 --- a/components/keyed_service/content/refcounted_browser_context_keyed_service_factory.h +++ b/components/keyed_service/content/refcounted_browser_context_keyed_service_factory.h
@@ -127,8 +127,7 @@ // RefcountedKeyedServiceFactory: scoped_refptr<RefcountedKeyedService> BuildServiceInstanceFor( - void* context, - void* side_parameter) const final; + void* context) const final; bool IsOffTheRecord(void* context) const final; // KeyedServiceBaseFactory:
diff --git a/components/keyed_service/core/BUILD.gn b/components/keyed_service/core/BUILD.gn index ae58817..bf7fbb42 100644 --- a/components/keyed_service/core/BUILD.gn +++ b/components/keyed_service/core/BUILD.gn
@@ -43,6 +43,23 @@ ] } +component("test_support") { + testonly = true + + output_name = "keyed_service_test_support" + sources = [ + "test_simple_factory_key.cc", + "test_simple_factory_key.h", + ] + + defines = [ "KEYED_SERVICE_IMPLEMENTATION" ] + + deps = [ + ":core", + "//base", + ] +} + source_set("unit_tests") { testonly = true sources = [
diff --git a/components/keyed_service/core/keyed_service_factory.cc b/components/keyed_service/core/keyed_service_factory.cc index 406a9df..635df28 100644 --- a/components/keyed_service/core/keyed_service_factory.cc +++ b/components/keyed_service/core/keyed_service_factory.cc
@@ -40,15 +40,13 @@ KeyedService* KeyedServiceFactory::SetTestingFactoryAndUse( void* context, - void* side_parameter, TestingFactory testing_factory) { DCHECK(testing_factory); SetTestingFactory(context, std::move(testing_factory)); - return GetServiceForContext(context, side_parameter, true); + return GetServiceForContext(context, true); } KeyedService* KeyedServiceFactory::GetServiceForContext(void* context, - void* side_parameter, bool create) { TRACE_EVENT1("browser,startup", "KeyedServiceFactory::GetServiceForContext", "service_name", name()); @@ -76,7 +74,7 @@ service = factory_iterator->second.Run(context); } } else { - service = BuildServiceInstanceFor(context, side_parameter); + service = BuildServiceInstanceFor(context); } return Associate(context, std::move(service));
diff --git a/components/keyed_service/core/keyed_service_factory.h b/components/keyed_service/core/keyed_service_factory.h index 11e7d3f..fdc15dce 100644 --- a/components/keyed_service/core/keyed_service_factory.h +++ b/components/keyed_service/core/keyed_service_factory.h
@@ -46,16 +46,13 @@ // created KeyedService. Since the factory will be used immediately, it may // not be empty. KeyedService* SetTestingFactoryAndUse(void* context, - void* side_parameter, TestingFactory testing_factory); // Common implementation that maps |context| to some service object. Deals // with incognito contexts per subclass instructions with GetContextToUse() // method on the base. If |create| is true, the service will be created - // using BuildServiceInstanceFor() if it doesn't already exist. Subclasses - // could pass |side_parameters| object if needed to create a service object. + // using BuildServiceInstanceFor() if it doesn't already exist. KeyedService* GetServiceForContext(void* context, - void* side_parameter, bool create); // Maps |context| to |service| with debug checks to prevent duplication and @@ -69,8 +66,7 @@ // |side_parameter| could be nullptr or some object required to create a // service instance. virtual std::unique_ptr<KeyedService> BuildServiceInstanceFor( - void* context, - void* side_parameter) const = 0; + void* context) const = 0; // Returns whether the |context| is off-the-record or not. virtual bool IsOffTheRecord(void* context) const = 0;
diff --git a/components/keyed_service/core/refcounted_keyed_service_factory.cc b/components/keyed_service/core/refcounted_keyed_service_factory.cc index a6d2efef..5bde50c2 100644 --- a/components/keyed_service/core/refcounted_keyed_service_factory.cc +++ b/components/keyed_service/core/refcounted_keyed_service_factory.cc
@@ -40,16 +40,14 @@ scoped_refptr<RefcountedKeyedService> RefcountedKeyedServiceFactory::SetTestingFactoryAndUse( void* context, - void* side_parameter, TestingFactory testing_factory) { DCHECK(testing_factory); SetTestingFactory(context, std::move(testing_factory)); - return GetServiceForContext(context, side_parameter, true); + return GetServiceForContext(context, true); } scoped_refptr<RefcountedKeyedService> RefcountedKeyedServiceFactory::GetServiceForContext(void* context, - void* side_parameter, bool create) { context = GetContextToUse(context); if (!context) @@ -75,7 +73,7 @@ service = factory_iterator->second.Run(context); } } else { - service = BuildServiceInstanceFor(context, side_parameter); + service = BuildServiceInstanceFor(context); } return Associate(context, std::move(service)); @@ -124,5 +122,5 @@ } void RefcountedKeyedServiceFactory::CreateServiceNow(void* context) { - GetServiceForContext(context, nullptr /* side_parameter */, true); + GetServiceForContext(context, true); }
diff --git a/components/keyed_service/core/refcounted_keyed_service_factory.h b/components/keyed_service/core/refcounted_keyed_service_factory.h index b1a416c9..f90f4b0 100644 --- a/components/keyed_service/core/refcounted_keyed_service_factory.h +++ b/components/keyed_service/core/refcounted_keyed_service_factory.h
@@ -49,16 +49,14 @@ // not be empty. scoped_refptr<RefcountedKeyedService> SetTestingFactoryAndUse( void* context, - void* side_parameter, TestingFactory testing_factory); // Common implementation that maps |context| to some service object. Deals // with incognito contexts per subclass instructions with GetContextToUse() // method on the base. If |create| is true, the service will be created - // using BuildServiceInstanceFor() if it doesn't already exist. Subclasses - // could pass |side_parameters| object if needed to create a service object. - scoped_refptr<RefcountedKeyedService> - GetServiceForContext(void* context, void* side_parameter, bool create); + // using BuildServiceInstanceFor() if it doesn't already exist. + scoped_refptr<RefcountedKeyedService> GetServiceForContext(void* context, + bool create); // Maps |context| to |service| with debug checks to prevent duplication and // returns |service|. @@ -70,11 +68,9 @@ void Disassociate(void* context); // Returns a new RefcountedKeyedService that will be associated with - // |context|. The |side_parameter| could be nullptr or some object required - // to create a service instance. + // |context|. virtual scoped_refptr<RefcountedKeyedService> BuildServiceInstanceFor( - void* context, - void* side_parameter) const = 0; + void* context) const = 0; // Returns whether the |context| is off-the-record or not. virtual bool IsOffTheRecord(void* context) const = 0;
diff --git a/components/keyed_service/core/simple_factory_key.cc b/components/keyed_service/core/simple_factory_key.cc index 17d891c..818c73f9 100644 --- a/components/keyed_service/core/simple_factory_key.cc +++ b/components/keyed_service/core/simple_factory_key.cc
@@ -4,8 +4,6 @@ #include "components/keyed_service/core/simple_factory_key.h" -SimpleFactoryKey::SimpleFactoryKey(const base::FilePath& path, - SimpleFactoryKey* original_key) - : path_(path), original_key_(original_key) {} +SimpleFactoryKey::SimpleFactoryKey(const base::FilePath& path) : path_(path) {} SimpleFactoryKey::~SimpleFactoryKey() = default;
diff --git a/components/keyed_service/core/simple_factory_key.h b/components/keyed_service/core/simple_factory_key.h index 1274adf..1003a693 100644 --- a/components/keyed_service/core/simple_factory_key.h +++ b/components/keyed_service/core/simple_factory_key.h
@@ -17,20 +17,16 @@ // responsibility of the embedder. class KEYED_SERVICE_EXPORT SimpleFactoryKey { public: - explicit SimpleFactoryKey(const base::FilePath& path, - SimpleFactoryKey* original_key = nullptr); - ~SimpleFactoryKey(); + explicit SimpleFactoryKey(const base::FilePath& path); + virtual ~SimpleFactoryKey(); const base::FilePath& path() const { return path_; } - bool is_off_the_record() const { return original_key_ != nullptr; } - SimpleFactoryKey* original_key() { return original_key_; } + + virtual bool is_off_the_record() const = 0; private: base::FilePath path_; - // Points to the original (non off-the-record) SimpleFactoryKey. - SimpleFactoryKey* original_key_ = nullptr; - DISALLOW_COPY_AND_ASSIGN(SimpleFactoryKey); };
diff --git a/components/keyed_service/core/simple_keyed_service_factory.cc b/components/keyed_service/core/simple_keyed_service_factory.cc index 6bf0b7b5..47038a8 100644 --- a/components/keyed_service/core/simple_keyed_service_factory.cc +++ b/components/keyed_service/core/simple_keyed_service_factory.cc
@@ -27,11 +27,10 @@ KeyedService* SimpleKeyedServiceFactory::SetTestingFactoryAndUse( SimpleFactoryKey* key, - PrefService* prefs, TestingFactory testing_factory) { DCHECK(testing_factory); return KeyedServiceFactory::SetTestingFactoryAndUse( - key, prefs, + key, base::BindRepeating( [](const TestingFactory& testing_factory, void* context) { return testing_factory.Run(static_cast<SimpleFactoryKey*>(context)); @@ -47,11 +46,10 @@ SimpleKeyedServiceFactory::~SimpleKeyedServiceFactory() {} KeyedService* SimpleKeyedServiceFactory::GetServiceForKey(SimpleFactoryKey* key, - PrefService* prefs, bool create) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - return KeyedServiceFactory::GetServiceForContext(key, prefs, create); + return KeyedServiceFactory::GetServiceForContext(key, create); } SimpleFactoryKey* SimpleKeyedServiceFactory::GetKeyToUse( @@ -76,10 +74,8 @@ } std::unique_ptr<KeyedService> -SimpleKeyedServiceFactory::BuildServiceInstanceFor(void* context, - void* side_parameter) const { - return BuildServiceInstanceFor(static_cast<SimpleFactoryKey*>(context), - static_cast<PrefService*>(side_parameter)); +SimpleKeyedServiceFactory::BuildServiceInstanceFor(void* context) const { + return BuildServiceInstanceFor(static_cast<SimpleFactoryKey*>(context)); } bool SimpleKeyedServiceFactory::IsOffTheRecord(void* context) const {
diff --git a/components/keyed_service/core/simple_keyed_service_factory.h b/components/keyed_service/core/simple_keyed_service_factory.h index 25ce3654..c552b4d 100644 --- a/components/keyed_service/core/simple_keyed_service_factory.h +++ b/components/keyed_service/core/simple_keyed_service_factory.h
@@ -13,7 +13,6 @@ #include "components/keyed_service/core/keyed_service_factory.h" class KeyedService; -class PrefService; class SimpleDependencyManager; class SimpleFactoryKey; @@ -77,7 +76,6 @@ // created KeyedService. Since the factory will be used immediately, it may // not be empty. KeyedService* SetTestingFactoryAndUse(SimpleFactoryKey* key, - PrefService* prefs, TestingFactory testing_factory); protected: @@ -92,7 +90,6 @@ // service will be created using BuildServiceInstanceFor() if it doesn't // already exist. KeyedService* GetServiceForKey(SimpleFactoryKey* key, - PrefService* prefs, bool create); // Interface for people building a concrete FooServiceFactory: -------------- @@ -105,8 +102,7 @@ // All subclasses of SimpleKeyedServiceFactory must return a // KeyedService. virtual std::unique_ptr<KeyedService> BuildServiceInstanceFor( - SimpleFactoryKey* key, - PrefService* prefs) const = 0; + SimpleFactoryKey* key) const = 0; // A helper object actually listens for notifications about BrowserContext // destruction, calculates the order in which things are destroyed and then @@ -132,8 +128,7 @@ // KeyedServiceFactory: std::unique_ptr<KeyedService> BuildServiceInstanceFor( - void* context, - void* side_parameter) const final; + void* context) const final; bool IsOffTheRecord(void* context) const final; // KeyedServiceBaseFactory:
diff --git a/components/keyed_service/core/test_simple_factory_key.cc b/components/keyed_service/core/test_simple_factory_key.cc new file mode 100644 index 0000000..31eded0 --- /dev/null +++ b/components/keyed_service/core/test_simple_factory_key.cc
@@ -0,0 +1,15 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/keyed_service/core/test_simple_factory_key.h" + +TestSimpleFactoryKey::TestSimpleFactoryKey(const base::FilePath& path, + bool is_off_the_record) + : SimpleFactoryKey(path), is_off_the_record_(is_off_the_record) {} + +TestSimpleFactoryKey::~TestSimpleFactoryKey() = default; + +bool TestSimpleFactoryKey::is_off_the_record() const { + return is_off_the_record_; +}
diff --git a/components/keyed_service/core/test_simple_factory_key.h b/components/keyed_service/core/test_simple_factory_key.h new file mode 100644 index 0000000..c5d0cf3 --- /dev/null +++ b/components/keyed_service/core/test_simple_factory_key.h
@@ -0,0 +1,28 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_KEYED_SERVICE_CORE_TEST_SIMPLE_FACTORY_KEY_H_ +#define COMPONENTS_KEYED_SERVICE_CORE_TEST_SIMPLE_FACTORY_KEY_H_ + +#include "base/files/file_path.h" +#include "base/macros.h" +#include "components/keyed_service/core/simple_factory_key.h" + +// A fake SimpleFactoryKey for testing. +class KEYED_SERVICE_EXPORT TestSimpleFactoryKey : public SimpleFactoryKey { + public: + TestSimpleFactoryKey(const base::FilePath& path, + bool is_off_the_record = false); + ~TestSimpleFactoryKey() override; + + // SimpleFactoryKey implementation. + bool is_off_the_record() const override; + + private: + bool is_off_the_record_; + + DISALLOW_COPY_AND_ASSIGN(TestSimpleFactoryKey); +}; + +#endif // COMPONENTS_KEYED_SERVICE_CORE_TEST_SIMPLE_FACTORY_KEY_H_
diff --git a/components/keyed_service/ios/browser_state_keyed_service_factory.cc b/components/keyed_service/ios/browser_state_keyed_service_factory.cc index 365a96df..533a3a2 100644 --- a/components/keyed_service/ios/browser_state_keyed_service_factory.cc +++ b/components/keyed_service/ios/browser_state_keyed_service_factory.cc
@@ -29,7 +29,7 @@ TestingFactory testing_factory) { DCHECK(testing_factory); return KeyedServiceFactory::SetTestingFactoryAndUse( - context, nullptr /* side_parameter */, + context, base::BindRepeating( [](const TestingFactory& testing_factory, void* context) { return testing_factory.Run( @@ -49,8 +49,7 @@ KeyedService* BrowserStateKeyedServiceFactory::GetServiceForBrowserState( web::BrowserState* context, bool create) { - return KeyedServiceFactory::GetServiceForContext( - context, nullptr /* side_parameter */, create); + return KeyedServiceFactory::GetServiceForContext(context, create); } web::BrowserState* BrowserStateKeyedServiceFactory::GetBrowserStateToUse( @@ -84,9 +83,7 @@ } std::unique_ptr<KeyedService> -BrowserStateKeyedServiceFactory::BuildServiceInstanceFor( - void* context, - void* side_parameter) const { +BrowserStateKeyedServiceFactory::BuildServiceInstanceFor(void* context) const { return BuildServiceInstanceFor(static_cast<web::BrowserState*>(context)); } @@ -117,6 +114,5 @@ } void BrowserStateKeyedServiceFactory::CreateServiceNow(void* context) { - KeyedServiceFactory::GetServiceForContext(context, - nullptr /* side_parameter */, true); + KeyedServiceFactory::GetServiceForContext(context, true); }
diff --git a/components/keyed_service/ios/browser_state_keyed_service_factory.h b/components/keyed_service/ios/browser_state_keyed_service_factory.h index 95711d32..05d2c58 100644 --- a/components/keyed_service/ios/browser_state_keyed_service_factory.h +++ b/components/keyed_service/ios/browser_state_keyed_service_factory.h
@@ -117,8 +117,7 @@ // KeyedServiceFactory: std::unique_ptr<KeyedService> BuildServiceInstanceFor( - void* context, - void* side_parameter) const final; + void* context) const final; bool IsOffTheRecord(void* context) const final; // KeyedServiceBaseFactory:
diff --git a/components/keyed_service/ios/refcounted_browser_state_keyed_service_factory.cc b/components/keyed_service/ios/refcounted_browser_state_keyed_service_factory.cc index 316319d..bf18ad5f 100644 --- a/components/keyed_service/ios/refcounted_browser_state_keyed_service_factory.cc +++ b/components/keyed_service/ios/refcounted_browser_state_keyed_service_factory.cc
@@ -31,7 +31,7 @@ TestingFactory testing_factory) { DCHECK(testing_factory); return RefcountedKeyedServiceFactory::SetTestingFactoryAndUse( - context, nullptr /* side_parameter*/, + context, base::BindRepeating( [](const TestingFactory& testing_factory, void* context) { return testing_factory.Run( @@ -54,8 +54,7 @@ RefcountedBrowserStateKeyedServiceFactory::GetServiceForBrowserState( web::BrowserState* context, bool create) { - return RefcountedKeyedServiceFactory::GetServiceForContext( - context, nullptr /* side_parameter*/, create); + return RefcountedKeyedServiceFactory::GetServiceForContext(context, create); } web::BrowserState* @@ -93,8 +92,7 @@ scoped_refptr<RefcountedKeyedService> RefcountedBrowserStateKeyedServiceFactory::BuildServiceInstanceFor( - void* context, - void* side_parameter) const { + void* context) const { return BuildServiceInstanceFor(static_cast<web::BrowserState*>(context)); }
diff --git a/components/keyed_service/ios/refcounted_browser_state_keyed_service_factory.h b/components/keyed_service/ios/refcounted_browser_state_keyed_service_factory.h index a0da0c05..8093c82 100644 --- a/components/keyed_service/ios/refcounted_browser_state_keyed_service_factory.h +++ b/components/keyed_service/ios/refcounted_browser_state_keyed_service_factory.h
@@ -122,8 +122,7 @@ // RefcountedKeyedServiceFactory: scoped_refptr<RefcountedKeyedService> BuildServiceInstanceFor( - void* context, - void* side_parameter) const final; + void* context) const final; bool IsOffTheRecord(void* context) const final; // KeyedServiceBaseFactory:
diff --git a/components/leveldb_proto/content/proto_database_provider_factory.cc b/components/leveldb_proto/content/proto_database_provider_factory.cc index 65c45c36..bfac697 100644 --- a/components/leveldb_proto/content/proto_database_provider_factory.cc +++ b/components/leveldb_proto/content/proto_database_provider_factory.cc
@@ -20,10 +20,9 @@ // static ProtoDatabaseProvider* ProtoDatabaseProviderFactory::GetForKey( - SimpleFactoryKey* key, - PrefService* prefs) { + SimpleFactoryKey* key) { return static_cast<ProtoDatabaseProvider*>( - GetInstance()->GetServiceForKey(key, prefs, true)); + GetInstance()->GetServiceForKey(key, true)); } ProtoDatabaseProviderFactory::ProtoDatabaseProviderFactory() @@ -34,8 +33,7 @@ std::unique_ptr<KeyedService> ProtoDatabaseProviderFactory::BuildServiceInstanceFor( - SimpleFactoryKey* key, - PrefService* prefs) const { + SimpleFactoryKey* key) const { return std::make_unique<ProtoDatabaseProvider>(key->path()); }
diff --git a/components/leveldb_proto/content/proto_database_provider_factory.h b/components/leveldb_proto/content/proto_database_provider_factory.h index 0126a39f..7578b51 100644 --- a/components/leveldb_proto/content/proto_database_provider_factory.h +++ b/components/leveldb_proto/content/proto_database_provider_factory.h
@@ -11,7 +11,6 @@ #include "components/keyed_service/core/simple_keyed_service_factory.h" class KeyedService; -class PrefService; class SimpleFactoryKey; namespace base { @@ -31,8 +30,7 @@ // Returns ProtoDatabaseProvider associated with |key|, so we can // instantiate ProtoDatabases that use the appropriate profile directory. - static ProtoDatabaseProvider* GetForKey(SimpleFactoryKey* key, - PrefService* prefs); + static ProtoDatabaseProvider* GetForKey(SimpleFactoryKey* key); private: friend class base::NoDestructor<ProtoDatabaseProviderFactory>; @@ -42,8 +40,7 @@ // SimpleKeyedServiceFactory overrides: std::unique_ptr<KeyedService> BuildServiceInstanceFor( - SimpleFactoryKey* key, - PrefService* prefs) const override; + SimpleFactoryKey* key) const override; DISALLOW_COPY_AND_ASSIGN(ProtoDatabaseProviderFactory); };
diff --git a/components/offline_pages/core/prefetch/generate_page_bundle_request.cc b/components/offline_pages/core/prefetch/generate_page_bundle_request.cc index 92b1eb6..e9766ef5 100644 --- a/components/offline_pages/core/prefetch/generate_page_bundle_request.cc +++ b/components/offline_pages/core/prefetch/generate_page_bundle_request.cc
@@ -43,7 +43,7 @@ fetcher_ = PrefetchRequestFetcher::CreateForPost( GeneratePageBundleRequestURL(channel), upload_data, testing_header_value, - url_loader_factory, + requested_urls_.empty(), url_loader_factory, base::BindOnce(&GeneratePageBundleRequest::OnCompleted, // Fetcher is owned by this instance. base::Unretained(this))); @@ -67,8 +67,7 @@ return; } - std::move(callback_).Run(PrefetchRequestStatus::kSuccess, operation_name, - pages); + std::move(callback_).Run(status, operation_name, pages); } } // namespace offline_pages
diff --git a/components/offline_pages/core/prefetch/prefetch_dispatcher_impl.cc b/components/offline_pages/core/prefetch/prefetch_dispatcher_impl.cc index 7899d0a..5803f593 100644 --- a/components/offline_pages/core/prefetch/prefetch_dispatcher_impl.cc +++ b/components/offline_pages/core/prefetch/prefetch_dispatcher_impl.cc
@@ -328,7 +328,8 @@ task_queue_.AddTask(std::make_unique<PageBundleUpdateTask>( prefetch_store, this, operation_name, pages)); - if (background_task_ && status != PrefetchRequestStatus::kSuccess) { + if (background_task_ && status != PrefetchRequestStatus::kSuccess && + status != PrefetchRequestStatus::kEmptyRequestSuccess) { PrefetchBackgroundTaskRescheduleType reschedule_type = PrefetchBackgroundTaskRescheduleType::NO_RESCHEDULE; switch (status) { @@ -341,12 +342,14 @@ PrefetchBackgroundTaskRescheduleType::RESCHEDULE_WITHOUT_BACKOFF; break; case PrefetchRequestStatus::kShouldSuspendForbiddenByOPS: + case PrefetchRequestStatus::kShouldSuspendNewlyForbiddenByOPS: case PrefetchRequestStatus::kShouldSuspendForbidden: case PrefetchRequestStatus::kShouldSuspendNotImplemented: case PrefetchRequestStatus::kShouldSuspendBlockedByAdministrator: reschedule_type = PrefetchBackgroundTaskRescheduleType::SUSPEND; break; case PrefetchRequestStatus::kSuccess: + case PrefetchRequestStatus::kEmptyRequestSuccess: NOTREACHED(); break; }
diff --git a/components/offline_pages/core/prefetch/prefetch_network_request_factory_impl.cc b/components/offline_pages/core/prefetch/prefetch_network_request_factory_impl.cc index 6544c59d..f82e1f51 100644 --- a/components/offline_pages/core/prefetch/prefetch_network_request_factory_impl.cc +++ b/components/offline_pages/core/prefetch/prefetch_network_request_factory_impl.cc
@@ -110,7 +110,8 @@ PrefetchRequestStatus status, const std::string& operation_name, const std::vector<RenderPageInfo>& pages) { - if (status == PrefetchRequestStatus::kShouldSuspendForbiddenByOPS) { + if (status == PrefetchRequestStatus::kShouldSuspendForbiddenByOPS || + status == PrefetchRequestStatus::kShouldSuspendNewlyForbiddenByOPS) { prefetch_prefs::SetEnabledByServer(prefs_, false); } std::move(callback).Run(status, operation_name, pages);
diff --git a/components/offline_pages/core/prefetch/prefetch_request_fetcher.cc b/components/offline_pages/core/prefetch/prefetch_request_fetcher.cc index 89fea0f..bf0dfade 100644 --- a/components/offline_pages/core/prefetch/prefetch_request_fetcher.cc +++ b/components/offline_pages/core/prefetch/prefetch_request_fetcher.cc
@@ -34,7 +34,7 @@ scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, FinishedCallback callback) { return base::WrapUnique( - new PrefetchRequestFetcher(url, std::string(), std::string(), + new PrefetchRequestFetcher(url, std::string(), std::string(), false, url_loader_factory, std::move(callback))); } @@ -43,20 +43,24 @@ const GURL& url, const std::string& message, const std::string& testing_header_value, + bool empty_request, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, FinishedCallback callback) { - return base::WrapUnique( - new PrefetchRequestFetcher(url, message, testing_header_value, - url_loader_factory, std::move(callback))); + return base::WrapUnique(new PrefetchRequestFetcher( + url, message, testing_header_value, empty_request, url_loader_factory, + std::move(callback))); } PrefetchRequestFetcher::PrefetchRequestFetcher( const GURL& url, const std::string& message, const std::string& testing_header_value, + bool empty_request, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, FinishedCallback callback) - : url_loader_factory_(url_loader_factory), callback_(std::move(callback)) { + : empty_request_(empty_request), + url_loader_factory_(url_loader_factory), + callback_(std::move(callback)) { net::NetworkTrafficAnnotationTag traffic_annotation = net::DefineNetworkTrafficAnnotation("offline_prefetch", R"( semantics { @@ -137,8 +141,11 @@ case net::HTTP_FORBIDDEN: // Check whether the request was forbidden because of a filter rule. if (response_body && response_body->find("request forbidden by OPS") != - std::string::npos) + std::string::npos) { + if (!empty_request_) + return PrefetchRequestStatus::kShouldSuspendNewlyForbiddenByOPS; return PrefetchRequestStatus::kShouldSuspendForbiddenByOPS; + } return PrefetchRequestStatus::kShouldSuspendForbidden; default: return PrefetchRequestStatus::kShouldRetryWithBackoff; @@ -158,6 +165,9 @@ } *data = *response_body; + + if (empty_request_) + return PrefetchRequestStatus::kEmptyRequestSuccess; return PrefetchRequestStatus::kSuccess; }
diff --git a/components/offline_pages/core/prefetch/prefetch_request_fetcher.h b/components/offline_pages/core/prefetch/prefetch_request_fetcher.h index 3571825..4c5c30d 100644 --- a/components/offline_pages/core/prefetch/prefetch_request_fetcher.h +++ b/components/offline_pages/core/prefetch/prefetch_request_fetcher.h
@@ -35,6 +35,7 @@ const GURL& url, const std::string& message, const std::string& testing_header_value, + bool empty_request, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, FinishedCallback callback); @@ -49,6 +50,7 @@ const GURL& url, const std::string& message, const std::string& testing_header_value, + bool empty_request, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, FinishedCallback callback); @@ -56,6 +58,9 @@ std::unique_ptr<std::string> response_body, std::string* data); + // Whether this is a GeneratePageBundle request with no pages (used for the + // server-enabled check). + bool empty_request_; scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_; std::unique_ptr<network::SimpleURLLoader> url_loader_; FinishedCallback callback_;
diff --git a/components/offline_pages/core/prefetch/prefetch_request_fetcher_unittest.cc b/components/offline_pages/core/prefetch/prefetch_request_fetcher_unittest.cc index 41ef2956..88b6f8d 100644 --- a/components/offline_pages/core/prefetch/prefetch_request_fetcher_unittest.cc +++ b/components/offline_pages/core/prefetch/prefetch_request_fetcher_unittest.cc
@@ -34,11 +34,13 @@ PrefetchRequestStatus RunFetcherWithHttpErrorAndData( net::HttpStatusCode http_error, const std::string& response_data); + void SetEmptyRequest(bool empty_request) { empty_request_ = empty_request; } private: PrefetchRequestStatus RunFetcher( base::OnceCallback<void(void)> respond_callback, std::string* data_received); + bool empty_request_; }; PrefetchRequestStatus PrefetchRequestFetcherTest::RunFetcherWithNetError( @@ -88,7 +90,7 @@ base::MockCallback<PrefetchRequestFetcher::FinishedCallback> callback; std::unique_ptr<PrefetchRequestFetcher> fetcher = PrefetchRequestFetcher::CreateForPost( - kTestURL, kTestMessage, /*testing_header_value=*/"", + kTestURL, kTestMessage, /*testing_header_value=*/"", empty_request_, shared_url_loader_factory(), callback.Get()); PrefetchRequestStatus status; @@ -141,6 +143,11 @@ EXPECT_EQ(PrefetchRequestStatus::kShouldRetryWithBackoff, RunFetcherWithHttpError(net::HTTP_GATEWAY_TIMEOUT)); + SetEmptyRequest(false); + EXPECT_EQ(PrefetchRequestStatus::kShouldSuspendNewlyForbiddenByOPS, + RunFetcherWithHttpErrorAndData(net::HTTP_FORBIDDEN, + "request forbidden by OPS")); + SetEmptyRequest(true); EXPECT_EQ(PrefetchRequestStatus::kShouldSuspendForbiddenByOPS, RunFetcherWithHttpErrorAndData(net::HTTP_FORBIDDEN, "request forbidden by OPS")); @@ -153,8 +160,17 @@ EXPECT_TRUE(data.empty()); } -TEST_F(PrefetchRequestFetcherTest, Success) { +TEST_F(PrefetchRequestFetcherTest, EmptyRequestSuccess) { std::string data; + SetEmptyRequest(true); + EXPECT_EQ(PrefetchRequestStatus::kEmptyRequestSuccess, + RunFetcherWithData("Any data.", &data)); + EXPECT_FALSE(data.empty()); +} + +TEST_F(PrefetchRequestFetcherTest, NonEmptyRequestSuccess) { + std::string data; + SetEmptyRequest(false); EXPECT_EQ(PrefetchRequestStatus::kSuccess, RunFetcherWithData("Any data.", &data)); EXPECT_FALSE(data.empty());
diff --git a/components/offline_pages/core/prefetch/prefetch_types.cc b/components/offline_pages/core/prefetch/prefetch_types.cc index 05177eaa..be5bf13 100644 --- a/components/offline_pages/core/prefetch/prefetch_types.cc +++ b/components/offline_pages/core/prefetch/prefetch_types.cc
@@ -39,6 +39,10 @@ return "SHOULD_SUSPEND_BLOCKED_BY_ADMINISTRATOR"; case PrefetchRequestStatus::kShouldSuspendForbiddenByOPS: return "SHOULD_SUSPEND_FORBIDDEN_BY_OPS"; + case PrefetchRequestStatus::kShouldSuspendNewlyForbiddenByOPS: + return "SHOULD_SUSPEND_NEWLY_FORBIDDEN_BY_OPS"; + case PrefetchRequestStatus::kEmptyRequestSuccess: + return "EMPTY_REQUEST_SUCCESS"; } DCHECK(false) << static_cast<int>(value) << " not valid enum value"; }
diff --git a/components/offline_pages/core/prefetch/prefetch_types.h b/components/offline_pages/core/prefetch/prefetch_types.h index e45f82f..57ec032 100644 --- a/components/offline_pages/core/prefetch/prefetch_types.h +++ b/components/offline_pages/core/prefetch/prefetch_types.h
@@ -62,8 +62,13 @@ // indicating that the request was forbidden specifically by an OPS request // filtering rule. kShouldSuspendForbiddenByOPS = 6, + // The server responded with 403 forbidden due to a filter rule though the + // last request was successful. + kShouldSuspendNewlyForbiddenByOPS = 7, + // A request for no URLs (i.e. server-enabled check) completed successfully. + kEmptyRequestSuccess = 8, // kMaxValue should always be the last type. - kMaxValue = kShouldSuspendForbiddenByOPS + kMaxValue = kEmptyRequestSuccess }; // Status indicating the page rendering status in the server.
diff --git a/components/offline_pages/core/prefetch/server_forbidden_check_request.cc b/components/offline_pages/core/prefetch/server_forbidden_check_request.cc index b089701..efef3a2 100644 --- a/components/offline_pages/core/prefetch/server_forbidden_check_request.cc +++ b/components/offline_pages/core/prefetch/server_forbidden_check_request.cc
@@ -16,7 +16,8 @@ PrefetchRequestStatus status, const std::string& operation_name, const std::vector<RenderPageInfo>& pages) { - if (status == PrefetchRequestStatus::kSuccess) { + if (status == PrefetchRequestStatus::kSuccess || + status == PrefetchRequestStatus::kEmptyRequestSuccess) { // Request succeeded; enable prefetching. prefetch_prefs::SetEnabledByServer(pref_service, true); }
diff --git a/components/offline_pages/core/prefetch/server_forbidden_check_request_unittest.cc b/components/offline_pages/core/prefetch/server_forbidden_check_request_unittest.cc index 5888551..a832cd4 100644 --- a/components/offline_pages/core/prefetch/server_forbidden_check_request_unittest.cc +++ b/components/offline_pages/core/prefetch/server_forbidden_check_request_unittest.cc
@@ -4,6 +4,8 @@ #include <memory> +#include "base/metrics/histogram_macros.h" +#include "base/test/metrics/histogram_tester.h" #include "components/offline_pages/core/offline_clock.h" #include "components/offline_pages/core/prefetch/prefetch_prefs.h" #include "components/offline_pages/core/prefetch/prefetch_request_test_base.h" @@ -43,7 +45,7 @@ prefetch_prefs::RegisterPrefs(pref_service_.registry()); - // Ensure check will happen + // Ensure check will happen. prefetch_prefs::SetPrefetchingEnabledInSettings(prefs(), true); } @@ -52,15 +54,24 @@ } TEST_F(ServerForbiddenCheckRequestTest, StillForbidden) { + base::HistogramTester histogram_tester; + + prefetch_prefs::SetEnabledByServer(prefs(), false); MakeRequest(); RespondWithHttpErrorAndData(net::HTTP_FORBIDDEN, "request forbidden by OPS"); RunUntilIdle(); EXPECT_FALSE(prefetch_prefs::IsForbiddenCheckDue(prefs())); EXPECT_FALSE(prefetch_prefs::IsEnabledByServer(prefs())); + + // Ensure that the status was recorded in UMA. + histogram_tester.ExpectUniqueSample( + "OfflinePages.Prefetching.ServiceGetPageBundleStatus", + static_cast<int>(PrefetchRequestStatus::kShouldSuspendForbiddenByOPS), 1); } TEST_F(ServerForbiddenCheckRequestTest, NoLongerForbidden) { + base::HistogramTester histogram_tester; MakeRequest(); std::string operation_data, bundle_data; @@ -82,6 +93,11 @@ EXPECT_FALSE(prefetch_prefs::IsForbiddenCheckDue(prefs())); EXPECT_TRUE(prefetch_prefs::IsEnabledByServer(prefs())); + + // Ensure the request was recorded in UMA. + histogram_tester.ExpectUniqueSample( + "OfflinePages.Prefetching.ServiceGetPageBundleStatus", + static_cast<int>(PrefetchRequestStatus::kEmptyRequestSuccess), 1); } } // namespace offline_pages
diff --git a/components/omnibox/browser/BUILD.gn b/components/omnibox/browser/BUILD.gn index 607c2189..2f15596 100644 --- a/components/omnibox/browser/BUILD.gn +++ b/components/omnibox/browser/BUILD.gn
@@ -34,6 +34,7 @@ "bookmark.icon", "calculator.icon", "clear.icon", + "clock.icon", "drive_docs.icon", "drive_forms.icon", "drive_image.icon",
diff --git a/components/omnibox/browser/vector_icons/clock.icon b/components/omnibox/browser/vector_icons/clock.icon new file mode 100644 index 0000000..afc2d935 --- /dev/null +++ b/components/omnibox/browser/vector_icons/clock.icon
@@ -0,0 +1,25 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Source: time_16px.svg --> SVGOMG --> Skiafy + +CANVAS_DIMENSIONS, 16, +MOVE_TO, 8, 0, +ARC_TO, 7.99f, 7.99f, 0, 0, 0, 0, 8, +R_CUBIC_TO, 0, 4.42f, 3.58f, 8, 8, 8, +R_ARC_TO, 8, 8, 0, 1, 0, 0, -16, +CLOSE, +MOVE_TO, 8, 14, +R_CUBIC_TO, -3.31f, 0, -6, -2.68f, -6, -6, +R_CUBIC_TO, 0, -3.32f, 2.69f, -6, 6, -6, +R_CUBIC_TO, 3.31f, 0, 6, 2.69f, 6, 6, +R_CUBIC_TO, 0, 3.31f, -2.68f, 6, -6, 6, +CLOSE, +MOVE_TO, 8, 5, +H_LINE_TO, 7, +R_V_LINE_TO, 3.93f, +LINE_TO, 10.5f, 11, +R_LINE_TO, 0.5f, -0.81f, +R_LINE_TO, -3, -1.75f, +CLOSE
diff --git a/components/policy/resources/policy_templates.json b/components/policy/resources/policy_templates.json index 3ba1c52..9323d97 100644 --- a/components/policy/resources/policy_templates.json +++ b/components/policy/resources/policy_templates.json
@@ -418,6 +418,7 @@ 'ExtensionAllowInsecureUpdates', 'ExtensionSettings', 'ExtensionInstallListsMergeEnabled', + 'UninstallBlacklistedExtensions', ], }, { @@ -3777,6 +3778,25 @@ If you disable this setting or leave it unset, only list entries from the highest priority source are taken and all other sources are shown as conflicts but ignored.''', }, { + 'name': 'UninstallBlacklistedExtensions', + 'type': 'main', + 'schema': {'type': 'boolean' }, + 'supported_on': ['chrome.*:75-', 'chrome_os:75-'], + 'features' : { + 'dynamic_refresh' : True, + 'per_profile': True, + }, + 'example_value': True, + 'id': 546, + 'caption': '''Uninstall blacklisted extensions''', + 'tags': [], + 'desc': '''This will remove extensions appearing in the <ph name="EXTENSION_INSTALL_BLACKLIST_POLICY_NAME">ExtensionInstallBlacklist</ph> or extensions appearing in <ph name="EXTENSION_SETTINGS_POLICY_NAME">ExtensionSettings</ph> that have the installation mode set to blocked and will purge local user data with it. Refer to the extensions privacy policy or data retention policy to understand what may happen with the user data that is not stored locally. + + When the policy is set to enabled, extensions that fall in the aforementioned lists (if already installed on a machine) will be removed from that machine in its entirety (including local user data). + + When the policy is set to disabled or left unset, extensions that fall in the aforementioned lists (if already installed on a machine and existing in the blacklist <ph name="EXTENSION_INSTALL_BLACKLIST_POLICY_NAME">ExtensionInstallBlacklist</ph>) will be disabled on the machine and not uninstalled.''', + }, + { 'name': 'ShowHomeButton', 'type': 'main', 'schema': { 'type': 'boolean' }, @@ -15516,5 +15536,5 @@ }, 'placeholders': [], 'deleted_policy_ids': [412], - 'highest_id_currently_used': 545 + 'highest_id_currently_used': 546 }
diff --git a/components/printing/browser/printer_capabilities.cc b/components/printing/browser/printer_capabilities.cc index 833a049..4f79764c 100644 --- a/components/printing/browser/printer_capabilities.cc +++ b/components/printing/browser/printer_capabilities.cc
@@ -10,6 +10,7 @@ #include <vector> #include "base/logging.h" +#include "base/metrics/histogram_macros.h" #include "base/stl_util.h" #include "base/strings/string_piece.h" #include "base/threading/scoped_blocking_call.h" @@ -136,6 +137,7 @@ const PrinterBasicInfo& basic_info, const PrinterSemanticCapsAndDefaults::Papers& additional_papers, scoped_refptr<PrintBackend> print_backend) { + SCOPED_UMA_HISTOGRAM_TIMER("Printing.PrinterCapabilities"); base::ScopedBlockingCall scoped_blocking_call(FROM_HERE, base::BlockingType::MAY_BLOCK);
diff --git a/components/viz/service/display/dc_layer_overlay.cc b/components/viz/service/display/dc_layer_overlay.cc index 429590b..422e4b3 100644 --- a/components/viz/service/display/dc_layer_overlay.cc +++ b/components/viz/service/display/dc_layer_overlay.cc
@@ -193,12 +193,10 @@ void RecordOverlayHistograms(bool is_overlay, bool has_occluding_surface_damage, - bool is_full_screen_mode, bool zero_damage_rect, bool occluding_damage_equal_to_damage_rect) { UMA_HISTOGRAM_BOOLEAN("GPU.DirectComposition.IsUnderlay", !is_overlay); - UMA_HISTOGRAM_BOOLEAN("GPU.DirectComposition.FullScreenOverlay", - is_full_screen_mode); + OverlayProcessor::RecordOverlayDamageRectHistograms( is_overlay, has_occluding_surface_damage, zero_damage_rect, occluding_damage_equal_to_damage_rect); @@ -447,13 +445,8 @@ current_frame_overlay_rect_union_.Union(rect_in_root); RecordDCLayerResult(DC_LAYER_SUCCESS, dc_layer.protected_video_type); - // In full screen mode, some video quads don't fill up the screen in height - // or width due to the screen aspect ratio. To determine full screen mode, - // just check either width or height. - bool is_full_screen_mode = rect_in_root.width() == display_rect.width() || - rect_in_root.height() == display_rect.height(); RecordOverlayHistograms(is_overlay, has_occluding_surface_damage, - is_full_screen_mode, damage_rect->IsEmpty(), + damage_rect->IsEmpty(), occlusion_bounding_box == gfx::RectF(*damage_rect)); dc_layer_overlays->push_back(dc_layer);
diff --git a/content/browser/loader/navigation_url_loader_impl.cc b/content/browser/loader/navigation_url_loader_impl.cc index 47bbde5ce..f113e6e0 100644 --- a/content/browser/loader/navigation_url_loader_impl.cc +++ b/content/browser/loader/navigation_url_loader_impl.cc
@@ -1032,7 +1032,11 @@ // receiving unexpected call. if (head.headers && head.headers->response_code() == net::HTTP_NOT_MODIFIED) { - OnComplete(network::URLLoaderCompletionStatus(net::ERR_ABORTED)); + // Call CancelWithError instead of OnComplete so that if there is an + // intercepting URLLoaderFactory it gets notified. + url_loader_->CancelWithError( + net::ERR_ABORTED, + base::StringPiece(base::NumberToString(net::ERR_ABORTED))); return; } @@ -1168,13 +1172,21 @@ if (base::FeatureList::IsEnabled(network::features::kNetworkService) && !bypass_redirect_checks_ && !IsRedirectSafe(url_, redirect_info.new_url, resource_context_)) { - OnComplete(network::URLLoaderCompletionStatus(net::ERR_UNSAFE_REDIRECT)); + // Call CancelWithError instead of OnComplete so that if there is an + // intercepting URLLoaderFactory (created through the embedder's + // ContentBrowserClient::WillCreateURLLoaderFactory) it gets notified. + url_loader_->CancelWithError( + net::ERR_UNSAFE_REDIRECT, + base::StringPiece(base::NumberToString(net::ERR_UNSAFE_REDIRECT))); return; } if (--redirect_limit_ == 0) { - OnComplete( - network::URLLoaderCompletionStatus(net::ERR_TOO_MANY_REDIRECTS)); + // Call CancelWithError instead of OnComplete so that if there is an + // intercepting URLLoaderFactory it gets notified. + url_loader_->CancelWithError( + net::ERR_TOO_MANY_REDIRECTS, + base::StringPiece(base::NumberToString(net::ERR_TOO_MANY_REDIRECTS))); return; }
diff --git a/content/common/throttling_url_loader.h b/content/common/throttling_url_loader.h index c3bf3da..da725255 100644 --- a/content/common/throttling_url_loader.h +++ b/content/common/throttling_url_loader.h
@@ -73,6 +73,8 @@ // datapipe endpoints. network::mojom::URLLoaderClientEndpointsPtr Unbind(); + void CancelWithError(int error_code, base::StringPiece custom_reason); + // Sets the forwarding client to receive all subsequent notifications. void set_forwarding_client(network::mojom::URLLoaderClient* client) { forwarding_client_ = client; @@ -130,7 +132,6 @@ void OnClientConnectionError(); - void CancelWithError(int error_code, base::StringPiece custom_reason); void Resume(); void SetPriority(net::RequestPriority priority); void UpdateDeferredRequestHeaders(
diff --git a/content/public/android/java/src/org/chromium/content/browser/androidoverlay/DialogOverlayCore.java b/content/public/android/java/src/org/chromium/content/browser/androidoverlay/DialogOverlayCore.java index d94d15e..82ddb24 100644 --- a/content/public/android/java/src/org/chromium/content/browser/androidoverlay/DialogOverlayCore.java +++ b/content/public/android/java/src/org/chromium/content/browser/androidoverlay/DialogOverlayCore.java
@@ -8,6 +8,7 @@ import android.app.Dialog; import android.content.Context; import android.os.IBinder; +import android.os.Looper; import android.view.Gravity; import android.view.Surface; import android.view.SurfaceHolder; @@ -15,6 +16,7 @@ import android.view.WindowManager; import org.chromium.base.Log; +import org.chromium.base.ThreadUtils; import org.chromium.gfx.mojom.Rect; import org.chromium.media.mojom.AndroidOverlayConfig; @@ -61,6 +63,9 @@ // If true, then we'll be a panel rather than media overlay. This is for testing. private boolean mAsPanel; + // Looper that we're initialized on, for thread checking. + private Looper mLooper; + /** * Construction may be called from a random thread, for simplicity. Call initialize from the * proper thread before doing anything else. @@ -76,6 +81,7 @@ */ public void initialize( Context context, AndroidOverlayConfig config, Host host, boolean asPanel) { + mLooper = Looper.myLooper(); mHost = host; mAsPanel = asPanel; @@ -92,6 +98,8 @@ * the client releasing the AndroidOverlay. This may be called more than once. */ public void release() { + assertProperThread(); + // If we've not released the dialog yet, then do so. dismissDialogQuietly(); @@ -144,6 +152,8 @@ @Override public void surfaceCreated(SurfaceHolder holder) { + assertProperThread(); + // Make sure that we haven't torn down the dialog yet. if (mDialog == null) return; @@ -152,6 +162,8 @@ @Override public void surfaceDestroyed(SurfaceHolder holder) { + assertProperThread(); + if (mDialog == null || mHost == null) return; // Notify the host that we've been destroyed, and wait for it to clean up or time out. @@ -166,6 +178,8 @@ } public void onWindowToken(IBinder token) { + assertProperThread(); + if (mDialog == null || mHost == null) return; if (token == null || (mLayoutParams.token != null && token != mLayoutParams.token)) { @@ -269,4 +283,16 @@ mDialog = null; mDialogCallbacks = null; } + + // Throw an exception if we're on the wrong thread, regardless of build. + private void assertProperThread() { + if (mLooper == Looper.myLooper()) return; + + // Special-case the browser UI thread, just to be more helpful. + if (ThreadUtils.runningOnUiThread()) { + throw new RuntimeException("DialogOverlayCore is on the UI thread"); + } else { + throw new RuntimeException("DialogOverlayCore is on the wrong thread"); + } + } }
diff --git a/content/shell/BUILD.gn b/content/shell/BUILD.gn index bf3ec5e6..10a0dbb 100644 --- a/content/shell/BUILD.gn +++ b/content/shell/BUILD.gn
@@ -289,6 +289,7 @@ "//components/download/public/background_service:public", "//components/download/public/common:public", "//components/keyed_service/content", + "//components/keyed_service/core:test_support", "//components/network_session_configurator/browser", "//components/plugins/renderer", "//components/url_formatter",
diff --git a/content/shell/browser/web_test/web_test_background_fetch_delegate.cc b/content/shell/browser/web_test/web_test_background_fetch_delegate.cc index da55c1d..931aec6 100644 --- a/content/shell/browser/web_test/web_test_background_fetch_delegate.cc +++ b/content/shell/browser/web_test/web_test_background_fetch_delegate.cc
@@ -17,7 +17,7 @@ #include "components/download/public/background_service/download_params.h" #include "components/download/public/background_service/download_service.h" #include "components/download/public/background_service/features.h" -#include "components/keyed_service/core/simple_factory_key.h" +#include "components/keyed_service/core/test_simple_factory_key.h" #include "content/public/browser/background_fetch_description.h" #include "content/public/browser/background_fetch_response.h" #include "content/public/browser/browser_context.h" @@ -251,8 +251,8 @@ BrowserContext::GetDefaultStoragePartition(browser_context_) ->GetURLLoaderFactoryForBrowserProcess() .get(); - simple_factory_key_ = - std::make_unique<SimpleFactoryKey>(base::FilePath()); + simple_factory_key_ = std::make_unique<TestSimpleFactoryKey>( + browser_context_->GetPath(), browser_context_->IsOffTheRecord()); download_service_ = base::WrapUnique(download::BuildInMemoryDownloadService( simple_factory_key_.get(), std::move(clients),
diff --git a/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py b/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py index cc0c146a..055c0ef 100644 --- a/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py +++ b/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py
@@ -90,10 +90,6 @@ self.Skip('conformance2/rendering/texture-switch-performance.html', bug=735483) - # TODO(shrekshao): Remove after updating this test case. - self.Fail('conformance2/rendering/depth-stencil-feedback-loop.html', - bug=660844) # WebGL 2.0.1 - # Nvidia bugs fixed in latest driver # TODO(http://crbug.com/887241): Upgrade the drivers on the bots. self.Fail('conformance/glsl/bugs/assign-to-swizzled-twice-in-function.html', @@ -116,6 +112,8 @@ ['win', 'no_passthrough'], bug=3033) # angle bug ID self.Fail('conformance2/glsl3/tricky-loop-conditions.html', ['win'], bug=1465) # anglebug.com/1465 + self.Fail('conformance/rendering/blending.html', + ['win', 'no_passthrough'], bug=951628) # Win / NVidia self.Flaky('deqp/functional/gles3/fbomultisample*', @@ -345,8 +343,8 @@ # Passthrough command decoder self.Fail('conformance/misc/webgl-specific-stencil-settings.html', ['passthrough'], bug=844349) - self.Fail('conformance/rendering/rendering-sampling-feedback-loop.html', - ['passthrough'], bug=660844) # WebGL 2.0.1 + self.Fail('conformance/rendering/blending.html', + ['passthrough'], bug=951628) # Passthrough command decoder / OpenGL self.Fail('conformance2/misc/uninitialized-test-2.html',
diff --git a/content/test/gpu/gpu_tests/webgl_conformance_expectations.py b/content/test/gpu/gpu_tests/webgl_conformance_expectations.py index 089b43fa..d8d0474 100644 --- a/content/test/gpu/gpu_tests/webgl_conformance_expectations.py +++ b/content/test/gpu/gpu_tests/webgl_conformance_expectations.py
@@ -136,6 +136,9 @@ self.Skip('conformance/rendering/texture-switch-performance.html', bug=735483) + self.Fail('conformance/rendering/blending.html', + ['passthrough'], bug=951628) + # Passthrough command decoder / OpenGL self.Fail( 'conformance/textures/canvas/tex-2d-alpha-alpha-unsigned_byte.html', @@ -143,9 +146,6 @@ self.Fail('conformance/textures/canvas/' + 'tex-2d-luminance_alpha-luminance_alpha-unsigned_byte.html', ['passthrough', 'opengl'], bug=2952) # angle bug ID - # Need to add detection of feedback loops with multiple render targets. - self.Fail('conformance/rendering/rendering-sampling-feedback-loop.html', - ['passthrough'], bug=660844) # Intel graphics driver issue. Passed on 25.20.100.6471 self.Fail('conformance/glsl/constructors/glsl-construct-mat2.html', @@ -207,6 +207,8 @@ # Win NVIDIA failures self.Flaky('conformance/textures/misc/texture-npot-video.html', ['win', 'nvidia', 'no_passthrough'], bug=626524) + self.Fail('conformance/rendering/blending.html', + ['win', 'nvidia', 'no_passthrough'], bug=951628) self.Flaky('conformance/textures/misc/texture-upload-size.html', ['win', 'nvidia'], bug=630860) self.Skip('conformance/rendering/out-of-bounds-index-buffers.html', @@ -313,9 +315,6 @@ ['win', 'd3d9'], bug=617148) self.Skip('conformance/glsl/misc/large-loop-compile.html', ['win', 'd3d9'], bug=674572) - # Test needs GL_EXT_draw_buffers which is not supported - self.Skip('conformance/rendering/rendering-sampling-feedback-loop.html', - ['win', 'd3d9', 'no_passthrough']) # WIN / OpenGL / NVIDIA failures self.Fail('conformance/limits/gl-max-texture-dimensions.html', @@ -648,6 +647,9 @@ self.Fail('conformance/textures/misc/' + 'copytexsubimage2d-large-partial-copy-corruption.html', ['android', 'no_passthrough', 'qualcomm'], bug=679697) + + self.Fail('conformance/rendering/blending.html', + ['android', 'no_passthrough'], bug=951628) # The following WebView crashes are causing problems with further # tests in the suite, so skip them for now. self.Skip('conformance/textures/video/' + @@ -738,8 +740,6 @@ self.Fail('conformance/glsl/bugs/' + 'varying-arrays-should-not-be-reversed.html', ['android', ('qualcomm', 'Adreno (TM) 330')], bug=709704) - self.Skip('conformance/rendering/rendering-sampling-feedback-loop.html', - ['android', ('qualcomm', 'Adreno (TM) 330'), 'no_passthrough']) # Nexus 5X # The following test recently became so flaky that it had to be @@ -808,9 +808,6 @@ ['android', ('qualcomm', 'Adreno (TM) 418')], bug=610951) self.Flaky('conformance/limits/gl-max-texture-dimensions.html', ['android', ('qualcomm', 'Adreno (TM) 418'), 'passthrough'], bug=914631) - # Test needs GL_EXT_draw_buffers which is not supported - self.Skip('conformance/rendering/rendering-sampling-feedback-loop.html', - ['android', ('qualcomm', 'Adreno (TM) 418'), 'no_passthrough']) # Nexus 6 (Adreno 420) and 6P (Adreno 430) self.Fail('conformance/context/' + @@ -875,9 +872,6 @@ ('qualcomm', 'Adreno (TM) 420'), ('qualcomm', 'Adreno (TM) 430')]) self.Fail('conformance/glsl/misc/uninitialized-local-global-variables.html', ['android', ('qualcomm', 'Adreno (TM) 420')], bug=2046) # angle bug ID - self.Skip('conformance/rendering/rendering-sampling-feedback-loop.html', - ['android', ('qualcomm', 'Adreno (TM) 420'), - ('qualcomm', 'Adreno (TM) 430'), 'no_passthrough']) # Nexus 9 self.Fail('deqp/data/gles2/shaders/functions.html',
diff --git a/content/test/gpu/gpu_tests/webgl_conformance_integration_test.py b/content/test/gpu/gpu_tests/webgl_conformance_integration_test.py index f838853..4704648 100644 --- a/content/test/gpu/gpu_tests/webgl_conformance_integration_test.py +++ b/content/test/gpu/gpu_tests/webgl_conformance_integration_test.py
@@ -339,7 +339,7 @@ '--disable-domain-blocking-for-3d-apis', '--disable-gpu-process-crash-limit', '--test-type=gpu', - '--enable-experimental-web-platform-features', + '--enable-webgl-draft-extensions', # Try disabling the GPU watchdog to see if this affects the # intermittent GPU process hangs that have been seen on the # waterfall. crbug.com/596622 crbug.com/609252
diff --git a/content/test/gpu/gpu_tests/webgl_conformance_revision.txt b/content/test/gpu/gpu_tests/webgl_conformance_revision.txt index 91019ea..18cc5d8 100644 --- a/content/test/gpu/gpu_tests/webgl_conformance_revision.txt +++ b/content/test/gpu/gpu_tests/webgl_conformance_revision.txt
@@ -1,3 +1,3 @@ # AUTOGENERATED FILE - DO NOT EDIT # SEE roll_webgl_conformance.py -Current webgl revision 688fbfe33779392aa210d67d4aa12cb012f112c2 +Current webgl revision 3f6583d3fee4ab71866ade794504a20eb6f63f88
diff --git a/content/utility/utility_service_factory.cc b/content/utility/utility_service_factory.cc index 17f3d126..3a4a72d 100644 --- a/content/utility/utility_service_factory.cc +++ b/content/utility/utility_service_factory.cc
@@ -105,6 +105,26 @@ #endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) +void RunNetworkServiceOnIOThread( + service_manager::mojom::ServiceRequest service_request, + std::unique_ptr<service_manager::BinderRegistry> network_registry, + scoped_refptr<base::SequencedTaskRunner> main_thread_task_runner) { + auto service = std::make_unique<network::NetworkService>( + std::move(network_registry), nullptr /* request */, nullptr /* net_log */, + std::move(service_request), true); + + // Transfer ownership of the service to itself, and have it post to the main + // thread on self-termination to kill the process. + auto* raw_service = service.get(); + raw_service->set_termination_closure(base::BindOnce( + [](std::unique_ptr<network::NetworkService> service, + scoped_refptr<base::SequencedTaskRunner> main_thread_task_runner) { + main_thread_task_runner->PostTask( + FROM_HERE, base::BindOnce(&TerminateThisProcess)); + }, + std::move(service), std::move(main_thread_task_runner))); +} + } // namespace UtilityServiceFactory::UtilityServiceFactory() @@ -146,8 +166,8 @@ network_registry_.get()); ChildProcess::current()->io_task_runner()->PostTask( FROM_HERE, - base::BindOnce(&UtilityServiceFactory::RunNetworkServiceOnIOThread, - base::Unretained(this), std::move(request), + base::BindOnce(&RunNetworkServiceOnIOThread, std::move(request), + std::move(network_registry_), base::SequencedTaskRunnerHandle::Get())); return; } else if (service_name == video_capture::mojom::kServiceName) { @@ -184,25 +204,6 @@ utility_thread->ReleaseProcess(); } -void UtilityServiceFactory::RunNetworkServiceOnIOThread( - service_manager::mojom::ServiceRequest service_request, - scoped_refptr<base::SequencedTaskRunner> main_thread_task_runner) { - auto service = std::make_unique<network::NetworkService>( - std::move(network_registry_), nullptr /* request */, - nullptr /* net_log */, std::move(service_request), true); - - // Transfer ownership of the service to itself, and have it post to the main - // thread on self-termination to kill the process. - auto* raw_service = service.get(); - raw_service->set_termination_closure(base::BindOnce( - [](std::unique_ptr<network::NetworkService> service, - scoped_refptr<base::SequencedTaskRunner> main_thread_task_runner) { - main_thread_task_runner->PostTask( - FROM_HERE, base::BindOnce(&TerminateThisProcess)); - }, - std::move(service), std::move(main_thread_task_runner))); -} - std::unique_ptr<service_manager::Service> UtilityServiceFactory::CreateAudioService( service_manager::mojom::ServiceRequest request) {
diff --git a/content/utility/utility_service_factory.h b/content/utility/utility_service_factory.h index 129b2d0..1313ee5c 100644 --- a/content/utility/utility_service_factory.h +++ b/content/utility/utility_service_factory.h
@@ -29,9 +29,6 @@ mojo::PendingReceiver<service_manager::mojom::Service> receiver); private: - void RunNetworkServiceOnIOThread( - service_manager::mojom::ServiceRequest service_request, - scoped_refptr<base::SequencedTaskRunner> main_thread_task_runner); std::unique_ptr<service_manager::Service> CreateAudioService( service_manager::mojom::ServiceRequest request);
diff --git a/device/bluetooth/chromeos/bluetooth_utils.cc b/device/bluetooth/chromeos/bluetooth_utils.cc index 4d0dbc0b..8b9098c9 100644 --- a/device/bluetooth/chromeos/bluetooth_utils.cc +++ b/device/bluetooth/chromeos/bluetooth_utils.cc
@@ -64,6 +64,12 @@ BluetoothAdapter::DeviceList result; for (BluetoothDevice* device : devices) { + // Always allow paired devices to appear in the UI. + if (device->IsPaired()) { + result.push_back(device); + continue; + } + switch (device->GetType()) { // Device with invalid bluetooth transport is filtered out. case BLUETOOTH_TRANSPORT_INVALID:
diff --git a/device/fido/hid/fake_hid_impl_for_testing.cc b/device/fido/hid/fake_hid_impl_for_testing.cc index d16cbce54..7c9c255 100644 --- a/device/fido/hid/fake_hid_impl_for_testing.cc +++ b/device/fido/hid/fake_hid_impl_for_testing.cc
@@ -166,6 +166,7 @@ } void FakeHidManager::Connect(const std::string& device_guid, + mojom::HidConnectionClientPtr connection_client, ConnectCallback callback) { auto device_it = devices_.find(device_guid); auto connection_it = connections_.find(device_guid);
diff --git a/device/fido/hid/fake_hid_impl_for_testing.h b/device/fido/hid/fake_hid_impl_for_testing.h index c49e461e..45499654 100644 --- a/device/fido/hid/fake_hid_impl_for_testing.h +++ b/device/fido/hid/fake_hid_impl_for_testing.h
@@ -108,6 +108,7 @@ GetDevicesCallback callback) override; void GetDevices(GetDevicesCallback callback) override; void Connect(const std::string& device_guid, + mojom::HidConnectionClientPtr connection_client, ConnectCallback callback) override; void AddBinding(mojo::ScopedMessagePipeHandle handle); void AddBinding2(device::mojom::HidManagerRequest request);
diff --git a/device/fido/hid/fido_hid_device.cc b/device/fido/hid/fido_hid_device.cc index 564f3fb..89e03b8 100644 --- a/device/fido/hid/fido_hid_device.cc +++ b/device/fido/hid/fido_hid_device.cc
@@ -156,7 +156,8 @@ void FidoHidDevice::Connect( device::mojom::HidManager::ConnectCallback callback) { DCHECK(hid_manager_); - hid_manager_->Connect(device_info_->guid, std::move(callback)); + hid_manager_->Connect(device_info_->guid, /*connection_client=*/nullptr, + std::move(callback)); } void FidoHidDevice::OnConnect(device::mojom::HidConnectionPtr connection) {
diff --git a/device/gamepad/nintendo_controller.cc b/device/gamepad/nintendo_controller.cc index 5cdcc0f..5e1d96a 100644 --- a/device/gamepad/nintendo_controller.cc +++ b/device/gamepad/nintendo_controller.cc
@@ -1124,7 +1124,8 @@ void NintendoController::Connect(mojom::HidManager::ConnectCallback callback) { DCHECK(!is_composite_); DCHECK(hid_manager_); - hid_manager_->Connect(device_info_->guid, std::move(callback)); + hid_manager_->Connect(device_info_->guid, /*connection_client=*/nullptr, + std::move(callback)); } void NintendoController::OnConnect(mojom::HidConnectionPtr connection) {
diff --git a/docs/infra/cq_builders.md b/docs/infra/cq_builders.md index 4f521a0..3f33b6f 100644 --- a/docs/infra/cq_builders.md +++ b/docs/infra/cq_builders.md
@@ -120,11 +120,52 @@ Path regular expressions: * [`//chromeos/CHROMEOS_LKGM`](https://cs.chromium.org/search/?q=package:%5Echromium$+file:chromeos/CHROMEOS_LKGM) +* [chromeos-kevin-rel](https://ci.chromium.org/p/chromium/builders/luci.chromium.try/chromeos-kevin-rel) ([`commit-queue.cfg` entry](https://cs.chromium.org/search/?q=package:%5Echromium$+file:commit-queue.cfg+chromium/try/chromeos-kevin-rel)) ([matching builders](https://cs.chromium.org/search/?q=file:trybots.py+chromeos-kevin-rel)) + + Path regular expressions: + * [`//build/chromeos/.+`](https://cs.chromium.org/chromium/src/build/chromeos/) + * [closure_compilation](https://ci.chromium.org/p/chromium/builders/luci.chromium.try/closure_compilation) ([`commit-queue.cfg` entry](https://cs.chromium.org/search/?q=package:%5Echromium$+file:commit-queue.cfg+chromium/try/closure_compilation)) ([matching builders](https://cs.chromium.org/search/?q=file:trybots.py+closure_compilation)) Path regular expressions: * [`//third_party/closure_compiler/.+`](https://cs.chromium.org/chromium/src/third_party/closure_compiler/) +* [dawn-linux-x64-deps-rel](https://ci.chromium.org/p/chromium/builders/luci.chromium.try/dawn-linux-x64-deps-rel) ([`commit-queue.cfg` entry](https://cs.chromium.org/search/?q=package:%5Echromium$+file:commit-queue.cfg+chromium/try/dawn-linux-x64-deps-rel)) ([matching builders](https://cs.chromium.org/search/?q=file:trybots.py+dawn-linux-x64-deps-rel)) + + Path regular expressions: + * [`//testing/buildbot/chromium.dawn.json`](https://cs.chromium.org/search/?q=package:%5Echromium$+file:testing/buildbot/chromium.dawn.json) + * [`//third_party/blink/renderer/modules/webgpu/.+`](https://cs.chromium.org/chromium/src/third_party/blink/renderer/modules/webgpu/) + * [`//third_party/blink/web_tests/FlagExpectations/enable-unsafe-webgpu`](https://cs.chromium.org/search/?q=package:%5Echromium$+file:third_party/blink/web_tests/FlagExpectations/enable-unsafe-webgpu) + * [`//third_party/blink/web_tests/webgpu/.+`](https://cs.chromium.org/chromium/src/third_party/blink/web_tests/webgpu/) + * [`//third_party/dawn/.+`](https://cs.chromium.org/chromium/src/third_party/dawn/) + +* [dawn-mac-x64-deps-rel](https://ci.chromium.org/p/chromium/builders/luci.chromium.try/dawn-mac-x64-deps-rel) ([`commit-queue.cfg` entry](https://cs.chromium.org/search/?q=package:%5Echromium$+file:commit-queue.cfg+chromium/try/dawn-mac-x64-deps-rel)) ([matching builders](https://cs.chromium.org/search/?q=file:trybots.py+dawn-mac-x64-deps-rel)) + + Path regular expressions: + * [`//testing/buildbot/chromium.dawn.json`](https://cs.chromium.org/search/?q=package:%5Echromium$+file:testing/buildbot/chromium.dawn.json) + * [`//third_party/blink/renderer/modules/webgpu/.+`](https://cs.chromium.org/chromium/src/third_party/blink/renderer/modules/webgpu/) + * [`//third_party/blink/web_tests/FlagExpectations/enable-unsafe-webgpu`](https://cs.chromium.org/search/?q=package:%5Echromium$+file:third_party/blink/web_tests/FlagExpectations/enable-unsafe-webgpu) + * [`//third_party/blink/web_tests/webgpu/.+`](https://cs.chromium.org/chromium/src/third_party/blink/web_tests/webgpu/) + * [`//third_party/dawn/.+`](https://cs.chromium.org/chromium/src/third_party/dawn/) + +* [dawn-win10-x64-deps-rel](https://ci.chromium.org/p/chromium/builders/luci.chromium.try/dawn-win10-x64-deps-rel) ([`commit-queue.cfg` entry](https://cs.chromium.org/search/?q=package:%5Echromium$+file:commit-queue.cfg+chromium/try/dawn-win10-x64-deps-rel)) ([matching builders](https://cs.chromium.org/search/?q=file:trybots.py+dawn-win10-x64-deps-rel)) + + Path regular expressions: + * [`//testing/buildbot/chromium.dawn.json`](https://cs.chromium.org/search/?q=package:%5Echromium$+file:testing/buildbot/chromium.dawn.json) + * [`//third_party/blink/renderer/modules/webgpu/.+`](https://cs.chromium.org/chromium/src/third_party/blink/renderer/modules/webgpu/) + * [`//third_party/blink/web_tests/FlagExpectations/enable-unsafe-webgpu`](https://cs.chromium.org/search/?q=package:%5Echromium$+file:third_party/blink/web_tests/FlagExpectations/enable-unsafe-webgpu) + * [`//third_party/blink/web_tests/webgpu/.+`](https://cs.chromium.org/chromium/src/third_party/blink/web_tests/webgpu/) + * [`//third_party/dawn/.+`](https://cs.chromium.org/chromium/src/third_party/dawn/) + +* [dawn-win10-x86-deps-rel](https://ci.chromium.org/p/chromium/builders/luci.chromium.try/dawn-win10-x86-deps-rel) ([`commit-queue.cfg` entry](https://cs.chromium.org/search/?q=package:%5Echromium$+file:commit-queue.cfg+chromium/try/dawn-win10-x86-deps-rel)) ([matching builders](https://cs.chromium.org/search/?q=file:trybots.py+dawn-win10-x86-deps-rel)) + + Path regular expressions: + * [`//testing/buildbot/chromium.dawn.json`](https://cs.chromium.org/search/?q=package:%5Echromium$+file:testing/buildbot/chromium.dawn.json) + * [`//third_party/blink/renderer/modules/webgpu/.+`](https://cs.chromium.org/chromium/src/third_party/blink/renderer/modules/webgpu/) + * [`//third_party/blink/web_tests/FlagExpectations/enable-unsafe-webgpu`](https://cs.chromium.org/search/?q=package:%5Echromium$+file:third_party/blink/web_tests/FlagExpectations/enable-unsafe-webgpu) + * [`//third_party/blink/web_tests/webgpu/.+`](https://cs.chromium.org/chromium/src/third_party/blink/web_tests/webgpu/) + * [`//third_party/dawn/.+`](https://cs.chromium.org/chromium/src/third_party/dawn/) + * [ios-simulator-cronet](https://ci.chromium.org/p/chromium/builders/luci.chromium.try/ios-simulator-cronet) ([`commit-queue.cfg` entry](https://cs.chromium.org/search/?q=package:%5Echromium$+file:commit-queue.cfg+chromium/try/ios-simulator-cronet)) ([matching builders](https://cs.chromium.org/search/?q=file:trybots.py+ios-simulator-cronet)) Path regular expressions:
diff --git a/extensions/browser/api/hid/hid_device_manager.cc b/extensions/browser/api/hid/hid_device_manager.cc index ecaf885..f613295 100644 --- a/extensions/browser/api/hid/hid_device_manager.cc +++ b/extensions/browser/api/hid/hid_device_manager.cc
@@ -171,7 +171,7 @@ ConnectCallback callback) { DCHECK(initialized_); - hid_manager_->Connect(device_guid, + hid_manager_->Connect(device_guid, /*connection_client=*/nullptr, mojo::WrapCallbackWithDefaultInvokeIfNotRun( std::move(callback), nullptr)); }
diff --git a/extensions/browser/extension_prefs.cc b/extensions/browser/extension_prefs.cc index cd01681..2886319 100644 --- a/extensions/browser/extension_prefs.cc +++ b/extensions/browser/extension_prefs.cc
@@ -1869,6 +1869,8 @@ true); registry->RegisterIntegerPref(kCorruptedDisableCount, 0); registry->RegisterBooleanPref(pref_names::kInsecureExtensionUpdatesEnabled, + true); + registry->RegisterBooleanPref(pref_names::kUninstallBlacklistedExtensions, false); #if !defined(OS_MACOSX)
diff --git a/extensions/browser/management_policy.cc b/extensions/browser/management_policy.cc index 933fd338..7bf6a45 100644 --- a/extensions/browser/management_policy.cc +++ b/extensions/browser/management_policy.cc
@@ -65,6 +65,12 @@ return false; } +bool ManagementPolicy::Provider::ShouldForceUninstall( + const Extension* extension, + base::string16* error) const { + return false; +} + void ManagementPolicy::RegisterProvider(Provider* provider) { providers_.insert(provider); } @@ -143,6 +149,12 @@ &Provider::MustRemainInstalled, "Removing", false, extension, error); } +bool ManagementPolicy::ShouldForceUninstall(const Extension* extension, + base::string16* error) const { + return ApplyToProviderList(&Provider::ShouldForceUninstall, "Uninstalling", + false, extension, error); +} + void ManagementPolicy::UnregisterAllProviders() { providers_.clear(); }
diff --git a/extensions/browser/management_policy.h b/extensions/browser/management_policy.h index 8ba2f2ad..f3e77191 100644 --- a/extensions/browser/management_policy.h +++ b/extensions/browser/management_policy.h
@@ -101,6 +101,11 @@ virtual bool MustRemainInstalled(const Extension* extension, base::string16* error) const; + // Providers should return true for extensions that should be force + // uninstalled. + virtual bool ShouldForceUninstall(const Extension* extension, + base::string16* error) const; + private: DISALLOW_COPY_AND_ASSIGN(Provider); }; @@ -160,6 +165,10 @@ bool MustRemainInstalled(const Extension* extension, base::string16* error) const; + // Returns true for extensions that should be force uninstalled. + bool ShouldForceUninstall(const Extension* extension, + base::string16* error) const; + // For use in testing. void UnregisterAllProviders(); int GetNumProviders() const;
diff --git a/extensions/browser/pref_names.cc b/extensions/browser/pref_names.cc index a6dc437..e207eaf 100644 --- a/extensions/browser/pref_names.cc +++ b/extensions/browser/pref_names.cc
@@ -56,6 +56,7 @@ const char kPrefRegularOnlyPreferences[] = "regular_only_preferences"; const char kPrefContentSettings[] = "content_settings"; const char kPrefIncognitoContentSettings[] = "incognito_content_settings"; +const char kUninstallBlacklistedExtensions[] = "extensions.remove_blacklisted"; } // namespace pref_names } // namespace extensions
diff --git a/extensions/browser/pref_names.h b/extensions/browser/pref_names.h index 80a6e180..cca047b 100644 --- a/extensions/browser/pref_names.h +++ b/extensions/browser/pref_names.h
@@ -121,6 +121,9 @@ // Extension-set incognito content settings. extern const char kPrefIncognitoContentSettings[]; +// A boolean that when set removes blacklisted extensions automatically. +extern const char kUninstallBlacklistedExtensions[]; + } // namespace pref_names } // namespace extensions
diff --git a/extensions/browser/url_loader_factory_manager.cc b/extensions/browser/url_loader_factory_manager.cc index 56bbb4fc..adafc8c 100644 --- a/extensions/browser/url_loader_factory_manager.cc +++ b/extensions/browser/url_loader_factory_manager.cc
@@ -115,6 +115,7 @@ "4884C48FB64665BD86509BA1F2D22D75D61ACBF9", "4913450195D177430217CAB64B356DC6F6B0F483", "49FFDF2212E50090963E33159DBF853B5C475340", + "4A15AD9F12FB35BEEA6FF1807AC782A1DF979387", "4A4E0B370B65C9EC65C8A615B1B9FB55A1B3E1FD", "4A8EEEB4754A3E87C3A177CB31474A30967CB3C8", "4E4167EDA0CFF22F261C0655E979B9474BF67C04",
diff --git a/extensions/common/api/_api_features.json b/extensions/common/api/_api_features.json index 0b00a92..5209a16 100644 --- a/extensions/common/api/_api_features.json +++ b/extensions/common/api/_api_features.json
@@ -85,6 +85,9 @@ "contexts": ["webui"], "matches": [ "chrome://bluetooth-pairing/*", + // TODO(maybelle): Audit and remove chrome://settings or + // chrome://os-settings as appropriate + "chrome://os-settings/*", "chrome://settings/*" ] }], @@ -101,6 +104,9 @@ "contexts": ["webui"], "matches": [ "chrome://bluetooth-pairing/*", + // TODO(maybelle): Audit and remove chrome://settings or + // chrome://os-settings as appropriate + "chrome://os-settings/*", "chrome://settings/*" ] }], @@ -263,6 +269,9 @@ "chrome://extensions/*", "chrome://extensions-frame/*", "chrome://chrome/extensions/*", + // TODO(maybelle): Audit and remove chrome://settings or + // chrome://os-settings as appropriate + "chrome://os-settings/*", "chrome://settings/*" ] }], @@ -295,6 +304,9 @@ "matches": [ "chrome://bookmarks/*", "chrome://extensions/*", + // TODO(maybelle): Audit and remove chrome://settings or + // chrome://os-settings as appropriate + "chrome://os-settings/*", "chrome://settings/*", "chrome://sync-confirmation/*", "chrome://welcome/*" @@ -379,6 +391,9 @@ "chrome://oobe/*", "chrome://internet-config-dialog/*", "chrome://internet-detail-dialog/*", + // TODO(maybelle): Audit and remove chrome://settings or + // chrome://os-settings as appropriate + "chrome://os-settings/*", "chrome://settings/*" ] }], @@ -522,6 +537,9 @@ "channel": "stable", "contexts": ["webui"], "matches": [ + // TODO(maybelle): Audit and remove chrome://settings or + // chrome://os-settings as appropriate + "chrome://os-settings/*", "chrome://settings/*" ] }],
diff --git a/fuchsia/engine/BUILD.gn b/fuchsia/engine/BUILD.gn index 1112933128..91147bc3 100644 --- a/fuchsia/engine/BUILD.gn +++ b/fuchsia/engine/BUILD.gn
@@ -102,16 +102,6 @@ "browser/discarding_event_filter.h", "browser/frame_impl.cc", "browser/frame_impl.h", - "browser/legacy_context_bridge.cc", - "browser/legacy_context_bridge.h", - "browser/legacy_frame_bridge.cc", - "browser/legacy_frame_bridge.h", - "browser/legacy_message_port_bridge.cc", - "browser/legacy_message_port_bridge.h", - "browser/legacy_navigation_controller_bridge.cc", - "browser/legacy_navigation_controller_bridge.h", - "browser/legacy_navigation_event_listener_bridge.cc", - "browser/legacy_navigation_event_listener_bridge.h", "browser/message_port_impl.cc", "browser/message_port_impl.h", "browser/web_engine_browser_context.cc", @@ -136,6 +126,18 @@ "context_provider_impl.h", "context_provider_main.cc", "context_provider_main.h", + "legacy_context_bridge.cc", + "legacy_context_bridge.h", + "legacy_context_provider_bridge.cc", + "legacy_context_provider_bridge.h", + "legacy_frame_bridge.cc", + "legacy_frame_bridge.h", + "legacy_message_port_bridge.cc", + "legacy_message_port_bridge.h", + "legacy_navigation_controller_bridge.cc", + "legacy_navigation_controller_bridge.h", + "legacy_navigation_event_listener_bridge.cc", + "legacy_navigation_event_listener_bridge.h", "renderer/on_load_script_injector.cc", "renderer/on_load_script_injector.h", "renderer/web_engine_content_renderer_client.cc",
diff --git a/fuchsia/engine/browser/context_impl.cc b/fuchsia/engine/browser/context_impl.cc index ad3fc6e0..299798e 100644 --- a/fuchsia/engine/browser/context_impl.cc +++ b/fuchsia/engine/browser/context_impl.cc
@@ -11,7 +11,7 @@ #include "base/fuchsia/fuchsia_logging.h" #include "content/public/browser/web_contents.h" #include "fuchsia/engine/browser/frame_impl.h" -#include "fuchsia/engine/browser/legacy_frame_bridge.h" +#include "fuchsia/engine/legacy_frame_bridge.h" ContextImpl::ContextImpl(content::BrowserContext* browser_context) : browser_context_(browser_context) {}
diff --git a/fuchsia/engine/browser/frame_impl_browsertest.cc b/fuchsia/engine/browser/frame_impl_browsertest.cc index 2bf2017..dbe2fb7a 100644 --- a/fuchsia/engine/browser/frame_impl_browsertest.cc +++ b/fuchsia/engine/browser/frame_impl_browsertest.cc
@@ -11,6 +11,7 @@ #include "base/test/bind_test_util.h" #include "base/test/test_timeouts.h" #include "content/public/browser/browser_context.h" +#include "content/public/browser/navigation_handle.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_observer.h" #include "fuchsia/base/fit_adapter.h" @@ -55,17 +56,21 @@ return !arg.is_null(); } +MATCHER_P(NavigationHandleUrlEquals, + url, + "Checks equality with a NavigationHandle's URL.") { + return arg->GetURL() == url; +} + class MockWebContentsObserver : public content::WebContentsObserver { public: - MockWebContentsObserver() = default; + explicit MockWebContentsObserver(content::WebContents* web_contents) { + Observe(web_contents); + } + ~MockWebContentsObserver() override = default; - // WebContentsObserver implementation. - using content::WebContentsObserver::Observe; - - MOCK_METHOD2(DidFinishLoad, - void(content::RenderFrameHost* render_frame_host, - const GURL& validated_url)); + MOCK_METHOD1(DidStartNavigation, void(content::NavigationHandle*)); }; // Defines a suite of tests that exercise Frame-level functionality, such as @@ -266,23 +271,28 @@ controller->LoadUrl(url.spec(), chromium::web::LoadUrlParams()); navigation_observer_.RunUntilNavigationEquals(url, kPage1Title); - MockWebContentsObserver web_contents_observer; - web_contents_observer.Observe( - context_impl()->GetFrameImplForTest(&frame)->web_contents_.get()); - // Reload with NO_CACHE. { + MockWebContentsObserver web_contents_observer( + context_impl()->GetFrameImplForTest(&frame)->web_contents_.get()); base::RunLoop run_loop; - EXPECT_CALL(web_contents_observer, DidFinishLoad(_, url)) + EXPECT_CALL(web_contents_observer, + DidStartNavigation(NavigationHandleUrlEquals(url))) .WillOnce(InvokeWithoutArgs([&run_loop]() { run_loop.Quit(); })); + controller->Reload(chromium::web::ReloadType::NO_CACHE); run_loop.Run(); } + // Reload with PARTIAL_CACHE. { + MockWebContentsObserver web_contents_observer( + context_impl()->GetFrameImplForTest(&frame)->web_contents_.get()); base::RunLoop run_loop; - EXPECT_CALL(web_contents_observer, DidFinishLoad(_, url)) + EXPECT_CALL(web_contents_observer, + DidStartNavigation(NavigationHandleUrlEquals(url))) .WillOnce(InvokeWithoutArgs([&run_loop]() { run_loop.Quit(); })); + controller->Reload(chromium::web::ReloadType::PARTIAL_CACHE); run_loop.Run(); } @@ -377,13 +387,12 @@ GURL title1(embedded_test_server()->GetURL(kPage1Path)); GURL title2(embedded_test_server()->GetURL(kPage2Path)); - MockWebContentsObserver observer; - observer.Observe( + MockWebContentsObserver observer( context_impl()->GetFrameImplForTest(&frame)->web_contents_.get()); { base::RunLoop run_loop; - EXPECT_CALL(observer, DidFinishLoad(_, title1)) + EXPECT_CALL(observer, DidStartNavigation(NavigationHandleUrlEquals(title1))) .WillOnce(InvokeWithoutArgs([&run_loop]() { run_loop.Quit(); })); controller->LoadUrl(title1.spec(), chromium::web::LoadUrlParams()); run_loop.Run(); @@ -391,7 +400,7 @@ { base::RunLoop run_loop; - EXPECT_CALL(observer, DidFinishLoad(_, title2)) + EXPECT_CALL(observer, DidStartNavigation(NavigationHandleUrlEquals(title2))) .WillOnce(InvokeWithoutArgs([&run_loop]() { run_loop.Quit(); })); controller->LoadUrl(title2.spec(), chromium::web::LoadUrlParams()); run_loop.Run(); @@ -709,10 +718,10 @@ GURL title1(embedded_test_server()->GetURL(kPage1Path)); GURL title2(embedded_test_server()->GetURL(kPage2Path)); - MockWebContentsObserver web_contents_observer; - web_contents_observer.Observe( + MockWebContentsObserver web_contents_observer( context_impl()->GetFrameImplForTest(&frame)->web_contents_.get()); - EXPECT_CALL(web_contents_observer, DidFinishLoad(_, title1)); + EXPECT_CALL(web_contents_observer, + DidStartNavigation(NavigationHandleUrlEquals(title1))); controller->LoadUrl(title1.spec(), chromium::web::LoadUrlParams()); navigation_observer_.RunUntilNavigationEquals(title1, kPage1Title); @@ -723,14 +732,14 @@ base::RunLoop().RunUntilIdle(); base::RunLoop run_loop; - EXPECT_CALL(web_contents_observer, DidFinishLoad(_, title2)) + EXPECT_CALL(web_contents_observer, + DidStartNavigation(NavigationHandleUrlEquals(title2))) .WillOnce(InvokeWithoutArgs([&run_loop]() { run_loop.Quit(); })); controller->LoadUrl(title2.spec(), chromium::web::LoadUrlParams()); run_loop.Run(); } -// TODO(crbug.com/947268): Re-enable this once flakiness is addressed. -IN_PROC_BROWSER_TEST_F(FrameImplTest, DISABLED_DelayedNavigationEventAck) { +IN_PROC_BROWSER_TEST_F(FrameImplTest, DelayedNavigationEventAck) { chromium::web::FramePtr frame = CreateFrame(); chromium::web::NavigationControllerPtr controller; @@ -740,9 +749,6 @@ GURL title1(embedded_test_server()->GetURL(kPage1Path)); GURL title2(embedded_test_server()->GetURL(kPage2Path)); - MockWebContentsObserver web_contents_observer; - EXPECT_CALL(web_contents_observer, DidFinishLoad(_, title1)); - // Expect an navigation event here, but deliberately postpone acknowledgement // until the end of the test. base::RunLoop captured_ack_run_loop; @@ -757,29 +763,31 @@ navigation_observer_.RunUntilNavigationEquals(title1, kPage1Title); EXPECT_TRUE(captured_ack_cb); - // Since we have blocked NavigationEventObserver's flow, we must observe the - // WebContents events directly via a test-only seam. - web_contents_observer.Observe( - context_impl()->GetFrameImplForTest(&frame)->web_contents_.get()); - // Navigate to a second page. { + // Since we have blocked NavigationEventObserver's flow, we must observe the + // lower level browser navigation events directly from the WebContents. + MockWebContentsObserver web_contents_observer( + context_impl()->GetFrameImplForTest(&frame)->web_contents_.get()); + base::RunLoop run_loop; - EXPECT_CALL(web_contents_observer, DidFinishLoad(_, title2)) + EXPECT_CALL(web_contents_observer, + DidStartNavigation(NavigationHandleUrlEquals(title2))) .WillOnce(InvokeWithoutArgs([&run_loop]() { run_loop.Quit(); })); controller->LoadUrl(title2.spec(), chromium::web::LoadUrlParams()); run_loop.Run(); - Mock::VerifyAndClearExpectations(this); } // Navigate to the first page. { + MockWebContentsObserver web_contents_observer( + context_impl()->GetFrameImplForTest(&frame)->web_contents_.get()); base::RunLoop run_loop; - EXPECT_CALL(web_contents_observer, DidFinishLoad(_, title1)) + EXPECT_CALL(web_contents_observer, + DidStartNavigation(NavigationHandleUrlEquals(title1))) .WillOnce(InvokeWithoutArgs([&run_loop]() { run_loop.Quit(); })); controller->LoadUrl(title1.spec(), chromium::web::LoadUrlParams()); run_loop.Run(); - Mock::VerifyAndClearExpectations(this); } // Since there was no observable change in navigation state since the last @@ -807,17 +815,15 @@ // indefinitely. GURL hung_url(embedded_test_server()->GetURL("/hung")); - WebContentsObserverForStop observer; - observer.Observe( - context_impl()->GetFrameImplForTest(&frame)->web_contents_.get()); - { base::RunLoop run_loop; + WebContentsObserverForStop observer; + observer.Observe( + context_impl()->GetFrameImplForTest(&frame)->web_contents_.get()); EXPECT_CALL(observer, DidStartNavigation(_)) .WillOnce(InvokeWithoutArgs([&run_loop]() { run_loop.Quit(); })); controller->LoadUrl(hung_url.spec(), chromium::web::LoadUrlParams()); run_loop.Run(); - Mock::VerifyAndClearExpectations(this); } EXPECT_TRUE( @@ -825,11 +831,13 @@ { base::RunLoop run_loop; + WebContentsObserverForStop observer; + observer.Observe( + context_impl()->GetFrameImplForTest(&frame)->web_contents_.get()); EXPECT_CALL(observer, NavigationStopped()) .WillOnce(InvokeWithoutArgs([&run_loop]() { run_loop.Quit(); })); controller->Stop(); run_loop.Run(); - Mock::VerifyAndClearExpectations(this); } EXPECT_FALSE(
diff --git a/fuchsia/engine/browser/web_engine_browser_main_parts.cc b/fuchsia/engine/browser/web_engine_browser_main_parts.cc index 5021c69..1539ab9f 100644 --- a/fuchsia/engine/browser/web_engine_browser_main_parts.cc +++ b/fuchsia/engine/browser/web_engine_browser_main_parts.cc
@@ -12,7 +12,6 @@ #include "base/logging.h" #include "content/public/browser/render_frame_host.h" #include "fuchsia/engine/browser/context_impl.h" -#include "fuchsia/engine/browser/legacy_context_bridge.h" #include "fuchsia/engine/browser/web_engine_browser_context.h" #include "fuchsia/engine/browser/web_engine_screen.h" #include "fuchsia/engine/common.h" @@ -20,8 +19,8 @@ #include "ui/ozone/public/ozone_platform.h" WebEngineBrowserMainParts::WebEngineBrowserMainParts( - zx::channel context_channel) - : context_channel_(std::move(context_channel)) {} + fidl::InterfaceRequest<fuchsia::web::Context> request) + : request_(std::move(request)) {} WebEngineBrowserMainParts::~WebEngineBrowserMainParts() { display::Screen::SetScreenInstance(nullptr); @@ -45,14 +44,10 @@ browser_context_ = std::make_unique<WebEngineBrowserContext>( base::CommandLine::ForCurrentProcess()->HasSwitch(kIncognitoSwitch)); + DCHECK(request_); context_service_ = std::make_unique<ContextImpl>(browser_context_.get()); - - fuchsia::web::ContextPtr fuchsia_context; context_binding_ = std::make_unique<fidl::Binding<fuchsia::web::Context>>( - context_service_.get(), fuchsia_context.NewRequest()); - new LegacyContextBridge(fidl::InterfaceRequest<chromium::web::Context>( - std::move(context_channel_)), - std::move(fuchsia_context)); + context_service_.get(), std::move(request_)); // Quit the browser main loop when the Context connection is dropped. context_binding_->set_error_handler([this](zx_status_t status) {
diff --git a/fuchsia/engine/browser/web_engine_browser_main_parts.h b/fuchsia/engine/browser/web_engine_browser_main_parts.h index 35a1933b..49db75f0 100644 --- a/fuchsia/engine/browser/web_engine_browser_main_parts.h +++ b/fuchsia/engine/browser/web_engine_browser_main_parts.h
@@ -21,10 +21,10 @@ class WebEngineBrowserMainParts : public content::BrowserMainParts { public: - explicit WebEngineBrowserMainParts(zx::channel context_channel); + explicit WebEngineBrowserMainParts( + fidl::InterfaceRequest<fuchsia::web::Context> request); ~WebEngineBrowserMainParts() override; - ContextImpl* context() const { return context_service_.get(); } content::BrowserContext* browser_context() const { return browser_context_.get(); } @@ -34,8 +34,10 @@ void PreDefaultMainMessageLoopRun(base::OnceClosure quit_closure) override; void PostMainMessageLoopRun() override; + ContextImpl* context_for_test() const { return context_service_.get(); } + private: - zx::channel context_channel_; + fidl::InterfaceRequest<fuchsia::web::Context> request_; std::unique_ptr<display::Screen> screen_; std::unique_ptr<WebEngineBrowserContext> browser_context_;
diff --git a/fuchsia/engine/browser/web_engine_content_browser_client.cc b/fuchsia/engine/browser/web_engine_content_browser_client.cc index 8a376845..0cb301c 100644 --- a/fuchsia/engine/browser/web_engine_content_browser_client.cc +++ b/fuchsia/engine/browser/web_engine_content_browser_client.cc
@@ -14,16 +14,16 @@ #include "fuchsia/engine/browser/web_engine_devtools_manager_delegate.h" WebEngineContentBrowserClient::WebEngineContentBrowserClient( - zx::channel context_channel) - : context_channel_(std::move(context_channel)) {} + fidl::InterfaceRequest<fuchsia::web::Context> request) + : request_(std::move(request)) {} WebEngineContentBrowserClient::~WebEngineContentBrowserClient() = default; content::BrowserMainParts* WebEngineContentBrowserClient::CreateBrowserMainParts( const content::MainFunctionParams& parameters) { - DCHECK(context_channel_); - main_parts_ = new WebEngineBrowserMainParts(std::move(context_channel_)); + DCHECK(request_); + main_parts_ = new WebEngineBrowserMainParts(std::move(request_)); return main_parts_; }
diff --git a/fuchsia/engine/browser/web_engine_content_browser_client.h b/fuchsia/engine/browser/web_engine_content_browser_client.h index 66cea8b56..34b3e51 100644 --- a/fuchsia/engine/browser/web_engine_content_browser_client.h +++ b/fuchsia/engine/browser/web_engine_content_browser_client.h
@@ -5,6 +5,7 @@ #ifndef FUCHSIA_ENGINE_BROWSER_WEB_ENGINE_CONTENT_BROWSER_CLIENT_H_ #define FUCHSIA_ENGINE_BROWSER_WEB_ENGINE_CONTENT_BROWSER_CLIENT_H_ +#include <fuchsia/web/cpp/fidl.h> #include <lib/zx/channel.h> #include "base/macros.h" @@ -14,7 +15,8 @@ class WebEngineContentBrowserClient : public content::ContentBrowserClient { public: - explicit WebEngineContentBrowserClient(zx::channel context_channel); + explicit WebEngineContentBrowserClient( + fidl::InterfaceRequest<fuchsia::web::Context> request); ~WebEngineContentBrowserClient() override; WebEngineBrowserMainParts* main_parts_for_test() const { return main_parts_; } @@ -29,7 +31,7 @@ content::WebPreferences* web_prefs) override; private: - zx::channel context_channel_; + fidl::InterfaceRequest<fuchsia::web::Context> request_; WebEngineBrowserMainParts* main_parts_; DISALLOW_COPY_AND_ASSIGN(WebEngineContentBrowserClient);
diff --git a/fuchsia/engine/context_provider_impl.cc b/fuchsia/engine/context_provider_impl.cc index 5921227..de2c27e 100644 --- a/fuchsia/engine/context_provider_impl.cc +++ b/fuchsia/engine/context_provider_impl.cc
@@ -52,8 +52,8 @@ ContextProviderImpl::~ContextProviderImpl() = default; void ContextProviderImpl::Create( - chromium::web::CreateContextParams params, - fidl::InterfaceRequest<chromium::web::Context> context_request) { + fuchsia::web::CreateContextParams params, + fidl::InterfaceRequest<fuchsia::web::Context> context_request) { if (!context_request.is_valid()) { // TODO(crbug.com/934539): Add type epitaph. DLOG(WARNING) << "Invalid |context_request|."; @@ -121,11 +121,6 @@ ignore_result(context_handle.release()); } -void ContextProviderImpl::Bind( - fidl::InterfaceRequest<chromium::web::ContextProvider> request) { - bindings_.AddBinding(this, std::move(request)); -} - void ContextProviderImpl::SetLaunchCallbackForTest( LaunchCallbackForTest launch) { launch_for_test_ = std::move(launch);
diff --git a/fuchsia/engine/context_provider_impl.h b/fuchsia/engine/context_provider_impl.h index 0f39756d..ebb58f49 100644 --- a/fuchsia/engine/context_provider_impl.h +++ b/fuchsia/engine/context_provider_impl.h
@@ -5,6 +5,7 @@ #ifndef FUCHSIA_ENGINE_CONTEXT_PROVIDER_IMPL_H_ #define FUCHSIA_ENGINE_CONTEXT_PROVIDER_IMPL_H_ +#include <fuchsia/web/cpp/fidl.h> #include <lib/fidl/cpp/binding_set.h> #include <memory> @@ -20,7 +21,7 @@ } // namespace base class WEB_ENGINE_EXPORT ContextProviderImpl - : public chromium::web::ContextProvider { + : public fuchsia::web::ContextProvider { public: using LaunchCallbackForTest = base::RepeatingCallback<base::Process( const base::CommandLine& command, @@ -29,15 +30,10 @@ ContextProviderImpl(); ~ContextProviderImpl() override; - // Binds |this| object instance to |request|. - // The service will persist and continue to serve other channels in the event - // that a bound channel is dropped. - void Bind(fidl::InterfaceRequest<chromium::web::ContextProvider> request); - - // chromium::web::ContextProvider implementation. - void Create(chromium::web::CreateContextParams params, - ::fidl::InterfaceRequest<chromium::web::Context> context_request) - override; + // fuchsia::web::ContextProvider implementation. + void Create( + fuchsia::web::CreateContextParams params, + fidl::InterfaceRequest<fuchsia::web::Context> context_request) override; // Sets a |launch| callback to use instead of calling LaunchProcess() to // create Context processes. @@ -48,8 +44,6 @@ // fake Context process to be launched. LaunchCallbackForTest launch_for_test_; - fidl::BindingSet<chromium::web::ContextProvider> bindings_; - DISALLOW_COPY_AND_ASSIGN(ContextProviderImpl); };
diff --git a/fuchsia/engine/context_provider_impl_unittest.cc b/fuchsia/engine/context_provider_impl_unittest.cc index 7f1235f..29c691d 100644 --- a/fuchsia/engine/context_provider_impl_unittest.cc +++ b/fuchsia/engine/context_provider_impl_unittest.cc
@@ -33,6 +33,7 @@ #include "base/test/test_timeouts.h" #include "fuchsia/engine/common.h" #include "fuchsia/engine/fake_context.h" +#include "fuchsia/engine/legacy_context_provider_bridge.h" #include "fuchsia/fidl/chromium/web/cpp/fidl_test_base.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/multiprocess_func_list.h" @@ -56,24 +57,24 @@ } } - zx::channel context_handle(zx_take_startup_handle(kContextRequestHandleId)); - CHECK(context_handle); + fidl::InterfaceRequest<fuchsia::web::Context> fuchsia_context( + zx::channel(zx_take_startup_handle(kContextRequestHandleId))); + CHECK(fuchsia_context); FakeContext context; - fidl::Binding<chromium::web::Context> context_binding( - &context, fidl::InterfaceRequest<chromium::web::Context>( - std::move(context_handle))); + fidl::Binding<fuchsia::web::Context> context_binding( + &context, std::move(fuchsia_context)); - // When a Frame's NavigationEventObserver is bound, immediately broadcast a + // When a Frame's NavigationEventListener is bound, immediately broadcast a // navigation event to its listeners. context.set_on_create_frame_callback( base::BindRepeating([](FakeFrame* frame) { - frame->set_on_set_observer_callback(base::BindOnce( + frame->set_on_set_listener_callback(base::BindOnce( [](FakeFrame* frame) { - chromium::web::NavigationEvent event; - event.url = kUrl; - event.title = kTitle; - frame->observer()->OnNavigationStateChanged(std::move(event), + fuchsia::web::NavigationState state; + state.set_url(kUrl); + state.set_title(kTitle); + frame->listener()->OnNavigationStateChanged(std::move(state), []() {}); }, frame)); @@ -103,10 +104,17 @@ class ContextProviderImplTest : public base::MultiProcessTest { public: ContextProviderImplTest() - : provider_(std::make_unique<ContextProviderImpl>()) { - provider_->SetLaunchCallbackForTest( + : context_provider_(std::make_unique<ContextProviderImpl>()) { + fuchsia::web::ContextProviderPtr fuchsia_context_provider; + legacy_binding_ = + std::make_unique<fidl::Binding<fuchsia::web::ContextProvider>>( + context_provider_.get(), fuchsia_context_provider.NewRequest()); + provider_ = std::make_unique<LegacyContextProviderBridge>( + std::move(fuchsia_context_provider)); + + context_provider_->SetLaunchCallbackForTest( base::BindRepeating(&LaunchFakeContextProcess)); - provider_->Bind(provider_ptr_.NewRequest()); + bindings_.AddBinding(provider_.get(), provider_ptr_.NewRequest()); } ~ContextProviderImplTest() override { @@ -175,8 +183,10 @@ protected: base::MessageLoopForIO message_loop_; - std::unique_ptr<ContextProviderImpl> provider_; + std::unique_ptr<LegacyContextProviderBridge> provider_; + std::unique_ptr<fidl::Binding<fuchsia::web::ContextProvider>> legacy_binding_; chromium::web::ContextProviderPtr provider_ptr_; + fidl::BindingSet<chromium::web::ContextProvider> bindings_; private: struct CapturingNavigationEventObserver @@ -200,6 +210,8 @@ chromium::web::NavigationEvent captured_event_; }; + std::unique_ptr<ContextProviderImpl> context_provider_; + DISALLOW_COPY_AND_ASSIGN(ContextProviderImplTest); }; @@ -214,13 +226,13 @@ TEST_F(ContextProviderImplTest, MultipleConcurrentClients) { // Bind a Provider connection, and create a Context from it. chromium::web::ContextProviderPtr provider_1_ptr; - provider_->Bind(provider_1_ptr.NewRequest()); + bindings_.AddBinding(provider_.get(), provider_1_ptr.NewRequest()); chromium::web::ContextPtr context_1; provider_1_ptr->Create(BuildCreateContextParams(), context_1.NewRequest()); // Do the same on another Provider connection. chromium::web::ContextProviderPtr provider_2_ptr; - provider_->Bind(provider_2_ptr.NewRequest()); + bindings_.AddBinding(provider_.get(), provider_2_ptr.NewRequest()); chromium::web::ContextPtr context_2; provider_2_ptr->Create(BuildCreateContextParams(), context_2.NewRequest()); @@ -296,7 +308,7 @@ // Bind to the ContextProvider. chromium::web::ContextProviderPtr provider; - provider_->Bind(provider.NewRequest()); + bindings_.AddBinding(provider_.get(), provider.NewRequest()); // Verify that our current default job is still empty. ASSERT_TRUE(WaitUntilJobIsEmpty(base::GetDefaultJob(), zx::duration()));
diff --git a/fuchsia/engine/context_provider_main.cc b/fuchsia/engine/context_provider_main.cc index cdf9683..6ecda8c 100644 --- a/fuchsia/engine/context_provider_main.cc +++ b/fuchsia/engine/context_provider_main.cc
@@ -11,6 +11,7 @@ #include "base/run_loop.h" #include "fuchsia/base/lifecycle_impl.h" #include "fuchsia/engine/context_provider_impl.h" +#include "fuchsia/engine/legacy_context_provider_bridge.h" int ContextProviderMain() { base::MessageLoopForUI message_loop; @@ -18,9 +19,17 @@ base::fuchsia::ServiceDirectory::GetDefault(); ContextProviderImpl context_provider; - base::fuchsia::ScopedServiceBinding<chromium::web::ContextProvider> binding( + base::fuchsia::ScopedServiceBinding<fuchsia::web::ContextProvider> binding( directory, &context_provider); + fuchsia::web::ContextProviderPtr fuchsia_context_provider; + fidl::Binding<fuchsia::web::ContextProvider> fuchsia_binding( + &context_provider, fuchsia_context_provider.NewRequest()); + LegacyContextProviderBridge legacy_context_provider( + std::move(fuchsia_context_provider)); + base::fuchsia::ScopedServiceBinding<chromium::web::ContextProvider> + legacy_binding(directory, &legacy_context_provider); + base::RunLoop run_loop; cr_fuchsia::LifecycleImpl lifecycle(directory, run_loop.QuitClosure());
diff --git a/fuchsia/engine/fake_context.cc b/fuchsia/engine/fake_context.cc index 1b1b491..b229509 100644 --- a/fuchsia/engine/fake_context.cc +++ b/fuchsia/engine/fake_context.cc
@@ -7,7 +7,7 @@ #include "base/fuchsia/fuchsia_logging.h" #include "base/logging.h" -FakeFrame::FakeFrame(fidl::InterfaceRequest<chromium::web::Frame> request) +FakeFrame::FakeFrame(fidl::InterfaceRequest<fuchsia::web::Frame> request) : binding_(this, std::move(request)) { binding_.set_error_handler([this](zx_status_t status) { ZX_CHECK(status == ZX_ERR_PEER_CLOSED, status); @@ -18,18 +18,18 @@ FakeFrame::~FakeFrame() = default; void FakeFrame::GetNavigationController( - fidl::InterfaceRequest<chromium::web::NavigationController> controller) { + fidl::InterfaceRequest<fuchsia::web::NavigationController> controller) { if (navigation_controller_) { navigation_controller_bindings_.AddBinding(navigation_controller_, std::move(controller)); } } -void FakeFrame::SetNavigationEventObserver( - fidl::InterfaceHandle<chromium::web::NavigationEventObserver> observer) { - observer_.Bind(std::move(observer)); - if (on_set_observer_callback_) - std::move(on_set_observer_callback_).Run(); +void FakeFrame::SetNavigationEventListener( + fidl::InterfaceHandle<fuchsia::web::NavigationEventListener> listener) { + listener_.Bind(std::move(listener)); + if (on_set_listener_callback_) + std::move(on_set_listener_callback_).Run(); } void FakeFrame::NotImplemented_(const std::string& name) { @@ -40,7 +40,7 @@ FakeContext::~FakeContext() = default; void FakeContext::CreateFrame( - fidl::InterfaceRequest<chromium::web::Frame> frame_request) { + fidl::InterfaceRequest<fuchsia::web::Frame> frame_request) { FakeFrame* new_frame = new FakeFrame(std::move(frame_request)); if (on_create_frame_callback_) on_create_frame_callback_.Run(new_frame);
diff --git a/fuchsia/engine/fake_context.h b/fuchsia/engine/fake_context.h index 3d809f61..e5676333 100644 --- a/fuchsia/engine/fake_context.h +++ b/fuchsia/engine/fake_context.h
@@ -5,6 +5,8 @@ #ifndef FUCHSIA_ENGINE_FAKE_CONTEXT_H_ #define FUCHSIA_ENGINE_FAKE_CONTEXT_H_ +#include <fuchsia/web/cpp/fidl.h> +#include <fuchsia/web/cpp/fidl_test_base.h> #include <lib/fidl/cpp/binding.h> #include <lib/fidl/cpp/binding_set.h> @@ -12,53 +14,51 @@ #include "base/callback.h" #include "base/macros.h" -#include "fuchsia/fidl/chromium/web/cpp/fidl.h" -#include "fuchsia/fidl/chromium/web/cpp/fidl_test_base.h" // A fake Frame implementation that manages its own lifetime. -class FakeFrame : public chromium::web::testing::Frame_TestBase { +class FakeFrame : public fuchsia::web::testing::Frame_TestBase { public: - explicit FakeFrame(fidl::InterfaceRequest<chromium::web::Frame> request); + explicit FakeFrame(fidl::InterfaceRequest<fuchsia::web::Frame> request); ~FakeFrame() override; - void set_on_set_observer_callback(base::OnceClosure callback) { - on_set_observer_callback_ = std::move(callback); + void set_on_set_listener_callback(base::OnceClosure callback) { + on_set_listener_callback_ = std::move(callback); } // Tests can provide e.g a mock NavigationController, which the FakeFrame will // pass bind GetNavigationController() requests to. void set_navigation_controller( - chromium::web::NavigationController* controller) { + fuchsia::web::NavigationController* controller) { navigation_controller_ = controller; } - chromium::web::NavigationEventObserver* observer() { return observer_.get(); } + fuchsia::web::NavigationEventListener* listener() { return listener_.get(); } - // chromium::web::Frame implementation. + // fuchsia::web::Frame implementation. void GetNavigationController( - fidl::InterfaceRequest<chromium::web::NavigationController> controller) + fidl::InterfaceRequest<fuchsia::web::NavigationController> controller) override; - void SetNavigationEventObserver( - fidl::InterfaceHandle<chromium::web::NavigationEventObserver> observer) + void SetNavigationEventListener( + fidl::InterfaceHandle<fuchsia::web::NavigationEventListener> listener) override; - // chromium::web::testing::Frame_TestBase implementation. + // fuchsia::web::testing::Frame_TestBase implementation. void NotImplemented_(const std::string& name) override; private: - fidl::Binding<chromium::web::Frame> binding_; - chromium::web::NavigationEventObserverPtr observer_; - base::OnceClosure on_set_observer_callback_; + fidl::Binding<fuchsia::web::Frame> binding_; + fuchsia::web::NavigationEventListenerPtr listener_; + base::OnceClosure on_set_listener_callback_; - chromium::web::NavigationController* navigation_controller_ = nullptr; - fidl::BindingSet<chromium::web::NavigationController> + fuchsia::web::NavigationController* navigation_controller_ = nullptr; + fidl::BindingSet<fuchsia::web::NavigationController> navigation_controller_bindings_; DISALLOW_COPY_AND_ASSIGN(FakeFrame); }; // An implementation of Context that creates and binds FakeFrames. -class FakeContext : public chromium::web::testing::Context_TestBase { +class FakeContext : public fuchsia::web::testing::Context_TestBase { public: using CreateFrameCallback = base::RepeatingCallback<void(FakeFrame*)>; @@ -70,11 +70,11 @@ on_create_frame_callback_ = callback; } - // chromium::web::Context implementation. + // fuchsia::web::Context implementation. void CreateFrame( - fidl::InterfaceRequest<chromium::web::Frame> frame_request) override; + fidl::InterfaceRequest<fuchsia::web::Frame> frame_request) override; - // chromium::web::testing::Frame_TestBase implementation. + // fuchsia::web::testing::Frame_TestBase implementation. void NotImplemented_(const std::string& name) override; private:
diff --git a/fuchsia/engine/browser/legacy_context_bridge.cc b/fuchsia/engine/legacy_context_bridge.cc similarity index 90% rename from fuchsia/engine/browser/legacy_context_bridge.cc rename to fuchsia/engine/legacy_context_bridge.cc index ef18ecca..5e14c5c0 100644 --- a/fuchsia/engine/browser/legacy_context_bridge.cc +++ b/fuchsia/engine/legacy_context_bridge.cc
@@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "fuchsia/engine/browser/legacy_context_bridge.h" +#include "fuchsia/engine/legacy_context_bridge.h" #include "base/fuchsia/fuchsia_logging.h" -#include "fuchsia/engine/browser/legacy_frame_bridge.h" +#include "fuchsia/engine/legacy_frame_bridge.h" LegacyContextBridge::LegacyContextBridge( fidl::InterfaceRequest<chromium::web::Context> request,
diff --git a/fuchsia/engine/browser/legacy_context_bridge.h b/fuchsia/engine/legacy_context_bridge.h similarity index 86% rename from fuchsia/engine/browser/legacy_context_bridge.h rename to fuchsia/engine/legacy_context_bridge.h index 3d3996e..99fb1367 100644 --- a/fuchsia/engine/browser/legacy_context_bridge.h +++ b/fuchsia/engine/legacy_context_bridge.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FUCHSIA_ENGINE_BROWSER_LEGACY_CONTEXT_BRIDGE_H_ -#define FUCHSIA_ENGINE_BROWSER_LEGACY_CONTEXT_BRIDGE_H_ +#ifndef FUCHSIA_ENGINE_LEGACY_CONTEXT_BRIDGE_H_ +#define FUCHSIA_ENGINE_LEGACY_CONTEXT_BRIDGE_H_ #include <fuchsia/web/cpp/fidl.h> #include <lib/fidl/cpp/binding.h> @@ -34,4 +34,4 @@ DISALLOW_COPY_AND_ASSIGN(LegacyContextBridge); }; -#endif // FUCHSIA_ENGINE_BROWSER_LEGACY_CONTEXT_BRIDGE_H_ +#endif // FUCHSIA_ENGINE_LEGACY_CONTEXT_BRIDGE_H_
diff --git a/fuchsia/engine/legacy_context_provider_bridge.cc b/fuchsia/engine/legacy_context_provider_bridge.cc new file mode 100644 index 0000000..1c65449 --- /dev/null +++ b/fuchsia/engine/legacy_context_provider_bridge.cc
@@ -0,0 +1,35 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "fuchsia/engine/legacy_context_provider_bridge.h" + +#include "base/fuchsia/fuchsia_logging.h" +#include "fuchsia/engine/legacy_context_bridge.h" + +LegacyContextProviderBridge::LegacyContextProviderBridge( + fuchsia::web::ContextProviderPtr handle) + : context_provider_(std::move(handle)) {} + +LegacyContextProviderBridge::~LegacyContextProviderBridge() = default; + +void LegacyContextProviderBridge::Create( + chromium::web::CreateContextParams params, + fidl::InterfaceRequest<chromium::web::Context> context_request) { + fuchsia::web::CreateContextParams fuchsia_params; + if (params.has_service_directory()) { + fuchsia_params.set_service_directory( + std::move(*params.mutable_service_directory())); + } + + if (params.has_data_directory()) { + fuchsia_params.set_data_directory( + std::move(*params.mutable_data_directory())); + } + + fuchsia::web::ContextPtr fuchsia_context; + context_provider_->Create(std::move(fuchsia_params), + fuchsia_context.NewRequest()); + new LegacyContextBridge(std::move(context_request), + std::move(fuchsia_context)); +}
diff --git a/fuchsia/engine/legacy_context_provider_bridge.h b/fuchsia/engine/legacy_context_provider_bridge.h new file mode 100644 index 0000000..c61a7e1 --- /dev/null +++ b/fuchsia/engine/legacy_context_provider_bridge.h
@@ -0,0 +1,32 @@ +// 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 FUCHSIA_ENGINE_LEGACY_CONTEXT_PROVIDER_BRIDGE_H_ +#define FUCHSIA_ENGINE_LEGACY_CONTEXT_PROVIDER_BRIDGE_H_ + +#include <fuchsia/web/cpp/fidl.h> +#include <lib/fidl/cpp/binding_set.h> + +#include "base/macros.h" +#include "fuchsia/fidl/chromium/web/cpp/fidl.h" + +// Allows chromium::web::ContextProvider clients to connect to +// fuchsia::web::ContextProvider instances. +class LegacyContextProviderBridge : public chromium::web::ContextProvider { + public: + LegacyContextProviderBridge(fuchsia::web::ContextProviderPtr handle); + ~LegacyContextProviderBridge() override; + + private: + // chromium::web::ContextProvider implementation. + void Create( + chromium::web::CreateContextParams params, + fidl::InterfaceRequest<chromium::web::Context> context_request) override; + + fuchsia::web::ContextProviderPtr context_provider_; + + DISALLOW_COPY_AND_ASSIGN(LegacyContextProviderBridge); +}; + +#endif // FUCHSIA_ENGINE_LEGACY_CONTEXT_PROVIDER_BRIDGE_H_
diff --git a/fuchsia/engine/browser/legacy_frame_bridge.cc b/fuchsia/engine/legacy_frame_bridge.cc similarity index 95% rename from fuchsia/engine/browser/legacy_frame_bridge.cc rename to fuchsia/engine/legacy_frame_bridge.cc index 4bede06..5d3e464d 100644 --- a/fuchsia/engine/browser/legacy_frame_bridge.cc +++ b/fuchsia/engine/legacy_frame_bridge.cc
@@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "fuchsia/engine/browser/legacy_frame_bridge.h" +#include "fuchsia/engine/legacy_frame_bridge.h" #include "base/fuchsia/fuchsia_logging.h" -#include "fuchsia/engine/browser/legacy_message_port_bridge.h" -#include "fuchsia/engine/browser/legacy_navigation_controller_bridge.h" -#include "fuchsia/engine/browser/legacy_navigation_event_listener_bridge.h" +#include "fuchsia/engine/legacy_message_port_bridge.h" +#include "fuchsia/engine/legacy_navigation_controller_bridge.h" +#include "fuchsia/engine/legacy_navigation_event_listener_bridge.h" namespace {
diff --git a/fuchsia/engine/browser/legacy_frame_bridge.h b/fuchsia/engine/legacy_frame_bridge.h similarity index 93% rename from fuchsia/engine/browser/legacy_frame_bridge.h rename to fuchsia/engine/legacy_frame_bridge.h index d13f72f..0122d42 100644 --- a/fuchsia/engine/browser/legacy_frame_bridge.h +++ b/fuchsia/engine/legacy_frame_bridge.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FUCHSIA_ENGINE_BROWSER_LEGACY_FRAME_BRIDGE_H_ -#define FUCHSIA_ENGINE_BROWSER_LEGACY_FRAME_BRIDGE_H_ +#ifndef FUCHSIA_ENGINE_LEGACY_FRAME_BRIDGE_H_ +#define FUCHSIA_ENGINE_LEGACY_FRAME_BRIDGE_H_ #include <fuchsia/web/cpp/fidl.h> #include <lib/fidl/cpp/binding.h> @@ -67,4 +67,4 @@ DISALLOW_COPY_AND_ASSIGN(LegacyFrameBridge); }; -#endif // FUCHSIA_ENGINE_BROWSER_LEGACY_FRAME_BRIDGE_H_ +#endif // FUCHSIA_ENGINE_LEGACY_FRAME_BRIDGE_H_
diff --git a/fuchsia/engine/browser/legacy_message_port_bridge.cc b/fuchsia/engine/legacy_message_port_bridge.cc similarity index 97% rename from fuchsia/engine/browser/legacy_message_port_bridge.cc rename to fuchsia/engine/legacy_message_port_bridge.cc index bc089431..bb2be80 100644 --- a/fuchsia/engine/browser/legacy_message_port_bridge.cc +++ b/fuchsia/engine/legacy_message_port_bridge.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "fuchsia/engine/browser/legacy_message_port_bridge.h" +#include "fuchsia/engine/legacy_message_port_bridge.h" #include "base/fuchsia/fuchsia_logging.h"
diff --git a/fuchsia/engine/browser/legacy_message_port_bridge.h b/fuchsia/engine/legacy_message_port_bridge.h similarity index 88% rename from fuchsia/engine/browser/legacy_message_port_bridge.h rename to fuchsia/engine/legacy_message_port_bridge.h index cde670c..b935c46 100644 --- a/fuchsia/engine/browser/legacy_message_port_bridge.h +++ b/fuchsia/engine/legacy_message_port_bridge.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FUCHSIA_ENGINE_BROWSER_LEGACY_MESSAGE_PORT_BRIDGE_H_ -#define FUCHSIA_ENGINE_BROWSER_LEGACY_MESSAGE_PORT_BRIDGE_H_ +#ifndef FUCHSIA_ENGINE_LEGACY_MESSAGE_PORT_BRIDGE_H_ +#define FUCHSIA_ENGINE_LEGACY_MESSAGE_PORT_BRIDGE_H_ #include <lib/fidl/cpp/binding.h> @@ -40,4 +40,4 @@ DISALLOW_COPY_AND_ASSIGN(LegacyMessagePortBridge); }; -#endif // FUCHSIA_ENGINE_BROWSER_LEGACY_MESSAGE_PORT_BRIDGE_H_ +#endif // FUCHSIA_ENGINE_LEGACY_MESSAGE_PORT_BRIDGE_H_
diff --git a/fuchsia/engine/browser/legacy_navigation_controller_bridge.cc b/fuchsia/engine/legacy_navigation_controller_bridge.cc similarity index 96% rename from fuchsia/engine/browser/legacy_navigation_controller_bridge.cc rename to fuchsia/engine/legacy_navigation_controller_bridge.cc index 4ad1850..f0b852587 100644 --- a/fuchsia/engine/browser/legacy_navigation_controller_bridge.cc +++ b/fuchsia/engine/legacy_navigation_controller_bridge.cc
@@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "fuchsia/engine/browser/legacy_navigation_controller_bridge.h" +#include "fuchsia/engine/legacy_navigation_controller_bridge.h" #include "base/fuchsia/fuchsia_logging.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" -#include "fuchsia/engine/browser/legacy_frame_bridge.h" +#include "fuchsia/engine/legacy_frame_bridge.h" namespace {
diff --git a/fuchsia/engine/browser/legacy_navigation_controller_bridge.h b/fuchsia/engine/legacy_navigation_controller_bridge.h similarity index 87% rename from fuchsia/engine/browser/legacy_navigation_controller_bridge.h rename to fuchsia/engine/legacy_navigation_controller_bridge.h index 72920881..f5f3e55 100644 --- a/fuchsia/engine/browser/legacy_navigation_controller_bridge.h +++ b/fuchsia/engine/legacy_navigation_controller_bridge.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FUCHSIA_ENGINE_BROWSER_LEGACY_NAVIGATION_CONTROLLER_BRIDGE_H_ -#define FUCHSIA_ENGINE_BROWSER_LEGACY_NAVIGATION_CONTROLLER_BRIDGE_H_ +#ifndef FUCHSIA_ENGINE_LEGACY_NAVIGATION_CONTROLLER_BRIDGE_H_ +#define FUCHSIA_ENGINE_LEGACY_NAVIGATION_CONTROLLER_BRIDGE_H_ #include <fuchsia/web/cpp/fidl.h> #include <lib/fidl/cpp/binding.h> @@ -42,4 +42,4 @@ DISALLOW_COPY_AND_ASSIGN(LegacyNavigationControllerBridge); }; -#endif // FUCHSIA_ENGINE_BROWSER_LEGACY_NAVIGATION_CONTROLLER_BRIDGE_H_ +#endif // FUCHSIA_ENGINE_LEGACY_NAVIGATION_CONTROLLER_BRIDGE_H_
diff --git a/fuchsia/engine/browser/legacy_navigation_event_listener_bridge.cc b/fuchsia/engine/legacy_navigation_event_listener_bridge.cc similarity index 95% rename from fuchsia/engine/browser/legacy_navigation_event_listener_bridge.cc rename to fuchsia/engine/legacy_navigation_event_listener_bridge.cc index c398d4f..fab5357 100644 --- a/fuchsia/engine/browser/legacy_navigation_event_listener_bridge.cc +++ b/fuchsia/engine/legacy_navigation_event_listener_bridge.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "fuchsia/engine/browser/legacy_navigation_event_listener_bridge.h" +#include "fuchsia/engine/legacy_navigation_event_listener_bridge.h" #include "base/fuchsia/fuchsia_logging.h"
diff --git a/fuchsia/engine/browser/legacy_navigation_event_listener_bridge.h b/fuchsia/engine/legacy_navigation_event_listener_bridge.h similarity index 85% rename from fuchsia/engine/browser/legacy_navigation_event_listener_bridge.h rename to fuchsia/engine/legacy_navigation_event_listener_bridge.h index c6cedf8..b831b070 100644 --- a/fuchsia/engine/browser/legacy_navigation_event_listener_bridge.h +++ b/fuchsia/engine/legacy_navigation_event_listener_bridge.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FUCHSIA_ENGINE_BROWSER_LEGACY_NAVIGATION_EVENT_LISTENER_BRIDGE_H_ -#define FUCHSIA_ENGINE_BROWSER_LEGACY_NAVIGATION_EVENT_LISTENER_BRIDGE_H_ +#ifndef FUCHSIA_ENGINE_LEGACY_NAVIGATION_EVENT_LISTENER_BRIDGE_H_ +#define FUCHSIA_ENGINE_LEGACY_NAVIGATION_EVENT_LISTENER_BRIDGE_H_ #include <fuchsia/web/cpp/fidl.h> #include <lib/fidl/cpp/binding.h> @@ -38,4 +38,4 @@ DISALLOW_COPY_AND_ASSIGN(LegacyNavigationEventListenerBridge); }; -#endif // FUCHSIA_ENGINE_BROWSER_LEGACY_NAVIGATION_EVENT_LISTENER_BRIDGE_H_ +#endif // FUCHSIA_ENGINE_LEGACY_NAVIGATION_EVENT_LISTENER_BRIDGE_H_
diff --git a/fuchsia/engine/test/web_engine_browser_test.cc b/fuchsia/engine/test/web_engine_browser_test.cc index 22a042f..fc94228 100644 --- a/fuchsia/engine/test/web_engine_browser_test.cc +++ b/fuchsia/engine/test/web_engine_browser_test.cc
@@ -8,6 +8,7 @@ #include "fuchsia/engine/browser/web_engine_browser_context.h" #include "fuchsia/engine/browser/web_engine_browser_main_parts.h" #include "fuchsia/engine/browser/web_engine_content_browser_client.h" +#include "fuchsia/engine/legacy_context_bridge.h" #include "fuchsia/engine/web_engine_main_delegate.h" #include "net/test/embedded_test_server/default_handlers.h" @@ -22,10 +23,13 @@ WebEngineBrowserTest::~WebEngineBrowserTest() = default; void WebEngineBrowserTest::PreRunTestOnMainThread() { - zx_status_t result = context_.Bind(zx::channel(g_context_channel)); + fuchsia::web::ContextPtr fuchsia_context; + zx_status_t result = fuchsia_context.Bind(zx::channel(g_context_channel)); ZX_DCHECK(result == ZX_OK, result) << "Context::Bind"; g_context_channel = ZX_HANDLE_INVALID; + new LegacyContextBridge(context_.NewRequest(), std::move(fuchsia_context)); + net::test_server::RegisterDefaultHandlers(embedded_test_server()); if (!test_server_root_.empty()) { embedded_test_server()->ServeFilesFromSourceDirectory(test_server_root_); @@ -70,7 +74,7 @@ return WebEngineMainDelegate::GetInstanceForTest() ->browser_client() ->main_parts_for_test() - ->context(); + ->context_for_test(); } } // namespace cr_fuchsia
diff --git a/fuchsia/engine/test/web_engine_test_launcher.cc b/fuchsia/engine/test/web_engine_test_launcher.cc index 10fd25dc..a264ecc 100644 --- a/fuchsia/engine/test/web_engine_test_launcher.cc +++ b/fuchsia/engine/test/web_engine_test_launcher.cc
@@ -39,15 +39,14 @@ content::ContentMainDelegate* CreateContentMainDelegate() override { // Set up the channels for the Context service, but postpone client // binding until after the browser TaskRunners are up and running. - zx::channel server_channel; - zx::channel client_channel; - zx_status_t result = - zx::channel::create(0, &client_channel, &server_channel); - ZX_CHECK(result == ZX_OK, result) << "zx::channel::create"; - cr_fuchsia::WebEngineBrowserTest::SetContextClientChannel( - std::move(client_channel)); + fidl::InterfaceHandle<fuchsia::web::Context> context; + content::ContentMainDelegate* content_main_delegate = + new WebEngineMainDelegate(context.NewRequest()); - return new WebEngineMainDelegate(std::move(server_channel)); + cr_fuchsia::WebEngineBrowserTest::SetContextClientChannel( + context.TakeChannel()); + + return content_main_delegate; } private:
diff --git a/fuchsia/engine/web_engine_main.cc b/fuchsia/engine/web_engine_main.cc index 8849927..af415df 100644 --- a/fuchsia/engine/web_engine_main.cc +++ b/fuchsia/engine/web_engine_main.cc
@@ -17,22 +17,23 @@ std::string process_type = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( service_manager::switches::kProcessType); - zx::channel context_channel; + fidl::InterfaceRequest<fuchsia::web::Context> context; if (process_type.empty()) { // zx_take_startup_handle() is called only when process_type is empty (i.e. // for Browser and ContextProvider processes). Renderer and other child // processes may use the same handle id for other handles. - context_channel.reset(zx_take_startup_handle(kContextRequestHandleId)); + context.set_channel( + zx::channel(zx_take_startup_handle(kContextRequestHandleId))); // If |process_type| is empty then this may be a Browser process, or the // main ContextProvider process. Browser processes will have a // |context_channel| set - if (!context_channel) + if (!context) return ContextProviderMain(); } - WebEngineMainDelegate delegate(std::move(context_channel)); + WebEngineMainDelegate delegate(std::move(context)); content::ContentMainParams params(&delegate); // Repeated base::CommandLine::Init() is ignored, so it's safe to pass null
diff --git a/fuchsia/engine/web_engine_main_delegate.cc b/fuchsia/engine/web_engine_main_delegate.cc index a19fc9d..03718b2f 100644 --- a/fuchsia/engine/web_engine_main_delegate.cc +++ b/fuchsia/engine/web_engine_main_delegate.cc
@@ -56,8 +56,9 @@ return g_current_web_engine_main_delegate; } -WebEngineMainDelegate::WebEngineMainDelegate(zx::channel context_channel) - : context_channel_(std::move(context_channel)) { +WebEngineMainDelegate::WebEngineMainDelegate( + fidl::InterfaceRequest<fuchsia::web::Context> request) + : request_(std::move(request)) { g_current_web_engine_main_delegate = this; } @@ -87,8 +88,8 @@ content::ContentBrowserClient* WebEngineMainDelegate::CreateContentBrowserClient() { DCHECK(!browser_client_); - browser_client_ = std::make_unique<WebEngineContentBrowserClient>( - std::move(context_channel_)); + browser_client_ = + std::make_unique<WebEngineContentBrowserClient>(std::move(request_)); return browser_client_.get(); }
diff --git a/fuchsia/engine/web_engine_main_delegate.h b/fuchsia/engine/web_engine_main_delegate.h index e99b787..8b1b0fb 100644 --- a/fuchsia/engine/web_engine_main_delegate.h +++ b/fuchsia/engine/web_engine_main_delegate.h
@@ -5,6 +5,7 @@ #ifndef FUCHSIA_ENGINE_WEB_ENGINE_MAIN_DELEGATE_H_ #define FUCHSIA_ENGINE_WEB_ENGINE_MAIN_DELEGATE_H_ +#include <fuchsia/web/cpp/fidl.h> #include <lib/zx/channel.h> #include <memory> #include <string> @@ -23,7 +24,8 @@ class WEB_ENGINE_EXPORT WebEngineMainDelegate : public content::ContentMainDelegate { public: - explicit WebEngineMainDelegate(zx::channel context_channel); + explicit WebEngineMainDelegate( + fidl::InterfaceRequest<fuchsia::web::Context> request); ~WebEngineMainDelegate() override; static WebEngineMainDelegate* GetInstanceForTest(); @@ -46,7 +48,7 @@ std::unique_ptr<WebEngineContentBrowserClient> browser_client_; std::unique_ptr<WebEngineContentRendererClient> renderer_client_; - zx::channel context_channel_; + fidl::InterfaceRequest<fuchsia::web::Context> request_; DISALLOW_COPY_AND_ASSIGN(WebEngineMainDelegate); };
diff --git a/gpu/command_buffer/service/gpu_switches.cc b/gpu/command_buffer/service/gpu_switches.cc index ff0f8ae..e920902 100644 --- a/gpu/command_buffer/service/gpu_switches.cc +++ b/gpu/command_buffer/service/gpu_switches.cc
@@ -73,9 +73,6 @@ // tracking. const char kUseCmdDecoder[] = "use-cmd-decoder"; -// Turns on rastering to SkImage with RasterDecoder. -const char kEnableRasterToSkImage[] = "enable-raster-to-sk-image"; - // Enable Vulkan support, must also have ENABLE_VULKAN defined. const char kEnableVulkan[] = "enable-vulkan";
diff --git a/gpu/command_buffer/service/gpu_switches.h b/gpu/command_buffer/service/gpu_switches.h index 60b6a5ed..bff68af 100644 --- a/gpu/command_buffer/service/gpu_switches.h +++ b/gpu/command_buffer/service/gpu_switches.h
@@ -36,7 +36,6 @@ GPU_EXPORT extern const char kGLShaderIntermOutput[]; GPU_EXPORT extern const char kEmulateShaderPrecision[]; GPU_EXPORT extern const char kUseCmdDecoder[]; -GPU_EXPORT extern const char kEnableRasterToSkImage[]; GPU_EXPORT extern const char kEnableVulkan[]; GPU_EXPORT extern const char kDisableVulkanSurface[]; GPU_EXPORT extern const char kDisableVulkanFallbackToGLForTesting[];
diff --git a/gpu/command_buffer/service/service_utils.cc b/gpu/command_buffer/service/service_utils.cc index af3b69a..ca291cdb 100644 --- a/gpu/command_buffer/service/service_utils.cc +++ b/gpu/command_buffer/service/service_utils.cc
@@ -167,8 +167,6 @@ command_line->HasSwitch(switches::kIgnoreGpuBlacklist); gpu_preferences.enable_webgpu = command_line->HasSwitch(switches::kEnableUnsafeWebGPU); - gpu_preferences.enable_raster_to_sk_image = - command_line->HasSwitch(switches::kEnableRasterToSkImage); gpu_preferences.enable_vulkan = command_line->HasSwitch(switches::kEnableVulkan); gpu_preferences.disable_vulkan_surface =
diff --git a/gpu/command_buffer/service/shared_image_factory.cc b/gpu/command_buffer/service/shared_image_factory.cc index 66d40d6b..9480785 100644 --- a/gpu/command_buffer/service/shared_image_factory.cc +++ b/gpu/command_buffer/service/shared_image_factory.cc
@@ -62,7 +62,8 @@ MailboxManager* mailbox_manager, SharedImageManager* shared_image_manager, ImageFactory* image_factory, - MemoryTracker* memory_tracker) + MemoryTracker* memory_tracker, + bool is_using_skia_renderer) : mailbox_manager_(mailbox_manager), shared_image_manager_(shared_image_manager), memory_tracker_(std::make_unique<MemoryTypeTracker>(memory_tracker)), @@ -89,7 +90,10 @@ // Others DCHECK(!using_vulkan_); #endif - if (gpu_preferences.enable_raster_to_sk_image) { + // Certain test suites may enable UseSkiaRenderer feature flag, but never + // create a SkiaRenderer. In this case context_state is nullptr and we should + // not create a WrappedSkImageFactory. + if (is_using_skia_renderer && context_state) { wrapped_sk_image_factory_ = std::make_unique<raster::WrappedSkImageFactory>(context_state); }
diff --git a/gpu/command_buffer/service/shared_image_factory.h b/gpu/command_buffer/service/shared_image_factory.h index 824f2c9..e4e75bb 100644 --- a/gpu/command_buffer/service/shared_image_factory.h +++ b/gpu/command_buffer/service/shared_image_factory.h
@@ -45,7 +45,8 @@ MailboxManager* mailbox_manager, SharedImageManager* manager, ImageFactory* image_factory, - MemoryTracker* tracker); + MemoryTracker* tracker, + bool is_using_skia_renderer); ~SharedImageFactory(); bool CreateSharedImage(const Mailbox& mailbox, @@ -100,7 +101,7 @@ // Used for creating shared image which can be shared between gl and vulakn. std::unique_ptr<SharedImageBackingFactory> interop_backing_factory_; - // Non-null if gpu_preferences.senable_raster_to_sk_image. + // Non-null if compositing with SkiaRenderer. std::unique_ptr<raster::WrappedSkImageFactory> wrapped_sk_image_factory_; };
diff --git a/gpu/command_buffer/service/shared_image_factory_unittest.cc b/gpu/command_buffer/service/shared_image_factory_unittest.cc index fbc5770..c6cfb09 100644 --- a/gpu/command_buffer/service/shared_image_factory_unittest.cc +++ b/gpu/command_buffer/service/shared_image_factory_unittest.cc
@@ -40,7 +40,8 @@ workarounds.max_texture_size = INT_MAX - 1; factory_ = std::make_unique<SharedImageFactory>( preferences, workarounds, GpuFeatureInfo(), nullptr, &mailbox_manager_, - &shared_image_manager_, &image_factory_, nullptr); + &shared_image_manager_, &image_factory_, nullptr, + /*is_using_skia_renderer=*/false); } void TearDown() override { @@ -89,7 +90,8 @@ workarounds.max_texture_size = INT_MAX - 1; auto other_factory = std::make_unique<SharedImageFactory>( preferences, workarounds, GpuFeatureInfo(), nullptr, &mailbox_manager_, - &shared_image_manager_, &image_factory_, nullptr); + &shared_image_manager_, &image_factory_, nullptr, + /*is_using_skia_renderer=*/false); EXPECT_FALSE(other_factory->CreateSharedImage(mailbox, format, size, color_space, usage)); }
diff --git a/gpu/command_buffer/tests/fuzzer_main.cc b/gpu/command_buffer/tests/fuzzer_main.cc index 14f170b..8931747 100644 --- a/gpu/command_buffer/tests/fuzzer_main.cc +++ b/gpu/command_buffer/tests/fuzzer_main.cc
@@ -384,7 +384,8 @@ shared_image_factory_ = std::make_unique<SharedImageFactory>( gpu_preferences_, config_.workarounds, gpu_feature_info, context_state_.get(), &mailbox_manager_, shared_image_manager_.get(), - nullptr /* image_factory */, nullptr /* memory_tracker */); + nullptr /* image_factory */, nullptr /* memory_tracker */, + false /* is_using_skia_renderer */); for (uint32_t usage = SHARED_IMAGE_USAGE_GLES2; usage <= SHARED_IMAGE_USAGE_RGB_EMULATION; usage <<= 1) { Mailbox::Name name;
diff --git a/gpu/config/gpu_preferences.h b/gpu/config/gpu_preferences.h index b866fbf..838aab5 100644 --- a/gpu/config/gpu_preferences.h +++ b/gpu/config/gpu_preferences.h
@@ -195,7 +195,6 @@ bool disable_oop_rasterization = false; bool enable_oop_rasterization_ddl = false; - bool enable_raster_to_sk_image = false; // Start the watchdog suspended, as the app is already backgrounded and won't // send a background/suspend signal.
diff --git a/gpu/ipc/common/gpu_preferences.mojom b/gpu/ipc/common/gpu_preferences.mojom index 04b1901..b6bfac1 100644 --- a/gpu/ipc/common/gpu_preferences.mojom +++ b/gpu/ipc/common/gpu_preferences.mojom
@@ -62,7 +62,6 @@ bool enable_oop_rasterization; bool disable_oop_rasterization; bool enable_oop_rasterization_ddl; - bool enable_raster_to_sk_image; bool watchdog_starts_backgrounded; bool enable_vulkan; bool disable_vulkan_surface;
diff --git a/gpu/ipc/common/gpu_preferences_struct_traits.h b/gpu/ipc/common/gpu_preferences_struct_traits.h index 107ba37..d30fc05 100644 --- a/gpu/ipc/common/gpu_preferences_struct_traits.h +++ b/gpu/ipc/common/gpu_preferences_struct_traits.h
@@ -119,7 +119,6 @@ out->enable_oop_rasterization = prefs.enable_oop_rasterization(); out->disable_oop_rasterization = prefs.disable_oop_rasterization(); out->enable_oop_rasterization_ddl = prefs.enable_oop_rasterization_ddl(); - out->enable_raster_to_sk_image = prefs.enable_raster_to_sk_image(); out->watchdog_starts_backgrounded = prefs.watchdog_starts_backgrounded(); out->enable_vulkan = prefs.enable_vulkan(); out->disable_vulkan_surface = prefs.disable_vulkan_surface(); @@ -261,9 +260,6 @@ static bool enable_oop_rasterization_ddl(const gpu::GpuPreferences& prefs) { return prefs.enable_oop_rasterization_ddl; } - static bool enable_raster_to_sk_image(const gpu::GpuPreferences& prefs) { - return prefs.enable_raster_to_sk_image; - } static bool watchdog_starts_backgrounded(const gpu::GpuPreferences& prefs) { return prefs.watchdog_starts_backgrounded; }
diff --git a/gpu/ipc/in_process_command_buffer.cc b/gpu/ipc/in_process_command_buffer.cc index 4dd1f2d05..375d7184 100644 --- a/gpu/ipc/in_process_command_buffer.cc +++ b/gpu/ipc/in_process_command_buffer.cc
@@ -27,6 +27,7 @@ #include "base/trace_event/memory_dump_manager.h" #include "base/trace_event/trace_event.h" #include "build/build_config.h" +#include "components/viz/common/features.h" #include "gpu/command_buffer/client/gpu_control_client.h" #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" #include "gpu/command_buffer/client/shared_image_interface.h" @@ -1371,7 +1372,7 @@ GetGpuPreferences(), context_group_->feature_info()->workarounds(), GetGpuFeatureInfo(), context_state_.get(), context_group_->mailbox_manager(), task_executor_->shared_image_manager(), - image_factory_, nullptr); + image_factory_, nullptr, features::IsUsingSkiaRenderer()); } void InProcessCommandBuffer::CreateSharedImageOnGpuThread(
diff --git a/gpu/ipc/service/direct_composition_surface_win.cc b/gpu/ipc/service/direct_composition_surface_win.cc index 969d5f37..4f10a94 100644 --- a/gpu/ipc/service/direct_composition_surface_win.cc +++ b/gpu/ipc/service/direct_composition_surface_win.cc
@@ -146,6 +146,54 @@ {OverlayFormat::kBGRA, DXGI_FORMAT_B8G8R8A8_UNORM, 0}, }; +// These values are persisted to logs. Entries should not be renumbered and +// numeric values should never be reused. +enum class OverlayFullScreenTypes { + kWindowMode, + kFullScreenMode, + kFullScreenInWidthOnly, + kFullScreenInHeightOnly, + kOverSizedFullScreen, + kNotAvailable, + kMaxValue = kNotAvailable, +}; + +void RecordOverlayFullScreenTypes(bool workaround_applied, + const gfx::Rect& overlay_onscreen_rect) { + OverlayFullScreenTypes full_screen_type; + const gfx::Size& screen_size = g_overlay_monitor_size; + const gfx::Size& overlay_onscreen_size = overlay_onscreen_rect.size(); + const gfx::Point& origin = overlay_onscreen_rect.origin(); + + // The kFullScreenInWidthOnly type might be over counted, it's possible the + // video width fits the screen but it's still in a window mode. + if (screen_size.IsEmpty()) { + full_screen_type = OverlayFullScreenTypes::kNotAvailable; + } else if (origin.IsOrigin() && overlay_onscreen_size == screen_size) + full_screen_type = OverlayFullScreenTypes::kFullScreenMode; + else if (overlay_onscreen_size.width() > screen_size.width() || + overlay_onscreen_size.height() > screen_size.height()) { + full_screen_type = OverlayFullScreenTypes::kOverSizedFullScreen; + } else if (origin.x() == 0 && + overlay_onscreen_size.width() == screen_size.width()) { + full_screen_type = OverlayFullScreenTypes::kFullScreenInWidthOnly; + } else if (origin.y() == 0 && + overlay_onscreen_size.height() == screen_size.height()) { + full_screen_type = OverlayFullScreenTypes::kFullScreenInHeightOnly; + } else { + full_screen_type = OverlayFullScreenTypes::kWindowMode; + } + + UMA_HISTOGRAM_ENUMERATION("GPU.DirectComposition.OverlayFullScreenTypes", + full_screen_type); + + // TODO(magchen): To be deleted once we know if this workaround is still + // needed + UMA_HISTOGRAM_BOOLEAN( + "GPU.DirectComposition.DisableLargerThanScreenOverlaysWorkaround", + workaround_applied); +} + const char* ProtectedVideoTypeToString(ui::ProtectedVideoType type) { switch (type) { case ui::ProtectedVideoType::kClear: @@ -851,6 +899,10 @@ // to read the minimal amount of data. DWM is also less likely to promote a // surface to an overlay if it's much larger than its area on-screen. gfx::Size swap_chain_size = params.content_rect.size(); + gfx::Size overlay_onscreen_size = swap_chain_size; + gfx::RectF bounds(params.quad_rect); + params.transform.TransformRect(&bounds); + overlay_onscreen_size = gfx::ToEnclosingRect(bounds).size(); // If transform isn't a scale or translation then swap chain can't be promoted // to an overlay so avoid blitting to a large surface unnecessarily. Also, @@ -859,9 +911,7 @@ // the transform to counteract. // TODO(sunnyps): Support 90/180/270 deg rotations using video context. if (params.transform.IsScaleOrTranslation()) { - gfx::RectF bounds(params.quad_rect); - params.transform.TransformRect(&bounds); - swap_chain_size = gfx::ToEnclosingRect(bounds).size(); + swap_chain_size = overlay_onscreen_size; } if (g_supports_scaled_overlays) { @@ -871,6 +921,7 @@ swap_chain_size.SetToMin(params.content_rect.size()); } + bool workaround_applied = false; if (layer_tree_->workarounds().disable_larger_than_screen_overlays && !g_overlay_monitor_size.IsEmpty()) { // Because of the rounding when converting between pixels and DIPs, a @@ -888,14 +939,19 @@ (swap_chain_size.width() <= g_overlay_monitor_size.width() + kOversizeMargin)) { swap_chain_size.set_width(g_overlay_monitor_size.width()); + workaround_applied = true; } if ((swap_chain_size.height() > g_overlay_monitor_size.height()) && (swap_chain_size.height() <= g_overlay_monitor_size.height() + kOversizeMargin)) { swap_chain_size.set_height(g_overlay_monitor_size.height()); + workaround_applied = true; } } + RecordOverlayFullScreenTypes( + workaround_applied, + /*overlay_onscreen_rect*/ gfx::ToEnclosingRect(bounds)); // 4:2:2 subsampled formats like YUY2 must have an even width, and 4:2:0 // subsampled formats like NV12 must have an even width and height.
diff --git a/gpu/ipc/service/shared_image_stub.cc b/gpu/ipc/service/shared_image_stub.cc index 1a0dd1b..fdb04d3 100644 --- a/gpu/ipc/service/shared_image_stub.cc +++ b/gpu/ipc/service/shared_image_stub.cc
@@ -8,6 +8,7 @@ #include "base/trace_event/memory_dump_manager.h" #include "base/trace_event/trace_event.h" +#include "components/viz/common/features.h" #include "gpu/command_buffer/service/mailbox_manager.h" #include "gpu/command_buffer/service/scheduler.h" #include "gpu/command_buffer/service/shared_image_factory.h" @@ -311,7 +312,8 @@ channel_manager->gpu_feature_info(), context_state_.get(), channel_manager->mailbox_manager(), channel_manager->shared_image_manager(), - gmb_factory ? gmb_factory->AsImageFactory() : nullptr, this); + gmb_factory ? gmb_factory->AsImageFactory() : nullptr, this, + features::IsUsingSkiaRenderer()); return ContextResult::kSuccess; }
diff --git a/infra/config/commit-queue.cfg b/infra/config/commit-queue.cfg index 8ea9195..c49fe4413 100644 --- a/infra/config/commit-queue.cfg +++ b/infra/config/commit-queue.cfg
@@ -186,10 +186,46 @@ location_regexp: ".+/[+]/chromeos/CHROMEOS_LKGM" } builders { + name: "chromium/try/chromeos-kevin-rel" + location_regexp: ".+/[+]/build/chromeos/.+" + } + builders { name: "chromium/try/closure_compilation" location_regexp: ".+/[+]/third_party/closure_compiler/.+" } builders { + name: "chromium/try/dawn-linux-x64-deps-rel" + location_regexp: ".+/[+]/testing/buildbot/chromium.dawn.json" + location_regexp: ".+/[+]/third_party/blink/renderer/modules/webgpu/.+" + location_regexp: ".+/[+]/third_party/blink/web_tests/FlagExpectations/enable-unsafe-webgpu" + location_regexp: ".+/[+]/third_party/blink/web_tests/webgpu/.+" + location_regexp: ".+/[+]/third_party/dawn/.+" + } + builders { + name: "chromium/try/dawn-mac-x64-deps-rel" + location_regexp: ".+/[+]/testing/buildbot/chromium.dawn.json" + location_regexp: ".+/[+]/third_party/blink/renderer/modules/webgpu/.+" + location_regexp: ".+/[+]/third_party/blink/web_tests/FlagExpectations/enable-unsafe-webgpu" + location_regexp: ".+/[+]/third_party/blink/web_tests/webgpu/.+" + location_regexp: ".+/[+]/third_party/dawn/.+" + } + builders { + name: "chromium/try/dawn-win10-x64-deps-rel" + location_regexp: ".+/[+]/testing/buildbot/chromium.dawn.json" + location_regexp: ".+/[+]/third_party/blink/renderer/modules/webgpu/.+" + location_regexp: ".+/[+]/third_party/blink/web_tests/FlagExpectations/enable-unsafe-webgpu" + location_regexp: ".+/[+]/third_party/blink/web_tests/webgpu/.+" + location_regexp: ".+/[+]/third_party/dawn/.+" + } + builders { + name: "chromium/try/dawn-win10-x86-deps-rel" + location_regexp: ".+/[+]/testing/buildbot/chromium.dawn.json" + location_regexp: ".+/[+]/third_party/blink/renderer/modules/webgpu/.+" + location_regexp: ".+/[+]/third_party/blink/web_tests/FlagExpectations/enable-unsafe-webgpu" + location_regexp: ".+/[+]/third_party/blink/web_tests/webgpu/.+" + location_regexp: ".+/[+]/third_party/dawn/.+" + } + builders { name: "chromium/try/ios-simulator-cronet" location_regexp: ".+/[+]/components/cronet/.+" location_regexp: ".+/[+]/components/grpc_support/.+"
diff --git a/infra/config/cr-buildbucket.cfg b/infra/config/cr-buildbucket.cfg index 928c8c1..66a75ea 100644 --- a/infra/config/cr-buildbucket.cfg +++ b/infra/config/cr-buildbucket.cfg
@@ -843,30 +843,35 @@ builders { name: "Android WebView L (dbg)" mixins: "android-ci" + mixins: "builderless" dimensions: "os:Ubuntu-14.04" } builders { name: "Android WebView M (dbg)" mixins: "android-ci" + mixins: "builderless" dimensions: "os:Ubuntu-14.04" } builders { name: "Android WebView N (dbg)" mixins: "android-ci" + mixins: "builderless" dimensions: "os:Ubuntu-14.04" } builders { name: "Android WebView O (dbg)" mixins: "android-ci" + mixins: "builderless" dimensions: "os:Ubuntu-14.04" } builders { name: "Android WebView O NetworkService (dbg)" mixins: "android-fyi-ci" + mixins: "builderless" dimensions: "os:Ubuntu-14.04" } @@ -2934,6 +2939,56 @@ mixins: "goma-ci" mixins: "goma-j300" } + # Goma RBE FYI + builders { + name: "Cast Linux (Goma RBE FYI)" + dimensions: "os:Ubuntu-14.04" + mixins: "experimental" + mixins: "goma-ci" + mixins: "goma-ats" + auto_builder_dimension: NO + } + builders { + name: "chromeos-amd64-generic-rel (Goma RBE FYI)" + dimensions: "os:Ubuntu-14.04" + mixins: "experimental" + mixins: "goma-ci" + mixins: "goma-ats" + auto_builder_dimension: NO + } + builders { + name: "fuchsia-fyi-arm64-rel (Goma RBE FYI)" + dimensions: "os:Ubuntu-14.04" + mixins: "experimental" + mixins: "goma-ci" + mixins: "goma-ats" + auto_builder_dimension: NO + } + builders { + name: "fuchsia-fyi-x64-rel (Goma RBE FYI)" + dimensions: "os:Ubuntu-14.04" + mixins: "experimental" + mixins: "goma-ci" + mixins: "goma-ats" + auto_builder_dimension: NO + } + builders { + name: "Linux ASan LSan Builder (Goma RBE FYI)" + dimensions: "os:Ubuntu-14.04" + mixins: "experimental" + mixins: "goma-ci" + mixins: "goma-ats" + auto_builder_dimension: NO + } + builders { + name: "Linux MSan Builder (Goma RBE FYI)" + dimensions: "os:Ubuntu-14.04" + mixins: "experimental" + mixins: "goma-ci" + mixins: "goma-ats" + auto_builder_dimension: NO + } + # Goma Staging builders { name: "Chromium Mac Goma Staging" dimensions: "os:Mac-10.13"
diff --git a/infra/config/luci-milo.cfg b/infra/config/luci-milo.cfg index 2178ee6..49c400a 100644 --- a/infra/config/luci-milo.cfg +++ b/infra/config/luci-milo.cfg
@@ -2927,6 +2927,46 @@ consoles { header_id: "chromium" + id: "chromium.goma.fyi" + name: "chromium.goma.fyi" + repo_url: "https://chromium.googlesource.com/chromium/src" + refs: "refs/heads/master" + manifest_name: "REVISION" + include_experimental_builds: true + builders { + name: "buildbucket/luci.chromium.ci/Cast Linux (Goma RBE FYI)" + category: "chromium.linux|cast" + short_name: "vid" + } + builders { + name: "buildbucket/luci.chromium.ci/fuchsia-fyi-arm64-rel (Goma RBE FYI)" + category: "chromium.linux|fuchsia|misc" + short_name: "a64" + } + builders { + name: "buildbucket/luci.chromium.ci/fuchsia-fyi-x64-rel (Goma RBE FYI)" + category: "chromium.linux|fuchsia|misc" + short_name: "x64" + } + builders { + name: "buildbucket/luci.chromium.ci/chromeos-amd64-generic-rel (Goma RBE FYI)" + category: "chromium.chromiumos|simple|release|x64" + short_name: "rel" + } + builders { + name: "buildbucket/luci.chromium.ci/Linux ASan LSan Builder (Goma RBE FYI)" + category: "chromium.memory|linux|asan lsan" + short_name: "bld" + } + builders { + name: "buildbucket/luci.chromium.ci/Linux MSan Builder (Goma RBE FYI)" + category: "chromium.memory|linux|msan" + short_name: "bld" + } +} + +consoles { + header_id: "chromium" id: "chromium.gpu" name: "chromium.gpu" repo_url: "https://chromium.googlesource.com/chromium/src"
diff --git a/infra/config/luci-scheduler.cfg b/infra/config/luci-scheduler.cfg index 3980ea3..59b8997 100644 --- a/infra/config/luci-scheduler.cfg +++ b/infra/config/luci-scheduler.cfg
@@ -99,6 +99,7 @@ triggers: "Cast Android (dbg)" triggers: "Cast Audio Linux" triggers: "Cast Linux" + triggers: "Cast Linux (Goma RBE FYI)" triggers: "Chromium Android ARM 32-bit Goma RBE LoadTest" triggers: "Chromium Android ARM 32-bit Goma RBE LoadTest (clobber)" triggers: "Chromium Android ARM 32-bit Goma RBE LoadTest (clobber) (debug)" @@ -197,6 +198,7 @@ triggers: "Libfuzzer Upload Windows ASan" triggers: "Linux ARM" triggers: "Linux ASan LSan Builder" + triggers: "Linux ASan LSan Builder (Goma RBE FYI)" triggers: "Linux Builder (dbg)" triggers: "Linux Builder (dbg)(32)" triggers: "Linux Builder Goma Canary" @@ -208,6 +210,7 @@ triggers: "Linux ChromiumOS MSan Builder" triggers: "Linux FYI GPU TSAN Release" triggers: "Linux MSan Builder" + triggers: "Linux MSan Builder (Goma RBE FYI)" triggers: "Linux TSan Builder" triggers: "Linux Viz" triggers: "Linux remote_run Builder" @@ -320,6 +323,7 @@ triggers: "chromeos-amd64-generic-asan-rel" triggers: "chromeos-amd64-generic-cfi-thin-lto-rel" triggers: "chromeos-amd64-generic-rel" + triggers: "chromeos-amd64-generic-rel (Goma RBE FYI)" triggers: "chromeos-amd64-generic-rel-goma-canary" triggers: "chromeos-amd64-generic-rel-goma-latest" triggers: "chromeos-amd64-generic-rel-vm-tests" @@ -328,8 +332,10 @@ triggers: "chromeos-kevin-rel-hw-tests" triggers: "chromeos-vm-code-coverage" triggers: "fuchsia-fyi-arm64-rel" + triggers: "fuchsia-fyi-arm64-rel (Goma RBE FYI)" triggers: "fuchsia-fyi-x64-dbg" triggers: "fuchsia-fyi-x64-rel" + triggers: "fuchsia-fyi-x64-rel (Goma RBE FYI)" triggers: "ios-simulator-code-coverage" triggers: "ios-device" triggers: "ios-device-goma-canary-clobber" @@ -5018,6 +5024,66 @@ } job { + id: "Cast Linux (Goma RBE FYI)" + acl_sets: "default" + buildbucket: { + server: "cr-buildbucket.appspot.com" + bucket: "luci.chromium.ci" + builder: "Cast Linux (Goma RBE FYI)" + } +} + +job { + id: "Linux ASan LSan Builder (Goma RBE FYI)" + acl_sets: "default" + buildbucket: { + server: "cr-buildbucket.appspot.com" + bucket: "luci.chromium.ci" + builder: "Linux ASan LSan Builder (Goma RBE FYI)" + } +} + +job { + id: "Linux MSan Builder (Goma RBE FYI)" + acl_sets: "default" + buildbucket: { + server: "cr-buildbucket.appspot.com" + bucket: "luci.chromium.ci" + builder: "Linux MSan Builder (Goma RBE FYI)" + } +} + +job { + id: "chromeos-amd64-generic-rel (Goma RBE FYI)" + acl_sets: "default" + buildbucket: { + server: "cr-buildbucket.appspot.com" + bucket: "luci.chromium.ci" + builder: "chromeos-amd64-generic-rel (Goma RBE FYI)" + } +} + +job { + id: "fuchsia-fyi-arm64-rel (Goma RBE FYI)" + acl_sets: "default" + buildbucket: { + server: "cr-buildbucket.appspot.com" + bucket: "luci.chromium.ci" + builder: "fuchsia-fyi-arm64-rel (Goma RBE FYI)" + } +} + +job { + id: "fuchsia-fyi-x64-rel (Goma RBE FYI)" + acl_sets: "default" + buildbucket: { + server: "cr-buildbucket.appspot.com" + bucket: "luci.chromium.ci" + builder: "fuchsia-fyi-x64-rel (Goma RBE FYI)" + } +} + +job { id: "Chromium Mac Goma Staging" acl_sets: "default" buildbucket: {
diff --git a/ios/chrome/app/strings/ios_strings.grd b/ios/chrome/app/strings/ios_strings.grd index 267fac2..3373b2a4 100644 --- a/ios/chrome/app/strings/ios_strings.grd +++ b/ios/chrome/app/strings/ios_strings.grd
@@ -1661,6 +1661,15 @@ <message name="IDS_IOS_SYNC_SETTING_TITLE" desc="The title for the Sync control for sync [iOS only]"> Sync </message> + <message name="IDS_IOS_SYNC_SETTINGS_NOT_CONFIRMED" desc="The error message to display when sign-in was interrupted and the user didn't review the sync settings."> + Initial sync setup was not finished. Sync is off. + </message> + <message name="IDS_IOS_SYNC_SETTINGS_NOT_CONFIRMED_ACTION" desc="Button title to invite the user to review sync settings. The sign-in flow has been interrupted and the user never confirmed Sync."> + Open Settings + </message> + <message name="IDS_IOS_SYNC_SETTINGS_NOT_CONFIRMED_DESCRIPTION" desc="The error message to display when sign-in was interrupted and the user didn't review the sync settings."> + Initial sync setup was not finished. To start Sync, enabled the Sync toggle. + </message> <message name="IDS_IOS_SYNC_SETUP_IN_PROGRESS" desc="The message to display when the sync setup is in progress and sync isn't available yet. [Length: 60em] [iOS only]"> Setup in progress… </message>
diff --git a/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SYNC_MISSING_SYNC_SETUP_COMPLETE.png.sha1 b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SYNC_MISSING_SYNC_SETUP_COMPLETE.png.sha1 new file mode 100644 index 0000000..757d4f0f --- /dev/null +++ b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SYNC_MISSING_SYNC_SETUP_COMPLETE.png.sha1
@@ -0,0 +1 @@ +9a8ad4591276fd9ffe8c00e3182af82ef05da20c \ No newline at end of file
diff --git a/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SYNC_MISSING_SYNC_SETUP_COMPLETE_ACTION.png.sha1 b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SYNC_MISSING_SYNC_SETUP_COMPLETE_ACTION.png.sha1 new file mode 100644 index 0000000..757d4f0f --- /dev/null +++ b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SYNC_MISSING_SYNC_SETUP_COMPLETE_ACTION.png.sha1
@@ -0,0 +1 @@ +9a8ad4591276fd9ffe8c00e3182af82ef05da20c \ No newline at end of file
diff --git a/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SYNC_MISSING_SYNC_SETUP_COMPLETE_DESCRIPTION.png.sha1 b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SYNC_MISSING_SYNC_SETUP_COMPLETE_DESCRIPTION.png.sha1 new file mode 100644 index 0000000..2b56100b --- /dev/null +++ b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SYNC_MISSING_SYNC_SETUP_COMPLETE_DESCRIPTION.png.sha1
@@ -0,0 +1 @@ +0fc027c078994c41cc13f14aeca59295ba186ddf \ No newline at end of file
diff --git a/ios/chrome/browser/about_flags.mm b/ios/chrome/browser/about_flags.mm index 491ce8d..92d57e5e 100644 --- a/ios/chrome/browser/about_flags.mm +++ b/ios/chrome/browser/about_flags.mm
@@ -586,6 +586,18 @@ flag_descriptions::kOmniboxUseDefaultSearchEngineFaviconDescription, flags_ui::kOsIos, FEATURE_VALUE_TYPE(kOmniboxUseDefaultSearchEngineFavicon)}, + {"enable-autofill-import-dynamic-forms", + flag_descriptions::kEnableAutofillImportDynamicFormsName, + flag_descriptions::kEnableAutofillImportDynamicFormsDescription, + flags_ui::kOsIos, + FEATURE_VALUE_TYPE(autofill::features::kAutofillImportDynamicForms)}, + {"enable-autofill-import-non-focusable-credit-card-forms", + flag_descriptions::kEnableAutofillImportNonFocusableCreditCardFormsName, + flag_descriptions:: + kEnableAutofillImportNonFocusableCreditCardFormsDescription, + flags_ui::kOsIos, + FEATURE_VALUE_TYPE( + autofill::features::kAutofillImportNonFocusableCreditCardForms)}, }; // 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 c89742a..fa9b535 100644 --- a/ios/chrome/browser/ios_chrome_flag_descriptions.cc +++ b/ios/chrome/browser/ios_chrome_flag_descriptions.cc
@@ -169,6 +169,19 @@ "When enabled, autofill will generally require a form to have at least 3 " "fillable fields before uploading field-type votes for that form."; +const char kEnableAutofillImportDynamicFormsName[] = + "Allow credit card import from dynamic forms after entry"; +const char kEnableAutofillImportDynamicFormsDescription[] = + "If enabled, offers credit card save for dynamic forms from the page after " + "information has been entered into them."; + +const char kEnableAutofillImportNonFocusableCreditCardFormsName[] = + "Allow credit card import from forms that disappear after entry"; +const char kEnableAutofillImportNonFocusableCreditCardFormsDescription[] = + "If enabled, offers credit card save for forms that are hidden from the " + "page after information has been entered into them, including " + "accordion-style checkout flows."; + const char kAutofillIOSDelayBetweenFieldsName[] = "Autofill delay"; const char kAutofillIOSDelayBetweenFieldsDescription[] = "Delay between the different fields of a form being autofilled. In "
diff --git a/ios/chrome/browser/ios_chrome_flag_descriptions.h b/ios/chrome/browser/ios_chrome_flag_descriptions.h index 89b0e27f..e2a6e475 100644 --- a/ios/chrome/browser/ios_chrome_flag_descriptions.h +++ b/ios/chrome/browser/ios_chrome_flag_descriptions.h
@@ -125,6 +125,16 @@ extern const char kAutofillEnforceMinRequiredFieldsForUploadName[]; extern const char kAutofillEnforceMinRequiredFieldsForUploadDescription[]; +// Title and description for the flag to control the credit card import from +// dynamic forms. +extern const char kEnableAutofillImportDynamicFormsName[]; +extern const char kEnableAutofillImportDynamicFormsDescription[]; + +// Title and description for the flag to control the credit card import from +// accordion forms. +extern const char kEnableAutofillImportNonFocusableCreditCardFormsName[]; +extern const char kEnableAutofillImportNonFocusableCreditCardFormsDescription[]; + // Title and description for the flag to control the autofill delay. extern const char kAutofillIOSDelayBetweenFieldsName[]; extern const char kAutofillIOSDelayBetweenFieldsDescription[];
diff --git a/ios/chrome/browser/sync/sync_setup_service.cc b/ios/chrome/browser/sync/sync_setup_service.cc index 7c5c4e2..870cd694 100644 --- a/ios/chrome/browser/sync/sync_setup_service.cc +++ b/ios/chrome/browser/sync/sync_setup_service.cc
@@ -85,11 +85,11 @@ case SyncSetupService::kSyncServiceSignInNeedsUpdate: case SyncSetupService::kSyncServiceNeedsPassphrase: case SyncSetupService::kSyncServiceUnrecoverableError: - return true; - default: - NOTREACHED() << "Unknown sync service state."; + case SyncSetupService::kSyncSettingsNotConfirmed: return true; } + NOTREACHED() << "Unknown sync service state."; + return true; } bool SyncSetupService::IsSyncingAllDataTypes() const { @@ -154,6 +154,8 @@ return kSyncServiceUnrecoverableError; if (sync_service_->GetUserSettings()->IsPassphraseRequiredForDecryption()) return kSyncServiceNeedsPassphrase; + if (!IsFirstSetupComplete() && IsSyncEnabled()) + return kSyncSettingsNotConfirmed; return kNoSyncServiceError; }
diff --git a/ios/chrome/browser/sync/sync_setup_service.h b/ios/chrome/browser/sync/sync_setup_service.h index 90d8041..b807044 100644 --- a/ios/chrome/browser/sync/sync_setup_service.h +++ b/ios/chrome/browser/sync/sync_setup_service.h
@@ -28,6 +28,7 @@ kSyncServiceServiceUnavailable, kSyncServiceNeedsPassphrase, kSyncServiceUnrecoverableError, + kSyncSettingsNotConfirmed, kLastSyncServiceError = kSyncServiceUnrecoverableError };
diff --git a/ios/chrome/browser/ui/browser_view/browser_view_controller.mm b/ios/chrome/browser/ui/browser_view/browser_view_controller.mm index 749ae4d..8d75dc1 100644 --- a/ios/chrome/browser/ui/browser_view/browser_view_controller.mm +++ b/ios/chrome/browser/ui/browser_view/browser_view_controller.mm
@@ -4897,6 +4897,10 @@ [self.dispatcher showSyncPassphraseSettingsFromViewController:self]; } +- (void)showGoogleServicesSettings { + [self.dispatcher showGoogleServicesSettingsFromViewController:self]; +} + #pragma mark - NewTabPageTabHelperDelegate - (void)newTabPageHelperDidChangeVisibility:(NewTabPageTabHelper*)NTPHelper
diff --git a/ios/chrome/browser/ui/recent_tabs/recent_tabs_table_view_controller.mm b/ios/chrome/browser/ui/recent_tabs/recent_tabs_table_view_controller.mm index 481484d..b96c256 100644 --- a/ios/chrome/browser/ui/recent_tabs/recent_tabs_table_view_controller.mm +++ b/ios/chrome/browser/ui/recent_tabs/recent_tabs_table_view_controller.mm
@@ -1125,6 +1125,10 @@ [self.dispatcher showSyncPassphraseSettingsFromViewController:self]; } +- (void)showGoogleServicesSettings { + [self.dispatcher showGoogleServicesSettingsFromViewController:self]; +} + #pragma mark - SigninPresenter - (void)showSignin:(ShowSigninCommand*)command {
diff --git a/ios/chrome/browser/ui/settings/google_services/google_services_navigation_coordinator.h b/ios/chrome/browser/ui/settings/google_services/google_services_navigation_coordinator.h index f87e1e02..137c8b4 100644 --- a/ios/chrome/browser/ui/settings/google_services/google_services_navigation_coordinator.h +++ b/ios/chrome/browser/ui/settings/google_services/google_services_navigation_coordinator.h
@@ -28,6 +28,9 @@ // Global dispatcher. @property(nonatomic, weak) id<ApplicationCommands> dispatcher; +// Dismisses the Google services navigation view controller. +- (void)dismissAnimated:(BOOL)animated; + @end #endif // IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_GOOGLE_SERVICES_NAVIGATION_COORDINATOR_H_
diff --git a/ios/chrome/browser/ui/settings/google_services/google_services_navigation_coordinator.mm b/ios/chrome/browser/ui/settings/google_services/google_services_navigation_coordinator.mm index e58bc8d71..8a7c2ee 100644 --- a/ios/chrome/browser/ui/settings/google_services/google_services_navigation_coordinator.mm +++ b/ios/chrome/browser/ui/settings/google_services/google_services_navigation_coordinator.mm
@@ -52,27 +52,35 @@ completion:nil]; } -// This method should be moved to the view controller. -- (UIBarButtonItem*)closeButton { - UIBarButtonItem* closeButton = - [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon closeIcon] - target:self - action:@selector(closeSettings)]; - closeButton.accessibilityLabel = l10n_util::GetNSString(IDS_ACCNAME_CLOSE); - return closeButton; -} - -- (void)closeSettings { +- (void)dismissAnimated:(BOOL)animated { DCHECK_EQ(self.navigationController, self.baseViewController.presentedViewController); + DCHECK(self.googleServicesSettingsCoordinator); void (^completion)(void) = ^{ [self.googleServicesSettingsCoordinator stop]; self.googleServicesSettingsCoordinator.delegate = nil; self.googleServicesSettingsCoordinator = nil; [self.delegate googleServicesNavigationCoordinatorDidClose:self]; }; - [self.baseViewController dismissViewControllerAnimated:YES + [self.baseViewController dismissViewControllerAnimated:animated completion:completion]; } +#pragma mark - Private + +// This method should be moved to the view controller. +- (UIBarButtonItem*)closeButton { + UIBarButtonItem* closeButton = + [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon closeIcon] + target:self + action:@selector(closeButtonAction)]; + closeButton.accessibilityLabel = l10n_util::GetNSString(IDS_ACCNAME_CLOSE); + return closeButton; +} + +// Called by the close button. +- (void)closeButtonAction { + [self dismissAnimated:YES]; +} + @end
diff --git a/ios/chrome/browser/ui/settings/google_services/google_services_settings_coordinator.mm b/ios/chrome/browser/ui/settings/google_services/google_services_settings_coordinator.mm index fb53eed..926b8a6 100644 --- a/ios/chrome/browser/ui/settings/google_services/google_services_settings_coordinator.mm +++ b/ios/chrome/browser/ui/settings/google_services/google_services_settings_coordinator.mm
@@ -113,13 +113,10 @@ SyncSetupService* syncSetupService = SyncSetupServiceFactory::GetForBrowserState(self.browserState); if (self.mode == GoogleServicesSettingsModeSettings && - !syncSetupService->IsFirstSetupComplete() && - syncSetupService->IsSyncEnabled()) { - // Google services settings has been opened in the settings mode, and - // FirstSetupComplete is off, this means the user never accepted or - // refused to turn Sync on. - // When closing, FirstSetupComplete is still off, so the user doesn't - // want to turn Sync on. To acknowledge, Sync has to be turned off. + syncSetupService->GetSyncServiceState() == + SyncSetupService::kSyncSettingsNotConfirmed) { + // If Sync is still in aborted state, this means the user didn't turn on + // sync, and wants Sync off. To acknowledge, Sync has to be turned off. syncSetupService->SetSyncEnabled(false); } syncSetupService->CommitSyncChanges();
diff --git a/ios/chrome/browser/ui/settings/google_services/google_services_settings_mediator.mm b/ios/chrome/browser/ui/settings/google_services/google_services_settings_mediator.mm index f9279e3..2db8a92a 100644 --- a/ios/chrome/browser/ui/settings/google_services/google_services_settings_mediator.mm +++ b/ios/chrome/browser/ui/settings/google_services/google_services_settings_mediator.mm
@@ -65,6 +65,7 @@ ReauthDialogAsSyncIsInAuthErrorItemType, ShowPassphraseDialogErrorItemType, SyncDisabledByAdministratorErrorItemType, + SyncSettingsNotCofirmedErrorItemType, SyncChromeDataItemType, ManageSyncItemType, // NonPersonalizedSectionIdentifier section. @@ -96,8 +97,8 @@ // Returns YES if the user is authenticated. @property(nonatomic, assign, readonly) BOOL isAuthenticated; -// Returns YES if Sync setup is in progress. -@property(nonatomic, assign, readonly) BOOL isSyncSetupInProgress; +// Returns YES if Sync settings has been confirmed. +@property(nonatomic, assign, readonly) BOOL isSyncSettingsConfirmed; // Returns YES if the user cannot turn on sync for enterprise policy reasons. @property(nonatomic, assign, readonly) BOOL isSyncDisabledByAdministrator; // Returns YES if the user is allowed to turn on sync (even if there is a sync @@ -242,7 +243,7 @@ [self.resizedAvatarCache resizedAvatarForIdentity:identity]; self.accountItem.text = identity.userFullName; if (self.mode == GoogleServicesSettingsModeAdvancedSigninSettings || - self.isSyncSetupInProgress) { + self.isSyncSettingsConfirmed) { self.accountItem.detailText = GetNSString(IDS_IOS_SYNC_SETUP_IN_PROGRESS); } else { self.accountItem.detailText = identity.userEmail; @@ -338,6 +339,12 @@ type = ShowPassphraseDialogErrorItemType; hasError = YES; break; + case SyncSetupService::kSyncSettingsNotConfirmed: + if (self.mode == GoogleServicesSettingsModeSettings) { + type = SyncSettingsNotCofirmedErrorItemType; + hasError = YES; + } + break; case SyncSetupService::kNoSyncServiceError: case SyncSetupService::kSyncServiceCouldNotConnect: case SyncSetupService::kSyncServiceServiceUnavailable: @@ -362,7 +369,7 @@ } // Add the sync error item and its section. if (type == SyncDisabledByAdministratorErrorItemType) { - self.syncErrorItem = [self createSyncDisabledByAdministrator]; + self.syncErrorItem = [self createSyncDisabledByAdministratorErrorItem]; } else { self.syncErrorItem = [self createSyncErrorItemWithItemType:type]; } @@ -477,6 +484,7 @@ case ReauthDialogAsSyncIsInAuthErrorItemType: case ShowPassphraseDialogErrorItemType: case SyncDisabledByAdministratorErrorItemType: + case SyncSettingsNotCofirmedErrorItemType: case SyncChromeDataItemType: case ManageSyncItemType: NOTREACHED(); @@ -491,11 +499,9 @@ return self.authService->IsAuthenticated(); } -- (BOOL)isSyncSetupInProgress { - return self.isAuthenticated && - (self.mode == GoogleServicesSettingsModeAdvancedSigninSettings || - (self.syncSetupService->IsSyncEnabled() && - !self.syncSetupService->IsFirstSetupComplete())); +- (BOOL)isSyncSettingsConfirmed { + return self.syncSetupService->GetSyncServiceState() == + SyncSetupService::kSyncSettingsNotConfirmed; } - (BOOL)isSyncDisabledByAdministrator { @@ -563,10 +569,12 @@ // + RestartAuthenticationFlowErrorItemType // + ReauthDialogAsSyncIsInAuthErrorItemType // + ShowPassphraseDialogErrorItemType +// + SyncSettingsNotCofirmedErrorItemType - (TableViewItem*)createSyncErrorItemWithItemType:(NSInteger)itemType { DCHECK(itemType == RestartAuthenticationFlowErrorItemType || itemType == ReauthDialogAsSyncIsInAuthErrorItemType || - itemType == ShowPassphraseDialogErrorItemType); + itemType == ShowPassphraseDialogErrorItemType || + itemType == SyncSettingsNotCofirmedErrorItemType); SettingsImageDetailTextItem* syncErrorItem = [[SettingsImageDetailTextItem alloc] initWithType:itemType]; syncErrorItem.text = GetNSString(IDS_IOS_SYNC_ERROR_TITLE); @@ -585,7 +593,7 @@ // Returns an item to show to the user the sync cannot be turned on for an // enterprise policy reason. -- (TableViewItem*)createSyncDisabledByAdministrator { +- (TableViewItem*)createSyncDisabledByAdministratorErrorItem { TableViewImageItem* item = [[TableViewImageItem alloc] initWithType:SyncDisabledByAdministratorErrorItemType]; item.image = [UIImage imageNamed:kGoogleServicesEnterpriseImage]; @@ -650,6 +658,7 @@ case ReauthDialogAsSyncIsInAuthErrorItemType: case ShowPassphraseDialogErrorItemType: case SyncDisabledByAdministratorErrorItemType: + case SyncSettingsNotCofirmedErrorItemType: case ManageSyncItemType: NOTREACHED(); break; @@ -678,6 +687,7 @@ [self.commandHandler openManageSyncSettings]; break; case SyncDisabledByAdministratorErrorItemType: + case SyncSettingsNotCofirmedErrorItemType: case AutocompleteSearchesAndURLsItemType: case ImproveChromeItemType: case BetterSearchAndBrowsingItemType:
diff --git a/ios/chrome/browser/ui/settings/sync/utils/sync_error_infobar_delegate.mm b/ios/chrome/browser/ui/settings/sync/utils/sync_error_infobar_delegate.mm index 49c0ae3..d41ae814 100644 --- a/ios/chrome/browser/ui/settings/sync/utils/sync_error_infobar_delegate.mm +++ b/ios/chrome/browser/ui/settings/sync/utils/sync_error_infobar_delegate.mm
@@ -96,6 +96,8 @@ [presenter_ showSyncSettings]; } else if (ShouldShowSyncPassphraseSettings(error_state_)) { [presenter_ showSyncPassphraseSettings]; + } else if (ShouldShowGoogleServicesSettings(error_state_)) { + [presenter_ showGoogleServicesSettings]; } return false; }
diff --git a/ios/chrome/browser/ui/settings/sync/utils/sync_presenter.h b/ios/chrome/browser/ui/settings/sync/utils/sync_presenter.h index cba2e06..8df000d 100644 --- a/ios/chrome/browser/ui/settings/sync/utils/sync_presenter.h +++ b/ios/chrome/browser/ui/settings/sync/utils/sync_presenter.h
@@ -19,6 +19,9 @@ // Asks the presenter to display the sync encryption passphrase UI. - (void)showSyncPassphraseSettings; +// Presents the Google services settings. +- (void)showGoogleServicesSettings; + @end #endif // IOS_CHROME_BROWSER_UI_SETTINGS_SYNC_UTILS_SYNC_PRESENTER_H_
diff --git a/ios/chrome/browser/ui/settings/sync/utils/sync_util.h b/ios/chrome/browser/ui/settings/sync/utils/sync_util.h index 2ef13a1..986f4e6d 100644 --- a/ios/chrome/browser/ui/settings/sync/utils/sync_util.h +++ b/ios/chrome/browser/ui/settings/sync/utils/sync_util.h
@@ -45,6 +45,11 @@ bool ShouldShowSyncPassphraseSettings( SyncSetupService::SyncServiceState syncState); +// Returns true if Google services settings should be displayed based on +// |syncState|. +bool ShouldShowGoogleServicesSettings( + SyncSetupService::SyncServiceState syncState); + // Returns true if sync settings should be displayed based on |syncState|. bool ShouldShowSyncSettings(SyncSetupService::SyncServiceState syncState);
diff --git a/ios/chrome/browser/ui/settings/sync/utils/sync_util.mm b/ios/chrome/browser/ui/settings/sync/utils/sync_util.mm index d0b47a7..189594e3 100644 --- a/ios/chrome/browser/ui/settings/sync/utils/sync_util.mm +++ b/ios/chrome/browser/ui/settings/sync/utils/sync_util.mm
@@ -32,6 +32,7 @@ SYNC_SERVICE_UNAVAILABLE, SYNC_NEEDS_PASSPHRASE, SYNC_UNRECOVERABLE_ERROR, + SYNC_SYNC_SETTINGS_NOT_CONFIRMED, SYNC_ERROR_COUNT }; @@ -49,6 +50,9 @@ return l10n_util::GetNSString(IDS_IOS_SYNC_LOGIN_INFO_OUT_OF_DATE); case SyncSetupService::kSyncServiceNeedsPassphrase: return l10n_util::GetNSString(IDS_IOS_SYNC_ENCRYPTION_DESCRIPTION); + case SyncSetupService::kSyncSettingsNotConfirmed: + return l10n_util::GetNSString( + IDS_IOS_SYNC_SETTINGS_NOT_CONFIRMED_DESCRIPTION); case SyncSetupService::kSyncServiceServiceUnavailable: case SyncSetupService::kSyncServiceCouldNotConnect: case SyncSetupService::kSyncServiceUnrecoverableError: @@ -76,6 +80,8 @@ return l10n_util::GetNSString(IDS_IOS_SYNC_ERROR_COULD_NOT_CONNECT); case SyncSetupService::kSyncServiceUnrecoverableError: return l10n_util::GetNSString(IDS_IOS_SYNC_ERROR_UNRECOVERABLE); + case SyncSetupService::kSyncSettingsNotConfirmed: + return l10n_util::GetNSString(IDS_IOS_SYNC_SETTINGS_NOT_CONFIRMED); } } @@ -93,7 +99,11 @@ return l10n_util::GetNSString(IDS_IOS_SYNC_ENTER_PASSPHRASE); case SyncSetupService::kSyncServiceUnrecoverableError: return l10n_util::GetNSString(IDS_IOS_SYNC_SIGN_IN_AGAIN); - default: + case SyncSetupService::kSyncSettingsNotConfirmed: + return l10n_util::GetNSString(IDS_IOS_SYNC_SETTINGS_NOT_CONFIRMED_ACTION); + case SyncSetupService::kNoSyncServiceError: + case SyncSetupService::kSyncServiceServiceUnavailable: + case SyncSetupService::kSyncServiceCouldNotConnect: return nil; } } @@ -115,6 +125,11 @@ return syncState == SyncSetupService::kSyncServiceNeedsPassphrase; } +bool ShouldShowGoogleServicesSettings( + SyncSetupService::SyncServiceState syncState) { + return syncState == SyncSetupService::kSyncSettingsNotConfirmed; +} + bool ShouldShowSyncSettings(SyncSetupService::SyncServiceState syncState) { switch (syncState) { case SyncSetupService::kSyncServiceCouldNotConnect: @@ -160,6 +175,9 @@ case SyncSetupService::kSyncServiceUnrecoverableError: loggedErrorState = SYNC_UNRECOVERABLE_ERROR; break; + case SyncSetupService::kSyncSettingsNotConfirmed: + loggedErrorState = SYNC_SYNC_SETTINGS_NOT_CONFIRMED; + break; } UMA_HISTOGRAM_ENUMERATION("Sync.SyncErrorInfobarDisplayed", loggedErrorState, SYNC_ERROR_COUNT); @@ -181,6 +199,7 @@ case SyncSetupService::kSyncServiceSignInNeedsUpdate: case SyncSetupService::kSyncServiceNeedsPassphrase: case SyncSetupService::kSyncServiceUnrecoverableError: + case SyncSetupService::kSyncSettingsNotConfirmed: return false; } }
diff --git a/net/BUILD.gn b/net/BUILD.gn index efc93fa8..09e9ee0 100644 --- a/net/BUILD.gn +++ b/net/BUILD.gn
@@ -2886,6 +2886,8 @@ if (enable_reporting) { sources += [ + "network_error_logging/mock_persistent_nel_store.cc", + "network_error_logging/mock_persistent_nel_store.h", "network_error_logging/network_error_logging_test_util.cc", "network_error_logging/network_error_logging_test_util.h", "reporting/reporting_test_util.cc", @@ -5497,6 +5499,7 @@ if (enable_reporting) { sources += [ + "network_error_logging/mock_persistent_nel_store_unittest.cc", "network_error_logging/network_error_logging_service_unittest.cc", "reporting/reporting_browsing_data_remover_unittest.cc", "reporting/reporting_cache_unittest.cc",
diff --git a/net/base/network_change_notifier.cc b/net/base/network_change_notifier.cc index f021464..1fca778 100644 --- a/net/base/network_change_notifier.cc +++ b/net/base/network_change_notifier.cc
@@ -207,7 +207,7 @@ CHECK(false); return NULL; #elif defined(OS_CHROMEOS) - return new NetworkChangeNotifierPosix(CONNECTION_UNKNOWN, SUBTYPE_UNKNOWN); + return new NetworkChangeNotifierPosix(CONNECTION_NONE, SUBTYPE_NONE); #elif defined(OS_LINUX) return new NetworkChangeNotifierLinux(std::unordered_set<std::string>()); #elif defined(OS_MACOSX)
diff --git a/net/disk_cache/cache_util_win.cc b/net/disk_cache/cache_util_win.cc index 1bd12e5b..f38e608 100644 --- a/net/disk_cache/cache_util_win.cc +++ b/net/disk_cache/cache_util_win.cc
@@ -18,7 +18,7 @@ // wrong, that version will attempt to move file by file and fail at the end. if (!MoveFileEx(base::as_wcstr(from_path.value()), base::as_wcstr(to_path.value()), 0)) { - LOG(ERROR) << "Unable to move the cache: " << GetLastError(); + PLOG(ERROR) << "Unable to move the cache"; return false; } return true;
diff --git a/net/http/http_proxy_connect_job.cc b/net/http/http_proxy_connect_job.cc index dd39775a..42103498 100644 --- a/net/http/http_proxy_connect_job.cc +++ b/net/http/http_proxy_connect_job.cc
@@ -234,11 +234,12 @@ return false; } -void HttpProxyConnectJob::GetAdditionalErrorState(ClientSocketHandle* handle) { - if (ssl_cert_request_info_) { - handle->set_ssl_cert_request_info(ssl_cert_request_info_); - handle->set_is_ssl_error(true); - } +bool HttpProxyConnectJob::IsSSLError() const { + return ssl_cert_request_info_ != nullptr; +} + +scoped_refptr<SSLCertRequestInfo> HttpProxyConnectJob::GetCertRequestInfo() { + return ssl_cert_request_info_; } void HttpProxyConnectJob::OnConnectJobComplete(int result, ConnectJob* job) { @@ -486,16 +487,11 @@ int HttpProxyConnectJob::DoSSLConnectComplete(int result) { if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { - // Not really used to hold a socket. - // TODO(mmenke): Implement a better API to get this information. - ClientSocketHandle client_socket_handle; - nested_connect_job_->GetAdditionalErrorState(&client_socket_handle); - UMA_HISTOGRAM_MEDIUM_TIMES("Net.HttpProxy.ConnectLatency.Secure.Error", base::TimeTicks::Now() - connect_start_time_); - DCHECK(client_socket_handle.ssl_cert_request_info()); - ssl_cert_request_info_ = client_socket_handle.ssl_cert_request_info(); + ssl_cert_request_info_ = nested_connect_job_->GetCertRequestInfo(); + DCHECK(ssl_cert_request_info_); ssl_cert_request_info_->is_proxy = true; return result; }
diff --git a/net/http/http_proxy_connect_job.h b/net/http/http_proxy_connect_job.h index ae532cab..f5c11df 100644 --- a/net/http/http_proxy_connect_job.h +++ b/net/http/http_proxy_connect_job.h
@@ -102,8 +102,8 @@ // ConnectJob methods. LoadState GetLoadState() const override; bool HasEstablishedConnection() const override; - - void GetAdditionalErrorState(ClientSocketHandle* handle) override; + bool IsSSLError() const override; + scoped_refptr<SSLCertRequestInfo> GetCertRequestInfo() override; // ConnectJob::Delegate implementation. void OnConnectJobComplete(int result, ConnectJob* job) override;
diff --git a/net/network_error_logging/mock_persistent_nel_store.cc b/net/network_error_logging/mock_persistent_nel_store.cc new file mode 100644 index 0000000..1f0fa8c --- /dev/null +++ b/net/network_error_logging/mock_persistent_nel_store.cc
@@ -0,0 +1,161 @@ +// 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 "net/network_error_logging/mock_persistent_nel_store.h" + +#include <sstream> + +namespace net { + +MockPersistentNELStore::Command::Command( + Type type, + NELPoliciesLoadedCallback loaded_callback) + : type(type), loaded_callback(std::move(loaded_callback)) {} + +MockPersistentNELStore::Command::Command( + Type type, + const NetworkErrorLoggingService::NELPolicy& policy) + : type(type), origin(policy.origin) {} + +MockPersistentNELStore::Command::Command(Type type) : type(type) {} + +MockPersistentNELStore::Command::Command(const Command& other) + : type(other.type), origin(other.origin) {} + +MockPersistentNELStore::Command::Command(Command&& other) = default; + +MockPersistentNELStore::Command::~Command() = default; + +bool operator==(const MockPersistentNELStore::Command& lhs, + const MockPersistentNELStore::Command& rhs) { + if (lhs.type != rhs.type) + return false; + switch (lhs.type) { + // For LOAD_NEL_POLICIES and FLUSH, just check the type. + case MockPersistentNELStore::Command::Type::LOAD_NEL_POLICIES: + case MockPersistentNELStore::Command::Type::FLUSH: + return true; + // For ADD_NEL_POLICY, UPDATE_NEL_POLICY, and DELETE_NEL_POLICY, + // additionally check the policy's origin. + case MockPersistentNELStore::Command::Type::ADD_NEL_POLICY: + case MockPersistentNELStore::Command::Type::UPDATE_NEL_POLICY: + case MockPersistentNELStore::Command::Type::DELETE_NEL_POLICY: + return (lhs.origin == rhs.origin); + } +} + +bool operator!=(const MockPersistentNELStore::Command& lhs, + const MockPersistentNELStore::Command& rhs) { + return !(lhs == rhs); +} + +MockPersistentNELStore::MockPersistentNELStore() + : load_started_(false), policy_count_(0), queued_policy_count_delta_(0) {} + +MockPersistentNELStore::~MockPersistentNELStore() = default; + +void MockPersistentNELStore::LoadNELPolicies( + NELPoliciesLoadedCallback loaded_callback) { + DCHECK(!load_started_); + command_list_.emplace_back(Command::Type::LOAD_NEL_POLICIES, + std::move(loaded_callback)); + load_started_ = true; +} + +void MockPersistentNELStore::AddNELPolicy( + const NetworkErrorLoggingService::NELPolicy& policy) { + DCHECK(load_started_); + command_list_.emplace_back(Command::Type::ADD_NEL_POLICY, policy); + ++queued_policy_count_delta_; +} + +void MockPersistentNELStore::UpdateNELPolicyAccessTime( + const NetworkErrorLoggingService::NELPolicy& policy) { + DCHECK(load_started_); + command_list_.emplace_back(Command::Type::UPDATE_NEL_POLICY, policy); +} + +void MockPersistentNELStore::DeleteNELPolicy( + const NetworkErrorLoggingService::NELPolicy& policy) { + DCHECK(load_started_); + command_list_.emplace_back(Command::Type::DELETE_NEL_POLICY, policy); + --queued_policy_count_delta_; +} + +void MockPersistentNELStore::Flush() { + // Can be called before |load_started_| is true, if the + // NetworkErrorLoggingService is destroyed before getting a chance to load. + command_list_.emplace_back(Command::Type::FLUSH); + policy_count_ += queued_policy_count_delta_; + queued_policy_count_delta_ = 0; +} + +void MockPersistentNELStore::SetPrestoredPolicies( + std::vector<NetworkErrorLoggingService::NELPolicy> policies) { + DCHECK(!load_started_); + DCHECK_EQ(0, policy_count_); + policy_count_ += policies.size(); + prestored_policies_.swap(policies); +} + +void MockPersistentNELStore::FinishLoading(bool load_success) { + DCHECK(load_started_); + for (size_t i = 0; i < command_list_.size(); ++i) { + Command& command = command_list_[i]; + if (command.type == Command::Type::LOAD_NEL_POLICIES) { + // If LOAD_NEL_POLICIES has been initiated, it should be the first + // operation. + DCHECK_EQ(0u, i); + DCHECK(!command.loaded_callback.is_null()); + if (load_success) { + std::move(command.loaded_callback).Run(std::move(prestored_policies_)); + } else { + std::move(command.loaded_callback) + .Run(std::vector<NetworkErrorLoggingService::NELPolicy>()); + } + } + if (i > 0) { + // LOAD_NEL_POLICIES should not have been called twice. + DCHECK(command.type != Command::Type::LOAD_NEL_POLICIES); + } + } +} + +bool MockPersistentNELStore::VerifyCommands( + const CommandList& expected_commands) const { + return command_list_ == expected_commands; +} + +MockPersistentNELStore::CommandList MockPersistentNELStore::GetAllCommands() + const { + return command_list_; +} + +std::string MockPersistentNELStore::GetDebugString() const { + std::ostringstream s; + + for (const Command& command : command_list_) { + switch (command.type) { + case Command::Type::LOAD_NEL_POLICIES: + s << "LOAD; "; + break; + case Command::Type::ADD_NEL_POLICY: + s << "ADD(" << command.origin.Serialize() << "); "; + break; + case Command::Type::UPDATE_NEL_POLICY: + s << "UPDATE(" << command.origin.Serialize() << "); "; + break; + case Command::Type::DELETE_NEL_POLICY: + s << "DELETE(" << command.origin.Serialize() << "); "; + break; + case Command::Type::FLUSH: + s << "FLUSH; "; + break; + } + } + + return s.str(); +} + +} // namespace net
diff --git a/net/network_error_logging/mock_persistent_nel_store.h b/net/network_error_logging/mock_persistent_nel_store.h new file mode 100644 index 0000000..9f0d180a --- /dev/null +++ b/net/network_error_logging/mock_persistent_nel_store.h
@@ -0,0 +1,128 @@ +// 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 NET_NETWORK_ERROR_LOGGING_MOCK_PERSISTENT_NEL_STORE_H_ +#define NET_NETWORK_ERROR_LOGGING_MOCK_PERSISTENT_NEL_STORE_H_ + +#include <string> +#include <vector> + +#include "base/callback.h" +#include "base/macros.h" +#include "net/network_error_logging/network_error_logging_service.h" +#include "url/origin.h" + +namespace net { + +// A NetworkErrorLoggingService::PersistentNELStore implementation that stashes +// the received commands in order in a vector, to be checked by tests. +// Simulates loading pre-existing stored policies, which can be provided +// using SetLoadExpectation(). +class MockPersistentNELStore + : public NetworkErrorLoggingService::PersistentNELStore { + public: + // Represents a command that has been passed to the MockPersistentNELStore. + struct Command { + enum class Type { + LOAD_NEL_POLICIES, + ADD_NEL_POLICY, + UPDATE_NEL_POLICY, + DELETE_NEL_POLICY, + FLUSH + }; + + // Constructor for LOAD_NEL_POLICIES commands. + Command(Type type, NELPoliciesLoadedCallback loaded_callback); + // Constructor for ADD_NEL_POLICY, UPDATE_NEL_POLICY, and DELETE_NEL_POLICY + // commands. + Command(Type type, const NetworkErrorLoggingService::NELPolicy& policy); + // Constructor for FLUSH commands. + Command(Type type); + + Command(const Command& other); + Command(Command&& other); + + ~Command(); + + // Type of command. + Type type; + + // The origin of the policy that the command pertains to. (Only applies for + // add, update, and delete) + url::Origin origin; + + // The supplied callback to be run when loading is complete. (Only applies + // for load commands). + NELPoliciesLoadedCallback loaded_callback; + }; + + using CommandList = std::vector<Command>; + + MockPersistentNELStore(); + ~MockPersistentNELStore() override; + + // PersistentNELStore implementation: + void LoadNELPolicies(NELPoliciesLoadedCallback loaded_callback) override; + void AddNELPolicy( + const NetworkErrorLoggingService::NELPolicy& policy) override; + void UpdateNELPolicyAccessTime( + const NetworkErrorLoggingService::NELPolicy& policy) override; + void DeleteNELPolicy( + const NetworkErrorLoggingService::NELPolicy& policy) override; + void Flush() override; + + // Simulates pre-existing policies that were stored previously. Should only be + // called once, at the beginning of the test before any other method calls. + void SetPrestoredPolicies( + std::vector<NetworkErrorLoggingService::NELPolicy> policies); + + // Simulate finishing loading policies by executing the loaded_callback of the + // first LOAD_NEL_POLICIES command (which should also be the only + // LOAD_NEL_POLICIES command). If |load_success| is false, the vector of + // policies passed to the callback will be empty. If |load_success| is true, + // the vector of policies passed to the callback will be + // |prestored_policies_|. + void FinishLoading(bool load_success); + + // Verify that |command_list_| matches |expected_commands|. + bool VerifyCommands(const CommandList& expected_commands) const; + + CommandList GetAllCommands() const; + + // Returns the total number of policies that would be stored in the store, if + // this were a real store. + int StoredPoliciesCount() const { return policy_count_; } + + // Generates a string with the list of commands, for ease of debugging. + std::string GetDebugString() const; + + private: + // List of commands that we have received so far. + CommandList command_list_; + + // Simulated pre-existing stored policies. + std::vector<NetworkErrorLoggingService::NELPolicy> prestored_policies_; + + // Set when LoadNELPolicies() is called. + bool load_started_; + + // Simulates the total number of policies that would be stored in the store. + // Updated when pre-stored policies are added, and when Flush() is called. + int policy_count_; + + // Simulates the delta to be added to |policy_count_| the next time Flush() is + // called. Reset to 0 when Flush() is called. + int queued_policy_count_delta_; + + DISALLOW_COPY_AND_ASSIGN(MockPersistentNELStore); +}; + +bool operator==(const MockPersistentNELStore::Command& lhs, + const MockPersistentNELStore::Command& rhs); +bool operator!=(const MockPersistentNELStore::Command& lhs, + const MockPersistentNELStore::Command& rhs); + +} // namespace net + +#endif // NET_NETWORK_ERROR_LOGGING_MOCK_PERSISTENT_NEL_STORE_H_
diff --git a/net/network_error_logging/mock_persistent_nel_store_unittest.cc b/net/network_error_logging/mock_persistent_nel_store_unittest.cc new file mode 100644 index 0000000..3c976af --- /dev/null +++ b/net/network_error_logging/mock_persistent_nel_store_unittest.cc
@@ -0,0 +1,267 @@ +// 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 <string> + +#include "base/location.h" +#include "base/test/bind_test_util.h" +#include "net/network_error_logging/mock_persistent_nel_store.h" +#include "net/network_error_logging/network_error_logging_service.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "url/gurl.h" +#include "url/origin.h" + +namespace net { + +namespace { +const url::Origin kOrigin = url::Origin::Create(GURL("https://example.test/")); + +NetworkErrorLoggingService::NELPolicy MakePolicyForOrigin(url::Origin origin) { + NetworkErrorLoggingService::NELPolicy policy; + policy.origin = std::move(origin); + policy.expires = base::Time(); + policy.last_used = base::Time(); + + return policy; +} + +void RunClosureOnNELPoliciesLoaded( + base::OnceClosure closure, + std::vector<NetworkErrorLoggingService::NELPolicy>* policies_out, + std::vector<NetworkErrorLoggingService::NELPolicy> loaded_policies) { + std::move(closure).Run(); + loaded_policies.swap(*policies_out); +} + +// Makes a NELPoliciesLoadedCallback that will fail if it's never run before +// destruction. +MockPersistentNELStore::NELPoliciesLoadedCallback +MakeExpectedRunNELPoliciesLoadedCallback( + std::vector<NetworkErrorLoggingService::NELPolicy>* policies_out) { + base::OnceClosure closure = base::MakeExpectedRunClosure(FROM_HERE); + return base::BindOnce(&RunClosureOnNELPoliciesLoaded, std::move(closure), + policies_out); +} + +// Test that FinishLoading() runs the callback. +TEST(MockPersistentNELStoreTest, FinishLoading) { + MockPersistentNELStore store; + MockPersistentNELStore::CommandList expected_commands; + std::vector<NetworkErrorLoggingService::NELPolicy> loaded_policies; + + store.LoadNELPolicies( + MakeExpectedRunNELPoliciesLoadedCallback(&loaded_policies)); + expected_commands.emplace_back( + MockPersistentNELStore::Command::Type::LOAD_NEL_POLICIES); + + store.FinishLoading(true /* load_success */); + EXPECT_EQ(0u, loaded_policies.size()); + + EXPECT_EQ(1u, store.GetAllCommands().size()); + EXPECT_TRUE(store.VerifyCommands(expected_commands)); + EXPECT_EQ("LOAD; ", store.GetDebugString()); + + // Test should not crash because the callback has been run. +} + +TEST(MockPersistentNELStoreTest, PreStoredPolicies) { + MockPersistentNELStore store; + MockPersistentNELStore::CommandList expected_commands; + std::vector<NetworkErrorLoggingService::NELPolicy> loaded_policies; + + std::vector<NetworkErrorLoggingService::NELPolicy> prestored_policies = { + MakePolicyForOrigin(kOrigin)}; + store.SetPrestoredPolicies(std::move(prestored_policies)); + EXPECT_EQ(1, store.StoredPoliciesCount()); + + store.LoadNELPolicies( + MakeExpectedRunNELPoliciesLoadedCallback(&loaded_policies)); + expected_commands.emplace_back( + MockPersistentNELStore::Command::Type::LOAD_NEL_POLICIES); + store.FinishLoading(true /* load_success */); + ASSERT_EQ(1u, loaded_policies.size()); + EXPECT_EQ(kOrigin, loaded_policies[0].origin); + + EXPECT_EQ(1u, store.GetAllCommands().size()); + EXPECT_TRUE(store.VerifyCommands(expected_commands)); + EXPECT_EQ("LOAD; ", store.GetDebugString()); +} + +// Failed load should yield empty vector of policies. +TEST(MockPersistentNELStoreTest, FailedLoad) { + MockPersistentNELStore store; + MockPersistentNELStore::CommandList expected_commands; + std::vector<NetworkErrorLoggingService::NELPolicy> loaded_policies; + + std::vector<NetworkErrorLoggingService::NELPolicy> prestored_policies = { + MakePolicyForOrigin(kOrigin)}; + store.SetPrestoredPolicies(std::move(prestored_policies)); + EXPECT_EQ(1, store.StoredPoliciesCount()); + + store.LoadNELPolicies( + MakeExpectedRunNELPoliciesLoadedCallback(&loaded_policies)); + expected_commands.emplace_back( + MockPersistentNELStore::Command::Type::LOAD_NEL_POLICIES); + store.FinishLoading(false /* load_success */); + // The pre-stored policy is not returned because loading failed. + EXPECT_EQ(0u, loaded_policies.size()); + + EXPECT_EQ(1u, store.GetAllCommands().size()); + EXPECT_TRUE(store.VerifyCommands(expected_commands)); + EXPECT_EQ("LOAD; ", store.GetDebugString()); +} + +TEST(MockPersistentNELStoreTest, Add) { + MockPersistentNELStore store; + MockPersistentNELStore::CommandList expected_commands; + std::vector<NetworkErrorLoggingService::NELPolicy> loaded_policies; + + store.LoadNELPolicies( + MakeExpectedRunNELPoliciesLoadedCallback(&loaded_policies)); + expected_commands.emplace_back( + MockPersistentNELStore::Command::Type::LOAD_NEL_POLICIES); + EXPECT_EQ(1u, store.GetAllCommands().size()); + + store.FinishLoading(true /* load_success */); + EXPECT_EQ(0u, loaded_policies.size()); + + NetworkErrorLoggingService::NELPolicy policy = MakePolicyForOrigin(kOrigin); + store.AddNELPolicy(policy); + expected_commands.emplace_back( + MockPersistentNELStore::Command::Type::ADD_NEL_POLICY, policy); + // Add operation will be queued; the policy has not actually been stored yet + EXPECT_EQ(0, store.StoredPoliciesCount()); + EXPECT_EQ(2u, store.GetAllCommands().size()); + + store.Flush(); + expected_commands.emplace_back(MockPersistentNELStore::Command::Type::FLUSH); + EXPECT_EQ(1, store.StoredPoliciesCount()); + + EXPECT_EQ(3u, store.GetAllCommands().size()); + EXPECT_TRUE(store.VerifyCommands(expected_commands)); + EXPECT_EQ("LOAD; ADD(" + kOrigin.Serialize() + "); FLUSH; ", + store.GetDebugString()); +} + +TEST(MockPersistentNELStoreTest, AddThenDelete) { + MockPersistentNELStore store; + MockPersistentNELStore::CommandList expected_commands; + std::vector<NetworkErrorLoggingService::NELPolicy> loaded_policies; + + store.LoadNELPolicies( + MakeExpectedRunNELPoliciesLoadedCallback(&loaded_policies)); + expected_commands.emplace_back( + MockPersistentNELStore::Command::Type::LOAD_NEL_POLICIES); + EXPECT_EQ(1u, store.GetAllCommands().size()); + + store.FinishLoading(true /* load_success */); + EXPECT_EQ(0u, loaded_policies.size()); + + NetworkErrorLoggingService::NELPolicy policy = MakePolicyForOrigin(kOrigin); + store.AddNELPolicy(policy); + expected_commands.emplace_back( + MockPersistentNELStore::Command::Type::ADD_NEL_POLICY, policy); + EXPECT_EQ(2u, store.GetAllCommands().size()); + + store.DeleteNELPolicy(policy); + expected_commands.emplace_back( + MockPersistentNELStore::Command::Type::DELETE_NEL_POLICY, policy); + EXPECT_EQ(3u, store.GetAllCommands().size()); + + store.Flush(); + expected_commands.emplace_back(MockPersistentNELStore::Command::Type::FLUSH); + EXPECT_EQ(0, store.StoredPoliciesCount()); + EXPECT_EQ(4u, store.GetAllCommands().size()); + + EXPECT_TRUE(store.VerifyCommands(expected_commands)); + EXPECT_EQ("LOAD; ADD(" + kOrigin.Serialize() + + "); " + "DELETE(" + + kOrigin.Serialize() + "); FLUSH; ", + store.GetDebugString()); +} + +TEST(MockPersistentNELStoreTest, AddFlushThenDelete) { + MockPersistentNELStore store; + MockPersistentNELStore::CommandList expected_commands; + std::vector<NetworkErrorLoggingService::NELPolicy> loaded_policies; + + store.LoadNELPolicies( + MakeExpectedRunNELPoliciesLoadedCallback(&loaded_policies)); + expected_commands.emplace_back( + MockPersistentNELStore::Command::Type::LOAD_NEL_POLICIES); + EXPECT_EQ(1u, store.GetAllCommands().size()); + + store.FinishLoading(true /* load_success */); + EXPECT_EQ(0u, loaded_policies.size()); + + NetworkErrorLoggingService::NELPolicy policy = MakePolicyForOrigin(kOrigin); + store.AddNELPolicy(policy); + expected_commands.emplace_back( + MockPersistentNELStore::Command::Type::ADD_NEL_POLICY, policy); + EXPECT_EQ(2u, store.GetAllCommands().size()); + + store.Flush(); + expected_commands.emplace_back(MockPersistentNELStore::Command::Type::FLUSH); + EXPECT_EQ(1, store.StoredPoliciesCount()); + EXPECT_EQ(3u, store.GetAllCommands().size()); + + store.DeleteNELPolicy(policy); + expected_commands.emplace_back( + MockPersistentNELStore::Command::Type::DELETE_NEL_POLICY, policy); + EXPECT_EQ(4u, store.GetAllCommands().size()); + + store.Flush(); + expected_commands.emplace_back(MockPersistentNELStore::Command::Type::FLUSH); + EXPECT_EQ(0, store.StoredPoliciesCount()); + EXPECT_EQ(5u, store.GetAllCommands().size()); + + EXPECT_TRUE(store.VerifyCommands(expected_commands)); + EXPECT_EQ("LOAD; ADD(" + kOrigin.Serialize() + + "); FLUSH; " + "DELETE(" + + kOrigin.Serialize() + "); FLUSH; ", + store.GetDebugString()); +} + +TEST(MockPersistentNELStoreTest, AddThenUpdate) { + MockPersistentNELStore store; + MockPersistentNELStore::CommandList expected_commands; + std::vector<NetworkErrorLoggingService::NELPolicy> loaded_policies; + + store.LoadNELPolicies( + MakeExpectedRunNELPoliciesLoadedCallback(&loaded_policies)); + expected_commands.emplace_back( + MockPersistentNELStore::Command::Type::LOAD_NEL_POLICIES); + EXPECT_EQ(1u, store.GetAllCommands().size()); + + store.FinishLoading(true /* load_success */); + + NetworkErrorLoggingService::NELPolicy policy = MakePolicyForOrigin(kOrigin); + store.AddNELPolicy(policy); + expected_commands.emplace_back( + MockPersistentNELStore::Command::Type::ADD_NEL_POLICY, policy); + EXPECT_EQ(2u, store.GetAllCommands().size()); + + store.UpdateNELPolicyAccessTime(policy); + expected_commands.emplace_back( + MockPersistentNELStore::Command::Type::UPDATE_NEL_POLICY, policy); + EXPECT_EQ(3u, store.GetAllCommands().size()); + + store.Flush(); + expected_commands.emplace_back(MockPersistentNELStore::Command::Type::FLUSH); + EXPECT_EQ(1, store.StoredPoliciesCount()); + EXPECT_EQ(4u, store.GetAllCommands().size()); + + EXPECT_TRUE(store.VerifyCommands(expected_commands)); + EXPECT_EQ("LOAD; ADD(" + kOrigin.Serialize() + + "); " + "UPDATE(" + + kOrigin.Serialize() + "); FLUSH; ", + store.GetDebugString()); +} + +} // namespace + +} // namespace net
diff --git a/net/network_error_logging/network_error_logging_service_unittest.cc b/net/network_error_logging/network_error_logging_service_unittest.cc index c99bbd3..8e274fd53 100644 --- a/net/network_error_logging/network_error_logging_service_unittest.cc +++ b/net/network_error_logging/network_error_logging_service_unittest.cc
@@ -16,6 +16,7 @@ #include "base/values.h" #include "net/base/ip_address.h" #include "net/base/net_errors.h" +#include "net/network_error_logging/mock_persistent_nel_store.h" #include "net/network_error_logging/network_error_logging_service.h" #include "net/reporting/reporting_policy.h" #include "net/reporting/reporting_service.h" @@ -115,10 +116,17 @@ DISALLOW_COPY_AND_ASSIGN(TestReportingService); }; -class NetworkErrorLoggingServiceTest : public ::testing::Test { +// The tests are parametrized on a boolean value which represents whether or not +// to use a MockPersistentNELStore. +class NetworkErrorLoggingServiceTest : public ::testing::TestWithParam<bool> { protected: NetworkErrorLoggingServiceTest() { - service_ = NetworkErrorLoggingService::Create(nullptr /* store */); + if (GetParam()) { + store_ = std::make_unique<MockPersistentNELStore>(); + } else { + store_.reset(nullptr); + } + service_ = NetworkErrorLoggingService::Create(store_.get()); CreateReportingService(); } @@ -180,6 +188,7 @@ return details; } NetworkErrorLoggingService* service() { return service_.get(); } + MockPersistentNELStore* store() { return store_.get(); } const std::vector<TestReportingService::Report>& reports() { return reporting_service_->reports(); } @@ -239,6 +248,8 @@ const GURL kReferrer_ = GURL("https://referrer.com/"); private: + // |store_| needs to outlive |service_|. + std::unique_ptr<MockPersistentNELStore> store_; std::unique_ptr<NetworkErrorLoggingService> service_; std::unique_ptr<TestReportingService> reporting_service_; }; @@ -251,12 +262,12 @@ EXPECT_DOUBLE_EQ(expected_value, double_value) << key; } -TEST_F(NetworkErrorLoggingServiceTest, CreateService) { +TEST_P(NetworkErrorLoggingServiceTest, CreateService) { // Service is created by default in the test fixture.. EXPECT_TRUE(service()); } -TEST_F(NetworkErrorLoggingServiceTest, NoReportingService) { +TEST_P(NetworkErrorLoggingServiceTest, NoReportingService) { DestroyReportingService(); service()->OnHeader(kOrigin_, kServerIP_, kHeader_); @@ -264,13 +275,13 @@ service()->OnRequest(MakeRequestDetails(kUrl_, ERR_CONNECTION_REFUSED)); } -TEST_F(NetworkErrorLoggingServiceTest, NoPolicyForOrigin) { +TEST_P(NetworkErrorLoggingServiceTest, NoPolicyForOrigin) { service()->OnRequest(MakeRequestDetails(kUrl_, ERR_CONNECTION_REFUSED)); EXPECT_TRUE(reports().empty()); } -TEST_F(NetworkErrorLoggingServiceTest, JsonTooLong) { +TEST_P(NetworkErrorLoggingServiceTest, JsonTooLong) { service()->OnHeader(kOrigin_, kServerIP_, kHeaderTooLong_); service()->OnRequest(MakeRequestDetails(kUrl_, ERR_CONNECTION_REFUSED)); @@ -278,7 +289,7 @@ EXPECT_TRUE(reports().empty()); } -TEST_F(NetworkErrorLoggingServiceTest, JsonTooDeep) { +TEST_P(NetworkErrorLoggingServiceTest, JsonTooDeep) { service()->OnHeader(kOrigin_, kServerIP_, kHeaderTooDeep_); service()->OnRequest(MakeRequestDetails(kUrl_, ERR_CONNECTION_REFUSED)); @@ -286,7 +297,7 @@ EXPECT_TRUE(reports().empty()); } -TEST_F(NetworkErrorLoggingServiceTest, SuccessReportQueued) { +TEST_P(NetworkErrorLoggingServiceTest, SuccessReportQueued) { service()->OnHeader(kOrigin_, kServerIP_, kHeaderSuccessFraction1_); service()->OnRequest(MakeRequestDetails(kUrl_, OK)); @@ -321,7 +332,7 @@ NetworkErrorLoggingService::kTypeKey); } -TEST_F(NetworkErrorLoggingServiceTest, FailureReportQueued) { +TEST_P(NetworkErrorLoggingServiceTest, FailureReportQueued) { static const std::string kHeaderFailureFraction1 = "{\"report_to\":\"group\",\"max_age\":86400,\"failure_fraction\":1.0}"; service()->OnHeader(kOrigin_, kServerIP_, kHeaderFailureFraction1); @@ -358,7 +369,7 @@ NetworkErrorLoggingService::kTypeKey); } -TEST_F(NetworkErrorLoggingServiceTest, UnknownFailureReportQueued) { +TEST_P(NetworkErrorLoggingServiceTest, UnknownFailureReportQueued) { static const std::string kHeaderFailureFraction1 = "{\"report_to\":\"group\",\"max_age\":86400,\"failure_fraction\":1.0}"; service()->OnHeader(kOrigin_, kServerIP_, kHeaderFailureFraction1); @@ -376,7 +387,7 @@ NetworkErrorLoggingService::kTypeKey); } -TEST_F(NetworkErrorLoggingServiceTest, UnknownCertFailureReportQueued) { +TEST_P(NetworkErrorLoggingServiceTest, UnknownCertFailureReportQueued) { static const std::string kHeaderFailureFraction1 = "{\"report_to\":\"group\",\"max_age\":86400,\"failure_fraction\":1.0}"; service()->OnHeader(kOrigin_, kServerIP_, kHeaderFailureFraction1); @@ -395,7 +406,7 @@ NetworkErrorLoggingService::kTypeKey); } -TEST_F(NetworkErrorLoggingServiceTest, HttpErrorReportQueued) { +TEST_P(NetworkErrorLoggingServiceTest, HttpErrorReportQueued) { static const std::string kHeaderFailureFraction1 = "{\"report_to\":\"group\",\"max_age\":86400,\"failure_fraction\":1.0}"; service()->OnHeader(kOrigin_, kServerIP_, kHeaderFailureFraction1); @@ -432,7 +443,7 @@ NetworkErrorLoggingService::kTypeKey); } -TEST_F(NetworkErrorLoggingServiceTest, SuccessReportDowngraded) { +TEST_P(NetworkErrorLoggingServiceTest, SuccessReportDowngraded) { service()->OnHeader(kOrigin_, kServerIP_, kHeaderSuccessFraction1_); service()->OnRequest( @@ -466,7 +477,7 @@ NetworkErrorLoggingService::kTypeKey); } -TEST_F(NetworkErrorLoggingServiceTest, FailureReportDowngraded) { +TEST_P(NetworkErrorLoggingServiceTest, FailureReportDowngraded) { service()->OnHeader(kOrigin_, kServerIP_, kHeaderSuccessFraction1_); service()->OnRequest(MakeRequestDetails(kUrl_, ERR_CONNECTION_REFUSED, "GET", @@ -500,7 +511,7 @@ NetworkErrorLoggingService::kTypeKey); } -TEST_F(NetworkErrorLoggingServiceTest, HttpErrorReportDowngraded) { +TEST_P(NetworkErrorLoggingServiceTest, HttpErrorReportDowngraded) { service()->OnHeader(kOrigin_, kServerIP_, kHeaderSuccessFraction1_); service()->OnRequest( @@ -534,7 +545,7 @@ NetworkErrorLoggingService::kTypeKey); } -TEST_F(NetworkErrorLoggingServiceTest, DNSFailureReportNotDowngraded) { +TEST_P(NetworkErrorLoggingServiceTest, DNSFailureReportNotDowngraded) { service()->OnHeader(kOrigin_, kServerIP_, kHeaderSuccessFraction1_); service()->OnRequest(MakeRequestDetails(kUrl_, ERR_NAME_NOT_RESOLVED, "GET", @@ -568,7 +579,7 @@ NetworkErrorLoggingService::kTypeKey); } -TEST_F(NetworkErrorLoggingServiceTest, SuccessPOSTReportQueued) { +TEST_P(NetworkErrorLoggingServiceTest, SuccessPOSTReportQueued) { service()->OnHeader(kOrigin_, kServerIP_, kHeaderSuccessFraction1_); service()->OnRequest(MakeRequestDetails(kUrl_, OK, "POST")); @@ -597,7 +608,7 @@ NetworkErrorLoggingService::kTypeKey); } -TEST_F(NetworkErrorLoggingServiceTest, MaxAge0) { +TEST_P(NetworkErrorLoggingServiceTest, MaxAge0) { service()->OnHeader(kOrigin_, kServerIP_, kHeader_); EXPECT_EQ(1u, PolicyCount()); @@ -610,7 +621,7 @@ EXPECT_TRUE(reports().empty()); } -TEST_F(NetworkErrorLoggingServiceTest, SuccessFraction0) { +TEST_P(NetworkErrorLoggingServiceTest, SuccessFraction0) { service()->OnHeader(kOrigin_, kServerIP_, kHeaderSuccessFraction0_); // Each network error has a 0% chance of being reported. Fire off several and @@ -622,7 +633,7 @@ EXPECT_TRUE(reports().empty()); } -TEST_F(NetworkErrorLoggingServiceTest, SuccessFractionHalf) { +TEST_P(NetworkErrorLoggingServiceTest, SuccessFractionHalf) { // Include a different value for failure_fraction to ensure that we copy the // right value into sampling_fraction. static const std::string kHeaderSuccessFractionHalf = @@ -656,7 +667,7 @@ } } -TEST_F(NetworkErrorLoggingServiceTest, FailureFraction0) { +TEST_P(NetworkErrorLoggingServiceTest, FailureFraction0) { static const std::string kHeaderFailureFraction0 = "{\"report_to\":\"group\",\"max_age\":86400,\"failure_fraction\":0.0}"; service()->OnHeader(kOrigin_, kServerIP_, kHeaderFailureFraction0); @@ -670,7 +681,7 @@ EXPECT_TRUE(reports().empty()); } -TEST_F(NetworkErrorLoggingServiceTest, FailureFractionHalf) { +TEST_P(NetworkErrorLoggingServiceTest, FailureFractionHalf) { // Include a different value for success_fraction to ensure that we copy the // right value into sampling_fraction. static const std::string kHeaderFailureFractionHalf = @@ -702,7 +713,7 @@ } } -TEST_F(NetworkErrorLoggingServiceTest, +TEST_P(NetworkErrorLoggingServiceTest, ExcludeSubdomainsDoesntMatchDifferentPort) { service()->OnHeader(kOrigin_, kServerIP_, kHeader_); @@ -712,7 +723,7 @@ EXPECT_TRUE(reports().empty()); } -TEST_F(NetworkErrorLoggingServiceTest, ExcludeSubdomainsDoesntMatchSubdomain) { +TEST_P(NetworkErrorLoggingServiceTest, ExcludeSubdomainsDoesntMatchSubdomain) { service()->OnHeader(kOrigin_, kServerIP_, kHeader_); service()->OnRequest( @@ -721,7 +732,7 @@ EXPECT_TRUE(reports().empty()); } -TEST_F(NetworkErrorLoggingServiceTest, IncludeSubdomainsMatchesDifferentPort) { +TEST_P(NetworkErrorLoggingServiceTest, IncludeSubdomainsMatchesDifferentPort) { service()->OnHeader(kOrigin_, kServerIP_, kHeaderIncludeSubdomains_); service()->OnRequest( @@ -731,7 +742,7 @@ EXPECT_EQ(kUrlDifferentPort_, reports()[0].url); } -TEST_F(NetworkErrorLoggingServiceTest, IncludeSubdomainsMatchesSubdomain) { +TEST_P(NetworkErrorLoggingServiceTest, IncludeSubdomainsMatchesSubdomain) { service()->OnHeader(kOrigin_, kServerIP_, kHeaderIncludeSubdomains_); service()->OnRequest( @@ -740,7 +751,7 @@ ASSERT_EQ(1u, reports().size()); } -TEST_F(NetworkErrorLoggingServiceTest, +TEST_P(NetworkErrorLoggingServiceTest, IncludeSubdomainsDoesntMatchSuperdomain) { service()->OnHeader(kOriginSubdomain_, kServerIP_, kHeaderIncludeSubdomains_); @@ -749,7 +760,7 @@ EXPECT_TRUE(reports().empty()); } -TEST_F(NetworkErrorLoggingServiceTest, +TEST_P(NetworkErrorLoggingServiceTest, IncludeSubdomainsDoesntReportConnectionError) { service()->OnHeader(kOrigin_, kServerIP_, kHeaderIncludeSubdomains_); @@ -759,7 +770,7 @@ EXPECT_TRUE(reports().empty()); } -TEST_F(NetworkErrorLoggingServiceTest, +TEST_P(NetworkErrorLoggingServiceTest, IncludeSubdomainsDoesntReportApplicationError) { service()->OnHeader(kOrigin_, kServerIP_, kHeaderIncludeSubdomains_); @@ -769,7 +780,7 @@ EXPECT_TRUE(reports().empty()); } -TEST_F(NetworkErrorLoggingServiceTest, IncludeSubdomainsDoesntReportSuccess) { +TEST_P(NetworkErrorLoggingServiceTest, IncludeSubdomainsDoesntReportSuccess) { service()->OnHeader(kOrigin_, kServerIP_, kHeaderIncludeSubdomains_); service()->OnRequest(MakeRequestDetails(kUrlSubdomain_, OK)); @@ -777,7 +788,7 @@ EXPECT_TRUE(reports().empty()); } -TEST_F(NetworkErrorLoggingServiceTest, +TEST_P(NetworkErrorLoggingServiceTest, IncludeSubdomainsReportsSameOriginSuccess) { static const std::string kHeaderIncludeSubdomainsSuccess1 = "{\"report_to\":\"group\",\"max_age\":86400," @@ -790,7 +801,7 @@ EXPECT_EQ(kUrl_, reports()[0].url); } -TEST_F(NetworkErrorLoggingServiceTest, RemoveAllBrowsingData) { +TEST_P(NetworkErrorLoggingServiceTest, RemoveAllBrowsingData) { service()->OnHeader(kOrigin_, kServerIP_, kHeader_); EXPECT_EQ(1u, PolicyCount()); EXPECT_TRUE(HasPolicyForOrigin(kOrigin_)); @@ -804,7 +815,7 @@ EXPECT_TRUE(reports().empty()); } -TEST_F(NetworkErrorLoggingServiceTest, RemoveSomeBrowsingData) { +TEST_P(NetworkErrorLoggingServiceTest, RemoveSomeBrowsingData) { service()->OnHeader(kOrigin_, kServerIP_, kHeader_); service()->OnHeader(kOriginDifferentHost_, kServerIP_, kHeader_); EXPECT_EQ(2u, PolicyCount()); @@ -828,7 +839,7 @@ ASSERT_EQ(1u, reports().size()); } -TEST_F(NetworkErrorLoggingServiceTest, Nested) { +TEST_P(NetworkErrorLoggingServiceTest, Nested) { service()->OnHeader(kOrigin_, kServerIP_, kHeader_); NetworkErrorLoggingService::RequestDetails details = @@ -842,7 +853,7 @@ reports()[0].depth); } -TEST_F(NetworkErrorLoggingServiceTest, NestedTooDeep) { +TEST_P(NetworkErrorLoggingServiceTest, NestedTooDeep) { service()->OnHeader(kOrigin_, kServerIP_, kHeader_); NetworkErrorLoggingService::RequestDetails details = @@ -854,7 +865,7 @@ EXPECT_TRUE(reports().empty()); } -TEST_F(NetworkErrorLoggingServiceTest, StatusAsValue) { +TEST_P(NetworkErrorLoggingServiceTest, StatusAsValue) { // The expiration times will be bogus, but we need a reproducible value for // this test. base::SimpleTestClock clock; @@ -926,7 +937,7 @@ EXPECT_EQ(*expected, actual); } -TEST_F(NetworkErrorLoggingServiceTest, NoReportingService_SignedExchange) { +TEST_P(NetworkErrorLoggingServiceTest, NoReportingService_SignedExchange) { DestroyReportingService(); service()->OnHeader(kOrigin_, kServerIP_, kHeader_); @@ -934,13 +945,13 @@ false, "sxg.failed", kUrl_, kInnerUrl_, kCertUrl_, kServerIP_)); } -TEST_F(NetworkErrorLoggingServiceTest, NoPolicyForOrigin_SignedExchange) { +TEST_P(NetworkErrorLoggingServiceTest, NoPolicyForOrigin_SignedExchange) { service()->QueueSignedExchangeReport(MakeSignedExchangeReportDetails( false, "sxg.failed", kUrl_, kInnerUrl_, kCertUrl_, kServerIP_)); EXPECT_TRUE(reports().empty()); } -TEST_F(NetworkErrorLoggingServiceTest, SuccessFraction0_SignedExchange) { +TEST_P(NetworkErrorLoggingServiceTest, SuccessFraction0_SignedExchange) { service()->OnHeader(kOrigin_, kServerIP_, kHeaderSuccessFraction0_); // Each network error has a 0% chance of being reported. Fire off several and @@ -954,7 +965,7 @@ EXPECT_TRUE(reports().empty()); } -TEST_F(NetworkErrorLoggingServiceTest, SuccessReportQueued_SignedExchange) { +TEST_P(NetworkErrorLoggingServiceTest, SuccessReportQueued_SignedExchange) { service()->OnHeader(kOrigin_, kServerIP_, kHeaderSuccessFraction1_); service()->QueueSignedExchangeReport(MakeSignedExchangeReportDetails( true, "ok", kUrl_, kInnerUrl_, kCertUrl_, kServerIP_)); @@ -1000,7 +1011,7 @@ sxg_body->FindKey(NetworkErrorLoggingService::kCertUrlKey)->GetList()[0]); } -TEST_F(NetworkErrorLoggingServiceTest, FailureReportQueued_SignedExchange) { +TEST_P(NetworkErrorLoggingServiceTest, FailureReportQueued_SignedExchange) { service()->OnHeader(kOrigin_, kServerIP_, kHeader_); service()->QueueSignedExchangeReport(MakeSignedExchangeReportDetails( false, "sxg.failed", kUrl_, kInnerUrl_, kCertUrl_, kServerIP_)); @@ -1046,14 +1057,14 @@ sxg_body->FindKey(NetworkErrorLoggingService::kCertUrlKey)->GetList()[0]); } -TEST_F(NetworkErrorLoggingServiceTest, MismatchingSubdomain_SignedExchange) { +TEST_P(NetworkErrorLoggingServiceTest, MismatchingSubdomain_SignedExchange) { service()->OnHeader(kOrigin_, kServerIP_, kHeaderIncludeSubdomains_); service()->QueueSignedExchangeReport(MakeSignedExchangeReportDetails( false, "sxg.failed", kUrlSubdomain_, kInnerUrl_, kCertUrl_, kServerIP_)); EXPECT_TRUE(reports().empty()); } -TEST_F(NetworkErrorLoggingServiceTest, MismatchingIPAddress_SignedExchange) { +TEST_P(NetworkErrorLoggingServiceTest, MismatchingIPAddress_SignedExchange) { service()->OnHeader(kOrigin_, kServerIP_, kHeader_); service()->QueueSignedExchangeReport(MakeSignedExchangeReportDetails( false, "sxg.failed", kUrl_, kInnerUrl_, kCertUrl_, kOtherServerIP_)); @@ -1062,7 +1073,7 @@ // When the max number of policies is exceeded, first try to remove expired // policies before evicting the least recently used unexpired policy. -TEST_F(NetworkErrorLoggingServiceTest, EvictAllExpiredPoliciesFirst) { +TEST_P(NetworkErrorLoggingServiceTest, EvictAllExpiredPoliciesFirst) { base::SimpleTestClock clock; service()->SetClockForTesting(&clock); @@ -1086,7 +1097,7 @@ EXPECT_EQ(NetworkErrorLoggingService::kMaxPolicies - 100 + 1, PolicyCount()); } -TEST_F(NetworkErrorLoggingServiceTest, EvictLeastRecentlyUsedPolicy) { +TEST_P(NetworkErrorLoggingServiceTest, EvictLeastRecentlyUsedPolicy) { base::SimpleTestClock clock; service()->SetClockForTesting(&clock); @@ -1141,5 +1152,9 @@ // this test. } +INSTANTIATE_TEST_SUITE_P(NetworkErrorLoggingServiceStoreTest, + NetworkErrorLoggingServiceTest, + testing::Bool()); + } // namespace } // namespace net
diff --git a/net/socket/client_socket_handle.cc b/net/socket/client_socket_handle.cc index 0856264..5b54ccb 100644 --- a/net/socket/client_socket_handle.cc +++ b/net/socket/client_socket_handle.cc
@@ -204,7 +204,7 @@ } void ClientSocketHandle::SetAdditionalErrorState(ConnectJob* connect_job) { - connect_job->GetAdditionalErrorState(this); + connection_attempts_ = connect_job->GetConnectionAttempts(); // TODO(mmenke): Once redirects are no longer followed on // ERR_HTTPS_PROXY_TUNNEL_RESPONSE_REDIRECT, remove this code. @@ -215,6 +215,9 @@ // the normal path, so need to set timing information here. connect_timing_ = connect_job->connect_timing(); } + + is_ssl_error_ = connect_job->IsSSLError(); + ssl_cert_request_info_ = connect_job->GetCertRequestInfo(); } void ClientSocketHandle::OnIOComplete(int result) {
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc index fa12814..5dffcc7 100644 --- a/net/socket/client_socket_pool_base_unittest.cc +++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -356,13 +356,12 @@ return has_established_connection_; } - void GetAdditionalErrorState(ClientSocketHandle* handle) override { - if (store_additional_error_state_) { - // Set all of the additional error state fields in some way. - handle->set_is_ssl_error(true); - handle->set_ssl_cert_request_info( - base::MakeRefCounted<SSLCertRequestInfo>()); - } + bool IsSSLError() const override { return store_additional_error_state_; } + + scoped_refptr<SSLCertRequestInfo> GetCertRequestInfo() override { + if (store_additional_error_state_) + return base::MakeRefCounted<SSLCertRequestInfo>(); + return nullptr; } private:
diff --git a/net/socket/connect_job.cc b/net/socket/connect_job.cc index 8bcfe1c..1102ac1 100644 --- a/net/socket/connect_job.cc +++ b/net/socket/connect_job.cc
@@ -116,10 +116,23 @@ return rv; } +ConnectionAttempts ConnectJob::GetConnectionAttempts() const { + // Return empty list by default - used by proxy classes. + return ConnectionAttempts(); +} + std::unique_ptr<StreamSocket> ConnectJob::PassProxySocketOnFailure() { return nullptr; } +bool ConnectJob::IsSSLError() const { + return false; +} + +scoped_refptr<SSLCertRequestInfo> ConnectJob::GetCertRequestInfo() { + return nullptr; +} + void ConnectJob::SetSocket(std::unique_ptr<StreamSocket> socket) { if (socket) net_log().AddEvent(NetLogEventType::CONNECT_JOB_SET_SOCKET);
diff --git a/net/socket/connect_job.h b/net/socket/connect_job.h index d465246..2d9883bb 100644 --- a/net/socket/connect_job.h +++ b/net/socket/connect_job.h
@@ -19,6 +19,7 @@ #include "net/base/privacy_mode.h" #include "net/base/request_priority.h" #include "net/log/net_log_with_source.h" +#include "net/socket/connection_attempts.h" #include "net/socket/socket_tag.h" #include "net/socket/ssl_client_socket.h" #include "net/third_party/quiche/src/quic/core/quic_versions.h" @@ -26,7 +27,6 @@ namespace net { class ClientSocketFactory; -class ClientSocketHandle; class HostResolver; class HttpAuthCache; class HttpAuthController; @@ -41,6 +41,7 @@ class WebSocketEndpointLockManager; class QuicStreamFactory; class SpdySessionPool; +class SSLCertRequestInfo; // Immutable socket parameters intended for shared use by all ConnectJob types. // Excludes priority because it can be modified over the lifetime of a @@ -183,20 +184,25 @@ // Not safe to call after NotifyComplete() is invoked. virtual bool HasEstablishedConnection() const = 0; - // If Connect returns an error (or OnConnectJobComplete reports an error - // result) this method will be called, allowing a SocketPool to add additional - // error state to the ClientSocketHandle (post late-binding). - // - // TODO(mmenke): This is a layering violation. Consider refactoring it to not - // depend on ClientSocketHandle. Fixing this will need to wait until after - // proxy tunnel auth has been refactored. - virtual void GetAdditionalErrorState(ClientSocketHandle* handle) {} + // If the ConnectJobFailed, this method returns a list of failed attempts to + // connect to the destination server. Returns an empty list if connecting to a + // proxy. + virtual ConnectionAttempts GetConnectionAttempts() const; // On connect failure, returns the nested proxy socket, if there is one. // Returns nullptr otherwise. Only returns a non-null value for SSL sockets on // top of proxy sockets. virtual std::unique_ptr<StreamSocket> PassProxySocketOnFailure(); + // If the ConnectJob failed, returns true if the failure occurred after SSL + // negotiation started. If the ConnectJob succeeded, the returned value is + // undefined. + virtual bool IsSSLError() const; + + // If the ConnectJob failed with ERR_SSL_CLIENT_AUTH_CERT_NEEDED, returns the + // SSLCertRequestInfo received. Otherwise, returns nullptr. + virtual scoped_refptr<SSLCertRequestInfo> GetCertRequestInfo(); + const LoadTimingInfo::ConnectTiming& connect_timing() const { return connect_timing_; }
diff --git a/net/socket/ssl_connect_job.cc b/net/socket/ssl_connect_job.cc index 194e148..be99516 100644 --- a/net/socket/ssl_connect_job.cc +++ b/net/socket/ssl_connect_job.cc
@@ -176,12 +176,8 @@ std::move(restart_with_auth_callback)); } -void SSLConnectJob::GetAdditionalErrorState(ClientSocketHandle* handle) { - handle->set_ssl_cert_request_info(ssl_cert_request_info_); - if (ssl_negotiation_started_) - handle->set_is_ssl_error(true); - - handle->set_connection_attempts(connection_attempts_); +ConnectionAttempts SSLConnectJob::GetConnectionAttempts() const { + return connection_attempts_; } std::unique_ptr<StreamSocket> SSLConnectJob::PassProxySocketOnFailure() { @@ -190,6 +186,14 @@ return nullptr; } +bool SSLConnectJob::IsSSLError() const { + return ssl_negotiation_started_; +} + +scoped_refptr<SSLCertRequestInfo> SSLConnectJob::GetCertRequestInfo() { + return ssl_cert_request_info_; +} + base::TimeDelta SSLConnectJob::HandshakeTimeoutForTesting() { return kSSLHandshakeTimeout; } @@ -260,13 +264,11 @@ } int SSLConnectJob::DoTransportConnectComplete(int result) { - // TODO(https://crbug.com/927101): Implement a better API to get this - // information. - ClientSocketHandle bogus_handle; - nested_connect_job_->GetAdditionalErrorState(&bogus_handle); + ConnectionAttempts connection_attempts = + nested_connect_job_->GetConnectionAttempts(); connection_attempts_.insert(connection_attempts_.end(), - bogus_handle.connection_attempts().begin(), - bogus_handle.connection_attempts().end()); + connection_attempts.begin(), + connection_attempts.end()); if (result == OK) { next_state_ = STATE_SSL_CONNECT; nested_socket_ = nested_connect_job_->PassSocket(); @@ -319,9 +321,7 @@ // authentication so that when ClientSocketPoolBaseHelper calls // |GetAdditionalErrorState|, we can easily set the state. if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { - ClientSocketHandle handle_with_error_state; - nested_connect_job_->GetAdditionalErrorState(&handle_with_error_state); - ssl_cert_request_info_ = handle_with_error_state.ssl_cert_request_info(); + ssl_cert_request_info_ = nested_connect_job_->GetCertRequestInfo(); } else if (result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE_REDIRECT) { proxy_redirect_ = true; connect_timing_ = nested_connect_job_->connect_timing();
diff --git a/net/socket/ssl_connect_job.h b/net/socket/ssl_connect_job.h index 2656104e..8ed44809 100644 --- a/net/socket/ssl_connect_job.h +++ b/net/socket/ssl_connect_job.h
@@ -23,7 +23,6 @@ namespace net { -class ClientSocketHandle; class HostPortPair; class HttpProxySocketParams; class SocketTag; @@ -100,8 +99,10 @@ HttpAuthController* auth_controller, base::OnceClosure restart_with_auth_callback, ConnectJob* job) override; - void GetAdditionalErrorState(ClientSocketHandle* handle) override; + ConnectionAttempts GetConnectionAttempts() const override; std::unique_ptr<StreamSocket> PassProxySocketOnFailure() override; + bool IsSSLError() const override; + scoped_refptr<SSLCertRequestInfo> GetCertRequestInfo() override; // Returns the timeout for the SSL handshake. This is the same for all // connections regardless of whether or not there is a proxy in use.
diff --git a/net/socket/ssl_connect_job_unittest.cc b/net/socket/ssl_connect_job_unittest.cc index 7d346ba..801dda7 100644 --- a/net/socket/ssl_connect_job_unittest.cc +++ b/net/socket/ssl_connect_job_unittest.cc
@@ -31,8 +31,8 @@ #include "net/log/net_log_source.h" #include "net/log/net_log_with_source.h" #include "net/proxy_resolution/proxy_resolution_service.h" -#include "net/socket/client_socket_handle.h" #include "net/socket/connect_job_test_util.h" +#include "net/socket/connection_attempts.h" #include "net/socket/next_proto.h" #include "net/socket/socket_tag.h" #include "net/socket/socket_test_util.h" @@ -199,11 +199,11 @@ test_delegate.StartJobExpectingResult( ssl_connect_job.get(), ERR_CONNECTION_FAILED, io_mode == SYNCHRONOUS); EXPECT_FALSE(test_delegate.socket()); - ClientSocketHandle handle; - ssl_connect_job->GetAdditionalErrorState(&handle); - EXPECT_FALSE(handle.is_ssl_error()); - ASSERT_EQ(1u, handle.connection_attempts().size()); - EXPECT_THAT(handle.connection_attempts()[0].result, + EXPECT_FALSE(ssl_connect_job->IsSSLError()); + ConnectionAttempts connection_attempts = + ssl_connect_job->GetConnectionAttempts(); + ASSERT_EQ(1u, connection_attempts.size()); + EXPECT_THAT(connection_attempts[0].result, test::IsError(ERR_CONNECTION_FAILED)); } } @@ -314,9 +314,9 @@ true /* expect_sync_result */); EXPECT_EQ(MEDIUM, host_resolver_.last_request_priority()); - ClientSocketHandle handle; - ssl_connect_job->GetAdditionalErrorState(&handle); - EXPECT_EQ(0u, handle.connection_attempts().size()); + ConnectionAttempts connection_attempts = + ssl_connect_job->GetConnectionAttempts(); + EXPECT_EQ(0u, connection_attempts.size()); CheckConnectTimesSet(ssl_connect_job->connect_timing()); } @@ -341,9 +341,9 @@ host_resolver_.ResolveAllPending(); EXPECT_THAT(test_delegate.WaitForResult(), test::IsOk()); - ClientSocketHandle handle; - ssl_connect_job->GetAdditionalErrorState(&handle); - EXPECT_EQ(0u, handle.connection_attempts().size()); + ConnectionAttempts connection_attempts = + ssl_connect_job->GetConnectionAttempts(); + EXPECT_EQ(0u, connection_attempts.size()); // Check times. Since time is mocked out, all times will be the same, except // |dns_start|, which is the only one recorded before the FastForwardBy() @@ -437,11 +437,11 @@ test_delegate.StartJobExpectingResult(ssl_connect_job.get(), ERR_CERT_COMMON_NAME_INVALID, false /* expect_sync_result */); - ClientSocketHandle handle; - ssl_connect_job->GetAdditionalErrorState(&handle); - EXPECT_TRUE(handle.is_ssl_error()); - ASSERT_EQ(1u, handle.connection_attempts().size()); - EXPECT_THAT(handle.connection_attempts()[0].result, + EXPECT_TRUE(ssl_connect_job->IsSSLError()); + ConnectionAttempts connection_attempts = + ssl_connect_job->GetConnectionAttempts(); + ASSERT_EQ(1u, connection_attempts.size()); + EXPECT_THAT(connection_attempts[0].result, test::IsError(ERR_CERT_COMMON_NAME_INVALID)); CheckConnectTimesSet(ssl_connect_job->connect_timing()); } @@ -459,11 +459,10 @@ test_delegate.StartJobExpectingResult(ssl_connect_job.get(), ERR_SSL_PROTOCOL_ERROR, false /* expect_sync_result */); - ClientSocketHandle handle; - ssl_connect_job->GetAdditionalErrorState(&handle); - EXPECT_TRUE(handle.is_ssl_error()); - ASSERT_EQ(1u, handle.connection_attempts().size()); - EXPECT_THAT(handle.connection_attempts()[0].result, + ConnectionAttempts connection_attempts = + ssl_connect_job->GetConnectionAttempts(); + ASSERT_EQ(1u, connection_attempts.size()); + EXPECT_THAT(connection_attempts[0].result, test::IsError(ERR_SSL_PROTOCOL_ERROR)); } @@ -516,11 +515,11 @@ test_delegate.StartJobExpectingResult(ssl_connect_job.get(), ERR_PROXY_CONNECTION_FAILED, io_mode == SYNCHRONOUS); + EXPECT_FALSE(ssl_connect_job->IsSSLError()); - ClientSocketHandle handle; - ssl_connect_job->GetAdditionalErrorState(&handle); - EXPECT_FALSE(handle.is_ssl_error()); - EXPECT_EQ(0u, handle.connection_attempts().size()); + ConnectionAttempts connection_attempts = + ssl_connect_job->GetConnectionAttempts(); + EXPECT_EQ(0u, connection_attempts.size()); } } @@ -660,10 +659,10 @@ ERR_PROXY_CONNECTION_FAILED, io_mode == SYNCHRONOUS); - ClientSocketHandle handle; - ssl_connect_job->GetAdditionalErrorState(&handle); - EXPECT_FALSE(handle.is_ssl_error()); - EXPECT_EQ(0u, handle.connection_attempts().size()); + EXPECT_FALSE(ssl_connect_job->IsSSLError()); + ConnectionAttempts connection_attempts = + ssl_connect_job->GetConnectionAttempts(); + EXPECT_EQ(0u, connection_attempts.size()); } } @@ -691,9 +690,6 @@ SSLSocketDataProvider ssl(ASYNC, OK); socket_factory_.AddSSLSocketDataProvider(&ssl); - ClientSocketHandle handle; - TestCompletionCallback callback; - TestConnectJobDelegate test_delegate; std::unique_ptr<ConnectJob> ssl_connect_job = CreateConnectJob(&test_delegate, ProxyServer::SCHEME_HTTP); @@ -809,9 +805,6 @@ SSLSocketDataProvider ssl(ASYNC, OK); socket_factory_.AddSSLSocketDataProvider(&ssl); - ClientSocketHandle handle; - TestCompletionCallback callback; - TestConnectJobDelegate test_delegate; std::unique_ptr<ConnectJob> ssl_connect_job = CreateConnectJob(&test_delegate, ProxyServer::SCHEME_HTTP); @@ -905,9 +898,6 @@ SSLSocketDataProvider ssl(ASYNC, OK); socket_factory_.AddSSLSocketDataProvider(&ssl); - ClientSocketHandle handle; - TestCompletionCallback callback; - TestConnectJobDelegate test_delegate; std::unique_ptr<ConnectJob> ssl_connect_job = CreateConnectJob(&test_delegate, ProxyServer::SCHEME_HTTP);
diff --git a/net/socket/transport_connect_job.cc b/net/socket/transport_connect_job.cc index 308a6df..30707ffa 100644 --- a/net/socket/transport_connect_job.cc +++ b/net/socket/transport_connect_job.cc
@@ -131,7 +131,7 @@ return false; } -void TransportConnectJob::GetAdditionalErrorState(ClientSocketHandle* handle) { +ConnectionAttempts TransportConnectJob::GetConnectionAttempts() const { // If hostname resolution failed, record an empty endpoint and the result. // Also record any attempts made on either of the sockets. ConnectionAttempts attempts; @@ -143,7 +143,7 @@ connection_attempts_.end()); attempts.insert(attempts.begin(), fallback_connection_attempts_.begin(), fallback_connection_attempts_.end()); - handle->set_connection_attempts(attempts); + return attempts; } // static
diff --git a/net/socket/transport_connect_job.h b/net/socket/transport_connect_job.h index 5fafa76..b25ebc5 100644 --- a/net/socket/transport_connect_job.h +++ b/net/socket/transport_connect_job.h
@@ -104,7 +104,7 @@ // ConnectJob methods. LoadState GetLoadState() const override; bool HasEstablishedConnection() const override; - void GetAdditionalErrorState(ClientSocketHandle* handle) override; + ConnectionAttempts GetConnectionAttempts() const override; // Rolls |addrlist| forward until the first IPv4 address, if any. // WARNING: this method should only be used to implement the prefer-IPv4 hack.
diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc index 1e90fca0..8c9d510 100644 --- a/pdf/out_of_process_instance.cc +++ b/pdf/out_of_process_instance.cc
@@ -118,6 +118,9 @@ constexpr char kJSPrintPreviewUrl[] = "url"; constexpr char kJSPrintPreviewGrayscale[] = "grayscale"; constexpr char kJSPrintPreviewPageCount[] = "pageCount"; +// Background color changed (Page -> Plugin) +constexpr char kJSBackgroundColorChangedType[] = "backgroundColorChanged"; +constexpr char kJSBackgroundColor[] = "backgroundColor"; // Load preview page (Page -> Plugin) constexpr char kJSLoadPreviewPageType[] = "loadPreviewPage"; constexpr char kJSPreviewPageUrl[] = "url"; @@ -693,6 +696,13 @@ RotateCounterclockwise(); } else if (type == kJSSelectAllType) { engine_->SelectAll(); + } else if (type == kJSBackgroundColorChangedType) { + if (!dict.Get(pp::Var(kJSBackgroundColor)).is_string()) { + NOTREACHED(); + return; + } + base::HexStringToUInt(dict.Get(pp::Var(kJSBackgroundColor)).AsString(), + &background_color_); } else if (type == kJSResetPrintPreviewModeType) { if (!(dict.Get(pp::Var(kJSPrintPreviewUrl)).is_string() && dict.Get(pp::Var(kJSPrintPreviewGrayscale)).is_bool() &&
diff --git a/services/device/BUILD.gn b/services/device/BUILD.gn index 8eb1cd5c..7d3b0b2 100644 --- a/services/device/BUILD.gn +++ b/services/device/BUILD.gn
@@ -197,6 +197,7 @@ if (!is_linux_without_udev && !is_android) { sources += [ + "hid/hid_connection_impl_unittest.cc", "hid/hid_service_unittest.cc", "hid/input_service_linux_unittest.cc", "hid/test_report_descriptors.cc",
diff --git a/services/device/hid/hid_connection.cc b/services/device/hid/hid_connection.cc index 0d5be49..0ef7abd 100644 --- a/services/device/hid/hid_connection.cc +++ b/services/device/hid/hid_connection.cc
@@ -74,6 +74,12 @@ DCHECK(closed_); } +void HidConnection::SetClient(Client* client) { + DCHECK(pending_reads_.empty()); + DCHECK(pending_reports_.empty()); + client_ = client; +} + void HidConnection::Close() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK(!closed_); @@ -84,6 +90,7 @@ void HidConnection::Read(ReadCallback callback) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + DCHECK(!client_); if (device_info_->max_input_report_size() == 0) { HID_LOG(USER) << "This device does not support input reports."; std::move(callback).Run(false, NULL, 0); @@ -191,12 +198,17 @@ if (IsReportIdProtected(report_id)) return; - pending_reports_.emplace(buffer, size); - ProcessReadQueue(); + if (client_) { + client_->OnInputReport(buffer, size); + } else { + pending_reports_.emplace(buffer, size); + ProcessReadQueue(); + } } void HidConnection::ProcessReadQueue() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + DCHECK(!client_); // Hold a reference to |this| to prevent a callback from freeing this object // during the loop.
diff --git a/services/device/hid/hid_connection.h b/services/device/hid/hid_connection.h index 7471cce..ac6a788 100644 --- a/services/device/hid/hid_connection.h +++ b/services/device/hid/hid_connection.h
@@ -36,6 +36,18 @@ using WriteCallback = base::OnceCallback<void(bool success)>; + class Client { + public: + // Notify the client when an input report is received from the connected + // device. |buffer| contains the report data, and |size| is the size of the + // received report. The buffer is sized to fit the largest input report + // supported by the device, which may be larger than |size|. + virtual void OnInputReport(scoped_refptr<base::RefCountedBytes> buffer, + size_t size) = 0; + }; + + void SetClient(Client* client); + scoped_refptr<HidDeviceInfo> device_info() const { return device_info_; } bool has_protected_collection() const { return has_protected_collection_; } bool closed() const { return closed_; } @@ -84,6 +96,7 @@ private: scoped_refptr<HidDeviceInfo> device_info_; + Client* client_ = nullptr; bool has_protected_collection_; bool closed_;
diff --git a/services/device/hid/hid_connection_impl.cc b/services/device/hid/hid_connection_impl.cc index d5c0909d..7edc6dc0 100644 --- a/services/device/hid/hid_connection_impl.cc +++ b/services/device/hid/hid_connection_impl.cc
@@ -10,17 +10,35 @@ namespace device { HidConnectionImpl::HidConnectionImpl( - scoped_refptr<device::HidConnection> connection) - : hid_connection_(std::move(connection)), weak_factory_(this) {} + scoped_refptr<device::HidConnection> connection, + mojom::HidConnectionClientPtr connection_client) + : hid_connection_(std::move(connection)), weak_factory_(this) { + if (connection_client) { + hid_connection_->SetClient(this); + client_ = std::move(connection_client); + } +} HidConnectionImpl::~HidConnectionImpl() { DCHECK(hid_connection_); + hid_connection_->SetClient(nullptr); // Close |hid_connection_| on destruction because this class is owned by a // mojo::StrongBinding and will be destroyed when the pipe is closed. hid_connection_->Close(); } +void HidConnectionImpl::OnInputReport( + scoped_refptr<base::RefCountedBytes> buffer, + size_t size) { + DCHECK(client_); + uint8_t report_id = buffer->data()[0]; + uint8_t* begin = &buffer->data()[1]; + uint8_t* end = &buffer->data()[size]; + std::vector<uint8_t> data(begin, end); + client_->OnInputReport(report_id, data); +} + void HidConnectionImpl::Read(ReadCallback callback) { DCHECK(hid_connection_); hid_connection_->Read(base::BindOnce(&HidConnectionImpl::OnRead,
diff --git a/services/device/hid/hid_connection_impl.h b/services/device/hid/hid_connection_impl.h index d6e32dff..edb7ea2 100644 --- a/services/device/hid/hid_connection_impl.h +++ b/services/device/hid/hid_connection_impl.h
@@ -6,6 +6,7 @@ #define SERVICES_DEVICE_HID_HID_CONNECTION_IMPL_H_ #include "base/memory/ref_counted.h" +#include "mojo/public/cpp/bindings/interface_ptr.h" #include "services/device/hid/hid_connection.h" #include "services/device/public/mojom/hid.mojom.h" @@ -14,11 +15,17 @@ // HidConnectionImpl is reponsible for handling mojo communications from // clients. It delegates to HidConnection the real work of creating // connections in different platforms. -class HidConnectionImpl : public mojom::HidConnection { +class HidConnectionImpl : public mojom::HidConnection, + public HidConnection::Client { public: - explicit HidConnectionImpl(scoped_refptr<device::HidConnection> connection); + HidConnectionImpl(scoped_refptr<device::HidConnection> connection, + mojom::HidConnectionClientPtr connection_client); ~HidConnectionImpl() final; + // HidConnection::Client implementation: + void OnInputReport(scoped_refptr<base::RefCountedBytes> buffer, + size_t size) override; + // mojom::HidConnection implementation: void Read(ReadCallback callback) override; void Write(uint8_t report_id, @@ -43,6 +50,8 @@ void OnSendFeatureReport(SendFeatureReportCallback callback, bool success); scoped_refptr<device::HidConnection> hid_connection_; + mojo::InterfacePtr<mojom::HidConnectionClient> client_; + base::WeakPtrFactory<HidConnectionImpl> weak_factory_; DISALLOW_COPY_AND_ASSIGN(HidConnectionImpl);
diff --git a/services/device/hid/hid_connection_impl_unittest.cc b/services/device/hid/hid_connection_impl_unittest.cc new file mode 100644 index 0000000..92f692d6 --- /dev/null +++ b/services/device/hid/hid_connection_impl_unittest.cc
@@ -0,0 +1,249 @@ +// 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 "services/device/hid/hid_connection_impl.h" + +#include "base/bind.h" +#include "base/bind_helpers.h" +#include "base/memory/ref_counted_memory.h" +#include "build/build_config.h" +#include "mojo/public/cpp/bindings/binding.h" +#include "services/device/device_service_test_base.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace device { + +namespace { + +#if defined(OS_MACOSX) +const uint64_t kTestDeviceId = 123; +#else +const char* kTestDeviceId = "123"; +#endif + +// The report ID to use for reports sent to or received from the test device. +const uint8_t kTestReportId = 0x42; + +// The max size of input and output reports for the test device. Feature reports +// are not used in this test. +const uint64_t kMaxReportSizeBytes = 10; + +// A fake HidConnection implementation that allows the test to simulate an +// input report. +class FakeHidConnection : public HidConnection { + public: + FakeHidConnection(scoped_refptr<HidDeviceInfo> device) + : HidConnection(device) {} + + // HidConnection implementation. + void PlatformClose() override {} + void PlatformWrite(scoped_refptr<base::RefCountedBytes> buffer, + WriteCallback callback) override { + std::move(callback).Run(true); + } + void PlatformGetFeatureReport(uint8_t report_id, + ReadCallback callback) override { + NOTIMPLEMENTED(); + } + void PlatformSendFeatureReport(scoped_refptr<base::RefCountedBytes> buffer, + WriteCallback callback) override { + NOTIMPLEMENTED(); + } + + void SimulateInputReport(scoped_refptr<base::RefCountedBytes> buffer) { + ProcessInputReport(buffer, buffer->size()); + } + + private: + ~FakeHidConnection() override = default; + + DISALLOW_COPY_AND_ASSIGN(FakeHidConnection); +}; + +// A test implementation of HidConnectionClient that signals once an input +// report has been received. The contents of the input report are saved. +class TestHidConnectionClient : public mojom::HidConnectionClient { + public: + TestHidConnectionClient() : binding_(this) {} + + void Bind(mojom::HidConnectionClientRequest request) { + binding_.Bind(std::move(request)); + } + + // mojom::HidConnectionClient implementation. + void OnInputReport(uint8_t report_id, + const std::vector<uint8_t>& buffer) override { + report_id_ = report_id; + buffer_ = buffer; + run_loop_.Quit(); + } + + void WaitForInputReport() { run_loop_.Run(); } + + uint8_t report_id() { return report_id_; } + const std::vector<uint8_t>& buffer() { return buffer_; } + + private: + base::RunLoop run_loop_; + mojo::Binding<mojom::HidConnectionClient> binding_; + uint8_t report_id_ = 0; + std::vector<uint8_t> buffer_; + + DISALLOW_COPY_AND_ASSIGN(TestHidConnectionClient); +}; + +// A utility for capturing the state returned by mojom::HidConnection I/O +// callbacks. +class TestIoCallback { + public: + TestIoCallback() = default; + ~TestIoCallback() = default; + + void SetReadResult(bool result, + uint8_t report_id, + const base::Optional<std::vector<uint8_t>>& buffer) { + result_ = result; + report_id_ = report_id; + has_buffer_ = buffer.has_value(); + if (has_buffer_) + buffer_ = *buffer; + run_loop_.Quit(); + } + + void SetWriteResult(bool result) { + result_ = result; + run_loop_.Quit(); + } + + bool WaitForResult() { + run_loop_.Run(); + return result_; + } + + mojom::HidConnection::ReadCallback GetReadCallback() { + return base::BindOnce(&TestIoCallback::SetReadResult, + base::Unretained(this)); + } + + mojom::HidConnection::WriteCallback GetWriteCallback() { + return base::BindOnce(&TestIoCallback::SetWriteResult, + base::Unretained(this)); + } + + uint8_t report_id() { return report_id_; } + bool has_buffer() { return has_buffer_; } + const std::vector<uint8_t>& buffer() { return buffer_; } + + private: + base::RunLoop run_loop_; + bool result_ = false; + uint8_t report_id_ = 0; + bool has_buffer_ = false; + std::vector<uint8_t> buffer_; +}; + +} // namespace + +class HidConnectionImplTest : public DeviceServiceTestBase { + public: + HidConnectionImplTest() = default; + + protected: + void SetUp() override { + DeviceServiceTestBase::SetUp(); + base::RunLoop().RunUntilIdle(); + } + + void CreateHidConnection(bool with_connection_client) { + mojom::HidConnectionClientPtr hid_connection_client; + if (with_connection_client) { + connection_client_ = std::make_unique<TestHidConnectionClient>(); + connection_client_->Bind(mojo::MakeRequest(&hid_connection_client)); + } + fake_connection_ = new FakeHidConnection(CreateTestDevice()); + hid_connection_impl_ = std::make_unique<HidConnectionImpl>( + fake_connection_, std::move(hid_connection_client)); + } + + scoped_refptr<HidDeviceInfo> CreateTestDevice() { + auto hid_collection_info = mojom::HidCollectionInfo::New(); + hid_collection_info->usage = mojom::HidUsageAndPage::New(0, 0); + hid_collection_info->report_ids.push_back(kTestReportId); + return base::MakeRefCounted<HidDeviceInfo>( + kTestDeviceId, 0x1234, 0xabcd, "product name", "serial number", + mojom::HidBusType::kHIDBusTypeUSB, std::move(hid_collection_info), + kMaxReportSizeBytes, kMaxReportSizeBytes, 0); + } + + std::unique_ptr<HidConnectionImpl> hid_connection_impl_; + scoped_refptr<FakeHidConnection> fake_connection_; + std::unique_ptr<TestHidConnectionClient> connection_client_; +}; + +TEST_F(HidConnectionImplTest, ReadWrite) { + CreateHidConnection(false); + // Buffer contents: [0x42 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09] + const size_t kTestBufferSize = kMaxReportSizeBytes; + std::vector<uint8_t> buffer_vec(kTestBufferSize); + buffer_vec[0] = kTestReportId; + for (size_t i = 1; i < kTestBufferSize; ++i) + buffer_vec[i] = i; + + // Simulate an output report (host to device). + TestIoCallback write_callback; + hid_connection_impl_->Write(kTestReportId, buffer_vec, + write_callback.GetWriteCallback()); + ASSERT_TRUE(write_callback.WaitForResult()); + + // Simulate an input report (device to host). + auto buffer = base::MakeRefCounted<base::RefCountedBytes>(buffer_vec); + ASSERT_EQ(buffer->size(), kTestBufferSize); + fake_connection_->SimulateInputReport(buffer); + + // Simulate reading the input report. + TestIoCallback read_callback; + hid_connection_impl_->Read(read_callback.GetReadCallback()); + ASSERT_TRUE(read_callback.WaitForResult()); + EXPECT_EQ(read_callback.report_id(), kTestReportId); + ASSERT_TRUE(read_callback.has_buffer()); + const auto& read_buffer = read_callback.buffer(); + ASSERT_EQ(read_buffer.size(), kTestBufferSize - 1); + for (size_t i = 1; i < kTestBufferSize; ++i) { + EXPECT_EQ(read_buffer[i - 1], buffer_vec[i]) + << "Mismatch at index " << i << "."; + } +} + +TEST_F(HidConnectionImplTest, ReadWriteWithConnectionClient) { + CreateHidConnection(true); + // Buffer contents: [0x42 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09] + const size_t kTestBufferSize = kMaxReportSizeBytes; + std::vector<uint8_t> buffer_vec(kTestBufferSize); + buffer_vec[0] = kTestReportId; + for (size_t i = 1; i < kTestBufferSize; ++i) + buffer_vec[i] = i; + + // Simulate an output report (host to device). + TestIoCallback write_callback; + hid_connection_impl_->Write(kTestReportId, buffer_vec, + write_callback.GetWriteCallback()); + ASSERT_TRUE(write_callback.WaitForResult()); + + // Simulate an input report (device to host). + auto buffer = base::MakeRefCounted<base::RefCountedBytes>(buffer_vec); + ASSERT_EQ(buffer->size(), kTestBufferSize); + fake_connection_->SimulateInputReport(buffer); + connection_client_->WaitForInputReport(); + + // The connection client should have been notified. + EXPECT_EQ(connection_client_->report_id(), kTestReportId); + const std::vector<uint8_t>& in_buffer = connection_client_->buffer(); + ASSERT_EQ(in_buffer.size(), kTestBufferSize - 1); + for (size_t i = 1; i < kTestBufferSize; ++i) { + EXPECT_EQ(in_buffer[i - 1], buffer_vec[i]) + << "Mismatch at index " << i << "."; + } +} + +} // namespace device
diff --git a/services/device/hid/hid_manager_impl.cc b/services/device/hid/hid_manager_impl.cc index 8b35b34..aaf1643d 100644 --- a/services/device/hid/hid_manager_impl.cc +++ b/services/device/hid/hid_manager_impl.cc
@@ -4,6 +4,8 @@ #include "services/device/hid/hid_manager_impl.h" +#include <utility> + #include "base/bind.h" #include "base/callback_helpers.h" #include "base/lazy_instance.h" @@ -69,22 +71,28 @@ } void HidManagerImpl::Connect(const std::string& device_guid, + mojom::HidConnectionClientPtr connection_client, ConnectCallback callback) { hid_service_->Connect( device_guid, - base::Bind(&HidManagerImpl::CreateConnection, weak_factory_.GetWeakPtr(), - base::Passed(&callback))); + base::AdaptCallbackForRepeating(base::BindOnce( + &HidManagerImpl::CreateConnection, weak_factory_.GetWeakPtr(), + std::move(callback), std::move(connection_client)))); } -void HidManagerImpl::CreateConnection(ConnectCallback callback, - scoped_refptr<HidConnection> connection) { +void HidManagerImpl::CreateConnection( + ConnectCallback callback, + mojom::HidConnectionClientPtr connection_client, + scoped_refptr<HidConnection> connection) { if (!connection) { std::move(callback).Run(nullptr); return; } mojom::HidConnectionPtr client; - mojo::MakeStrongBinding(std::make_unique<HidConnectionImpl>(connection), + auto connection_impl = std::make_unique<HidConnectionImpl>( + connection, std::move(connection_client)); + mojo::MakeStrongBinding(std::move(connection_impl), mojo::MakeRequest(&client)); std::move(callback).Run(std::move(client)); }
diff --git a/services/device/hid/hid_manager_impl.h b/services/device/hid/hid_manager_impl.h index d57a9823..d12f8eb 100644 --- a/services/device/hid/hid_manager_impl.h +++ b/services/device/hid/hid_manager_impl.h
@@ -37,6 +37,7 @@ GetDevicesCallback callback) override; void GetDevices(GetDevicesCallback callback) override; void Connect(const std::string& device_guid, + mojom::HidConnectionClientPtr connection_client, ConnectCallback callback) override; private: @@ -45,6 +46,7 @@ std::vector<mojom::HidDeviceInfoPtr> devices); void CreateConnection(ConnectCallback callback, + mojom::HidConnectionClientPtr connection_client, scoped_refptr<HidConnection> connection); // HidService::Observer:
diff --git a/services/device/hid/hid_manager_unittest.cc b/services/device/hid/hid_manager_unittest.cc index eb49cc9..1e5185bb 100644 --- a/services/device/hid/hid_manager_unittest.cc +++ b/services/device/hid/hid_manager_unittest.cc
@@ -245,7 +245,7 @@ { base::RunLoop run_loop; hid_manager_->Connect( - device0->device_guid(), + device0->device_guid(), /*connection_client=*/nullptr, base::BindOnce(&OnConnect, run_loop.QuitClosure(), client.get())); run_loop.Run(); }
diff --git a/services/device/public/cpp/hid/fake_hid_manager.cc b/services/device/public/cpp/hid/fake_hid_manager.cc index 9c3af41..ef6c71e 100644 --- a/services/device/public/cpp/hid/fake_hid_manager.cc +++ b/services/device/public/cpp/hid/fake_hid_manager.cc
@@ -119,17 +119,18 @@ } void FakeHidManager::Connect(const std::string& device_guid, + mojom::HidConnectionClientPtr connection_client, ConnectCallback callback) { if (!base::ContainsKey(devices_, device_guid)) { std::move(callback).Run(nullptr); return; } - mojom::HidConnectionPtr client; + mojom::HidConnectionPtr connection; mojo::MakeStrongBinding( std::make_unique<FakeHidConnection>(devices_[device_guid]->Clone()), - mojo::MakeRequest(&client)); - std::move(callback).Run(std::move(client)); + mojo::MakeRequest(&connection)); + std::move(callback).Run(std::move(connection)); } mojom::HidDeviceInfoPtr FakeHidManager::CreateAndAddDevice(
diff --git a/services/device/public/cpp/hid/fake_hid_manager.h b/services/device/public/cpp/hid/fake_hid_manager.h index a94eb69..8287d375 100644 --- a/services/device/public/cpp/hid/fake_hid_manager.h +++ b/services/device/public/cpp/hid/fake_hid_manager.h
@@ -48,6 +48,7 @@ GetDevicesCallback callback) override; void GetDevices(GetDevicesCallback callback) override; void Connect(const std::string& device_guid, + mojom::HidConnectionClientPtr connection_client, ConnectCallback callback) override; mojom::HidDeviceInfoPtr CreateAndAddDevice(const std::string& product_name,
diff --git a/services/device/public/mojom/hid.mojom b/services/device/public/mojom/hid.mojom index 4e31ad0..4c77bd5 100644 --- a/services/device/public/mojom/hid.mojom +++ b/services/device/public/mojom/hid.mojom
@@ -136,6 +136,16 @@ uint16 usage_page; }; +// A HID report is a packet of data sent between a HID device and its host. The +// structure of the report is described in the HID report descriptor as an +// ordered sequence of report items that define the size, count, and usages of +// fields within the report. A single HidReportItem represents one or more +// similar fields within the report, and captures the current state of local and +// global items when a main item was encountered while parsing the report +// descriptor. +// See section 6.2.2 of the Device Class Definition for HID for additional +// information about the HID report descriptor and parser behavior. +// https://www.usb.org/sites/default/files/documents/hid1_11.pdf struct HidReportItem { // True if the usages for this item are defined by |usage_minimum| and // |usage_maximum|. False if the usages for this item are defined by |usages|. @@ -218,6 +228,12 @@ uint32 report_count; }; +// Contains information collected from the HID report descriptor regarding a +// single report. The HID specification defines three categories of reports: +// Input (device to host), Output (host to device), and Feature +// (bi-directional). When a device requires multiple reports of a single +// category, each report is assigned a unique 8-bit ID. Devices that do not use +// more than one report of any type may omit report IDs. struct HidReportDescription { // Report ID associated with this report, or zero if the device does not use // report IDs. @@ -227,6 +243,15 @@ array<HidReportItem> items; }; +// Contains information collected from the HID report descriptor regarding a +// single collection. Collections are hierarchical structures within the HID +// report descriptor used to group similar items. Within a report, collections +// are used to associate fields that share physical or logical characteristics. +// Collections may also be used to group entire reports or even other +// collections. +// See section 6.2.2.6 of the Device Class Definition for HID for more +// information about HID collections. +// https://www.usb.org/sites/default/files/documents/hid1_11.pdf struct HidCollectionInfo { // Collection's usage ID. HidUsageAndPage usage; @@ -251,6 +276,10 @@ array<HidCollectionInfo> children; }; +// Contains information related to a single logical HID device. Note that a +// single physical device may expose multiple logical devices, for instance a +// keyboard/mouse combo device would expose separate logical HID devices for +// keyboard and mouse functionality. struct HidDeviceInfo { string guid; uint16 vendor_id; @@ -267,6 +296,8 @@ string device_node; }; +// A client interface for receiving a notification when HID devices are +// physically connected or disconnected. interface HidManagerClient { // Notifies the client that a device is added. DeviceAdded(HidDeviceInfo device_info); @@ -276,6 +307,9 @@ DeviceRemoved(HidDeviceInfo device_info); }; +// Provides an interface for enumerating available HID devices, registering for +// device connection and disconnection notifications, and opening a connection +// for reading from and writing to a HID device. interface HidManager { // Enumerates available devices and set as a client of HidManager. // The implementation of HidManager guarantees that the returned callback @@ -287,15 +321,22 @@ GetDevices() => (array<HidDeviceInfo> devices); // Opens a connection to a device by given guid. The callback will be run - // with null on failure. - Connect(string device_guid) => (HidConnection? connection); + // with null on failure. If a connection client is provided, it will be + // notified when input reports are received. + Connect(string device_guid, HidConnectionClient? connection_client) + => (HidConnection? connection); }; +// Provides an interface for communication with a HID device. The HID spec +// allows a device to define its own packet formats (reports) for sending or +// receiving data. The methods in HidConnection send or receive data and specify +// which report is used. interface HidConnection { - // The report_id is returned as 0 if not supported by the device. + // A |report_id| of 0 is returned via callback if report IDs are not + // supported by the device. Read() => (bool success, uint8 report_id, array<uint8>? buffer); - // Pass the report_id as 0 if not supported by the device. + // Pass the |report_id| as 0 if not supported by the device. Write(uint8 report_id, array<uint8> buffer) => (bool success); // The buffer will contain whatever report data was received from the device. @@ -303,6 +344,14 @@ // device may respond with other data in place of the report ID. GetFeatureReport(uint8 report_id) => (bool success, array<uint8>? buffer); - // Pass the report_id as 0 if not supported by the device. + // Pass the |report_id| as 0 if not supported by the device. SendFeatureReport(uint8 report_id, array<uint8> buffer) => (bool success); }; + +// A client interface for receiving a notification when input reports are +// received. +interface HidConnectionClient { + // Notifies the client that an input report was received. A |report_id| of 0 + // is passed if report IDs are not used by the device. + OnInputReport(uint8 report_id, array<uint8> buffer); +};
diff --git a/services/service_manager/sandbox/mac/common.sb b/services/service_manager/sandbox/mac/common.sb index 889ee21c..f786184 100644 --- a/services/service_manager/sandbox/mac/common.sb +++ b/services/service_manager/sandbox/mac/common.sb
@@ -110,6 +110,7 @@ ; Allow reads of system libraries and frameworks. (allow file-read* (subpath "/System/Library/CoreServices/CoreTypes.bundle") + (subpath "/System/Library/CoreServices/SystemVersion.bundle") (subpath "/System/Library/Frameworks") (subpath "/System/Library/Preferences/Logging") (subpath "/System/Library/PrivateFrameworks") @@ -160,8 +161,10 @@ ; Access to the home directory. (allow file-read-data + (path (string-append (user-homedir-path "/Library/Preferences/") (param bundle-id) ".plist")) (path (user-homedir-path "/Library/Preferences/.GlobalPreferences.plist")) (regex (user-homedir-path #"/Library/Preferences/ByHost/.GlobalPreferences.*")) + (path (user-homedir-path "/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist")) ) ; Mach IPC needed by all Chromium Helper instances.
diff --git a/services/service_manager/sandbox/mac/gpu_v2.sb b/services/service_manager/sandbox/mac/gpu_v2.sb index 40c11e4..241a58475 100644 --- a/services/service_manager/sandbox/mac/gpu_v2.sb +++ b/services/service_manager/sandbox/mac/gpu_v2.sb
@@ -69,6 +69,7 @@ ) (allow file-read-data + (path "/Library/MessageTracer/SubmitDiagInfo.default.domains.searchtree") (regex (user-homedir-path #"/Library/Preferences/ByHost/com.apple.AppleGVA.*")) )
diff --git a/sql/database.cc b/sql/database.cc index 31ffbf6..65743fe 100644 --- a/sql/database.cc +++ b/sql/database.cc
@@ -518,20 +518,25 @@ // SQLITE_ERROR often indicates some sort of mismatch between the statement // and the schema, possibly due to a failed schema migration. if (error == SQLITE_ERROR) { - const char* kVersionSql = "SELECT value FROM meta WHERE key = 'version'"; - sqlite3_stmt* s; - int rc = sqlite3_prepare_v2(db_, kVersionSql, -1, &s, nullptr); + static const char kVersionSql[] = + "SELECT value FROM meta WHERE key='version'"; + sqlite3_stmt* sqlite_statement; + // When the number of bytes passed to sqlite3_prepare_v3() includes the null + // terminator, SQLite avoids a buffer copy. + int rc = sqlite3_prepare_v3(db_, kVersionSql, sizeof(kVersionSql), + SQLITE_PREPARE_NO_VTAB, &sqlite_statement, + /* pzTail= */ nullptr); if (rc == SQLITE_OK) { - rc = sqlite3_step(s); + rc = sqlite3_step(sqlite_statement); if (rc == SQLITE_ROW) { base::StringAppendF(&debug_info, "version: %d\n", - sqlite3_column_int(s, 0)); + sqlite3_column_int(sqlite_statement, 0)); } else if (rc == SQLITE_DONE) { debug_info += "version: none\n"; } else { base::StringAppendF(&debug_info, "version: error %d\n", rc); } - sqlite3_finalize(s); + sqlite3_finalize(sqlite_statement); } else { base::StringAppendF(&debug_info, "version: prepare error %d\n", rc); } @@ -548,15 +553,19 @@ // |rootpage| is not interesting for debugging, without the contents of the // database. The COALESCE is because certain automatic elements will have a // |name| but no |sql|, - const char* kSchemaSql = "SELECT COALESCE(sql, name) FROM sqlite_master"; - rc = sqlite3_prepare_v2(db_, kSchemaSql, -1, &s, nullptr); + static const char kSchemaSql[] = + "SELECT COALESCE(sql,name) FROM sqlite_master"; + rc = sqlite3_prepare_v3(db_, kSchemaSql, sizeof(kSchemaSql), + SQLITE_PREPARE_NO_VTAB, &sqlite_statement, + /* pzTail= */ nullptr); if (rc == SQLITE_OK) { - while ((rc = sqlite3_step(s)) == SQLITE_ROW) { - base::StringAppendF(&debug_info, "%s\n", sqlite3_column_text(s, 0)); + while ((rc = sqlite3_step(sqlite_statement)) == SQLITE_ROW) { + base::StringAppendF(&debug_info, "%s\n", + sqlite3_column_text(sqlite_statement, 0)); } if (rc != SQLITE_DONE) base::StringAppendF(&debug_info, "error %d\n", rc); - sqlite3_finalize(s); + sqlite3_finalize(sqlite_statement); } else { base::StringAppendF(&debug_info, "prepare error %d\n", rc); } @@ -1099,24 +1108,24 @@ int rc = SQLITE_OK; while ((rc == SQLITE_OK) && *sql) { - sqlite3_stmt* stmt = nullptr; + sqlite3_stmt* sqlite_statement; const char* leftover_sql; - - rc = sqlite3_prepare_v2(db_, sql, -1, &stmt, &leftover_sql); - sql = leftover_sql; - + rc = sqlite3_prepare_v3(db_, sql, /* nByte= */ -1, /* prepFlags= */ 0, + &sqlite_statement, &leftover_sql); // Stop if an error is encountered. if (rc != SQLITE_OK) break; + sql = leftover_sql; + // This happens if |sql| originally only contained comments or whitespace. // TODO(shess): Audit to see if this can become a DCHECK(). Having // extraneous comments and whitespace in the SQL statements increases // runtime cost and can easily be shifted out to the C++ layer. - if (!stmt) + if (!sqlite_statement) continue; - while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) { + while ((rc = sqlite3_step(sqlite_statement)) == SQLITE_ROW) { // TODO(shess): Audit to see if this can become a DCHECK. I think PRAGMA // is the only legitimate case for this. Previously recorded histograms // show significant use of this code path. @@ -1124,7 +1133,7 @@ // sqlite3_finalize() returns SQLITE_OK if the most recent sqlite3_step() // returned SQLITE_DONE or SQLITE_ROW, otherwise the error code. - rc = sqlite3_finalize(stmt); + rc = sqlite3_finalize(sqlite_statement); // sqlite3_exec() does this, presumably to avoid spinning the parser for // trailing whitespace. @@ -1216,8 +1225,11 @@ base::Optional<base::ScopedBlockingCall> scoped_blocking_call; InitScopedBlockingCall(&scoped_blocking_call); - sqlite3_stmt* stmt = nullptr; - int rc = sqlite3_prepare_v2(db_, sql, -1, &stmt, nullptr); + // TODO(pwnall): Cached statements (but not unique statements) should be + // prepared with prepFlags set to SQLITE_PREPARE_PERSISTENT. + sqlite3_stmt* sqlite_statement; + int rc = sqlite3_prepare_v3(db_, sql, /* nByte= */ -1, /* prepFlags= */ 0, + &sqlite_statement, /* pzTail= */ nullptr); if (rc != SQLITE_OK) { // This is evidence of a syntax error in the incoming SQL. DCHECK_NE(rc, SQLITE_ERROR) << "SQL compile error " << GetErrorMessage(); @@ -1226,7 +1238,8 @@ OnSqliteError(rc, nullptr, sql); return base::MakeRefCounted<StatementRef>(nullptr, nullptr, false); } - return base::MakeRefCounted<StatementRef>(tracking_db, stmt, true); + return base::MakeRefCounted<StatementRef>(tracking_db, sqlite_statement, + true); } scoped_refptr<Database::StatementRef> Database::GetUntrackedStatement( @@ -1265,11 +1278,14 @@ return false; } - sqlite3_stmt* stmt = nullptr; - if (sqlite3_prepare_v2(db_, sql, -1, &stmt, nullptr) != SQLITE_OK) + sqlite3_stmt* sqlite_statement = nullptr; + if (sqlite3_prepare_v3(db_, sql, /* nByte= */ -1, /* prepFlags= */ 0, + &sqlite_statement, + /* pzTail= */ nullptr) != SQLITE_OK) { return false; + } - sqlite3_finalize(stmt); + sqlite3_finalize(sqlite_statement); return true; }
diff --git a/sql/vfs_wrapper.cc b/sql/vfs_wrapper.cc index 5087a2e..c3c2b9a 100644 --- a/sql/vfs_wrapper.cc +++ b/sql/vfs_wrapper.cc
@@ -340,26 +340,6 @@ wrapped_vfs, relative_path, buf_size, absolute_path); } -void* DlOpen(sqlite3_vfs* vfs, const char* filename) { - sqlite3_vfs* wrapped_vfs = GetWrappedVfs(vfs); - return wrapped_vfs->xDlOpen(wrapped_vfs, filename); -} - -void DlError(sqlite3_vfs* vfs, int buf_size, char* error_buffer) { - sqlite3_vfs* wrapped_vfs = GetWrappedVfs(vfs); - wrapped_vfs->xDlError(wrapped_vfs, buf_size, error_buffer); -} - -void(*DlSym(sqlite3_vfs* vfs, void* handle, const char* sym))(void) { - sqlite3_vfs* wrapped_vfs = GetWrappedVfs(vfs); - return wrapped_vfs->xDlSym(wrapped_vfs, handle, sym); -} - -void DlClose(sqlite3_vfs* vfs, void* handle) { - sqlite3_vfs* wrapped_vfs = GetWrappedVfs(vfs); - wrapped_vfs->xDlClose(wrapped_vfs, handle); -} - int Randomness(sqlite3_vfs* vfs, int buf_size, char* buffer) { sqlite3_vfs* wrapped_vfs = GetWrappedVfs(vfs); return wrapped_vfs->xRandomness(wrapped_vfs, buf_size, buffer); @@ -370,11 +350,6 @@ return wrapped_vfs->xSleep(wrapped_vfs, microseconds); } -int CurrentTime(sqlite3_vfs* vfs, double* now) { - sqlite3_vfs* wrapped_vfs = GetWrappedVfs(vfs); - return wrapped_vfs->xCurrentTime(wrapped_vfs, now); -} - int GetLastError(sqlite3_vfs* vfs, int e, char* s) { sqlite3_vfs* wrapped_vfs = GetWrappedVfs(vfs); return wrapped_vfs->xGetLastError(wrapped_vfs, e, s); @@ -385,22 +360,6 @@ return wrapped_vfs->xCurrentTimeInt64(wrapped_vfs, now); } -int SetSystemCall(sqlite3_vfs* vfs, const char* name, - sqlite3_syscall_ptr func) { - sqlite3_vfs* wrapped_vfs = GetWrappedVfs(vfs); - return wrapped_vfs->xSetSystemCall(wrapped_vfs, name, func); -} - -sqlite3_syscall_ptr GetSystemCall(sqlite3_vfs* vfs, const char* name) { - sqlite3_vfs* wrapped_vfs = GetWrappedVfs(vfs); - return wrapped_vfs->xGetSystemCall(wrapped_vfs, name); -} - -const char* NextSystemCall(sqlite3_vfs* vfs, const char* name) { - sqlite3_vfs* wrapped_vfs = GetWrappedVfs(vfs); - return wrapped_vfs->xNextSystemCall(wrapped_vfs, name); -} - } // namespace sqlite3_vfs* VFSWrapper() { @@ -435,13 +394,18 @@ // VFS implementations should always work with a SQLite that only knows about // earlier versions. - wrapper_vfs->iVersion = std::min(wrapped_vfs->iVersion, 3); + constexpr int kSqliteVfsApiVersion = 3; + wrapper_vfs->iVersion = kSqliteVfsApiVersion; + + // All the SQLite VFS implementations used by Chrome should support the + // version proxied here. + DCHECK_GE(wrapped_vfs->iVersion, kSqliteVfsApiVersion); // Caller of xOpen() allocates this much space. wrapper_vfs->szOsFile = sizeof(VfsFile); wrapper_vfs->mxPathname = wrapped_vfs->mxPathname; - wrapper_vfs->pNext = nullptr; + wrapper_vfs->pNext = nullptr; // Field used by SQLite. wrapper_vfs->zName = kVFSName; // Keep a reference to the wrapped vfs for use in methods. @@ -452,26 +416,39 @@ wrapper_vfs->xDelete = &Delete; wrapper_vfs->xAccess = &Access; wrapper_vfs->xFullPathname = &FullPathname; - wrapper_vfs->xDlOpen = &DlOpen; - wrapper_vfs->xDlError = &DlError; - wrapper_vfs->xDlSym = &DlSym; - wrapper_vfs->xDlClose = &DlClose; + + // SQLite's dynamic extension loading is disabled in Chrome. Not proxying + // these methods lets us ship less logic and provides a tiny bit of extra + // security, as we know for sure that SQLite will not dynamically load code. + wrapper_vfs->xDlOpen = nullptr; + wrapper_vfs->xDlError = nullptr; + wrapper_vfs->xDlSym = nullptr; + wrapper_vfs->xDlClose = nullptr; + wrapper_vfs->xRandomness = &Randomness; wrapper_vfs->xSleep = &Sleep; - // |xCurrentTime| is null when SQLite is built with SQLITE_OMIT_DEPRECATED. - wrapper_vfs->xCurrentTime = - (wrapped_vfs->xCurrentTime ? &CurrentTime : nullptr); + + // |xCurrentTime| is null when SQLite is built with SQLITE_OMIT_DEPRECATED, so + // it does not need to be proxied. + wrapper_vfs->xCurrentTime = nullptr; + wrapper_vfs->xGetLastError = &GetLastError; - // The methods above are in version 1 of sqlite_vfs. - DCHECK(wrapped_vfs->xCurrentTimeInt64); + + // The methods above are in version 1 of SQLite's VFS API. + + DCHECK(wrapped_vfs->xCurrentTimeInt64 != nullptr); wrapper_vfs->xCurrentTimeInt64 = &CurrentTimeInt64; - // The methods above are in version 2 of sqlite_vfs. - DCHECK(wrapped_vfs->xSetSystemCall); - wrapper_vfs->xSetSystemCall = &SetSystemCall; - DCHECK(wrapped_vfs->xGetSystemCall); - wrapper_vfs->xGetSystemCall = &GetSystemCall; - DCHECK(wrapped_vfs->xNextSystemCall); - wrapper_vfs->xNextSystemCall = &NextSystemCall; + + // The methods above are in version 2 of SQLite's VFS API. + + // The VFS system call interception API is intended for very low-level SQLite + // testing and tweaks. Proxying these methods is not necessary because Chrome + // does not do very low-level SQLite testing, and the VFS wrapper supports all + // the needed tweaks. + wrapper_vfs->xSetSystemCall = nullptr; + wrapper_vfs->xGetSystemCall = nullptr; + wrapper_vfs->xNextSystemCall = nullptr; + // The methods above are in version 3 of sqlite_vfs. if (SQLITE_OK == sqlite3_vfs_register(wrapper_vfs.get(), 0)) {
diff --git a/testing/buildbot/chromium.android.json b/testing/buildbot/chromium.android.json index ccd35f3..98a669f 100644 --- a/testing/buildbot/chromium.android.json +++ b/testing/buildbot/chromium.android.json
@@ -683,31 +683,286 @@ ] }, "Android WebView M (dbg)": { - "cts_tests": [ + "gtest_tests": [ { - "arch": "arm64", - "platform": "M" - } - ], - "instrumentation_tests": [ - { + "args": [ + "--gs-results-bucket=chromium-result-details", + "--recover-devices" + ], + "merge": { + "args": [ + "--bucket", + "chromium-result-details", + "--test-name", + "system_webview_shell_layout_test_apk" + ], + "script": "//build/android/pylib/results/presentation/test_results_presentation.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "infra/tools/luci/logdog/butler/${platform}", + "location": "bin", + "revision": "git_revision:ff387eadf445b24c935f1cf7d6ddd279f8a6b04c" + } + ], + "dimension_sets": [ + { + "device_os": "MRA58Z", + "device_os_flavor": "aosp", + "device_type": "hammerhead", + "os": "Android" + } + ], + "output_links": [ + { + "link": [ + "https://luci-logdog.appspot.com/v/?s", + "=android%2Fswarming%2Flogcats%2F", + "${TASK_ID}%2F%2B%2Funified_logcats" + ], + "name": "shard #${SHARD_INDEX} logcats" + } + ] + }, "test": "system_webview_shell_layout_test_apk" }, { + "args": [ + "--gs-results-bucket=chromium-result-details", + "--recover-devices" + ], + "merge": { + "args": [ + "--bucket", + "chromium-result-details", + "--test-name", + "webview_cts_tests" + ], + "script": "//build/android/pylib/results/presentation/test_results_presentation.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/android_webview/tools/cts_archive", + "location": "android_webview/tools/cts_archive", + "revision": "version:1.5" + }, + { + "cipd_package": "infra/tools/luci/logdog/butler/${platform}", + "location": "bin", + "revision": "git_revision:ff387eadf445b24c935f1cf7d6ddd279f8a6b04c" + } + ], + "dimension_sets": [ + { + "device_os": "MRA58Z", + "device_os_flavor": "aosp", + "device_type": "hammerhead", + "os": "Android" + } + ], + "output_links": [ + { + "link": [ + "https://luci-logdog.appspot.com/v/?s", + "=android%2Fswarming%2Flogcats%2F", + "${TASK_ID}%2F%2B%2Funified_logcats" + ], + "name": "shard #${SHARD_INDEX} logcats" + } + ], + "shards": 3 + }, + "test": "webview_cts_tests" + }, + { + "args": [ + "--gs-results-bucket=chromium-result-details", + "--recover-devices" + ], + "merge": { + "args": [ + "--bucket", + "chromium-result-details", + "--test-name", + "webview_ui_test_app_test_apk" + ], + "script": "//build/android/pylib/results/presentation/test_results_presentation.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "infra/tools/luci/logdog/butler/${platform}", + "location": "bin", + "revision": "git_revision:ff387eadf445b24c935f1cf7d6ddd279f8a6b04c" + } + ], + "dimension_sets": [ + { + "device_os": "MRA58Z", + "device_os_flavor": "aosp", + "device_type": "hammerhead", + "os": "Android" + } + ], + "output_links": [ + { + "link": [ + "https://luci-logdog.appspot.com/v/?s", + "=android%2Fswarming%2Flogcats%2F", + "${TASK_ID}%2F%2B%2Funified_logcats" + ], + "name": "shard #${SHARD_INDEX} logcats" + } + ] + }, "test": "webview_ui_test_app_test_apk" } ] }, "Android WebView N (dbg)": { - "cts_tests": [ + "gtest_tests": [ { - "arch": "arm64", - "platform": "N" - } - ], - "instrumentation_tests": [ - { + "args": [ + "--gs-results-bucket=chromium-result-details", + "--recover-devices" + ], + "merge": { + "args": [ + "--bucket", + "chromium-result-details", + "--test-name", + "system_webview_shell_layout_test_apk" + ], + "script": "//build/android/pylib/results/presentation/test_results_presentation.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "infra/tools/luci/logdog/butler/${platform}", + "location": "bin", + "revision": "git_revision:ff387eadf445b24c935f1cf7d6ddd279f8a6b04c" + } + ], + "dimension_sets": [ + { + "device_os": "NMF27E", + "device_os_flavor": "aosp", + "device_type": "bullhead", + "os": "Android" + } + ], + "output_links": [ + { + "link": [ + "https://luci-logdog.appspot.com/v/?s", + "=android%2Fswarming%2Flogcats%2F", + "${TASK_ID}%2F%2B%2Funified_logcats" + ], + "name": "shard #${SHARD_INDEX} logcats" + } + ] + }, "test": "system_webview_shell_layout_test_apk" + }, + { + "args": [ + "--gs-results-bucket=chromium-result-details", + "--recover-devices" + ], + "merge": { + "args": [ + "--bucket", + "chromium-result-details", + "--test-name", + "webview_cts_tests" + ], + "script": "//build/android/pylib/results/presentation/test_results_presentation.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/android_webview/tools/cts_archive", + "location": "android_webview/tools/cts_archive", + "revision": "version:1.5" + }, + { + "cipd_package": "infra/tools/luci/logdog/butler/${platform}", + "location": "bin", + "revision": "git_revision:ff387eadf445b24c935f1cf7d6ddd279f8a6b04c" + } + ], + "dimension_sets": [ + { + "device_os": "NMF27E", + "device_os_flavor": "aosp", + "device_type": "bullhead", + "os": "Android" + } + ], + "output_links": [ + { + "link": [ + "https://luci-logdog.appspot.com/v/?s", + "=android%2Fswarming%2Flogcats%2F", + "${TASK_ID}%2F%2B%2Funified_logcats" + ], + "name": "shard #${SHARD_INDEX} logcats" + } + ], + "shards": 3 + }, + "test": "webview_cts_tests" + }, + { + "args": [ + "--gs-results-bucket=chromium-result-details", + "--recover-devices" + ], + "merge": { + "args": [ + "--bucket", + "chromium-result-details", + "--test-name", + "webview_ui_test_app_test_apk" + ], + "script": "//build/android/pylib/results/presentation/test_results_presentation.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "infra/tools/luci/logdog/butler/${platform}", + "location": "bin", + "revision": "git_revision:ff387eadf445b24c935f1cf7d6ddd279f8a6b04c" + } + ], + "dimension_sets": [ + { + "device_os": "NMF27E", + "device_os_flavor": "aosp", + "device_type": "bullhead", + "os": "Android" + } + ], + "output_links": [ + { + "link": [ + "https://luci-logdog.appspot.com/v/?s", + "=android%2Fswarming%2Flogcats%2F", + "${TASK_ID}%2F%2B%2Funified_logcats" + ], + "name": "shard #${SHARD_INDEX} logcats" + } + ] + }, + "test": "webview_ui_test_app_test_apk" } ] },
diff --git a/testing/buildbot/chromium.fyi.json b/testing/buildbot/chromium.fyi.json index f29869b..f13aa2f2 100644 --- a/testing/buildbot/chromium.fyi.json +++ b/testing/buildbot/chromium.fyi.json
@@ -3292,6 +3292,9 @@ ], "gtest_tests": [ { + "args": [ + "--use-host-tast-bin" + ], "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [
diff --git a/testing/buildbot/chromium.gpu.fyi.json b/testing/buildbot/chromium.gpu.fyi.json index 5440ddf..76ed4eb 100644 --- a/testing/buildbot/chromium.gpu.fyi.json +++ b/testing/buildbot/chromium.gpu.fyi.json
@@ -8197,35 +8197,6 @@ }, { "args": [ - "--enable-gpu", - "--test-launcher-bot-mode", - "--test-launcher-jobs=1", - "--test-launcher-filter-file=../../testing/buildbot/filters/vulkan.content_browsertests.filter", - "--enable-features=VizDisplayCompositor,UseSkiaRenderer,UiGpuRasterization", - "--use-gl=any", - "--enable-oop-rasterization", - "--enable-vulkan", - "--enable-gpu-rasterization", - "--enable-raster-to-sk-image", - "--force-gpu-rasterization", - "--disable-software-compositing-fallback", - "--no-xvfb" - ], - "name": "vulkan_content_browsertests", - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "gpu": "10de:1cb3-410.78", - "os": "Ubuntu", - "pool": "Chrome-GPU" - } - ] - }, - "test": "content_browsertests" - }, - { - "args": [ "--use-gpu-in-tests", "--test-launcher-retry-limit=0" ],
diff --git a/testing/buildbot/test_suite_exceptions.pyl b/testing/buildbot/test_suite_exceptions.pyl index 8aa8a09c..70081947 100644 --- a/testing/buildbot/test_suite_exceptions.pyl +++ b/testing/buildbot/test_suite_exceptions.pyl
@@ -1474,6 +1474,7 @@ 'Linux FYI GPU TSAN Release', 'Linux FYI Release (AMD R7 240)', 'Linux FYI Debug (NVIDIA)', + 'Linux FYI Experimental Release (NVIDIA)', # Consistent hangs crbug.com/940750 'Linux FYI Experimental Release (Intel HD 630)', ],
diff --git a/testing/buildbot/test_suites.pyl b/testing/buildbot/test_suites.pyl index 4626e223..0467504 100644 --- a/testing/buildbot/test_suites.pyl +++ b/testing/buildbot/test_suites.pyl
@@ -243,16 +243,6 @@ }, }, - 'android_m_cts_tests': { - 'arch': 'arm64', - 'platform': 'M', - }, - - 'android_n_cts_tests': { - 'arch': 'arm64', - 'platform': 'N', - }, - 'android_oreo_standard_gtests': { 'chrome_public_test_apk': { 'swarming': { @@ -458,7 +448,11 @@ }, 'chromeos_device_friendly_gtests_experimental': { - 'chrome_login_tast_tests': {}, + 'chrome_login_tast_tests': { + 'args': [ + '--use-host-tast-bin', + ] + }, 'services_unittests': { 'args': [ '--vpython-dir=../../vpython_dir_linux_amd64', @@ -5125,11 +5119,6 @@ 'chromium_browser_tests', ], - 'system_webview_and_webview_ui_instrumentation_tests': [ - 'system_webview_shell_instrumentation_tests', - 'webview_ui_instrumentation_tests', - ], - 'webrtc_android_tests_with_baremetal_tests': [ 'webrtc_chromium_simple_baremetal_gtests', 'webrtc_chromium_simple_gtests',
diff --git a/testing/buildbot/waterfalls.pyl b/testing/buildbot/waterfalls.pyl index d1252fa..7fb0f9e 100644 --- a/testing/buildbot/waterfalls.pyl +++ b/testing/buildbot/waterfalls.pyl
@@ -157,18 +157,36 @@ }, 'Android WebView M (dbg)': { 'test_suites': { - 'cts_tests': 'android_m_cts_tests', - 'instrumentation_tests': 'system_webview_and_webview_ui_instrumentation_tests', + 'gtest_tests': 'webview_bot_gtests', }, - 'use_swarming': False, + 'swarming': { + 'dimension_sets': [ + { + 'device_os': 'MRA58Z', + 'device_os_flavor': 'aosp', + 'device_type': 'hammerhead', + 'os': 'Android', + }, + ], + }, + 'use_swarming': True, 'os_type': 'android', }, 'Android WebView N (dbg)': { 'test_suites': { - 'cts_tests': 'android_n_cts_tests', - 'instrumentation_tests': 'system_webview_shell_instrumentation_tests', + 'gtest_tests': 'webview_bot_gtests', }, - 'use_swarming': False, + 'swarming': { + 'dimension_sets': [ + { + 'device_os': 'NMF27E', + 'device_os_flavor': 'aosp', + 'device_type': 'bullhead', + 'os': 'Android', + }, + ], + }, + 'use_swarming': True, 'os_type': 'android', }, 'Android WebView O (dbg)': {
diff --git a/testing/variations/fieldtrial_testing_config.json b/testing/variations/fieldtrial_testing_config.json index df12c146..2d5a3c4d 100644 --- a/testing/variations/fieldtrial_testing_config.json +++ b/testing/variations/fieldtrial_testing_config.json
@@ -699,6 +699,26 @@ ] } ], + "AutofillImportDynamicForms": [ + { + "platforms": [ + "android", + "chromeos", + "ios", + "linux", + "mac", + "windows" + ], + "experiments": [ + { + "name": "Enabled", + "enable_features": [ + "AutofillImportDynamicForms" + ] + } + ] + } + ], "AutofillImportNonFocusableCreditCardForms": [ { "platforms": [ @@ -2967,12 +2987,11 @@ ], "experiments": [ { - "name": "AppsEmailBackgroundUS-005", + "name": "AppsBackgroundUS-005", "params": { - "new-user-modules": "nux-google-apps,nux-email,nux-ntp-background,nux-set-as-default,signin-view", - "onboarding-group": "AppsEmailBackgroundUSSynthetic-005", - "returning-user-modules": "nux-set-as-default", - "show-email-interstitial": "false" + "new-user-modules": "nux-google-apps,nux-ntp-background,nux-set-as-default,signin-view", + "onboarding-group": "AppsBackgroundUSSynthetic-005", + "returning-user-modules": "nux-set-as-default" }, "enable_features": [ "NuxOnboarding" @@ -4921,6 +4940,26 @@ ] } ], + "SyncUSSAutofillProfile": [ + { + "platforms": [ + "android", + "chromeos", + "ios", + "linux", + "mac", + "windows" + ], + "experiments": [ + { + "name": "Enabled", + "enable_features": [ + "SyncUSSAutofillProfile" + ] + } + ] + } + ], "SyncUssBookmarks'": [ { "platforms": [ @@ -5890,7 +5929,7 @@ ], "experiments": [ { - "name": "WebRtcHideLocalIpsWithMdns", + "name": "Enabled", "enable_features": [ "WebRtcHideLocalIpsWithMdns" ]
diff --git a/third_party/blink/renderer/bindings/scripts/generate_v8_context_snapshot_external_references.py b/third_party/blink/renderer/bindings/scripts/generate_v8_context_snapshot_external_references.py index aa33eb1..c380c93 100644 --- a/third_party/blink/renderer/bindings/scripts/generate_v8_context_snapshot_external_references.py +++ b/third_party/blink/renderer/bindings/scripts/generate_v8_context_snapshot_external_references.py
@@ -162,10 +162,12 @@ # in V8 context snapshot, so we can skip them. def _process_interface(self, interface, component, interfaces): def has_impl(interface): + component_info = self._info_provider.component_info + runtime_features = component_info['runtime_enabled_features'] # Non legacy callback interface does not provide V8 callbacks. if interface.is_callback: return len(interface.constants) > 0 - if 'RuntimeEnabled' in interface.extended_attributes: + if v8_utilities.runtime_enabled_feature_name(interface, runtime_features): return False if 'Exposed' not in interface.extended_attributes: return True
diff --git a/third_party/blink/renderer/core/css/resolver/element_resolve_context.h b/third_party/blink/renderer/core/css/resolver/element_resolve_context.h index 49bb15d..b7b00858 100644 --- a/third_party/blink/renderer/core/css/resolver/element_resolve_context.h +++ b/third_party/blink/renderer/core/css/resolver/element_resolve_context.h
@@ -46,7 +46,9 @@ Element* GetElement() const { return element_; } const ContainerNode* ParentNode() const { return parent_node_; } const ContainerNode* LayoutParent() const { return layout_parent_; } - const ComputedStyle* RootElementStyle() const { return root_element_style_; } + const ComputedStyle* RootElementStyle() const { + return root_element_style_.get(); + } const ComputedStyle* ParentStyle() const { return ParentNode() && ParentNode()->IsElementNode() ? ParentNode()->GetComputedStyle() @@ -64,7 +66,7 @@ Member<Element> element_; Member<ContainerNode> parent_node_; Member<ContainerNode> layout_parent_; - const ComputedStyle* root_element_style_; + scoped_refptr<const ComputedStyle> root_element_style_; EInsideLink element_link_state_; bool distributed_to_insertion_point_; };
diff --git a/third_party/blink/renderer/core/editing/caret_display_item_client.cc b/third_party/blink/renderer/core/editing/caret_display_item_client.cc index 30253cf..0aaff89 100644 --- a/third_party/blink/renderer/core/editing/caret_display_item_client.cc +++ b/third_party/blink/renderer/core/editing/caret_display_item_client.cc
@@ -117,9 +117,9 @@ void CaretDisplayItemClient::ClearPreviousVisualRect(const LayoutBlock& block) { if (block == layout_block_) - visual_rect_ = LayoutRect(); + visual_rect_ = IntRect(); if (block == previous_layout_block_) - visual_rect_in_previous_layout_block_ = LayoutRect(); + visual_rect_in_previous_layout_block_ = IntRect(); } void CaretDisplayItemClient::LayoutBlockWillBeDestroyed( @@ -148,7 +148,7 @@ if (layout_block_) layout_block_->SetShouldCheckForPaintInvalidation(); layout_block_ = new_layout_block; - visual_rect_ = LayoutRect(); + visual_rect_ = IntRect(); if (new_layout_block) { needs_paint_invalidation_ = true; if (new_layout_block == previous_layout_block_) { @@ -215,15 +215,15 @@ const PaintInvalidatorContext& context) { DCHECK(layout_block_); - LayoutRect new_visual_rect; + IntRect new_visual_rect; #if DCHECK_IS_ON() FindVisualRectNeedingUpdateScope finder(*layout_block_, context, visual_rect_, new_visual_rect); #endif if (context.NeedsVisualRectUpdate(*layout_block_)) { if (!local_rect_.IsEmpty()) { - new_visual_rect = local_rect_; - context.MapLocalRectToVisualRect(*layout_block_, new_visual_rect); + new_visual_rect = + context.MapLocalRectToVisualRect(*layout_block_, local_rect_); } } else { new_visual_rect = visual_rect_; @@ -273,7 +273,7 @@ return "Caret"; } -LayoutRect CaretDisplayItemClient::VisualRect() const { +IntRect CaretDisplayItemClient::VisualRect() const { return visual_rect_; }
diff --git a/third_party/blink/renderer/core/editing/caret_display_item_client.h b/third_party/blink/renderer/core/editing/caret_display_item_client.h index 1fe23287..9484d12 100644 --- a/third_party/blink/renderer/core/editing/caret_display_item_client.h +++ b/third_party/blink/renderer/core/editing/caret_display_item_client.h
@@ -79,7 +79,7 @@ DisplayItem::Type) const; // DisplayItemClient methods. - LayoutRect VisualRect() const final; + IntRect VisualRect() const final; String DebugName() const final; private: @@ -95,14 +95,14 @@ // Visual rect of the caret in layout_block_. This is updated by // InvalidatePaintIfNeeded(). - LayoutRect visual_rect_; + IntRect visual_rect_; // These are set to the previous value of layout_bloc_k and visual_rect_ // during UpdateStyleAndLayoutIfNeeded() if they haven't been set since the // last paint invalidation. They can only be used in InvalidatePaintIfNeeded() // to invalidate the caret in the previous layout block. const LayoutBlock* previous_layout_block_ = nullptr; - LayoutRect visual_rect_in_previous_layout_block_; + IntRect visual_rect_in_previous_layout_block_; bool needs_paint_invalidation_ = false;
diff --git a/third_party/blink/renderer/core/editing/caret_display_item_client_test.cc b/third_party/blink/renderer/core/editing/caret_display_item_client_test.cc index 97832e6..c8ffcfa 100644 --- a/third_party/blink/renderer/core/editing/caret_display_item_client_test.cc +++ b/third_party/blink/renderer/core/editing/caret_display_item_client_test.cc
@@ -89,15 +89,14 @@ UpdateAllLifecyclePhasesForCaretTest(); EXPECT_TRUE(block->ShouldPaintCursorCaret()); - LayoutRect caret_visual_rect = GetCaretDisplayItemClient().VisualRect(); + auto caret_visual_rect = GetCaretDisplayItemClient().VisualRect(); EXPECT_EQ(1, caret_visual_rect.Width()); - EXPECT_EQ(block->Location(), caret_visual_rect.Location()); + EXPECT_EQ(block->Location(), LayoutPoint(caret_visual_rect.Location())); EXPECT_THAT(GetRasterInvalidationTracking()->Invalidations(), - UnorderedElementsAre( - RasterInvalidationInfo{&GetCaretDisplayItemClient(), "Caret", - EnclosingIntRect(caret_visual_rect), - PaintInvalidationReason::kAppeared})); + UnorderedElementsAre(RasterInvalidationInfo{ + &GetCaretDisplayItemClient(), "Caret", caret_visual_rect, + PaintInvalidationReason::kAppeared})); EXPECT_THAT( *GetDocument().View()->TrackedObjectPaintInvalidations(), ElementsAre(PaintInvalidation{"Caret", PaintInvalidationReason::kCaret})); @@ -111,37 +110,35 @@ UpdateAllLifecyclePhasesForTest(); EXPECT_TRUE(block->ShouldPaintCursorCaret()); - LayoutRect new_caret_visual_rect = GetCaretDisplayItemClient().VisualRect(); + auto new_caret_visual_rect = GetCaretDisplayItemClient().VisualRect(); EXPECT_EQ(caret_visual_rect.Size(), new_caret_visual_rect.Size()); EXPECT_EQ(caret_visual_rect.Y(), new_caret_visual_rect.Y()); EXPECT_LT(caret_visual_rect.X(), new_caret_visual_rect.X()); - EXPECT_THAT( - GetRasterInvalidationTracking()->Invalidations(), - UnorderedElementsAre( - RasterInvalidationInfo{&GetCaretDisplayItemClient(), "Caret", - EnclosingIntRect(caret_visual_rect), - PaintInvalidationReason::kCaret}, - RasterInvalidationInfo{&GetCaretDisplayItemClient(), "Caret", - EnclosingIntRect(new_caret_visual_rect), - PaintInvalidationReason::kCaret})); + EXPECT_THAT(GetRasterInvalidationTracking()->Invalidations(), + UnorderedElementsAre( + RasterInvalidationInfo{&GetCaretDisplayItemClient(), "Caret", + caret_visual_rect, + PaintInvalidationReason::kCaret}, + RasterInvalidationInfo{&GetCaretDisplayItemClient(), "Caret", + new_caret_visual_rect, + PaintInvalidationReason::kCaret})); EXPECT_THAT( *GetDocument().View()->TrackedObjectPaintInvalidations(), ElementsAre(PaintInvalidation{"Caret", PaintInvalidationReason::kCaret})); GetDocument().View()->SetTracksPaintInvalidations(false); // Remove selection. Should invalidate the old caret. - LayoutRect old_caret_visual_rect = new_caret_visual_rect; + auto old_caret_visual_rect = new_caret_visual_rect; GetDocument().View()->SetTracksPaintInvalidations(true); Selection().SetSelectionAndEndTyping(SelectionInDOMTree()); UpdateAllLifecyclePhasesForCaretTest(); EXPECT_FALSE(block->ShouldPaintCursorCaret()); - EXPECT_EQ(LayoutRect(), GetCaretDisplayItemClient().VisualRect()); + EXPECT_EQ(IntRect(), GetCaretDisplayItemClient().VisualRect()); EXPECT_THAT(GetRasterInvalidationTracking()->Invalidations(), UnorderedElementsAre(RasterInvalidationInfo{ - &GetCaretDisplayItemClient(), "Caret", - EnclosingIntRect(old_caret_visual_rect), + &GetCaretDisplayItemClient(), "Caret", old_caret_visual_rect, PaintInvalidationReason::kDisappeared})); EXPECT_THAT( *GetDocument().View()->TrackedObjectPaintInvalidations(), @@ -162,10 +159,10 @@ // Focus the body. GetDocument().body()->focus(); UpdateAllLifecyclePhasesForCaretTest(); - LayoutRect caret_visual_rect1 = GetCaretDisplayItemClient().VisualRect(); + auto caret_visual_rect1 = GetCaretDisplayItemClient().VisualRect(); EXPECT_EQ(1, caret_visual_rect1.Width()); EXPECT_EQ(block1->FirstFragment().VisualRect().Location(), - caret_visual_rect1.Location()); + LayoutPoint(caret_visual_rect1.Location())); EXPECT_TRUE(block1->ShouldPaintCursorCaret()); EXPECT_FALSE(block2->ShouldPaintCursorCaret()); @@ -177,7 +174,7 @@ .Build()); UpdateAllLifecyclePhasesForTest(); - LayoutRect caret_visual_rect2 = GetCaretDisplayItemClient().VisualRect(); + auto caret_visual_rect2 = GetCaretDisplayItemClient().VisualRect(); EXPECT_EQ(1, caret_visual_rect2.Width()); EXPECT_EQ(block2->FirstFragment().VisualRect().Location(), caret_visual_rect2.Location()); @@ -187,10 +184,10 @@ EXPECT_THAT(GetRasterInvalidationTracking()->Invalidations(), UnorderedElementsAre( RasterInvalidationInfo{&GetCaretDisplayItemClient(), "Caret", - EnclosingIntRect(caret_visual_rect1), + caret_visual_rect1, PaintInvalidationReason::kCaret}, RasterInvalidationInfo{&GetCaretDisplayItemClient(), "Caret", - EnclosingIntRect(caret_visual_rect2), + caret_visual_rect2, PaintInvalidationReason::kCaret})); EXPECT_THAT( *GetDocument().View()->TrackedObjectPaintInvalidations(), @@ -213,10 +210,10 @@ EXPECT_THAT(GetRasterInvalidationTracking()->Invalidations(), UnorderedElementsAre( RasterInvalidationInfo{&GetCaretDisplayItemClient(), "Caret", - EnclosingIntRect(caret_visual_rect1), + caret_visual_rect1, PaintInvalidationReason::kCaret}, RasterInvalidationInfo{&GetCaretDisplayItemClient(), "Caret", - EnclosingIntRect(caret_visual_rect2), + caret_visual_rect2, PaintInvalidationReason::kCaret})); EXPECT_THAT( *GetDocument().View()->TrackedObjectPaintInvalidations(), @@ -297,7 +294,7 @@ UpdateAllLifecyclePhasesForCaretTest(); const auto* block = To<LayoutBlock>(GetDocument().body()->GetLayoutObject()); - LayoutRect caret_visual_rect = GetCaretDisplayItemClient().VisualRect(); + auto caret_visual_rect = GetCaretDisplayItemClient().VisualRect(); EXPECT_EQ(1, caret_visual_rect.Width()); EXPECT_EQ(block->Location(), caret_visual_rect.Location()); @@ -311,20 +308,19 @@ Selection().SetCaretVisible(true); UpdateAllLifecyclePhasesForCaretTest(); - LayoutRect new_caret_visual_rect = GetCaretDisplayItemClient().VisualRect(); + auto new_caret_visual_rect = GetCaretDisplayItemClient().VisualRect(); EXPECT_EQ(caret_visual_rect.Size(), new_caret_visual_rect.Size()); EXPECT_EQ(caret_visual_rect.Y(), new_caret_visual_rect.Y()); EXPECT_LT(caret_visual_rect.X(), new_caret_visual_rect.X()); - EXPECT_THAT( - GetRasterInvalidationTracking()->Invalidations(), - UnorderedElementsAre( - RasterInvalidationInfo{&GetCaretDisplayItemClient(), "Caret", - EnclosingIntRect(caret_visual_rect), - PaintInvalidationReason::kCaret}, - RasterInvalidationInfo{&GetCaretDisplayItemClient(), "Caret", - EnclosingIntRect(new_caret_visual_rect), - PaintInvalidationReason::kCaret})); + EXPECT_THAT(GetRasterInvalidationTracking()->Invalidations(), + UnorderedElementsAre( + RasterInvalidationInfo{&GetCaretDisplayItemClient(), "Caret", + caret_visual_rect, + PaintInvalidationReason::kCaret}, + RasterInvalidationInfo{&GetCaretDisplayItemClient(), "Caret", + new_caret_visual_rect, + PaintInvalidationReason::kCaret})); EXPECT_THAT( *GetDocument().View()->TrackedObjectPaintInvalidations(), ElementsAre(PaintInvalidation{"Caret", PaintInvalidationReason::kCaret})); @@ -352,8 +348,7 @@ EXPECT_TRUE(editor_block->ShouldPaintCursorCaret()); EXPECT_EQ(editor_block, CaretLayoutBlock()); - EXPECT_EQ(LayoutRect(116, 105, 1, 1), - GetCaretDisplayItemClient().VisualRect()); + EXPECT_EQ(IntRect(116, 105, 1, 1), GetCaretDisplayItemClient().VisualRect()); // Composite container. container->setAttribute(html_names::kStyleAttr, "will-change: transform"); @@ -361,15 +356,13 @@ // TODO(wangxianzhu): Why will-change:transform doens't trigger compositing // in CAP? if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) { - EXPECT_EQ(LayoutRect(50, 50, 1, 1), - GetCaretDisplayItemClient().VisualRect()); + EXPECT_EQ(IntRect(50, 50, 1, 1), GetCaretDisplayItemClient().VisualRect()); } // Uncomposite container. container->setAttribute(html_names::kStyleAttr, ""); UpdateAllLifecyclePhasesForCaretTest(); - EXPECT_EQ(LayoutRect(116, 105, 1, 1), - GetCaretDisplayItemClient().VisualRect()); + EXPECT_EQ(IntRect(116, 105, 1, 1), GetCaretDisplayItemClient().VisualRect()); } class ParameterizedComputeCaretRectTest
diff --git a/third_party/blink/renderer/core/frame/frame_overlay.cc b/third_party/blink/renderer/core/frame/frame_overlay.cc index a4c344f7..8e37dbd 100644 --- a/third_party/blink/renderer/core/frame/frame_overlay.cc +++ b/third_party/blink/renderer/core/frame/frame_overlay.cc
@@ -99,8 +99,8 @@ frame_->View()->Size()); } -LayoutRect FrameOverlay::VisualRect() const { - return LayoutRect(IntPoint(), Size()); +IntRect FrameOverlay::VisualRect() const { + return IntRect(IntPoint(), Size()); } IntRect FrameOverlay::ComputeInterestRect(const GraphicsLayer* graphics_layer,
diff --git a/third_party/blink/renderer/core/frame/frame_overlay.h b/third_party/blink/renderer/core/frame/frame_overlay.h index dc4c567..267312c 100644 --- a/third_party/blink/renderer/core/frame/frame_overlay.h +++ b/third_party/blink/renderer/core/frame/frame_overlay.h
@@ -78,7 +78,7 @@ // DisplayItemClient methods. String DebugName() const final { return "FrameOverlay"; } - LayoutRect VisualRect() const override; + IntRect VisualRect() const override; // GraphicsLayerClient implementation. Not needed for CompositeAfterPaint. bool NeedsRepaint(const GraphicsLayer&) const override { return true; }
diff --git a/third_party/blink/renderer/core/frame/frame_overlay_test.cc b/third_party/blink/renderer/core/frame/frame_overlay_test.cc index be38c6b..c605c6e 100644 --- a/third_party/blink/renderer/core/frame/frame_overlay_test.cc +++ b/third_party/blink/renderer/core/frame/frame_overlay_test.cc
@@ -162,7 +162,7 @@ frame_overlay->UpdatePrePaint(); GetWebView()->MainFrameWidget()->UpdateAllLifecyclePhases( WebWidget::LifecycleUpdateReason::kTest); - EXPECT_EQ(LayoutRect(0, 0, kViewportWidth, kViewportHeight), + EXPECT_EQ(IntRect(0, 0, kViewportWidth, kViewportHeight), frame_overlay->VisualRect()); }
diff --git a/third_party/blink/renderer/core/input/event_handler_test.cc b/third_party/blink/renderer/core/input/event_handler_test.cc index cb1cacc0a..8c326f66 100644 --- a/third_party/blink/renderer/core/input/event_handler_test.cc +++ b/third_party/blink/renderer/core/input/event_handler_test.cc
@@ -365,7 +365,7 @@ SetHtmlInnerHTML("blabla"); Node* const text = GetDocument().body()->firstChild(); HitTestLocation location( - text->GetLayoutObject()->FirstFragment().VisualRect().Center()); + text->GetLayoutObject()->AbsoluteBoundingBoxRect().Center()); HitTestResult hit = GetDocument().GetFrame()->GetEventHandler().HitTestResultAtLocation( location); @@ -379,7 +379,7 @@ SetHtmlInnerHTML("<span style='user-select: none'>blabla</span>"); Node* const text = GetDocument().body()->firstChild()->firstChild(); HitTestLocation location( - text->GetLayoutObject()->FirstFragment().VisualRect().Center()); + text->GetLayoutObject()->AbsoluteBoundingBoxRect().Center()); HitTestResult hit = GetDocument().GetFrame()->GetEventHandler().HitTestResultAtLocation( location); @@ -396,7 +396,7 @@ Node* const text = shadow_root->getElementById("bla")->firstChild(); HitTestLocation location( - text->GetLayoutObject()->FirstFragment().VisualRect().Center()); + text->GetLayoutObject()->AbsoluteBoundingBoxRect().Center()); HitTestResult hit = GetDocument().GetFrame()->GetEventHandler().HitTestResultAtLocation( location); @@ -414,7 +414,7 @@ Node* const text = GetDocument().body()->firstChild()->firstChild()->firstChild(); HitTestLocation location( - text->GetLayoutObject()->FirstFragment().VisualRect().Center()); + text->GetLayoutObject()->AbsoluteBoundingBoxRect().Center()); HitTestResult hit = GetDocument().GetFrame()->GetEventHandler().HitTestResultAtLocation( location); @@ -432,7 +432,7 @@ Node* const text = GetDocument().body()->firstChild()->firstChild()->firstChild(); HitTestLocation location( - text->GetLayoutObject()->FirstFragment().VisualRect().Center()); + text->GetLayoutObject()->AbsoluteBoundingBoxRect().Center()); HitTestResult hit = GetDocument().GetFrame()->GetEventHandler().HitTestResultAtLocation( location); @@ -450,7 +450,7 @@ Node* const text = GetDocument().body()->firstChild()->firstChild()->firstChild(); HitTestLocation location( - text->GetLayoutObject()->FirstFragment().VisualRect().Center()); + text->GetLayoutObject()->AbsoluteBoundingBoxRect().Center()); HitTestResult hit = GetDocument().GetFrame()->GetEventHandler().HitTestResultAtLocation( location); @@ -467,7 +467,7 @@ "</div>"); Node* const text = GetDocument().body()->firstChild()->firstChild()->firstChild(); HitTestLocation location( - text->GetLayoutObject()->FirstFragment().VisualRect().Center()); + text->GetLayoutObject()->AbsoluteBoundingBoxRect().Center()); HitTestResult hit = GetDocument().GetFrame()->GetEventHandler().HitTestResultAtLocation( location); @@ -484,7 +484,7 @@ Node* const text = shadow_root->getElementById("bla")->firstChild(); HitTestLocation location( - text->GetLayoutObject()->FirstFragment().VisualRect().Center()); + text->GetLayoutObject()->AbsoluteBoundingBoxRect().Center()); HitTestResult hit = GetDocument().GetFrame()->GetEventHandler().HitTestResultAtLocation( location); @@ -499,7 +499,7 @@ auto* const field = ToHTMLInputElement(GetDocument().body()->firstChild()); Element* const text = field->InnerEditorElement(); HitTestLocation location( - text->GetLayoutObject()->FirstFragment().VisualRect().Center()); + text->GetLayoutObject()->AbsoluteBoundingBoxRect().Center()); HitTestResult hit = GetDocument().GetFrame()->GetEventHandler().HitTestResultAtLocation( location); @@ -519,7 +519,7 @@ Node* const text = input->InnerEditorElement()->firstChild(); HitTestLocation location( - text->GetLayoutObject()->FirstFragment().VisualRect().Center()); + text->GetLayoutObject()->AbsoluteBoundingBoxRect().Center()); HitTestResult hit = GetDocument().GetFrame()->GetEventHandler().HitTestResultAtLocation( location); @@ -533,7 +533,7 @@ SetHtmlInnerHTML("<img>"); Element* const img = ToElement(GetDocument().body()->firstChild()); HitTestLocation location( - img->GetLayoutObject()->FirstFragment().VisualRect().Center()); + img->GetLayoutObject()->AbsoluteBoundingBoxRect().Center()); HitTestResult hit = GetDocument().GetFrame()->GetEventHandler().HitTestResultAtLocation( location); @@ -547,7 +547,7 @@ SetHtmlInnerHTML("<a href='bala'>link text</a>"); Node* const link = GetDocument().body()->firstChild(); HitTestLocation location( - link->GetLayoutObject()->FirstFragment().VisualRect().Center()); + link->GetLayoutObject()->AbsoluteBoundingBoxRect().Center()); HitTestResult result = GetDocument().GetFrame()->GetEventHandler().HitTestResultAtLocation( location); @@ -573,7 +573,7 @@ SetHtmlInnerHTML("<a contenteditable='true' href='bala'>editable link</a>"); Node* const link = GetDocument().body()->firstChild(); HitTestLocation location( - link->GetLayoutObject()->FirstFragment().VisualRect().Center()); + link->GetLayoutObject()->AbsoluteBoundingBoxRect().Center()); HitTestResult result = GetDocument().GetFrame()->GetEventHandler().HitTestResultAtLocation( location);
diff --git a/third_party/blink/renderer/core/inspector/inspect_tool_highlight.html b/third_party/blink/renderer/core/inspector/inspect_tool_highlight.html index 03a17962..a068c15 100644 --- a/third_party/blink/renderer/core/inspector/inspect_tool_highlight.html +++ b/third_party/blink/renderer/core/inspector/inspect_tool_highlight.html
@@ -595,20 +595,19 @@ } // If tooltip intersects with the bounds, hide it. - if (boxX < bounds.maxX && boxX + titleWidth > bounds.minX && - boxY < bounds.maxY && boxY + titleHeight > bounds.minY) { - tooltipContent.style.display = 'none'; - return; - } - - if (boxX + titleWidth >= bounds.minX && boxX + titleWidth <= bounds.maxX && boxY + titleHeight >= bounds.minY && boxY + titleHeight <= bounds.maxY) { + // Allow bounds to contain the box though for the large elements like <body>. + const includes = boxX >= bounds.minX && boxX + titleWidth <= bounds.maxX && + boxY >= bounds.minY && boxY + titleHeight <= bounds.maxY; + const overlaps = boxX < bounds.maxX && boxX + titleWidth > bounds.minX && + boxY < bounds.maxY && boxY + titleHeight > bounds.minY; + if (overlaps && !includes) { tooltipContent.style.display = 'none'; return; } tooltipContent.style.top = boxY + "px"; tooltipContent.style.left = boxX + "px"; - tooltipContent.style.setProperty('--arrow-visibility', arrowHidden ? 'hidden' : 'visible'); + tooltipContent.style.setProperty('--arrow-visibility', (arrowHidden || includes) ? 'hidden' : 'visible'); if (arrowHidden) return;
diff --git a/third_party/blink/renderer/core/layout/api/line_layout_item.h b/third_party/blink/renderer/core/layout/api/line_layout_item.h index 671caba..ecec3e0 100644 --- a/third_party/blink/renderer/core/layout/api/line_layout_item.h +++ b/third_party/blink/renderer/core/layout/api/line_layout_item.h
@@ -287,10 +287,10 @@ return layout_object_->DocumentBeingDestroyed(); } - LayoutRect VisualRectForInlineBox() const { + IntRect VisualRectForInlineBox() const { return layout_object_->VisualRectForInlineBox(); } - LayoutRect PartialInvalidationVisualRectForInlineBox() const { + IntRect PartialInvalidationVisualRectForInlineBox() const { return layout_object_->PartialInvalidationVisualRectForInlineBox(); }
diff --git a/third_party/blink/renderer/core/layout/jank_tracker.cc b/third_party/blink/renderer/core/layout/jank_tracker.cc index eb1c41e..a865c08 100644 --- a/third_party/blink/renderer/core/layout/jank_tracker.cc +++ b/third_party/blink/renderer/core/layout/jank_tracker.cc
@@ -170,7 +170,7 @@ } void JankTracker::NotifyObjectPrePaint(const LayoutObject& object, - const LayoutRect& old_visual_rect, + const IntRect& old_visual_rect, const PaintLayer& painting_layer) { if (!IsActive()) return;
diff --git a/third_party/blink/renderer/core/layout/jank_tracker.h b/third_party/blink/renderer/core/layout/jank_tracker.h index 47323e12..df0dddc 100644 --- a/third_party/blink/renderer/core/layout/jank_tracker.h +++ b/third_party/blink/renderer/core/layout/jank_tracker.h
@@ -13,8 +13,8 @@ namespace blink { +class IntRect; class LayoutObject; -class LayoutRect; class LocalFrameView; class PaintLayer; class TracedValue; @@ -29,7 +29,7 @@ JankTracker(LocalFrameView*); ~JankTracker() {} void NotifyObjectPrePaint(const LayoutObject& object, - const LayoutRect& old_visual_rect, + const IntRect& old_visual_rect, const PaintLayer& painting_layer); void NotifyCompositedLayerMoved(const PaintLayer&, FloatRect old_layer_rect,
diff --git a/third_party/blink/renderer/core/layout/layout_object.cc b/third_party/blink/renderer/core/layout/layout_object.cc index 4a61837..045a93e 100644 --- a/third_party/blink/renderer/core/layout/layout_object.cc +++ b/third_party/blink/renderer/core/layout/layout_object.cc
@@ -1662,17 +1662,17 @@ return GetNode() ? DOMNodeIds::IdForNode(GetNode()) : kInvalidDOMNodeId; } -LayoutRect LayoutObject::FragmentsVisualRectBoundingBox() const { +IntRect LayoutObject::FragmentsVisualRectBoundingBox() const { if (!fragment_.NextFragment()) return fragment_.VisualRect(); - LayoutRect visual_rect; + IntRect visual_rect; for (auto* fragment = &fragment_; fragment; fragment = fragment->NextFragment()) visual_rect.Unite(fragment->VisualRect()); return visual_rect; } -LayoutRect LayoutObject::VisualRect() const { +IntRect LayoutObject::VisualRect() const { return FragmentsVisualRectBoundingBox(); } @@ -1727,18 +1727,17 @@ } void LayoutObject::AdjustVisualRectForCompositedScrolling( - LayoutRect& rect, + IntRect& rect, const LayoutBoxModelObject& paint_invalidation_container) const { if (CompositedScrollsWithRespectTo(paint_invalidation_container)) { - LayoutSize offset( - -ToLayoutBox(&paint_invalidation_container)->ScrolledContentOffset()); - rect.Move(offset); + rect.Move( + -ToLayoutBox(paint_invalidation_container).ScrolledContentOffset()); } } -LayoutRect LayoutObject::VisualRectIncludingCompositedScrolling( +IntRect LayoutObject::VisualRectIncludingCompositedScrolling( const LayoutBoxModelObject& paint_invalidation_container) const { - LayoutRect rect = VisualRect(); + IntRect rect = VisualRect(); AdjustVisualRectForCompositedScrolling(rect, paint_invalidation_container); return rect; } @@ -1748,8 +1747,8 @@ for (auto* fragment = &fragment_; fragment; fragment = fragment->NextFragment()) { - fragment->SetVisualRect(LayoutRect()); - fragment->SetSelectionVisualRect(LayoutRect()); + fragment->SetVisualRect(IntRect()); + fragment->SetSelectionVisualRect(IntRect()); } // After clearing ("invalidating") the visual rects, mark this object as @@ -4226,8 +4225,8 @@ fragment->InvalidateClipPathCache(); } -LayoutRect LayoutObject::AdjustVisualRectForInlineBox( - const LayoutRect& visual_rect) const { +IntRect LayoutObject::AdjustVisualRectForInlineBox( + const IntRect& visual_rect) const { // For simplicity, we use the layout object's visual rect as the visual rect // of contained inline boxes, mapped to the correct transform space of the // inline boxes. @@ -4238,7 +4237,7 @@ // For now this happens for EllipsisBox only. auto float_visual_rect = FloatRect(visual_rect); float_visual_rect.Move(-scroll_translation->Translation2D()); - return EnclosingLayoutRect(float_visual_rect); + return EnclosingIntRect(float_visual_rect); } } return visual_rect;
diff --git a/third_party/blink/renderer/core/layout/layout_object.h b/third_party/blink/renderer/core/layout/layout_object.h index 401f04d..6b8aad64 100644 --- a/third_party/blink/renderer/core/layout/layout_object.h +++ b/third_party/blink/renderer/core/layout/layout_object.h
@@ -258,26 +258,26 @@ // Do not call VisualRect directly outside of the DisplayItemClient // interface, use a per-fragment one on FragmentData instead. - LayoutRect VisualRect() const final; + IntRect VisualRect() const final; void ClearPartialInvalidationVisualRect() const final { return GetMutableForPainting() .FirstFragment() - .SetPartialInvalidationVisualRect(LayoutRect()); + .SetPartialInvalidationVisualRect(IntRect()); } DOMNodeId OwnerNodeId() const final; public: - LayoutRect PartialInvalidationVisualRect() const final { + IntRect PartialInvalidationVisualRect() const final { return FirstFragment().PartialInvalidationVisualRect(); } - LayoutRect VisualRectForInlineBox() const { + IntRect VisualRectForInlineBox() const { return AdjustVisualRectForInlineBox(VisualRect()); } - LayoutRect PartialInvalidationVisualRectForInlineBox() const { + IntRect PartialInvalidationVisualRectForInlineBox() const { return AdjustVisualRectForInlineBox(PartialInvalidationVisualRect()); } @@ -1872,7 +1872,7 @@ // The visual rect, in the the space of the paint invalidation container // (*not* the graphics layer that paints this object). - LayoutRect VisualRectIncludingCompositedScrolling( + IntRect VisualRectIncludingCompositedScrolling( const LayoutBoxModelObject& paint_invalidation_container) const; // Called when the previous visual rect(s) is no longer valid. @@ -1988,7 +1988,7 @@ const FragmentData& FirstFragment() const { return fragment_; } // Returns the bounding box of the visual rects of all fragments. - LayoutRect FragmentsVisualRectBoundingBox() const; + IntRect FragmentsVisualRectBoundingBox() const; void SetNeedsOverflowRecalc(); @@ -2074,11 +2074,11 @@ // The following setters store the current values as calculated during the // pre-paint tree walk. TODO(wangxianzhu): Add check of lifecycle states. - void SetVisualRect(const LayoutRect& r) { + void SetVisualRect(const IntRect& r) { layout_object_.fragment_.SetVisualRect(r); } - void SetSelectionVisualRect(const LayoutRect& r) { + void SetSelectionVisualRect(const IntRect& r) { layout_object_.fragment_.SetSelectionVisualRect(r); } @@ -2101,7 +2101,7 @@ layout_object_.AddSubtreePaintPropertyUpdateReason(reason); } - void SetPartialInvalidationVisualRect(const LayoutRect& r) { + void SetPartialInvalidationVisualRect(const IntRect& r) { DCHECK_EQ(layout_object_.GetDocument().Lifecycle().GetState(), DocumentLifecycle::kInPrePaint); FirstFragment().SetPartialInvalidationVisualRect(r); @@ -2220,7 +2220,7 @@ return bitfields_.PreviousOutlineMayBeAffectedByDescendants(); } - LayoutRect SelectionVisualRect() const { + IntRect SelectionVisualRect() const { return fragment_.SelectionVisualRect(); } LayoutRect PartialInvalidationLocalRect() const { @@ -2468,7 +2468,7 @@ // the |paint_invalidation_container|, if needed. They can be different only // if |paint_invalidation_container| is a composited scroller. void AdjustVisualRectForCompositedScrolling( - LayoutRect& visual_rect, + IntRect& visual_rect, const LayoutBoxModelObject& paint_invalidation_container) const; FloatQuad LocalToAncestorQuadInternal(const FloatQuad&, @@ -2539,7 +2539,7 @@ void ApplyPseudoStyleChanges(const ComputedStyle* old_style); void ApplyFirstLineChanges(const ComputedStyle* old_style); - LayoutRect AdjustVisualRectForInlineBox(const LayoutRect&) const; + IntRect AdjustVisualRectForInlineBox(const IntRect&) const; // This is set by Set[Subtree]ShouldDoFullPaintInvalidation, and cleared // during PrePaint in this object's InvalidatePaint(). It's different from
diff --git a/third_party/blink/renderer/core/layout/layout_scrollbar.cc b/third_party/blink/renderer/core/layout/layout_scrollbar.cc index 5f7d9854..b0bab3a 100644 --- a/third_party/blink/renderer/core/layout/layout_scrollbar.cc +++ b/third_party/blink/renderer/core/layout/layout_scrollbar.cc
@@ -404,7 +404,7 @@ } } -void LayoutScrollbar::SetVisualRect(const LayoutRect& rect) { +void LayoutScrollbar::SetVisualRect(const IntRect& rect) { Scrollbar::SetVisualRect(rect); for (auto& part : parts_) part.value->GetMutableForPainting().FirstFragment().SetVisualRect(rect);
diff --git a/third_party/blink/renderer/core/layout/layout_scrollbar.h b/third_party/blink/renderer/core/layout/layout_scrollbar.h index 26a8b47..85de9892 100644 --- a/third_party/blink/renderer/core/layout/layout_scrollbar.h +++ b/third_party/blink/renderer/core/layout/layout_scrollbar.h
@@ -77,7 +77,7 @@ void InvalidateDisplayItemClientsOfScrollbarParts(); - void SetVisualRect(const LayoutRect&) final; + void SetVisualRect(const IntRect&) final; void Trace(blink::Visitor*) override;
diff --git a/third_party/blink/renderer/core/layout/line/inline_box.cc b/third_party/blink/renderer/core/layout/line/inline_box.cc index 70f6d1c..02ba437e 100644 --- a/third_party/blink/renderer/core/layout/line/inline_box.cc +++ b/third_party/blink/renderer/core/layout/line/inline_box.cc
@@ -95,11 +95,11 @@ return BoxName(); } -LayoutRect InlineBox::VisualRect() const { +IntRect InlineBox::VisualRect() const { return GetLineLayoutItem().VisualRectForInlineBox(); } -LayoutRect InlineBox::PartialInvalidationVisualRect() const { +IntRect InlineBox::PartialInvalidationVisualRect() const { return GetLineLayoutItem().PartialInvalidationVisualRectForInlineBox(); }
diff --git a/third_party/blink/renderer/core/layout/line/inline_box.h b/third_party/blink/renderer/core/layout/line/inline_box.h index cf148a1e..d6d23d6 100644 --- a/third_party/blink/renderer/core/layout/line/inline_box.h +++ b/third_party/blink/renderer/core/layout/line/inline_box.h
@@ -129,8 +129,8 @@ // DisplayItemClient methods String DebugName() const override; - LayoutRect VisualRect() const override; - LayoutRect PartialInvalidationVisualRect() const override; + IntRect VisualRect() const override; + IntRect PartialInvalidationVisualRect() const override; bool IsText() const { return bitfields_.IsText(); } void SetIsText(bool is_text) { bitfields_.SetIsText(is_text); }
diff --git a/third_party/blink/renderer/core/layout/visual_rect_mapping_test.cc b/third_party/blink/renderer/core/layout/visual_rect_mapping_test.cc index 6e190d4..cb240ad 100644 --- a/third_party/blink/renderer/core/layout/visual_rect_mapping_test.cc +++ b/third_party/blink/renderer/core/layout/visual_rect_mapping_test.cc
@@ -662,7 +662,7 @@ LayoutRect rect = normal_flow_visual_rect; EXPECT_TRUE(normal_flow->MapToVisualRectInAncestorSpace(scroller, rect)); EXPECT_EQ(LayoutRect(0, 0, 2000, 2000), rect); - EXPECT_EQ(rect, normal_flow->FirstFragment().VisualRect()); + EXPECT_EQ(EnclosingIntRect(rect), normal_flow->FirstFragment().VisualRect()); auto* stacking_context = To<LayoutBlock>(GetLayoutObjectByElementId("stacking-context")); @@ -769,7 +769,7 @@ } else { EXPECT_EQ(LayoutRect(66, 55, 33, 44), rect); } - EXPECT_EQ(rect, target->FirstFragment().VisualRect()); + EXPECT_EQ(EnclosingIntRect(rect), target->FirstFragment().VisualRect()); rect = target_visual_rect;
diff --git a/third_party/blink/renderer/core/paint/block_painter_test.cc b/third_party/blink/renderer/core/paint/block_painter_test.cc index 228b9139..3f69844 100644 --- a/third_party/blink/renderer/core/paint/block_painter_test.cc +++ b/third_party/blink/renderer/core/paint/block_painter_test.cc
@@ -641,12 +641,12 @@ scrolled_hit_test_data))); const auto& scroller_paint_chunk = paint_chunks[1]; - EXPECT_EQ(FloatRect(0, 0, 100, 100), scroller_paint_chunk.bounds); + EXPECT_EQ(IntRect(0, 0, 100, 100), scroller_paint_chunk.bounds); // The hit test rect for the scroller itself should not be scrolled. EXPECT_FALSE(scroller_paint_chunk.properties.Transform().ScrollNode()); const auto& scrolled_paint_chunk = paint_chunks[2]; - EXPECT_EQ(FloatRect(0, 0, 200, 50), scrolled_paint_chunk.bounds); + EXPECT_EQ(IntRect(0, 0, 200, 50), scrolled_paint_chunk.bounds); // The hit test rect for the scrolled contents should be scrolled. EXPECT_TRUE(scrolled_paint_chunk.properties.Transform().ScrollNode()); }
diff --git a/third_party/blink/renderer/core/paint/box_paint_invalidator.cc b/third_party/blink/renderer/core/paint/box_paint_invalidator.cc index 77fdd15..3628aab 100644 --- a/third_party/blink/renderer/core/paint/box_paint_invalidator.cc +++ b/third_party/blink/renderer/core/paint/box_paint_invalidator.cc
@@ -140,9 +140,9 @@ // - pixel snapping, or not snapping e.g. for some visual overflowing effects, // - scale, rotate, skew etc. transforms, // - visual (ink) overflows. - if (context_.old_visual_rect != + if (LayoutRect(context_.old_visual_rect) != LayoutRect(context_.old_paint_offset, box_.PreviousSize()) || - context_.fragment_data->VisualRect() != + LayoutRect(context_.fragment_data->VisualRect()) != LayoutRect(context_.fragment_data->PaintOffset(), box_.Size())) { return PaintInvalidationReason::kGeometry; }
diff --git a/third_party/blink/renderer/core/paint/box_paint_invalidator_test.cc b/third_party/blink/renderer/core/paint/box_paint_invalidator_test.cc index cf596d2..be3ff037 100644 --- a/third_party/blink/renderer/core/paint/box_paint_invalidator_test.cc +++ b/third_party/blink/renderer/core/paint/box_paint_invalidator_test.cc
@@ -27,7 +27,7 @@ protected: PaintInvalidationReason ComputePaintInvalidationReason( const LayoutBox& box, - const LayoutRect& old_visual_rect, + const IntRect& old_visual_rect, const LayoutPoint& old_paint_offset) { FragmentData fragment_data; PaintInvalidatorContext context; @@ -48,8 +48,8 @@ UpdateAllLifecyclePhasesForTest(); auto& target = *GetDocument().getElementById("target"); auto& box = *ToLayoutBox(target.GetLayoutObject()); - LayoutRect visual_rect = box.FirstFragment().VisualRect(); - LayoutPoint paint_offset = box.FirstFragment().PaintOffset(); + auto visual_rect = box.FirstFragment().VisualRect(); + auto paint_offset = box.FirstFragment().PaintOffset(); // No geometry change. EXPECT_EQ(PaintInvalidationReason::kNone, @@ -61,7 +61,7 @@ GetDocument().View()->UpdateLifecycleToCompositingInputsClean(); // Simulate that PaintInvalidator updates visual rect. box.GetMutableForPainting().SetVisualRect( - LayoutRect(visual_rect.Location(), box.Size())); + IntRect(visual_rect.Location(), RoundedIntSize(box.Size()))); EXPECT_EQ(PaintInvalidationReason::kGeometry, ComputePaintInvalidationReason(box, visual_rect, paint_offset)); @@ -108,12 +108,12 @@ UpdateAllLifecyclePhasesForTest(); EXPECT_TRUE(box.PaintedOutputOfObjectHasNoEffectRegardlessOfSize()); - LayoutRect visual_rect = box.FirstFragment().VisualRect(); + auto visual_rect = box.FirstFragment().VisualRect(); // No geometry change. - EXPECT_EQ( - PaintInvalidationReason::kNone, - ComputePaintInvalidationReason(box, visual_rect, visual_rect.Location())); + EXPECT_EQ(PaintInvalidationReason::kNone, + ComputePaintInvalidationReason( + box, visual_rect, LayoutPoint(visual_rect.Location()))); // Paint offset change. EXPECT_EQ(PaintInvalidationReason::kNone, @@ -121,16 +121,16 @@ box, visual_rect, visual_rect.Location() + LayoutSize(10, 20))); // Visual rect size change. - LayoutRect old_visual_rect = visual_rect; + auto old_visual_rect = visual_rect; target.setAttribute(html_names::kStyleAttr, "width: 200px"); GetDocument().View()->UpdateLifecycleToLayoutClean(); // Simulate that PaintInvalidator updates visual rect. box.GetMutableForPainting().SetVisualRect( - LayoutRect(visual_rect.Location(), box.Size())); + IntRect(visual_rect.Location(), RoundedIntSize(box.Size()))); EXPECT_EQ(PaintInvalidationReason::kNone, - ComputePaintInvalidationReason(box, old_visual_rect, - old_visual_rect.Location())); + ComputePaintInvalidationReason( + box, old_visual_rect, LayoutPoint(old_visual_rect.Location()))); } TEST_P(BoxPaintInvalidatorTest, ComputePaintInvalidationReasonBasic) { @@ -143,29 +143,30 @@ UpdateAllLifecyclePhasesForTest(); box.SetShouldCheckForPaintInvalidation(); - LayoutRect visual_rect = box.FirstFragment().VisualRect(); - EXPECT_EQ(LayoutRect(0, 0, 50, 100), visual_rect); + auto visual_rect = box.FirstFragment().VisualRect(); + EXPECT_EQ(IntRect(0, 0, 50, 100), visual_rect); // No geometry change. - EXPECT_EQ( - PaintInvalidationReason::kNone, - ComputePaintInvalidationReason(box, visual_rect, visual_rect.Location())); + EXPECT_EQ(PaintInvalidationReason::kNone, + ComputePaintInvalidationReason( + box, visual_rect, LayoutPoint(visual_rect.Location()))); // Visual rect size change. - LayoutRect old_visual_rect = visual_rect; + auto old_visual_rect = visual_rect; target.setAttribute(html_names::kStyleAttr, "background: blue; width: 200px"); GetDocument().View()->UpdateLifecycleToLayoutClean(); // Simulate that PaintInvalidator updates visual rect. box.GetMutableForPainting().SetVisualRect( - LayoutRect(visual_rect.Location(), box.Size())); + IntRect(visual_rect.Location(), RoundedIntSize(box.Size()))); EXPECT_EQ(PaintInvalidationReason::kIncremental, - ComputePaintInvalidationReason(box, old_visual_rect, - old_visual_rect.Location())); + ComputePaintInvalidationReason( + box, old_visual_rect, LayoutPoint(old_visual_rect.Location()))); // Visual rect size change, with paint offset different from location of // visual rect. - LayoutPoint fake_paint_offset = visual_rect.Location() + LayoutSize(10, 20); + LayoutPoint fake_paint_offset = + LayoutPoint(visual_rect.Location()) + LayoutSize(10, 20); box.GetMutableForPainting().FirstFragment().SetPaintOffset(fake_paint_offset); EXPECT_EQ( PaintInvalidationReason::kGeometry, @@ -174,12 +175,13 @@ // Should use the existing full paint invalidation reason regardless of // geometry change. box.SetShouldDoFullPaintInvalidation(PaintInvalidationReason::kStyle); - EXPECT_EQ( - PaintInvalidationReason::kStyle, - ComputePaintInvalidationReason(box, visual_rect, visual_rect.Location())); EXPECT_EQ(PaintInvalidationReason::kStyle, ComputePaintInvalidationReason( - box, visual_rect, visual_rect.Location() + LayoutSize(10, 20))); + box, visual_rect, LayoutPoint(visual_rect.Location()))); + EXPECT_EQ(PaintInvalidationReason::kStyle, + ComputePaintInvalidationReason( + box, visual_rect, + LayoutPoint(visual_rect.Location()) + LayoutSize(10, 20))); } TEST_P(BoxPaintInvalidatorTest, ComputePaintInvalidationReasonOtherCases) {
diff --git a/third_party/blink/renderer/core/paint/find_paint_offset_and_visual_rect_needing_update.h b/third_party/blink/renderer/core/paint/find_paint_offset_and_visual_rect_needing_update.h index 7058bbe..c3357af 100644 --- a/third_party/blink/renderer/core/paint/find_paint_offset_and_visual_rect_needing_update.h +++ b/third_party/blink/renderer/core/paint/find_paint_offset_and_visual_rect_needing_update.h
@@ -75,7 +75,7 @@ protected: FindVisualRectNeedingUpdateScopeBase(const LayoutObject& object, const PaintInvalidatorContext& context, - const LayoutRect& old_visual_rect) + const IntRect& old_visual_rect) : object_(object), context_(context), old_visual_rect_(old_visual_rect), @@ -94,13 +94,13 @@ context_.NeedsVisualRectUpdate(object_)); } - static LayoutRect InflatedRect(const LayoutRect& r) { - LayoutRect result = r; + static IntRect InflatedRect(const IntRect& r) { + IntRect result = r; result.Inflate(1); return result; } - void CheckVisualRect(const LayoutRect& new_visual_rect) { + void CheckVisualRect(const IntRect& new_visual_rect) { if (needed_visual_rect_update_) return; DCHECK((old_visual_rect_.IsEmpty() && new_visual_rect.IsEmpty()) || @@ -122,7 +122,7 @@ const LayoutObject& object_; const PaintInvalidatorContext& context_; - LayoutRect old_visual_rect_; + IntRect old_visual_rect_; bool needed_visual_rect_update_; }; @@ -132,17 +132,17 @@ public: FindVisualRectNeedingUpdateScope(const LayoutObject& object, const PaintInvalidatorContext& context, - const LayoutRect& old_visual_rect, + const IntRect& old_visual_rect, // Must be a reference to a rect that // outlives this scope. - const LayoutRect& new_visual_rect) + const IntRect& new_visual_rect) : FindVisualRectNeedingUpdateScopeBase(object, context, old_visual_rect), new_visual_rect_ref_(new_visual_rect) {} ~FindVisualRectNeedingUpdateScope() { CheckVisualRect(new_visual_rect_ref_); } private: - const LayoutRect& new_visual_rect_ref_; + const IntRect& new_visual_rect_ref_; }; // For updates of object visual rect and location.
diff --git a/third_party/blink/renderer/core/paint/fragment_data.h b/third_party/blink/renderer/core/paint/fragment_data.h index 21b12a2..2eb6b7e 100644 --- a/third_party/blink/renderer/core/paint/fragment_data.h +++ b/third_party/blink/renderer/core/paint/fragment_data.h
@@ -40,8 +40,8 @@ // AdjustVisualRectForCompositedScrolling(). // It's location may be different from PaintOffset when there is visual (ink) // overflow to the top and/or the left. - LayoutRect VisualRect() const { return visual_rect_; } - void SetVisualRect(const LayoutRect& rect) { visual_rect_ = rect; } + IntRect VisualRect() const { return visual_rect_; } + void SetVisualRect(const IntRect& rect) { visual_rect_ = rect; } // An id for this object that is unique for the lifetime of the WebView. UniqueObjectId UniqueId() const { @@ -57,10 +57,10 @@ // Visual rect of the selection on this object, in the same coordinate space // as DisplayItemClient::VisualRect(). - LayoutRect SelectionVisualRect() const { - return rare_data_ ? rare_data_->selection_visual_rect : LayoutRect(); + IntRect SelectionVisualRect() const { + return rare_data_ ? rare_data_->selection_visual_rect : IntRect(); } - void SetSelectionVisualRect(const LayoutRect& r) { + void SetSelectionVisualRect(const IntRect& r) { if (rare_data_ || !r.IsEmpty()) EnsureRareData().selection_visual_rect = r; } @@ -83,11 +83,11 @@ // Covers the sub-rectangles of the object that need to be re-rastered, in // visual rect space (see VisualRect()). It will be cleared after the raster // invalidation is issued after paint. - LayoutRect PartialInvalidationVisualRect() const { + IntRect PartialInvalidationVisualRect() const { return rare_data_ ? rare_data_->partial_invalidation_visual_rect - : LayoutRect(); + : IntRect(); } - void SetPartialInvalidationVisualRect(const LayoutRect& r) { + void SetPartialInvalidationVisualRect(const IntRect& r) { if (rare_data_ || !r.IsEmpty()) EnsureRareData().partial_invalidation_visual_rect = r; } @@ -248,9 +248,9 @@ // avoid separate data structure for them. std::unique_ptr<PaintLayer> layer; UniqueObjectId unique_id; - LayoutRect selection_visual_rect; + IntRect selection_visual_rect; LayoutRect partial_invalidation_local_rect; - LayoutRect partial_invalidation_visual_rect; + IntRect partial_invalidation_visual_rect; // Fragment specific data. LayoutPoint pagination_offset; @@ -266,7 +266,7 @@ RareData& EnsureRareData(); - LayoutRect visual_rect_; + IntRect visual_rect_; LayoutPoint paint_offset_; std::unique_ptr<RareData> rare_data_;
diff --git a/third_party/blink/renderer/core/paint/fragment_data_test.cc b/third_party/blink/renderer/core/paint/fragment_data_test.cc index 38eec25..3ba988e 100644 --- a/third_party/blink/renderer/core/paint/fragment_data_test.cc +++ b/third_party/blink/renderer/core/paint/fragment_data_test.cc
@@ -16,20 +16,20 @@ FragmentData fragment; // Default SelectionVisualRect should not create RareData. - fragment.SetVisualRect(LayoutRect(10, 20, 30, 400)); - fragment.SetSelectionVisualRect(LayoutRect()); + fragment.SetVisualRect(IntRect(10, 20, 30, 400)); + fragment.SetSelectionVisualRect(IntRect()); EXPECT_FALSE(HasRareData(fragment)); - EXPECT_EQ(LayoutRect(), fragment.SelectionVisualRect()); + EXPECT_EQ(IntRect(), fragment.SelectionVisualRect()); // Non-Default SelectionVisualRect creates RareData. - fragment.SetSelectionVisualRect(LayoutRect(1, 2, 3, 4)); + fragment.SetSelectionVisualRect(IntRect(1, 2, 3, 4)); EXPECT_TRUE(HasRareData(fragment)); - EXPECT_EQ(LayoutRect(1, 2, 3, 4), fragment.SelectionVisualRect()); + EXPECT_EQ(IntRect(1, 2, 3, 4), fragment.SelectionVisualRect()); // PaintProperties should store default SelectionVisualRect once it's created. - fragment.SetSelectionVisualRect(LayoutRect()); + fragment.SetSelectionVisualRect(IntRect()); EXPECT_TRUE(HasRareData(fragment)); - EXPECT_EQ(LayoutRect(), fragment.SelectionVisualRect()); + EXPECT_EQ(IntRect(), fragment.SelectionVisualRect()); } TEST_F(FragmentDataTest, PreEffectClipProperties) {
diff --git a/third_party/blink/renderer/core/paint/image_element_timing.cc b/third_party/blink/renderer/core/paint/image_element_timing.cc index 025ef4de..93a3049 100644 --- a/third_party/blink/renderer/core/paint/image_element_timing.cc +++ b/third_party/blink/renderer/core/paint/image_element_timing.cc
@@ -142,7 +142,7 @@ const LayoutObject& layout_object, const PropertyTreeState& current_paint_chunk_properties) { // Compute the visible part of the image rect. - LayoutRect image_visual_rect = layout_object.FirstFragment().VisualRect(); + IntRect image_visual_rect = layout_object.FirstFragment().VisualRect(); FloatClipRect visual_rect = FloatClipRect(FloatRect(image_visual_rect)); GeometryMapper::LocalToAncestorVisualRect(current_paint_chunk_properties,
diff --git a/third_party/blink/renderer/core/paint/image_paint_timing_detector.cc b/third_party/blink/renderer/core/paint/image_paint_timing_detector.cc index 89cf2cc..a96e84dd 100644 --- a/third_party/blink/renderer/core/paint/image_paint_timing_detector.cc +++ b/third_party/blink/renderer/core/paint/image_paint_timing_detector.cc
@@ -290,7 +290,7 @@ if (records_manager_.IsRecordedVisibleNode(node_id) || !is_recording_) return; - LayoutRect visual_rect = object.FragmentsVisualRectBoundingBox(); + IntRect visual_rect = object.FragmentsVisualRectBoundingBox(); // Before the image resource starts loading, <img> has no size info. We wait // until the size is known. if (visual_rect.IsEmpty()) @@ -300,7 +300,7 @@ visual_rect, current_paint_chunk_properties); rect_size = DownScaleIfIntrinsicSizeIsSmaller( rect_size, intrinsic_size.Area(), - (visual_rect.Width() * visual_rect.Height()).ToUnsigned()); + visual_rect.Width() * visual_rect.Height()); DVLOG(2) << "Node id (" << node_id << "): size=" << rect_size << ", type=" << object.DebugName(); if (rect_size == 0) {
diff --git a/third_party/blink/renderer/core/paint/ng/ng_fragment_painter.cc b/third_party/blink/renderer/core/paint/ng/ng_fragment_painter.cc index 42338dfe..ccb321d 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_fragment_painter.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_fragment_painter.cc
@@ -54,7 +54,7 @@ if (!url.IsValid()) return; - IntRect rect = PixelSnappedIntRect(paint_fragment_.VisualRect()); + IntRect rect = paint_fragment_.VisualRect(); if (rect.IsEmpty()) return;
diff --git a/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.cc b/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.cc index c23e43bd..67a0197d 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.cc
@@ -658,7 +658,7 @@ return *containing_block_fragment->GetLayoutObject(); } -LayoutRect NGPaintFragment::VisualRect() const { +IntRect NGPaintFragment::VisualRect() const { // VisualRect is computed from fragment tree and set to LayoutObject in // pre-paint. Use the stored value in the LayoutObject. bool this_as_inline_box; @@ -667,7 +667,7 @@ : layout_object.FragmentsVisualRectBoundingBox(); } -LayoutRect NGPaintFragment::PartialInvalidationVisualRect() const { +IntRect NGPaintFragment::PartialInvalidationVisualRect() const { bool this_as_inline_box; const auto& layout_object = VisualRectLayoutObject(this_as_inline_box); return this_as_inline_box
diff --git a/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h b/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h index 49832c5..6e0c213 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h +++ b/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h
@@ -169,8 +169,8 @@ bool ShouldClipOverflow() const; bool HasSelfPaintingLayer() const; // This is equivalent to LayoutObject::VisualRect - LayoutRect VisualRect() const override; - LayoutRect PartialInvalidationVisualRect() const override; + IntRect VisualRect() const override; + IntRect PartialInvalidationVisualRect() const override; NGPhysicalOffsetRect ComputeLocalSelectionRectForText( const LayoutSelectionStatus&) const;
diff --git a/third_party/blink/renderer/core/paint/ng/ng_paint_fragment_test.cc b/third_party/blink/renderer/core/paint/ng/ng_paint_fragment_test.cc index afaf574..d7dd29f8 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_paint_fragment_test.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_paint_fragment_test.cc
@@ -122,19 +122,19 @@ const NGPaintFragment& outer_text = *line1_children[0]; EXPECT_EQ(NGPhysicalFragment::kFragmentText, outer_text.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 0, 60, 10), outer_text.VisualRect()); + EXPECT_EQ(IntRect(0, 0, 60, 10), outer_text.VisualRect()); const NGPaintFragment& inner_text1 = *line1_children[1]; EXPECT_EQ(NGPhysicalFragment::kFragmentText, inner_text1.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 0, 90, 20), inner_text1.VisualRect()); + EXPECT_EQ(IntRect(0, 0, 90, 20), inner_text1.VisualRect()); const NGPaintFragment& line2 = *lines[1]; EXPECT_EQ(1u, line2.Children().size()); const NGPaintFragment& inner_text2 = *line2.FirstChild(); EXPECT_EQ(NGPhysicalFragment::kFragmentText, inner_text2.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 00, 90, 20), inner_text2.VisualRect()); + EXPECT_EQ(IntRect(0, 00, 90, 20), inner_text2.VisualRect()); } TEST_F(NGPaintFragmentTest, InlineBoxWithDecorations) { @@ -160,31 +160,31 @@ const NGPaintFragment& outer_text = *line1_children[0]; EXPECT_EQ(NGPhysicalFragment::kFragmentText, outer_text.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 0, 60, 10), outer_text.VisualRect()); + EXPECT_EQ(IntRect(0, 0, 60, 10), outer_text.VisualRect()); // Inline boxes with box decorations generate box fragments. const NGPaintFragment& inline_box1 = *line1_children[1]; EXPECT_EQ(NGPhysicalFragment::kFragmentBox, inline_box1.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 0, 90, 20), inline_box1.VisualRect()); + EXPECT_EQ(IntRect(0, 0, 90, 20), inline_box1.VisualRect()); EXPECT_EQ(1u, inline_box1.Children().size()); const NGPaintFragment& inner_text1 = *inline_box1.FirstChild(); EXPECT_EQ(NGPhysicalFragment::kFragmentText, inner_text1.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 0, 90, 20), inner_text1.VisualRect()); + EXPECT_EQ(IntRect(0, 0, 90, 20), inner_text1.VisualRect()); const NGPaintFragment& line2 = *lines[1]; EXPECT_EQ(1u, line2.Children().size()); const NGPaintFragment& inline_box2 = *line2.FirstChild(); EXPECT_EQ(NGPhysicalFragment::kFragmentBox, inline_box2.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 0, 90, 20), inline_box2.VisualRect()); + EXPECT_EQ(IntRect(0, 0, 90, 20), inline_box2.VisualRect()); const NGPaintFragment& inner_text2 = *inline_box2.FirstChild(); EXPECT_EQ(NGPhysicalFragment::kFragmentText, inner_text2.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 0, 90, 20), inner_text2.VisualRect()); + EXPECT_EQ(IntRect(0, 0, 90, 20), inner_text2.VisualRect()); } TEST_F(NGPaintFragmentTest, InlineBlock) { @@ -217,7 +217,7 @@ .Text() .ToString()); // TODO(kojii): This is still incorrect. - EXPECT_EQ(LayoutRect(0, 0, 60, 10), outer_text.VisualRect()); + EXPECT_EQ(IntRect(0, 0, 60, 10), outer_text.VisualRect()); // Test |InlineFragmentsFor| can find the outer text. LayoutObject* layout_outer_text = @@ -233,7 +233,7 @@ EXPECT_EQ(NGPhysicalFragment::kFragmentBox, box1.PhysicalFragment().Type()); EXPECT_EQ(NGPhysicalFragment::kAtomicInline, box1.PhysicalFragment().BoxType()); - EXPECT_EQ(LayoutRect(60, 0, 10, 10), box1.VisualRect()); + EXPECT_EQ(IntRect(60, 0, 10, 10), box1.VisualRect()); // Test |InlineFragmentsFor| can find "box1". LayoutObject* layout_box1 = GetLayoutObjectByElementId("box1"); @@ -253,7 +253,7 @@ const NGPaintFragment& inner_text = *inner_line_box.FirstChild(); EXPECT_EQ(NGPhysicalFragment::kFragmentText, inner_text.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(60, 0, 10, 10), inner_text.VisualRect()); + EXPECT_EQ(IntRect(60, 0, 10, 10), inner_text.VisualRect()); // Test |InlineFragmentsFor| can find the inner text of "box1". LayoutObject* layout_inner_text = layout_box1->SlowFirstChild(); @@ -268,14 +268,14 @@ EXPECT_EQ(NGPhysicalFragment::kFragmentBox, box2.PhysicalFragment().Type()); EXPECT_EQ(NGPhysicalFragment::kAtomicInline, box2.PhysicalFragment().BoxType()); - EXPECT_EQ(LayoutRect(70, 10, 10, 10), box2.VisualRect()); + EXPECT_EQ(IntRect(70, 10, 10, 10), box2.VisualRect()); GetDocument().GetFrame()->Selection().SelectAll(); UpdateAllLifecyclePhasesForTest(); - EXPECT_EQ(LayoutRect(0, 0, 60, 10), outer_text.VisualRect()); - EXPECT_EQ(LayoutRect(60, 0, 10, 10), box1.VisualRect()); - EXPECT_EQ(LayoutRect(60, 0, 10, 10), inner_text.VisualRect()); - EXPECT_EQ(LayoutRect(70, 10, 10, 10), box2.VisualRect()); + EXPECT_EQ(IntRect(0, 0, 60, 10), outer_text.VisualRect()); + EXPECT_EQ(IntRect(60, 0, 10, 10), box1.VisualRect()); + EXPECT_EQ(IntRect(60, 0, 10, 10), inner_text.VisualRect()); + EXPECT_EQ(IntRect(70, 10, 10, 10), box2.VisualRect()); } TEST_F(NGPaintFragmentTest, RelativeBlock) { @@ -299,19 +299,19 @@ const NGPaintFragment& outer_text = *line1.FirstChild(); EXPECT_EQ(NGPhysicalFragment::kFragmentText, outer_text.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 10, 60, 10), outer_text.VisualRect()); + EXPECT_EQ(IntRect(0, 10, 60, 10), outer_text.VisualRect()); const NGPaintFragment& inner_text1 = *ToList(line1.Children())[1]; EXPECT_EQ(NGPhysicalFragment::kFragmentText, inner_text1.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 10, 90, 20), inner_text1.VisualRect()); + EXPECT_EQ(IntRect(0, 10, 90, 20), inner_text1.VisualRect()); const NGPaintFragment& line2 = *ToList(container->Children())[1]; EXPECT_EQ(1u, line2.Children().size()); const NGPaintFragment& inner_text2 = *line2.FirstChild(); EXPECT_EQ(NGPhysicalFragment::kFragmentText, inner_text2.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 10, 90, 20), inner_text2.VisualRect()); + EXPECT_EQ(IntRect(0, 10, 90, 20), inner_text2.VisualRect()); } TEST_F(NGPaintFragmentTest, RelativeInline) { @@ -337,30 +337,30 @@ const NGPaintFragment& outer_text = *line1_children[0]; EXPECT_EQ(NGPhysicalFragment::kFragmentText, outer_text.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 0, 60, 10), outer_text.VisualRect()); + EXPECT_EQ(IntRect(0, 0, 60, 10), outer_text.VisualRect()); const NGPaintFragment& inline_box1 = *line1_children[1]; EXPECT_EQ(NGPhysicalFragment::kFragmentBox, inline_box1.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 10, 90, 20), inline_box1.VisualRect()); + EXPECT_EQ(IntRect(0, 10, 90, 20), inline_box1.VisualRect()); EXPECT_EQ(1u, inline_box1.Children().size()); const NGPaintFragment& inner_text1 = *inline_box1.FirstChild(); EXPECT_EQ(NGPhysicalFragment::kFragmentText, inner_text1.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 10, 90, 20), inner_text1.VisualRect()); + EXPECT_EQ(IntRect(0, 10, 90, 20), inner_text1.VisualRect()); const NGPaintFragment& line2 = *lines[1]; EXPECT_EQ(1u, line2.Children().size()); const NGPaintFragment& inline_box2 = *line2.FirstChild(); EXPECT_EQ(NGPhysicalFragment::kFragmentBox, inline_box2.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 10, 90, 20), inline_box2.VisualRect()); + EXPECT_EQ(IntRect(0, 10, 90, 20), inline_box2.VisualRect()); const NGPaintFragment& inner_text2 = *inline_box2.FirstChild(); EXPECT_EQ(NGPhysicalFragment::kFragmentText, inner_text2.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 10, 90, 20), inner_text2.VisualRect()); + EXPECT_EQ(IntRect(0, 10, 90, 20), inner_text2.VisualRect()); } TEST_F(NGPaintFragmentTest, RelativeBlockAndInline) { @@ -386,30 +386,30 @@ const NGPaintFragment& outer_text = *line1_children[0]; EXPECT_EQ(NGPhysicalFragment::kFragmentText, outer_text.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 10, 60, 10), outer_text.VisualRect()); + EXPECT_EQ(IntRect(0, 10, 60, 10), outer_text.VisualRect()); const NGPaintFragment& inline_box1 = *line1_children[1]; EXPECT_EQ(NGPhysicalFragment::kFragmentBox, inline_box1.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 20, 90, 20), inline_box1.VisualRect()); + EXPECT_EQ(IntRect(0, 20, 90, 20), inline_box1.VisualRect()); EXPECT_EQ(1u, inline_box1.Children().size()); const NGPaintFragment& inner_text1 = *inline_box1.FirstChild(); EXPECT_EQ(NGPhysicalFragment::kFragmentText, inner_text1.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 20, 90, 20), inner_text1.VisualRect()); + EXPECT_EQ(IntRect(0, 20, 90, 20), inner_text1.VisualRect()); const NGPaintFragment& line2 = *lines[1]; EXPECT_EQ(1u, line2.Children().size()); const NGPaintFragment& inline_box2 = *line2.FirstChild(); EXPECT_EQ(NGPhysicalFragment::kFragmentBox, inline_box2.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 20, 90, 20), inline_box2.VisualRect()); + EXPECT_EQ(IntRect(0, 20, 90, 20), inline_box2.VisualRect()); const NGPaintFragment& inner_text2 = *inline_box2.FirstChild(); EXPECT_EQ(NGPhysicalFragment::kFragmentText, inner_text2.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 20, 90, 20), inner_text2.VisualRect()); + EXPECT_EQ(IntRect(0, 20, 90, 20), inner_text2.VisualRect()); } TEST_F(NGPaintFragmentTest, FlippedBlock) { @@ -437,32 +437,32 @@ const NGPaintFragment& line1 = *lines[0]; EXPECT_EQ(NGPhysicalFragment::kFragmentLineBox, line1.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 0, 200, 100), line1.VisualRect()); + EXPECT_EQ(IntRect(0, 0, 200, 100), line1.VisualRect()); EXPECT_EQ(1u, line1.Children().size()); const NGPaintFragment& text1 = *line1.FirstChild(); EXPECT_EQ(NGPhysicalFragment::kFragmentText, text1.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(180, 0, 20, 100), text1.VisualRect()); + EXPECT_EQ(IntRect(180, 0, 20, 100), text1.VisualRect()); const NGPaintFragment& line2 = *lines[1]; EXPECT_EQ(NGPhysicalFragment::kFragmentLineBox, line2.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(0, 0, 200, 100), line2.VisualRect()); + EXPECT_EQ(IntRect(0, 0, 200, 100), line2.VisualRect()); EXPECT_EQ(2u, line2.Children().size()); auto line2_children = ToList(line2.Children()); const NGPaintFragment& text2 = *line2_children[0]; EXPECT_EQ(NGPhysicalFragment::kFragmentText, text2.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(180, 0, 20, 100), text2.VisualRect()); + EXPECT_EQ(IntRect(180, 0, 20, 100), text2.VisualRect()); const NGPaintFragment& box = *line2_children[1]; EXPECT_EQ(NGPhysicalFragment::kFragmentBox, box.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(180, 40, 10, 30), box.VisualRect()); + EXPECT_EQ(IntRect(180, 40, 10, 30), box.VisualRect()); EXPECT_EQ(1u, box.Children().size()); const NGPaintFragment& text3 = *box.FirstChild(); EXPECT_EQ(NGPhysicalFragment::kFragmentText, text3.PhysicalFragment().Type()); - EXPECT_EQ(LayoutRect(180, 40, 10, 30), text3.VisualRect()); + EXPECT_EQ(IntRect(180, 40, 10, 30), text3.VisualRect()); } TEST_F(NGPaintFragmentTest, MarkLineBoxesDirtyByRemoveBr) {
diff --git a/third_party/blink/renderer/core/paint/object_paint_invalidator.cc b/third_party/blink/renderer/core/paint/object_paint_invalidator.cc index 8507dfa..d8b78e7b 100644 --- a/third_party/blink/renderer/core/paint/object_paint_invalidator.cc +++ b/third_party/blink/renderer/core/paint/object_paint_invalidator.cc
@@ -297,15 +297,15 @@ if (!full_invalidation && !object_.ShouldInvalidateSelection()) return reason; - LayoutRect old_selection_rect = object_.SelectionVisualRect(); - LayoutRect new_selection_rect; + IntRect old_selection_rect = object_.SelectionVisualRect(); + IntRect new_selection_rect; #if DCHECK_IS_ON() FindVisualRectNeedingUpdateScope finder(object_, context_, old_selection_rect, new_selection_rect); #endif if (context_.NeedsVisualRectUpdate(object_)) { - new_selection_rect = object_.LocalSelectionRect(); - context_.MapLocalRectToVisualRect(object_, new_selection_rect); + new_selection_rect = context_.MapLocalRectToVisualRect( + object_, object_.LocalSelectionRect()); } else { new_selection_rect = old_selection_rect; } @@ -318,8 +318,7 @@ // See layout_selection.cc SetShouldInvalidateIfNeeded for more detail. if (object_.IsSVGText()) return PaintInvalidationReason::kSelection; - const LayoutRect invalidation_rect = - UnionRect(new_selection_rect, old_selection_rect); + auto invalidation_rect = UnionRect(new_selection_rect, old_selection_rect); if (invalidation_rect.IsEmpty()) return reason; @@ -335,16 +334,16 @@ if (IsFullPaintInvalidationReason(reason)) return reason; - auto rect = object_.PartialInvalidationLocalRect(); - if (rect.IsEmpty()) + auto local_rect = object_.PartialInvalidationLocalRect(); + if (local_rect.IsEmpty()) return reason; - context_.MapLocalRectToVisualRect(object_, rect); - if (rect.IsEmpty()) + auto visual_rect = context_.MapLocalRectToVisualRect(object_, local_rect); + if (visual_rect.IsEmpty()) return reason; object_.GetMutableForPainting().SetPartialInvalidationVisualRect( - UnionRect(object_.PartialInvalidationVisualRect(), rect)); + UnionRect(object_.PartialInvalidationVisualRect(), visual_rect)); return PaintInvalidationReason::kRectangle; }
diff --git a/third_party/blink/renderer/core/paint/object_paint_invalidator_test.cc b/third_party/blink/renderer/core/paint/object_paint_invalidator_test.cc index c6b6732..b2f6b11e 100644 --- a/third_party/blink/renderer/core/paint/object_paint_invalidator_test.cc +++ b/third_party/blink/renderer/core/paint/object_paint_invalidator_test.cc
@@ -288,19 +288,17 @@ GetDocument().View()->UpdateAllLifecyclePhasesExceptPaint(); EXPECT_EQ(LayoutRect(), target->PartialInvalidationLocalRect()); - EXPECT_EQ(LayoutRect(18, 18, 80, 80), - target->PartialInvalidationVisualRect()); + EXPECT_EQ(IntRect(18, 18, 80, 80), target->PartialInvalidationVisualRect()); target->InvalidatePaintRectangle(LayoutRect(30, 30, 50, 80)); EXPECT_EQ(LayoutRect(30, 30, 50, 80), target->PartialInvalidationLocalRect()); GetDocument().View()->UpdateAllLifecyclePhasesExceptPaint(); // PartialInvalidationVisualRect should accumulate until painting. - EXPECT_EQ(LayoutRect(18, 18, 80, 100), - target->PartialInvalidationVisualRect()); + EXPECT_EQ(IntRect(18, 18, 80, 100), target->PartialInvalidationVisualRect()); UpdateAllLifecyclePhasesForTest(); EXPECT_EQ(LayoutRect(), target->PartialInvalidationLocalRect()); - EXPECT_EQ(LayoutRect(), target->PartialInvalidationVisualRect()); + EXPECT_EQ(IntRect(), target->PartialInvalidationVisualRect()); EXPECT_THAT( *GetDocument().View()->TrackedObjectPaintInvalidations(), @@ -326,7 +324,7 @@ EnableCompositing(); SetBodyInnerHTML("<img id='target' style='width: 100px; height: 100px'>"); auto* target = GetLayoutObjectByElementId("target"); - EXPECT_EQ(LayoutRect(), target->SelectionVisualRect()); + EXPECT_EQ(IntRect(), target->SelectionVisualRect()); // Add selection. GetDocument().View()->SetTracksPaintInvalidations(true); @@ -338,7 +336,7 @@ ASSERT_EQ(1u, invalidations->size()); EXPECT_EQ(IntRect(8, 8, 100, 100), (*invalidations)[0].rect); EXPECT_EQ(PaintInvalidationReason::kSelection, (*invalidations)[0].reason); - EXPECT_EQ(LayoutRect(8, 8, 100, 100), target->SelectionVisualRect()); + EXPECT_EQ(IntRect(8, 8, 100, 100), target->SelectionVisualRect()); GetDocument().View()->SetTracksPaintInvalidations(false); // Simulate a change without full invalidation or selection change. @@ -348,7 +346,7 @@ EXPECT_TRUE(graphics_layer->GetRasterInvalidationTracking() ->Invalidations() .IsEmpty()); - EXPECT_EQ(LayoutRect(8, 8, 100, 100), target->SelectionVisualRect()); + EXPECT_EQ(IntRect(8, 8, 100, 100), target->SelectionVisualRect()); GetDocument().View()->SetTracksPaintInvalidations(false); // Remove selection. @@ -360,7 +358,7 @@ ASSERT_EQ(1u, invalidations->size()); EXPECT_EQ(IntRect(8, 8, 100, 100), (*invalidations)[0].rect); EXPECT_EQ(PaintInvalidationReason::kSelection, (*invalidations)[0].reason); - EXPECT_EQ(LayoutRect(), target->SelectionVisualRect()); + EXPECT_EQ(IntRect(), target->SelectionVisualRect()); GetDocument().View()->SetTracksPaintInvalidations(false); }
diff --git a/third_party/blink/renderer/core/paint/paint_and_raster_invalidation_test.cc b/third_party/blink/renderer/core/paint/paint_and_raster_invalidation_test.cc index d477519..271ddf7 100644 --- a/third_party/blink/renderer/core/paint/paint_and_raster_invalidation_test.cc +++ b/third_party/blink/renderer/core/paint/paint_and_raster_invalidation_test.cc
@@ -240,13 +240,13 @@ SetUpHTML(*this); Element* target = GetDocument().getElementById("target"); LayoutObject* object = target->GetLayoutObject(); - EXPECT_EQ(LayoutRect(0, 0, 50, 100), object->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(0, 0, 50, 100), object->FirstFragment().VisualRect()); GetDocument().View()->SetTracksPaintInvalidations(true); target->setAttribute(html_names::kStyleAttr, "margin-top: 0.6px; width: 50px; height: 99.3px"); UpdateAllLifecyclePhasesForTest(); - EXPECT_EQ(LayoutRect(0, 0, 50, 100), object->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(0, 0, 50, 100), object->FirstFragment().VisualRect()); EXPECT_THAT(GetRasterInvalidationTracking()->Invalidations(), UnorderedElementsAre(RasterInvalidationInfo{ object, object->DebugName(), IntRect(0, 0, 50, 100), @@ -257,7 +257,7 @@ target->setAttribute(html_names::kStyleAttr, "margin-top: 0.6px; width: 49.3px; height: 98.5px"); UpdateAllLifecyclePhasesForTest(); - EXPECT_EQ(LayoutRect(0, 0, 50, 100), object->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(0, 0, 50, 100), object->FirstFragment().VisualRect()); EXPECT_THAT(GetRasterInvalidationTracking()->Invalidations(), UnorderedElementsAre(RasterInvalidationInfo{ object, object->DebugName(), IntRect(0, 0, 50, 100), @@ -783,14 +783,14 @@ LayoutView* child_layout_view = ChildDocument().GetLayoutView(); EXPECT_EQ(GetDocument().GetLayoutView(), &child_layout_view->ContainerForPaintInvalidation()); - EXPECT_EQ(LayoutRect(0, 0, 100, 100), + EXPECT_EQ(IntRect(0, 0, 100, 100), child_layout_view->FirstFragment().VisualRect()); iframe->setAttribute(html_names::kStyleAttr, "border: 20px solid blue"); UpdateAllLifecyclePhasesForTest(); EXPECT_EQ(GetDocument().GetLayoutView(), &child_layout_view->ContainerForPaintInvalidation()); - EXPECT_EQ(LayoutRect(0, 0, 100, 100), + EXPECT_EQ(IntRect(0, 0, 100, 100), child_layout_view->FirstFragment().VisualRect()); } @@ -860,19 +860,19 @@ // mask_rect's visual rect is in coordinates of the mask. auto* mask_rect = GetLayoutObjectByElementId("mask-rect"); - EXPECT_EQ(LayoutRect(), mask_rect->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(), mask_rect->FirstFragment().VisualRect()); // real_rect's visual rect is in coordinates of its paint invalidation // container (the view). auto* real_rect = GetLayoutObjectByElementId("real-rect"); - EXPECT_EQ(LayoutRect(55, 66, 7, 8), real_rect->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(55, 66, 7, 8), real_rect->FirstFragment().VisualRect()); GetDocument().View()->SetTracksPaintInvalidations(true); ToElement(mask_rect->GetNode())->setAttribute("x", "20"); UpdateAllLifecyclePhasesForTest(); - EXPECT_EQ(LayoutRect(), mask_rect->FirstFragment().VisualRect()); - EXPECT_EQ(LayoutRect(55, 66, 7, 8), real_rect->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(), mask_rect->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(55, 66, 7, 8), real_rect->FirstFragment().VisualRect()); // Should invalidate raster for real_rect only. if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) { @@ -914,11 +914,11 @@ )HTML"); auto* a = GetDocument().getElementById("a")->GetLayoutObject(); - EXPECT_EQ(LayoutRect(0, 0, 150, 20), a->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(0, 0, 150, 20), a->FirstFragment().VisualRect()); auto* b = GetDocument().getElementById("b")->GetLayoutObject(); - EXPECT_EQ(LayoutRect(150, 0, 150, 20), b->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(150, 0, 150, 20), b->FirstFragment().VisualRect()); auto* c = GetDocument().getElementById("c")->GetLayoutObject(); - EXPECT_EQ(LayoutRect(300, 0, 150, 20), c->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(300, 0, 150, 20), c->FirstFragment().VisualRect()); // Print the page with a width of 400px which will require wrapping 'c'. FloatSize page_size(400, 200); @@ -929,10 +929,10 @@ b = GetDocument().getElementById("b")->GetLayoutObject(); c = GetDocument().getElementById("c")->GetLayoutObject(); - EXPECT_EQ(LayoutRect(0, 0, 150, 20), a->FirstFragment().VisualRect()); - EXPECT_EQ(LayoutRect(150, 0, 150, 20), b->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(0, 0, 150, 20), a->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(150, 0, 150, 20), b->FirstFragment().VisualRect()); // 'c' should be on the next line. - EXPECT_EQ(LayoutRect(0, 20, 150, 20), c->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(0, 20, 150, 20), c->FirstFragment().VisualRect()); GetFrame().EndPrinting(); GetDocument().View()->UpdateLifecyclePhasesForPrinting(); @@ -940,9 +940,9 @@ b = GetDocument().getElementById("b")->GetLayoutObject(); c = GetDocument().getElementById("c")->GetLayoutObject(); - EXPECT_EQ(LayoutRect(0, 0, 150, 20), a->FirstFragment().VisualRect()); - EXPECT_EQ(LayoutRect(150, 0, 150, 20), b->FirstFragment().VisualRect()); - EXPECT_EQ(LayoutRect(300, 0, 150, 20), c->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(0, 0, 150, 20), a->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(150, 0, 150, 20), b->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(300, 0, 150, 20), c->FirstFragment().VisualRect()); } TEST_P(PaintAndRasterInvalidationTest, PaintPropertyChange) {
diff --git a/third_party/blink/renderer/core/paint/paint_invalidator.cc b/third_party/blink/renderer/core/paint/paint_invalidator.cc index 59cc574..3941e3d 100644 --- a/third_party/blink/renderer/core/paint/paint_invalidator.cc +++ b/third_party/blink/renderer/core/paint/paint_invalidator.cc
@@ -30,29 +30,27 @@ // layer raster invalidations during animation with subpixels. // See crbug.com/833083 for details. template <typename Rect, typename Point> -void PaintInvalidator::ExcludeCompositedLayerSubpixelAccumulation( +void PaintInvalidatorContext::ExcludeCompositedLayerSubpixelAccumulation( const LayoutObject& object, - const PaintInvalidatorContext& context, - Rect& rect) { + Rect& rect) const { // TODO(wangxianzhu): How to handle sub-pixel location animation for CAP? if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) return; // One of the following conditions happened in crbug.com/837226. - if (!context.paint_invalidation_container || - !context.paint_invalidation_container->FirstFragment() + if (!paint_invalidation_container || + !paint_invalidation_container->FirstFragment() .HasLocalBorderBoxProperties() || - !context.tree_builder_context_) + !tree_builder_context_) return; - if (!(context.paint_invalidation_container->Layer()->GetCompositingReasons() & + if (!(paint_invalidation_container->Layer()->GetCompositingReasons() & CompositingReason::kComboAllDirectReasons)) return; - if (object != context.paint_invalidation_container && - &context.paint_invalidation_container->FirstFragment() - .PostScrollTranslation() != - context.tree_builder_context_->current.transform) { + if (object != paint_invalidation_container && + &paint_invalidation_container->FirstFragment().PostScrollTranslation() != + tree_builder_context_->current.transform) { // Subpixel accumulation doesn't propagate through non-translation // transforms. Also skip all transforms, to avoid the runtime cost of // verifying whether the transform is a translation. @@ -66,72 +64,72 @@ // make sure the code is synced. // TODO(wangxianzhu): Avoid exposing subpixel accumulation to platform code. rect.MoveBy(Point(LayoutPoint( - -context.paint_invalidation_container->Layer()->SubpixelAccumulation()))); + -paint_invalidation_container->Layer()->SubpixelAccumulation()))); } -// This function is templatized to avoid FloatRect<->LayoutRect conversions -// which affect performance. -template <typename Rect, typename Point> -LayoutRect PaintInvalidator::MapLocalRectToVisualRect( +IntRect PaintInvalidatorContext::MapLocalRectToVisualRect( const LayoutObject& object, - const Rect& local_rect, - const PaintInvalidatorContext& context, - bool disable_flip) { - DCHECK(context.NeedsVisualRectUpdate(object)); + const LayoutRect& local_rect) const { + DCHECK(NeedsVisualRectUpdate(object)); + if (local_rect.IsEmpty()) - return LayoutRect(); + return IntRect(); - bool is_svg_child = object.IsSVGChild(); + DCHECK(!object.IsSVGChild() || + // This function applies to LayoutSVGText (for caret) and + // LayoutSVGInlineText (for selection). + object.IsSVGText() || object.IsSVGInlineText()); - // TODO(wkorman): The flip below is required because local visual rects are - // currently in "physical coordinates with flipped block-flow direction" - // (see LayoutBoxModelObject.h) but we need them to be in physical - // coordinates. - Rect rect = local_rect; - // Writing-mode flipping doesn't apply to non-root SVG. - if (!is_svg_child) { - if (!disable_flip) { - if (object.IsBox()) { - ToLayoutBox(object).FlipForWritingMode(rect); - } else { - // Also convert the rect for non-boxes into physical coordinates before - // applying paint offset. - // TODO(wangxianzhu): Avoid ContainingBlock(). - object.ContainingBlock()->FlipForWritingMode(rect); - } - } - - // Unite visual rect with clip path bounding rect. - // It is because the clip path display items are owned by the layout object - // who has the clip path, and uses its visual rect as bounding rect too. - // Usually it is done at layout object level and included as a part of - // local visual overflow, but clip-path can be a reference to SVG, and we - // have to wait until pre-paint to ensure clean layout. - // Note: SVG children don't need this adjustment because their visual - // overflow rects are already adjusted by clip path. - if (base::Optional<FloatRect> clip_path_bounding_box = - ClipPathClipper::LocalClipPathBoundingBox(object)) { - Rect box(EnclosingIntRect(*clip_path_bounding_box)); - rect.Unite(box); - } + // The flip below is required because local visual rects are currently in + // "physical coordinates with flipped block-flow direction" (see + // LayoutBoxModelObject.h) but we need them to be in physical coordinates. + auto rect = local_rect; + if (object.IsBox()) { + ToLayoutBox(object).FlipForWritingMode(rect); + } else { + // Also convert the rect for non-boxes into physical coordinates before + // applying paint offset. + // TODO(wangxianzhu): Avoid ContainingBlock(). + object.ContainingBlock()->FlipForWritingMode(rect); } + // Unite visual rect with clip path bounding rect. + // It is because the clip path display items are owned by the layout object + // who has the clip path, and uses its visual rect as bounding rect too. + // Usually it is done at layout object level and included as a part of + // local visual overflow, but clip-path can be a reference to SVG, and we + // have to wait until pre-paint to ensure clean layout. + if (base::Optional<FloatRect> clip_path_bounding_box = + ClipPathClipper::LocalClipPathBoundingBox(object)) + rect.Unite(LayoutRect(EnclosingIntRect(*clip_path_bounding_box))); + + rect.MoveBy(fragment_data->PaintOffset()); + ExcludeCompositedLayerSubpixelAccumulation<LayoutRect, LayoutPoint>(object, + rect); + // Use EnclosingIntRect to ensure the final visual rect will cover the rect + // in source coordinates no matter if the painting will snap to pixels. + return EnclosingIntRect(rect); +} + +IntRect PaintInvalidatorContext::MapLocalRectToVisualRectForSVGChild( + const LayoutObject& object, + const FloatRect& local_rect) const { + DCHECK(object.IsSVGChild()); + DCHECK(NeedsVisualRectUpdate(object)); + + if (local_rect.IsEmpty()) + return IntRect(); + // Visual rects are in the space of their local transform node. For SVG, the // input rect is in local SVG coordinates in which paint offset doesn't apply. - if (!is_svg_child) - rect.MoveBy(Point(context.fragment_data->PaintOffset())); - ExcludeCompositedLayerSubpixelAccumulation<Rect, Point>(object, context, - rect); + // We also don't need to adjust for clip path here because SVG the local + // visual rect has already been adjusted by clip path. + auto rect = local_rect; + ExcludeCompositedLayerSubpixelAccumulation<FloatRect, FloatPoint>(object, + rect); // Use EnclosingIntRect to ensure the final visual rect will cover the rect // in source coordinates no matter if the painting will snap to pixels. - return LayoutRect(EnclosingIntRect(rect)); -} - -void PaintInvalidatorContext::MapLocalRectToVisualRect( - const LayoutObject& object, - LayoutRect& rect) const { - rect = PaintInvalidator::MapLocalRectToVisualRect<LayoutRect, LayoutPoint>( - object, rect, *this); + return EnclosingIntRect(rect); } const PaintInvalidatorContext* @@ -141,17 +139,15 @@ : nullptr; } -LayoutRect PaintInvalidator::ComputeVisualRect( +IntRect PaintInvalidator::ComputeVisualRect( const LayoutObject& object, const PaintInvalidatorContext& context) { if (object.IsSVGChild()) { - FloatRect local_rect = SVGLayoutSupport::LocalVisualRect(object); - return MapLocalRectToVisualRect<FloatRect, FloatPoint>(object, local_rect, - context); + return context.MapLocalRectToVisualRectForSVGChild( + object, SVGLayoutSupport::LocalVisualRect(object)); } - LayoutRect local_rect = object.LocalVisualRect(); - return MapLocalRectToVisualRect<LayoutRect, LayoutPoint>(object, local_rect, - context); + + return context.MapLocalRectToVisualRect(object, object.LocalVisualRect()); } void PaintInvalidator::UpdatePaintingLayer(const LayoutObject& object, @@ -285,11 +281,7 @@ DCHECK(context.tree_builder_context_->current.paint_offset == fragment_data.PaintOffset()); - LayoutRect new_visual_rect = ComputeVisualRect(object, context); - // Make the empty visual rect more meaningful for debugging and testing. - if (new_visual_rect.IsEmpty()) - new_visual_rect.SetLocation(fragment_data.PaintOffset()); - fragment_data.SetVisualRect(new_visual_rect); + fragment_data.SetVisualRect(ComputeVisualRect(object, context)); } void PaintInvalidator::UpdateEmptyVisualRectFlag(
diff --git a/third_party/blink/renderer/core/paint/paint_invalidator.h b/third_party/blink/renderer/core/paint/paint_invalidator.h index cd5a9fd..a07089d6 100644 --- a/third_party/blink/renderer/core/paint/paint_invalidator.h +++ b/third_party/blink/renderer/core/paint/paint_invalidator.h
@@ -44,7 +44,17 @@ ParentContext()->paint_invalidation_container_for_stacked_contents), painting_layer(ParentContext()->painting_layer) {} - void MapLocalRectToVisualRect(const LayoutObject&, LayoutRect&) const; + // Maps a rect in the object's local coordinates in flipped blocks direction + // to a visual rect in the local transform space. This is for non-SVG-child, + // LayoutSVGText (when mapping caret rect) and LayoutSVGInlineText (when + // mapping selection rect). + IntRect MapLocalRectToVisualRect(const LayoutObject&, + const LayoutRect&) const; + + // Maps a rect in the SVG child object's local coordinates to a visual rect + // in the local transform space. + IntRect MapLocalRectToVisualRectForSVGChild(const LayoutObject&, + const FloatRect&) const; bool NeedsVisualRectUpdate(const LayoutObject& object) const { #if DCHECK_IS_ON() @@ -115,7 +125,7 @@ PaintLayer* painting_layer = nullptr; // The previous VisualRect and PaintOffset of FragmentData. - LayoutRect old_visual_rect; + IntRect old_visual_rect; LayoutPoint old_paint_offset; const FragmentData* fragment_data; @@ -123,6 +133,10 @@ private: friend class PaintInvalidator; + template <typename Rect, typename Point> + void ExcludeCompositedLayerSubpixelAccumulation(const LayoutObject&, + Rect&) const; + const PaintPropertyTreeBuilderFragmentContext* tree_builder_context_ = nullptr; @@ -150,19 +164,8 @@ friend struct PaintInvalidatorContext; friend class PrePaintTreeWalk; - template <typename Rect, typename Point> - static void ExcludeCompositedLayerSubpixelAccumulation( - const LayoutObject&, - const PaintInvalidatorContext&, - Rect&); - template <typename Rect, typename Point> - static LayoutRect MapLocalRectToVisualRect(const LayoutObject&, - const Rect&, - const PaintInvalidatorContext&, - bool disable_flip = false); - - ALWAYS_INLINE LayoutRect ComputeVisualRect(const LayoutObject&, - const PaintInvalidatorContext&); + ALWAYS_INLINE IntRect ComputeVisualRect(const LayoutObject&, + const PaintInvalidatorContext&); ALWAYS_INLINE void UpdatePaintingLayer(const LayoutObject&, PaintInvalidatorContext&); ALWAYS_INLINE void UpdatePaintInvalidationContainer(const LayoutObject&,
diff --git a/third_party/blink/renderer/core/paint/paint_layer.cc b/third_party/blink/renderer/core/paint/paint_layer.cc index 1fd5e018..e48929e 100644 --- a/third_party/blink/renderer/core/paint/paint_layer.cc +++ b/third_party/blink/renderer/core/paint/paint_layer.cc
@@ -235,7 +235,7 @@ return static_cast<const DisplayItemClient&>(GetLayoutObject()).OwnerNodeId(); } -LayoutRect PaintLayer::VisualRect() const { +IntRect PaintLayer::VisualRect() const { return layout_object_.FragmentsVisualRectBoundingBox(); } @@ -1107,7 +1107,12 @@ last_ancestor = current; current->child_needs_compositing_inputs_update_ = true; if (Compositor() && - current->GetLayoutObject().ShouldApplyStrictContainment()) + current->GetLayoutObject().ShouldApplyStrictContainment() && + // TODO(rego): Disable CompositingInputsRoot optimization if the + // "contain: strict" element has "position: sticky". This was causing + // crashes because PaintLayerScrollableArea::sticky_constraints_map_ was + // not updated correctly in some cases (see crbug.com/949887). + !current->GetLayoutObject().IsStickyPositioned()) break; }
diff --git a/third_party/blink/renderer/core/paint/paint_layer.h b/third_party/blink/renderer/core/paint/paint_layer.h index 5d5c736..ee1b855 100644 --- a/third_party/blink/renderer/core/paint/paint_layer.h +++ b/third_party/blink/renderer/core/paint/paint_layer.h
@@ -232,7 +232,7 @@ // DisplayItemClient methods String DebugName() const final; DOMNodeId OwnerNodeId() const final; - LayoutRect VisualRect() const final; + IntRect VisualRect() const final; LayoutBoxModelObject& GetLayoutObject() const { return layout_object_; } LayoutBox* GetLayoutBox() const {
diff --git a/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.cc b/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.cc index a27559b..67ef788 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.cc +++ b/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.cc
@@ -2642,12 +2642,11 @@ ScrollableArea::WillRemoveScrollbar(scrollbar, orientation); } -static LayoutRect ScrollControlVisualRect( - const IntRect& scroll_control_rect, - const LayoutBox& box, - const PaintInvalidatorContext& context, - const LayoutRect& previous_visual_rect) { - LayoutRect visual_rect(scroll_control_rect); +static IntRect ScrollControlVisualRect(const IntRect& scroll_control_rect, + const LayoutBox& box, + const PaintInvalidatorContext& context, + const IntRect& previous_visual_rect) { + IntRect visual_rect(scroll_control_rect); #if DCHECK_IS_ON() FindVisualRectNeedingUpdateScope finder(box, context, previous_visual_rect, visual_rect); @@ -2663,8 +2662,8 @@ // Returns true if the scroll control is invalidated. static bool InvalidatePaintOfScrollControlIfNeeded( - const LayoutRect& new_visual_rect, - const LayoutRect& previous_visual_rect, + const IntRect& new_visual_rect, + const IntRect& previous_visual_rect, bool needs_paint_invalidation, LayoutBox& box, const LayoutBoxModelObject& paint_invalidation_container) { @@ -2680,17 +2679,17 @@ return should_invalidate_new_rect; } -static LayoutRect InvalidatePaintOfScrollbarIfNeeded( +static IntRect InvalidatePaintOfScrollbarIfNeeded( Scrollbar* scrollbar, GraphicsLayer* graphics_layer, bool& previously_was_overlay, - const LayoutRect& previous_visual_rect, + const IntRect& previous_visual_rect, bool needs_paint_invalidation_arg, LayoutBox& box, const PaintInvalidatorContext& context) { bool is_overlay = scrollbar && scrollbar->IsOverlayScrollbar(); - LayoutRect new_visual_rect; + IntRect new_visual_rect; // Calculate visual rect of the scrollbar, except overlay composited // scrollbars because we invalidate the graphics layer only. if (scrollbar && !(graphics_layer && is_overlay)) { @@ -2721,10 +2720,10 @@ // the box must have changed size and have been invalidated. const LayoutBoxModelObject& paint_invalidation_container = *context.paint_invalidation_container; - LayoutSize new_scrollbar_used_space_in_box; + IntSize new_scrollbar_used_space_in_box; if (!is_overlay) new_scrollbar_used_space_in_box = new_visual_rect.Size(); - LayoutSize previous_scrollbar_used_space_in_box; + IntSize previous_scrollbar_used_space_in_box; if (!previously_was_overlay) previous_scrollbar_used_space_in_box = previous_visual_rect.Size(); @@ -2772,7 +2771,7 @@ vertical_scrollbar_visual_rect_, VerticalScrollbarNeedsPaintInvalidation(), box, context)); - LayoutRect scroll_corner_and_resizer_visual_rect = + IntRect scroll_corner_and_resizer_visual_rect = ScrollControlVisualRect(ScrollCornerAndResizerRect(), box, context, scroll_corner_and_resizer_visual_rect_); const LayoutBoxModelObject& paint_invalidation_container = @@ -2799,27 +2798,27 @@ } void PaintLayerScrollableArea::ClearPreviousVisualRects() { - SetHorizontalScrollbarVisualRect(LayoutRect()); - SetVerticalScrollbarVisualRect(LayoutRect()); - SetScrollCornerAndResizerVisualRect(LayoutRect()); + SetHorizontalScrollbarVisualRect(IntRect()); + SetVerticalScrollbarVisualRect(IntRect()); + SetScrollCornerAndResizerVisualRect(IntRect()); } void PaintLayerScrollableArea::SetHorizontalScrollbarVisualRect( - const LayoutRect& rect) { + const IntRect& rect) { horizontal_scrollbar_visual_rect_ = rect; if (Scrollbar* scrollbar = HorizontalScrollbar()) scrollbar->SetVisualRect(rect); } void PaintLayerScrollableArea::SetVerticalScrollbarVisualRect( - const LayoutRect& rect) { + const IntRect& rect) { vertical_scrollbar_visual_rect_ = rect; if (Scrollbar* scrollbar = VerticalScrollbar()) scrollbar->SetVisualRect(rect); } void PaintLayerScrollableArea::SetScrollCornerAndResizerVisualRect( - const LayoutRect& rect) { + const IntRect& rect) { scroll_corner_and_resizer_visual_rect_ = rect; if (LayoutScrollbarPart* scroll_corner = ScrollCorner()) scroll_corner->GetMutableForPainting().FirstFragment().SetVisualRect(rect); @@ -2870,7 +2869,7 @@ GetLayoutBox()->UniqueId(), CompositorElementIdNamespace::kScroll); } -LayoutRect +IntRect PaintLayerScrollableArea::ScrollingBackgroundDisplayItemClient::VisualRect() const { const auto* box = scrollable_area_->GetLayoutBox(); @@ -2880,7 +2879,7 @@ auto scroll_size = scrollable_area_->PixelSnappedContentsSize(paint_offset); // Ensure scrolling contents are at least as large as the scroll clip scroll_size = scroll_size.ExpandedTo(overflow_clip_rect.Size()); - LayoutRect result(overflow_clip_rect.Location(), scroll_size); + IntRect result(overflow_clip_rect.Location(), scroll_size); #if DCHECK_IS_ON() if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) { DCHECK_EQ(result,
diff --git a/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h b/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h index de833994..41b18f68 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h +++ b/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h
@@ -619,9 +619,9 @@ void ScrollControlWasSetNeedsPaintInvalidation() override; - void SetHorizontalScrollbarVisualRect(const LayoutRect&); - void SetVerticalScrollbarVisualRect(const LayoutRect&); - void SetScrollCornerAndResizerVisualRect(const LayoutRect&); + void SetHorizontalScrollbarVisualRect(const IntRect&); + void SetVerticalScrollbarVisualRect(const IntRect&); + void SetScrollCornerAndResizerVisualRect(const IntRect&); // PaintLayer is destructed before PaintLayerScrollable area, during this // time before PaintLayerScrollableArea has been collected layer_ will @@ -696,9 +696,9 @@ bool horizontal_scrollbar_previously_was_overlay_; bool vertical_scrollbar_previously_was_overlay_; - LayoutRect horizontal_scrollbar_visual_rect_; - LayoutRect vertical_scrollbar_visual_rect_; - LayoutRect scroll_corner_and_resizer_visual_rect_; + IntRect horizontal_scrollbar_visual_rect_; + IntRect vertical_scrollbar_visual_rect_; + IntRect scroll_corner_and_resizer_visual_rect_; class ScrollingBackgroundDisplayItemClient final : public DisplayItemClient { DISALLOW_NEW(); @@ -711,7 +711,7 @@ void Trace(Visitor* visitor) { visitor->Trace(scrollable_area_); } private: - LayoutRect VisualRect() const final; + IntRect VisualRect() const final; String DebugName() const final; DOMNodeId OwnerNodeId() const final; bool PaintedOutputOfObjectHasNoEffectRegardlessOfSize() const final;
diff --git a/third_party/blink/renderer/core/paint/paint_layer_scrollable_area_test.cc b/third_party/blink/renderer/core/paint/paint_layer_scrollable_area_test.cc index 67b7cca3..da1c8fc 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_scrollable_area_test.cc +++ b/third_party/blink/renderer/core/paint/paint_layer_scrollable_area_test.cc
@@ -1106,7 +1106,7 @@ </div> )HTML"); - EXPECT_EQ(LayoutRect(2, 3, 101, 200), + EXPECT_EQ(IntRect(2, 3, 101, 200), ToLayoutBox(GetLayoutObjectByElementId("scroller")) ->GetScrollableArea() ->GetScrollingBackgroundDisplayItemClient()
diff --git a/third_party/blink/renderer/core/paint/paint_layer_test.cc b/third_party/blink/renderer/core/paint/paint_layer_test.cc index 0557fbd..cc6242d 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_test.cc +++ b/third_party/blink/renderer/core/paint/paint_layer_test.cc
@@ -781,16 +781,16 @@ LayoutBox* scroller = ToLayoutBox(GetLayoutObjectByElementId("scroller")); LayoutObject* content_layer = GetLayoutObjectByElementId("content-layer"); LayoutObject* content = GetLayoutObjectByElementId("content"); - EXPECT_EQ(LayoutRect(0, 30, 50, 10), + EXPECT_EQ(IntRect(0, 30, 50, 10), content_layer->FirstFragment().VisualRect()); - EXPECT_EQ(LayoutRect(0, 30, 50, 5), content->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(0, 30, 50, 5), content->FirstFragment().VisualRect()); scroller->GetScrollableArea()->SetScrollOffset(ScrollOffset(0, 20), kProgrammaticScroll); UpdateAllLifecyclePhasesForTest(); - EXPECT_EQ(LayoutRect(0, 30, 50, 10), + EXPECT_EQ(IntRect(0, 30, 50, 10), content_layer->FirstFragment().VisualRect()); - EXPECT_EQ(LayoutRect(0, 30, 50, 5), content->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(0, 30, 50, 5), content->FirstFragment().VisualRect()); } TEST_P(PaintLayerTest, PaintInvalidationOnCompositedScroll) { @@ -810,16 +810,16 @@ LayoutBox* scroller = ToLayoutBox(GetLayoutObjectByElementId("scroller")); LayoutObject* content_layer = GetLayoutObjectByElementId("content-layer"); LayoutObject* content = GetLayoutObjectByElementId("content"); - EXPECT_EQ(LayoutRect(0, 30, 50, 10), + EXPECT_EQ(IntRect(0, 30, 50, 10), content_layer->FirstFragment().VisualRect()); - EXPECT_EQ(LayoutRect(0, 30, 50, 5), content->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(0, 30, 50, 5), content->FirstFragment().VisualRect()); scroller->GetScrollableArea()->SetScrollOffset(ScrollOffset(0, 20), kProgrammaticScroll); UpdateAllLifecyclePhasesForTest(); - EXPECT_EQ(LayoutRect(0, 30, 50, 10), + EXPECT_EQ(IntRect(0, 30, 50, 10), content_layer->FirstFragment().VisualRect()); - EXPECT_EQ(LayoutRect(0, 30, 50, 5), content->FirstFragment().VisualRect()); + EXPECT_EQ(IntRect(0, 30, 50, 5), content->FirstFragment().VisualRect()); } TEST_P(PaintLayerTest, CompositingContainerStackedFloatUnderStackingInline) {
diff --git a/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.cc b/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.cc index 70aa98f..eaca2eb4 100644 --- a/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.cc +++ b/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.cc
@@ -5508,8 +5508,8 @@ EXPECT_EQ(LayoutPoint(), first_fragment.PaintOffset()); EXPECT_EQ(LayoutPoint(390, -10), second_fragment->PaintOffset()); - EXPECT_EQ(LayoutRect(0, 0, 20, 20), first_fragment.VisualRect()); - EXPECT_EQ(LayoutRect(390, -10, 20, 20), second_fragment->VisualRect()); + EXPECT_EQ(IntRect(0, 0, 20, 20), first_fragment.VisualRect()); + EXPECT_EQ(IntRect(390, -10, 20, 20), second_fragment->VisualRect()); } TEST_P(PaintPropertyTreeBuilderTest, FragmentClipPixelSnapped) {
diff --git a/third_party/blink/renderer/core/paint/paint_timing_detector.cc b/third_party/blink/renderer/core/paint/paint_timing_detector.cc index 6f8ebb9..74865cb6 100644 --- a/third_party/blink/renderer/core/paint/paint_timing_detector.cc +++ b/third_party/blink/renderer/core/paint/paint_timing_detector.cc
@@ -135,7 +135,7 @@ } uint64_t PaintTimingDetector::CalculateVisualSize( - const LayoutRect& visual_rect, + const IntRect& visual_rect, const PropertyTreeState& current_paint_chunk_properties) const { // This case should be dealt with outside the function. DCHECK(!visual_rect.IsEmpty());
diff --git a/third_party/blink/renderer/core/paint/paint_timing_detector.h b/third_party/blink/renderer/core/paint/paint_timing_detector.h index d63348c3..e36eda8 100644 --- a/third_party/blink/renderer/core/paint/paint_timing_detector.h +++ b/third_party/blink/renderer/core/paint/paint_timing_detector.h
@@ -12,15 +12,14 @@ namespace blink { +class Image; +class ImagePaintTimingDetector; +class ImageResourceContent; class LayoutObject; class LocalFrameView; -class LayoutRect; -class TextPaintTimingDetector; -class ImagePaintTimingDetector; class PropertyTreeState; -class Image; class StyleImage; -class ImageResourceContent; +class TextPaintTimingDetector; // PaintTimingDetector contains some of paint metric detectors, // providing common infrastructure for these detectors. @@ -59,7 +58,7 @@ // |visual_rect| should be an object's bounding rect in the space of // PropertyTreeState. - uint64_t CalculateVisualSize(const LayoutRect& visual_rect, + uint64_t CalculateVisualSize(const IntRect& visual_rect, const PropertyTreeState&) const; void Dispose();
diff --git a/third_party/blink/renderer/core/paint/text_paint_timing_detector.cc b/third_party/blink/renderer/core/paint/text_paint_timing_detector.cc index 0ab200d..45d02cf 100644 --- a/third_party/blink/renderer/core/paint/text_paint_timing_detector.cc +++ b/third_party/blink/renderer/core/paint/text_paint_timing_detector.cc
@@ -155,7 +155,7 @@ uint64_t visual_size = 0; // Compared to object.FirstFragment().VisualRect(), this will include other // fragments of the object. - LayoutRect visual_rect = object.FragmentsVisualRectBoundingBox(); + IntRect visual_rect = object.FragmentsVisualRectBoundingBox(); if (!visual_rect.IsEmpty()) { visual_size = frame_view_->GetPaintTimingDetector().CalculateVisualSize( visual_rect, current_paint_chunk_properties);
diff --git a/third_party/blink/renderer/core/script/script_runner.cc b/third_party/blink/renderer/core/script/script_runner.cc index 9c50f4c..a82cb82 100644 --- a/third_party/blink/renderer/core/script/script_runner.cc +++ b/third_party/blink/renderer/core/script/script_runner.cc
@@ -238,7 +238,7 @@ void ScriptRunner::ExecuteTask() { // This method is triggered by ScriptRunner::PostTask, and runs directly from // the scheduler. So, the call stack is safe to reenter. - scheduler::CooperativeSchedulingManager::WhitelistedStackScope + scheduler::CooperativeSchedulingManager::AllowedStackScope whitelisted_stack_scope( scheduler::CooperativeSchedulingManager::Instance());
diff --git a/third_party/blink/renderer/core/scroll/scrollbar.h b/third_party/blink/renderer/core/scroll/scrollbar.h index 78766f6..a231d19 100644 --- a/third_party/blink/renderer/core/scroll/scrollbar.h +++ b/third_party/blink/renderer/core/scroll/scrollbar.h
@@ -170,9 +170,9 @@ return orientation_ == kHorizontalScrollbar ? "HorizontalScrollbar" : "VerticalScrollbar"; } - LayoutRect VisualRect() const final { return visual_rect_; } + IntRect VisualRect() const final { return visual_rect_; } - virtual void SetVisualRect(const LayoutRect& r) { visual_rect_ = r; } + virtual void SetVisualRect(const IntRect& r) { visual_rect_ = r; } // Marks the scrollbar as needing to be redrawn. // @@ -235,7 +235,7 @@ int theme_scrollbar_thickness_; bool track_needs_repaint_; bool thumb_needs_repaint_; - LayoutRect visual_rect_; + IntRect visual_rect_; IntRect frame_rect_; };
diff --git a/third_party/blink/renderer/devtools/front_end/network/NetworkConfigView.js b/third_party/blink/renderer/devtools/front_end/network/NetworkConfigView.js index 1a295227..e83f69d 100644 --- a/third_party/blink/renderer/devtools/front_end/network/NetworkConfigView.js +++ b/third_party/blink/renderer/devtools/front_end/network/NetworkConfigView.js
@@ -341,16 +341,17 @@ { title: 'UC Browser \u2014 Android Mobile', value: - 'Mozilla/5.0 (Linux; U; Android 4.4.4; en-US; XT1022 Build/KXC21.5-40) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 UCBrowser/10.7.0.636 U3/0.8.0 Mobile Safari/534.30' + 'Mozilla/5.0 (Linux; U; Android 8.1.0; en-US; Nexus 6P Build/OPM7.181205.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 UCBrowser/12.11.1.1197 Mobile Safari/537.36' }, { title: 'UC Browser \u2014 iOS', - value: 'UCWEB/2.0 (iPad; U; CPU OS 7_1 like Mac OS X; en; iPad3,6) U2/1.0.0 UCBrowser/9.3.1.344' + value: + 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X; zh-CN) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/16B92 UCBrowser/12.1.7.1109 Mobile AliApp(TUnionSDK/0.1.20.3)' }, { title: 'UC Browser \u2014 Windows Phone', value: - 'NokiaX2-02/2.0 (11.79) Profile/MIDP-2.1 Configuration/CLDC-1.1 Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2;.NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2) UCBrowser8.4.0.159/70/352' + 'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920) UCBrowser/10.1.0.563 Mobile' } ] }
diff --git a/third_party/blink/renderer/modules/webdatabase/sqlite/sqlite_statement.cc b/third_party/blink/renderer/modules/webdatabase/sqlite/sqlite_statement.cc index faf6cac..3e8725e 100644 --- a/third_party/blink/renderer/modules/webdatabase/sqlite/sqlite_statement.cc +++ b/third_party/blink/renderer/modules/webdatabase/sqlite/sqlite_statement.cc
@@ -101,21 +101,22 @@ SQL_DVLOG(1) << "SQL - prepare - " << query.data(); // Pass the length of the string including the null character to - // sqlite3_prepare_v2; this lets SQLite avoid an extra string copy. + // sqlite3_prepare_v3(); this lets SQLite avoid an extra string copy. wtf_size_t length_including_null_character = query.length() + 1; - error = sqlite3_prepare_v2(database_.Sqlite3Handle(), query.data(), - length_including_null_character, statement.get(), - tail.get()); + error = sqlite3_prepare_v3(database_.Sqlite3Handle(), query.data(), + length_including_null_character, + /* prepFlags= */ 0, statement.get(), tail.get()); } statement_ = *statement; - if (error != SQLITE_OK) - SQL_DVLOG(1) << "sqlite3_prepare16 failed (" << error << ")\n" + if (error != SQLITE_OK) { + SQL_DVLOG(1) << "sqlite3_prepare_v3 failed (" << error << ")\n" << query.data() << "\n" << sqlite3_errmsg(database_.Sqlite3Handle()); - else if (*tail && **tail) + } else if (*tail && **tail) { error = SQLITE_ERROR; + } #if DCHECK_IS_ON() is_prepared_ = error == SQLITE_OK;
diff --git a/third_party/blink/renderer/platform/graphics/compositing/chunk_to_layer_mapper.cc b/third_party/blink/renderer/platform/graphics/compositing/chunk_to_layer_mapper.cc index 1bc50ee9..9e4e385 100644 --- a/third_party/blink/renderer/platform/graphics/compositing/chunk_to_layer_mapper.cc +++ b/third_party/blink/renderer/platform/graphics/compositing/chunk_to_layer_mapper.cc
@@ -71,14 +71,14 @@ has_filter_that_moves_pixels_ = new_has_filter_that_moves_pixels; } -IntRect ChunkToLayerMapper::MapVisualRect(const FloatRect& rect) const { +IntRect ChunkToLayerMapper::MapVisualRect(const IntRect& rect) const { if (rect.IsEmpty()) return IntRect(); if (UNLIKELY(has_filter_that_moves_pixels_)) return MapUsingGeometryMapper(rect); - auto mapped_rect = rect; + FloatRect mapped_rect(rect); translation_2d_or_matrix_.MapRect(mapped_rect); if (!mapped_rect.IsEmpty() && !clip_rect_.IsInfinite()) mapped_rect.Intersect(clip_rect_.Rect()); @@ -104,9 +104,8 @@ // This is called when the fast path doesn't apply if there is any filter that // moves pixels. GeometryMapper::LocalToAncestorVisualRect() will apply the // visual effects of the filters, though slowly. -IntRect ChunkToLayerMapper::MapUsingGeometryMapper( - const FloatRect& rect) const { - FloatClipRect visual_rect(rect); +IntRect ChunkToLayerMapper::MapUsingGeometryMapper(const IntRect& rect) const { + FloatClipRect visual_rect((FloatRect(rect))); GeometryMapper::LocalToAncestorVisualRect(chunk_state_, layer_state_, visual_rect); if (visual_rect.Rect().IsEmpty())
diff --git a/third_party/blink/renderer/platform/graphics/compositing/chunk_to_layer_mapper.h b/third_party/blink/renderer/platform/graphics/compositing/chunk_to_layer_mapper.h index 892054a..b08f8b90 100644 --- a/third_party/blink/renderer/platform/graphics/compositing/chunk_to_layer_mapper.h +++ b/third_party/blink/renderer/platform/graphics/compositing/chunk_to_layer_mapper.h
@@ -31,7 +31,7 @@ void SwitchToChunk(const PaintChunk&); // Maps a visual rectangle in the current chunk space into the layer space. - IntRect MapVisualRect(const FloatRect&) const; + IntRect MapVisualRect(const IntRect&) const; // Returns the combined transform from the current chunk to the layer. SkMatrix Transform() const { return translation_2d_or_matrix_.ToSkMatrix(); } @@ -44,7 +44,7 @@ private: friend class ChunkToLayerMapperTest; - IntRect MapUsingGeometryMapper(const FloatRect&) const; + IntRect MapUsingGeometryMapper(const IntRect&) const; void AdjustVisualRectBySubpixelOffset(FloatRect&) const; const PropertyTreeState layer_state_;
diff --git a/third_party/blink/renderer/platform/graphics/compositing/chunk_to_layer_mapper_test.cc b/third_party/blink/renderer/platform/graphics/compositing/chunk_to_layer_mapper_test.cc index 82e395c..87142ac 100644 --- a/third_party/blink/renderer/platform/graphics/compositing/chunk_to_layer_mapper_test.cc +++ b/third_party/blink/renderer/platform/graphics/compositing/chunk_to_layer_mapper_test.cc
@@ -61,10 +61,8 @@ EXPECT_EQ(SkMatrix::MakeTrans(-10, -20), mapper.Transform()); EXPECT_EQ(FloatClipRect(), mapper.ClipRect()); EXPECT_EQ(IntRect(20, 10, 88, 99), - mapper.MapVisualRect(FloatRect(30, 30, 88, 99))); - EXPECT_EQ(IntRect(20, 10, 88, 99), - mapper.MapVisualRect(FloatRect(30.2f, 30.7f, 87.3f, 98.1f))); - EXPECT_EQ(IntRect(), mapper.MapVisualRect(FloatRect())); + mapper.MapVisualRect(IntRect(30, 30, 88, 99))); + EXPECT_EQ(IntRect(), mapper.MapVisualRect(IntRect())); } TEST_F(ChunkToLayerMapperTest, TwoChunkUsingLayerState) { @@ -77,20 +75,16 @@ EXPECT_EQ(SkMatrix::MakeTrans(-10, -20), mapper.Transform()); EXPECT_EQ(FloatClipRect(), mapper.ClipRect()); EXPECT_EQ(IntRect(20, 10, 88, 99), - mapper.MapVisualRect(FloatRect(30, 30, 88, 99))); - EXPECT_EQ(IntRect(20, 10, 88, 99), - mapper.MapVisualRect(FloatRect(30.2f, 30.7f, 87.3f, 98.1f))); - EXPECT_EQ(IntRect(), mapper.MapVisualRect(FloatRect())); + mapper.MapVisualRect(IntRect(30, 30, 88, 99))); + EXPECT_EQ(IntRect(), mapper.MapVisualRect(IntRect())); mapper.SwitchToChunk(chunk2); EXPECT_FALSE(HasFilterThatMovesPixels(mapper)); EXPECT_EQ(SkMatrix::MakeTrans(-10, -20), mapper.Transform()); EXPECT_EQ(FloatClipRect(), mapper.ClipRect()); EXPECT_EQ(IntRect(20, 10, 88, 99), - mapper.MapVisualRect(FloatRect(30, 30, 88, 99))); - EXPECT_EQ(IntRect(20, 10, 88, 99), - mapper.MapVisualRect(FloatRect(30.2f, 30.7f, 87.3f, 98.1f))); - EXPECT_EQ(IntRect(), mapper.MapVisualRect(FloatRect())); + mapper.MapVisualRect(IntRect(30, 30, 88, 99))); + EXPECT_EQ(IntRect(), mapper.MapVisualRect(IntRect())); } TEST_F(ChunkToLayerMapperTest, TwoChunkSameState) { @@ -111,8 +105,8 @@ EXPECT_EQ(FloatRect(0, -10, 100, 100), mapper.ClipRect().Rect()); EXPECT_TRUE(mapper.ClipRect().IsTight()); EXPECT_EQ(IntRect(50, 40, 50, 50), - mapper.MapVisualRect(FloatRect(30, 30, 88, 99))); - EXPECT_EQ(IntRect(), mapper.MapVisualRect(FloatRect())); + mapper.MapVisualRect(IntRect(30, 30, 88, 99))); + EXPECT_EQ(IntRect(), mapper.MapVisualRect(IntRect())); mapper.SwitchToChunk(chunk2); EXPECT_FALSE(HasFilterThatMovesPixels(mapper)); @@ -120,8 +114,8 @@ EXPECT_EQ(FloatRect(0, -10, 100, 100), mapper.ClipRect().Rect()); EXPECT_TRUE(mapper.ClipRect().IsTight()); EXPECT_EQ(IntRect(50, 40, 50, 50), - mapper.MapVisualRect(FloatRect(30, 30, 88, 99))); - EXPECT_EQ(IntRect(), mapper.MapVisualRect(FloatRect())); + mapper.MapVisualRect(IntRect(30, 30, 88, 99))); + EXPECT_EQ(IntRect(), mapper.MapVisualRect(IntRect())); } TEST_F(ChunkToLayerMapperTest, TwoChunkDifferentState) { @@ -146,8 +140,8 @@ EXPECT_EQ(FloatRect(0, -10, 100, 100), mapper.ClipRect().Rect()); EXPECT_TRUE(mapper.ClipRect().IsTight()); EXPECT_EQ(IntRect(50, 40, 50, 50), - mapper.MapVisualRect(FloatRect(30, 30, 88, 99))); - EXPECT_EQ(IntRect(), mapper.MapVisualRect(FloatRect())); + mapper.MapVisualRect(IntRect(30, 30, 88, 99))); + EXPECT_EQ(IntRect(), mapper.MapVisualRect(IntRect())); mapper.SwitchToChunk(chunk2); EXPECT_FALSE(HasFilterThatMovesPixels(mapper)); @@ -156,8 +150,8 @@ EXPECT_EQ(FloatRect(30, 40, 40, 40), mapper.ClipRect().Rect()); EXPECT_FALSE(mapper.ClipRect().IsTight()); EXPECT_EQ(IntRect(30, 40, 40, 40), - mapper.MapVisualRect(FloatRect(0, 0, 200, 200))); - EXPECT_EQ(IntRect(), mapper.MapVisualRect(FloatRect())); + mapper.MapVisualRect(IntRect(0, 0, 200, 200))); + EXPECT_EQ(IntRect(), mapper.MapVisualRect(IntRect())); } TEST_F(ChunkToLayerMapperTest, SlowPath) { @@ -198,20 +192,16 @@ EXPECT_EQ(SkMatrix::MakeTrans(-10, -20), mapper.Transform()); EXPECT_TRUE(mapper.ClipRect().IsInfinite()); EXPECT_EQ(IntRect(-40, -50, 208, 219), - mapper.MapVisualRect(FloatRect(30, 30, 88, 99))); - EXPECT_EQ(IntRect(-40, -50, 208, 219), - mapper.MapVisualRect(FloatRect(30.2f, 30.7f, 87.3f, 98.1f))); - EXPECT_EQ(IntRect(), mapper.MapVisualRect(FloatRect())); + mapper.MapVisualRect(IntRect(30, 30, 88, 99))); + EXPECT_EQ(IntRect(), mapper.MapVisualRect(IntRect())); mapper.SwitchToChunk(chunk3); EXPECT_TRUE(HasFilterThatMovesPixels(mapper)); EXPECT_EQ(SkMatrix::MakeTrans(-10, -20), mapper.Transform()); EXPECT_TRUE(mapper.ClipRect().IsInfinite()); EXPECT_EQ(IntRect(-40, -50, 208, 219), - mapper.MapVisualRect(FloatRect(30, 30, 88, 99))); - EXPECT_EQ(IntRect(-40, -50, 208, 219), - mapper.MapVisualRect(FloatRect(30.2f, 30.7f, 87.3f, 98.1f))); - EXPECT_EQ(IntRect(), mapper.MapVisualRect(FloatRect())); + mapper.MapVisualRect(IntRect(30, 30, 88, 99))); + EXPECT_EQ(IntRect(), mapper.MapVisualRect(IntRect())); mapper.SwitchToChunk(chunk4); EXPECT_FALSE(HasFilterThatMovesPixels(mapper));
diff --git a/third_party/blink/renderer/platform/graphics/compositing/content_layer_client_impl.cc b/third_party/blink/renderer/platform/graphics/compositing/content_layer_client_impl.cc index 1caf485d..e442dd8 100644 --- a/third_party/blink/renderer/platform/graphics/compositing/content_layer_client_impl.cc +++ b/third_party/blink/renderer/platform/graphics/compositing/content_layer_client_impl.cc
@@ -5,6 +5,7 @@ #include "third_party/blink/renderer/platform/graphics/compositing/content_layer_client_impl.h" #include <memory> +#include "base/bind.h" #include "base/optional.h" #include "base/trace_event/traced_value.h" #include "cc/paint/paint_flags.h" @@ -24,9 +25,9 @@ ContentLayerClientImpl::ContentLayerClientImpl() : cc_picture_layer_(cc::PictureLayer::Create(this)), - raster_invalidator_([this](const IntRect& rect) { - cc_picture_layer_->SetNeedsDisplayRect(rect); - }), + raster_invalidator_( + base::BindRepeating(&ContentLayerClientImpl::InvalidateRect, + base::Unretained(this))), layer_state_(PropertyTreeState::Uninitialized()), weak_ptr_factory_(this) { cc_picture_layer_->SetLayerClient(weak_ptr_factory_.GetWeakPtr());
diff --git a/third_party/blink/renderer/platform/graphics/compositing/content_layer_client_impl.h b/third_party/blink/renderer/platform/graphics/compositing/content_layer_client_impl.h index 18f8981..584ba16 100644 --- a/third_party/blink/renderer/platform/graphics/compositing/content_layer_client_impl.h +++ b/third_party/blink/renderer/platform/graphics/compositing/content_layer_client_impl.h
@@ -73,6 +73,11 @@ RasterInvalidator& GetRasterInvalidator() { return raster_invalidator_; } private: + // Callback from raster_invalidator_. + void InvalidateRect(const IntRect& rect) { + cc_picture_layer_->SetNeedsDisplayRect(rect); + } + base::Optional<PaintChunk::Id> id_; scoped_refptr<cc::PictureLayer> cc_picture_layer_; scoped_refptr<cc::DisplayItemList> cc_display_item_list_;
diff --git a/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor_test.cc b/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor_test.cc index 7872f3b..4aad18a 100644 --- a/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor_test.cc +++ b/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor_test.cc
@@ -1835,11 +1835,11 @@ TEST_P(PaintArtifactCompositorTest, MightOverlap) { PaintChunk paint_chunk = DefaultChunk(); - paint_chunk.bounds = FloatRect(0, 0, 100, 100); + paint_chunk.bounds = IntRect(0, 0, 100, 100); PendingLayer pending_layer(paint_chunk, 0, false); PaintChunk paint_chunk2 = DefaultChunk(); - paint_chunk2.bounds = FloatRect(0, 0, 100, 100); + paint_chunk2.bounds = IntRect(0, 0, 100, 100); { PendingLayer pending_layer2(paint_chunk2, 1, false); @@ -1868,7 +1868,7 @@ PaintChunk chunk1 = DefaultChunk(); chunk1.properties = PropertyTreeState::Root(); chunk1.known_to_be_opaque = true; - chunk1.bounds = FloatRect(0, 0, 30, 40); + chunk1.bounds = IntRect(0, 0, 30, 40); PendingLayer pending_layer(chunk1, 0, false); @@ -1879,7 +1879,7 @@ PaintChunk chunk2 = DefaultChunk(); chunk2.properties = chunk1.properties; chunk2.known_to_be_opaque = true; - chunk2.bounds = FloatRect(10, 20, 30, 40); + chunk2.bounds = IntRect(10, 20, 30, 40); pending_layer.Merge(PendingLayer(chunk2, 1, false)); // Bounds not equal to one PaintChunk. @@ -1890,7 +1890,7 @@ PaintChunk chunk3 = DefaultChunk(); chunk3.properties = chunk1.properties; chunk3.known_to_be_opaque = true; - chunk3.bounds = FloatRect(-5, -25, 20, 20); + chunk3.bounds = IntRect(-5, -25, 20, 20); pending_layer.Merge(PendingLayer(chunk3, 2, false)); EXPECT_EQ(FloatRect(-5, -25, 45, 85), pending_layer.bounds); @@ -1905,7 +1905,7 @@ PaintChunk chunk1 = DefaultChunk(); chunk1.properties = PropertyTreeState::Root(); - chunk1.bounds = FloatRect(0, 0, 30, 40); + chunk1.bounds = IntRect(0, 0, 30, 40); PendingLayer pending_layer(chunk1, 0, false); @@ -1914,7 +1914,7 @@ PaintChunk chunk2 = DefaultChunk(); chunk2.properties = chunk1.properties; SetTransform(chunk2, *transform); - chunk2.bounds = FloatRect(0, 0, 50, 60); + chunk2.bounds = IntRect(0, 0, 50, 60); pending_layer.Merge(PendingLayer(chunk2, 1, false)); EXPECT_EQ(FloatRect(0, 0, 70, 85), pending_layer.bounds); @@ -1925,7 +1925,7 @@ TEST_P(PaintArtifactCompositorTest, DISABLED_PendingLayerKnownOpaque) { PaintChunk chunk1 = DefaultChunk(); chunk1.properties = PropertyTreeState::Root(); - chunk1.bounds = FloatRect(0, 0, 30, 40); + chunk1.bounds = IntRect(0, 0, 30, 40); chunk1.known_to_be_opaque = false; PendingLayer pending_layer(chunk1, 0, false); @@ -1933,22 +1933,22 @@ PaintChunk chunk2 = DefaultChunk(); chunk2.properties = chunk1.properties; - chunk2.bounds = FloatRect(0, 0, 25, 35); + chunk2.bounds = IntRect(0, 0, 25, 35); chunk2.known_to_be_opaque = true; pending_layer.Merge(PendingLayer(chunk2, 1, false)); // Chunk 2 doesn't cover the entire layer, so not opaque. - EXPECT_EQ(chunk2.bounds, pending_layer.rect_known_to_be_opaque); + EXPECT_EQ(FloatRect(chunk2.bounds), pending_layer.rect_known_to_be_opaque); EXPECT_NE(pending_layer.bounds, pending_layer.rect_known_to_be_opaque); PaintChunk chunk3 = DefaultChunk(); chunk3.properties = chunk1.properties; - chunk3.bounds = FloatRect(0, 0, 50, 60); + chunk3.bounds = IntRect(0, 0, 50, 60); chunk3.known_to_be_opaque = true; pending_layer.Merge(PendingLayer(chunk3, 2, false)); // Chunk 3 covers the entire layer, so now it's opaque. - EXPECT_EQ(chunk3.bounds, pending_layer.bounds); + EXPECT_EQ(FloatRect(chunk3.bounds), pending_layer.bounds); EXPECT_EQ(pending_layer.bounds, pending_layer.rect_known_to_be_opaque); } @@ -3145,17 +3145,6 @@ EXPECT_TRUE(ContentLayerAt(0)->contents_opaque()); } -TEST_P(PaintArtifactCompositorTest, ContentsOpaqueSubpixel) { - TestPaintArtifact artifact; - artifact.Chunk() - .RectDrawing(FloatRect(100.5, 100.5, 200, 200), Color::kBlack) - .KnownToBeOpaque(); - Update(artifact.Build()); - ASSERT_EQ(1u, ContentLayerCount()); - EXPECT_EQ(gfx::Size(201, 201), ContentLayerAt(0)->bounds()); - EXPECT_FALSE(ContentLayerAt(0)->contents_opaque()); -} - TEST_P(PaintArtifactCompositorTest, ContentsOpaqueUnitedNonOpaque) { TestPaintArtifact artifact; artifact.Chunk()
diff --git a/third_party/blink/renderer/platform/graphics/compositing/paint_chunks_to_cc_layer.cc b/third_party/blink/renderer/platform/graphics/compositing/paint_chunks_to_cc_layer.cc index 966b594..aa75fdb4a 100644 --- a/third_party/blink/renderer/platform/graphics/compositing/paint_chunks_to_cc_layer.cc +++ b/third_party/blink/renderer/platform/graphics/compositing/paint_chunks_to_cc_layer.cc
@@ -711,7 +711,7 @@ cc_list_.EndPaintOfUnpaired( chunk_to_layer_mapper_.MapVisualRect(item.VisualRect())); } - UpdateEffectBounds(chunk.bounds, chunk_state.Transform()); + UpdateEffectBounds(FloatRect(chunk.bounds), chunk_state.Transform()); } }
diff --git a/third_party/blink/renderer/platform/graphics/compositing/paint_chunks_to_cc_layer_test.cc b/third_party/blink/renderer/platform/graphics/compositing/paint_chunks_to_cc_layer_test.cc index cbd7b49..bd0eed3 100644 --- a/third_party/blink/renderer/platform/graphics/compositing/paint_chunks_to_cc_layer_test.cc +++ b/third_party/blink/renderer/platform/graphics/compositing/paint_chunks_to_cc_layer_test.cc
@@ -151,7 +151,7 @@ PaintChunk::Id DefaultId() { DEFINE_STATIC_LOCAL(FakeDisplayItemClient, fake_client, - ("FakeDisplayItemClient", LayoutRect(0, 0, 100, 100))); + ("FakeDisplayItemClient", IntRect(0, 0, 100, 100))); return PaintChunk::Id(fake_client, DisplayItem::kDrawingFirst); } @@ -163,7 +163,7 @@ void AddChunk(const TransformPaintPropertyNode& t, const ClipPaintPropertyNode& c, const EffectPaintPropertyNode& e, - const FloatRect& bounds = FloatRect(0, 0, 100, 100)) { + const IntRect& bounds = IntRect(0, 0, 100, 100)) { auto record = sk_make_sp<PaintRecord>(); record->push<cc::DrawRectOp>(bounds, cc::PaintFlags()); AddChunk(std::move(record), t, c, e, bounds); @@ -174,7 +174,7 @@ const TransformPaintPropertyNode& t, const ClipPaintPropertyNode& c, const EffectPaintPropertyNode& e, - const FloatRect& bounds = FloatRect(0, 0, 100, 100)) { + const IntRect& bounds = IntRect(0, 0, 100, 100)) { size_t i = items.size(); items.AllocateAndConstruct<DrawingDisplayItem>( DefaultId().client, DefaultId().type, std::move(record)); @@ -187,8 +187,8 @@ // This test verifies effects are applied as a group. auto e1 = CreateOpacityEffect(e0(), 0.5f); TestChunks chunks; - chunks.AddChunk(t0(), c0(), *e1, FloatRect(0, 0, 50, 50)); - chunks.AddChunk(t0(), c0(), *e1, FloatRect(20, 20, 70, 70)); + chunks.AddChunk(t0(), c0(), *e1, IntRect(0, 0, 50, 50)); + chunks.AddChunk(t0(), c0(), *e1, IntRect(20, 20, 70, 70)); sk_sp<PaintRecord> output = PaintChunksToCcLayer::Convert( @@ -211,7 +211,7 @@ auto e3 = CreateOpacityEffect(*e1, 0.5f); TestChunks chunks; chunks.AddChunk(t0(), c0(), *e2); - chunks.AddChunk(t0(), c0(), *e3, FloatRect(111, 222, 333, 444)); + chunks.AddChunk(t0(), c0(), *e3, IntRect(111, 222, 333, 444)); sk_sp<PaintRecord> output = PaintChunksToCcLayer::Convert( @@ -243,8 +243,8 @@ filter.AppendBlurFilter(5); auto e2 = CreateFilterEffect(*e1, filter, FloatPoint(60, 60)); TestChunks chunks; - chunks.AddChunk(*t2, c0(), *e1, FloatRect(0, 0, 50, 50)); - chunks.AddChunk(*t1, c0(), *e2, FloatRect(20, 20, 70, 70)); + chunks.AddChunk(*t2, c0(), *e1, IntRect(0, 0, 50, 50)); + chunks.AddChunk(*t1, c0(), *e2, IntRect(20, 20, 70, 70)); sk_sp<PaintRecord> output = PaintChunksToCcLayer::Convert( @@ -297,8 +297,8 @@ TestChunks chunks; chunks.AddChunk(t0(), *c2, e0()); chunks.AddChunk(t0(), *c3, e0()); - chunks.AddChunk(t0(), *c4, *e2, FloatRect(0, 0, 50, 50)); - chunks.AddChunk(t0(), *c3, *e1, FloatRect(20, 20, 70, 70)); + chunks.AddChunk(t0(), *c4, *e2, IntRect(0, 0, 50, 50)); + chunks.AddChunk(t0(), *c3, *e1, IntRect(20, 20, 70, 70)); chunks.AddChunk(t0(), *c4, e0()); sk_sp<PaintRecord> output =
diff --git a/third_party/blink/renderer/platform/graphics/graphics_layer.cc b/third_party/blink/renderer/platform/graphics/graphics_layer.cc index a0959355..7112e2a 100644 --- a/third_party/blink/renderer/platform/graphics/graphics_layer.cc +++ b/third_party/blink/renderer/platform/graphics/graphics_layer.cc
@@ -117,9 +117,9 @@ DCHECK(!parent_); } -LayoutRect GraphicsLayer::VisualRect() const { +IntRect GraphicsLayer::VisualRect() const { DCHECK(layer_state_); - return LayoutRect(layer_state_->offset, LayoutSize(Size())); + return IntRect(layer_state_->offset, IntSize(Size())); } void GraphicsLayer::SetHasWillChangeTransformHint( @@ -590,8 +590,9 @@ RasterInvalidator& GraphicsLayer::EnsureRasterInvalidator() { if (!raster_invalidator_) { - raster_invalidator_ = std::make_unique<RasterInvalidator>( - [this](const IntRect& r) { SetNeedsDisplayInRect(r); }); + raster_invalidator_ = + std::make_unique<RasterInvalidator>(base::BindRepeating( + &GraphicsLayer::SetNeedsDisplayInRect, base::Unretained(this))); raster_invalidator_->SetTracksRasterInvalidations( client_.IsTrackingRasterInvalidations()); }
diff --git a/third_party/blink/renderer/platform/graphics/graphics_layer.h b/third_party/blink/renderer/platform/graphics/graphics_layer.h index 99b75a9..05b8c15 100644 --- a/third_party/blink/renderer/platform/graphics/graphics_layer.h +++ b/third_party/blink/renderer/platform/graphics/graphics_layer.h
@@ -274,7 +274,7 @@ // DisplayItemClient methods String DebugName() const final { return client_.DebugName(this); } - LayoutRect VisualRect() const override; + IntRect VisualRect() const override; void SetHasWillChangeTransformHint(bool);
diff --git a/third_party/blink/renderer/platform/graphics/link_highlight.h b/third_party/blink/renderer/platform/graphics/link_highlight.h index 913c7a7..39bf206f 100644 --- a/third_party/blink/renderer/platform/graphics/link_highlight.h +++ b/third_party/blink/renderer/platform/graphics/link_highlight.h
@@ -30,7 +30,7 @@ // TODO(wangxianzhu): This class doesn't need to be a DisplayItemClient in // CompositeAfterPaint. String DebugName() const final { return "LinkHighlight"; } - LayoutRect VisualRect() const final { return LayoutRect(); } + IntRect VisualRect() const final { return IntRect(); } }; } // namespace blink
diff --git a/third_party/blink/renderer/platform/graphics/paint/display_item.cc b/third_party/blink/renderer/platform/graphics/paint/display_item.cc index b1d1c66..721c500 100644 --- a/third_party/blink/renderer/platform/graphics/paint/display_item.cc +++ b/third_party/blink/renderer/platform/graphics/paint/display_item.cc
@@ -11,8 +11,8 @@ struct SameSizeAsDisplayItem { virtual ~SameSizeAsDisplayItem() = default; // Allocate vtable pointer. void* pointer; - LayoutRect rect; - LayoutUnit outset; + IntRect rect; + float outset; int i; }; static_assert(sizeof(DisplayItem) == sizeof(SameSizeAsDisplayItem),
diff --git a/third_party/blink/renderer/platform/graphics/paint/display_item.h b/third_party/blink/renderer/platform/graphics/paint/display_item.h index 2c5c6bb..8843a98 100644 --- a/third_party/blink/renderer/platform/graphics/paint/display_item.h +++ b/third_party/blink/renderer/platform/graphics/paint/display_item.h
@@ -5,7 +5,7 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_PAINT_DISPLAY_ITEM_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_PAINT_DISPLAY_ITEM_H_ -#include "third_party/blink/renderer/platform/geometry/float_rect.h" +#include "third_party/blink/renderer/platform/geometry/int_rect.h" #include "third_party/blink/renderer/platform/graphics/contiguous_container.h" #include "third_party/blink/renderer/platform/graphics/paint/display_item_client.h" #include "third_party/blink/renderer/platform/platform_export.h" @@ -188,14 +188,14 @@ // This equals to Client().VisualRect() as long as the client is alive and is // not invalidated. Otherwise it saves the previous visual rect of the client. // See DisplayItemClient::VisualRect() about its coordinate space. - const FloatRect& VisualRect() const { return visual_rect_; } + const IntRect& VisualRect() const { return visual_rect_; } float OutsetForRasterEffects() const { return outset_for_raster_effects_; } // Visual rect can change without needing invalidation of the client, e.g. // when ancestor clip changes. This is called from PaintController:: // UseCachedItemIfPossible() to update the visual rect of a cached display // item. - void UpdateVisualRect() { visual_rect_ = FloatRect(client_->VisualRect()); } + void UpdateVisualRect() { visual_rect_ = client_->VisualRect(); } Type GetType() const { return static_cast<Type>(type_); } @@ -281,7 +281,7 @@ DisplayItem() : draws_content_(false), is_tombstone_(true) {} const DisplayItemClient* client_; - FloatRect visual_rect_; + IntRect visual_rect_; float outset_for_raster_effects_; static_assert(kTypeLast < (1 << 7), "DisplayItem::Type should fit in 7 bits");
diff --git a/third_party/blink/renderer/platform/graphics/paint/display_item_client.h b/third_party/blink/renderer/platform/graphics/paint/display_item_client.h index 4342ad0..d5ac6cb2 100644 --- a/third_party/blink/renderer/platform/graphics/paint/display_item_client.h +++ b/third_party/blink/renderer/platform/graphics/paint/display_item_client.h
@@ -5,7 +5,7 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_PAINT_DISPLAY_ITEM_CLIENT_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_PAINT_DISPLAY_ITEM_CLIENT_H_ -#include "third_party/blink/renderer/platform/geometry/layout_rect.h" +#include "third_party/blink/renderer/platform/geometry/int_rect.h" #include "third_party/blink/renderer/platform/graphics/dom_node_id.h" #include "third_party/blink/renderer/platform/graphics/paint_invalidation_reason.h" #include "third_party/blink/renderer/platform/platform_export.h" @@ -52,7 +52,7 @@ // space of the object that owns the GraphicsLayer, i.e. offset by // GraphicsLayer::OffsetFromLayoutObjectWithSubpixelAccumulation(). // It's in the space of the parent transform node. - virtual LayoutRect VisualRect() const = 0; + virtual IntRect VisualRect() const = 0; // The outset will be used to inflate visual rect after the visual rect is // mapped into the space of the composited layer, for any special raster @@ -61,9 +61,7 @@ // The rect that needs to be invalidated partially for rasterization in this // client. It's in the same coordinate space as VisualRect(). - virtual LayoutRect PartialInvalidationVisualRect() const { - return LayoutRect(); - } + virtual IntRect PartialInvalidationVisualRect() const { return IntRect(); } // Called by PaintController::FinishCycle() for all clients after painting. virtual void ClearPartialInvalidationVisualRect() const {}
diff --git a/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator.cc b/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator.cc index 5806181..2d2433bf 100644 --- a/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator.cc +++ b/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator.cc
@@ -10,8 +10,8 @@ void DisplayItemRasterInvalidator::Generate() { struct OldAndNewDisplayItems { - const FloatRect* old_visual_rect = nullptr; - const FloatRect* new_visual_rect = nullptr; + const IntRect* old_visual_rect = nullptr; + const IntRect* new_visual_rect = nullptr; PaintInvalidationReason reason = PaintInvalidationReason::kNone; }; // If there are multiple display items changed for a client, the map will @@ -129,7 +129,7 @@ void DisplayItemRasterInvalidator::AddRasterInvalidation( const DisplayItemClient& client, - const FloatRect& rect, + const IntRect& rect, PaintInvalidationReason reason, RasterInvalidator::ClientIsOldOrNew old_or_new) { IntRect r = invalidator_.ClipByLayerBounds(mapper_.MapVisualRect(rect)); @@ -141,8 +141,8 @@ void DisplayItemRasterInvalidator::GenerateRasterInvalidation( const DisplayItemClient& client, - const FloatRect* old_visual_rect, - const FloatRect* new_visual_rect, + const IntRect* old_visual_rect, + const IntRect* new_visual_rect, PaintInvalidationReason reason) { if (!new_visual_rect || new_visual_rect->IsEmpty()) { if (old_visual_rect && !old_visual_rect->IsEmpty()) { @@ -178,50 +178,48 @@ GenerateIncrementalRasterInvalidation(client, *old_visual_rect, *new_visual_rect); - LayoutRect partial_rect = client.PartialInvalidationVisualRect(); - if (!partial_rect.IsEmpty()) { - AddRasterInvalidation(client, FloatRect(partial_rect), reason, - kClientIsNew); - } + IntRect partial_rect = client.PartialInvalidationVisualRect(); + if (!partial_rect.IsEmpty()) + AddRasterInvalidation(client, partial_rect, reason, kClientIsNew); } -static FloatRect ComputeRightDelta(const FloatPoint& location, - const FloatSize& old_size, - const FloatSize& new_size) { - float delta = new_size.Width() - old_size.Width(); +static IntRect ComputeRightDelta(const IntPoint& location, + const IntSize& old_size, + const IntSize& new_size) { + int delta = new_size.Width() - old_size.Width(); if (delta > 0) { - return FloatRect(location.X() + old_size.Width(), location.Y(), delta, - new_size.Height()); + return IntRect(location.X() + old_size.Width(), location.Y(), delta, + new_size.Height()); } if (delta < 0) { - return FloatRect(location.X() + new_size.Width(), location.Y(), -delta, - old_size.Height()); + return IntRect(location.X() + new_size.Width(), location.Y(), -delta, + old_size.Height()); } - return FloatRect(); + return IntRect(); } -static FloatRect ComputeBottomDelta(const FloatPoint& location, - const FloatSize& old_size, - const FloatSize& new_size) { - float delta = new_size.Height() - old_size.Height(); +static IntRect ComputeBottomDelta(const IntPoint& location, + const IntSize& old_size, + const IntSize& new_size) { + int delta = new_size.Height() - old_size.Height(); if (delta > 0) { - return FloatRect(location.X(), location.Y() + old_size.Height(), - new_size.Width(), delta); + return IntRect(location.X(), location.Y() + old_size.Height(), + new_size.Width(), delta); } if (delta < 0) { - return FloatRect(location.X(), location.Y() + new_size.Height(), - old_size.Width(), -delta); + return IntRect(location.X(), location.Y() + new_size.Height(), + old_size.Width(), -delta); } - return FloatRect(); + return IntRect(); } void DisplayItemRasterInvalidator::GenerateIncrementalRasterInvalidation( const DisplayItemClient& client, - const FloatRect& old_visual_rect, - const FloatRect& new_visual_rect) { + const IntRect& old_visual_rect, + const IntRect& new_visual_rect) { DCHECK(old_visual_rect.Location() == new_visual_rect.Location()); - FloatRect right_delta = + IntRect right_delta = ComputeRightDelta(new_visual_rect.Location(), old_visual_rect.Size(), new_visual_rect.Size()); if (!right_delta.IsEmpty()) { @@ -229,7 +227,7 @@ PaintInvalidationReason::kIncremental, kClientIsNew); } - FloatRect bottom_delta = + IntRect bottom_delta = ComputeBottomDelta(new_visual_rect.Location(), old_visual_rect.Size(), new_visual_rect.Size()); if (!bottom_delta.IsEmpty()) { @@ -240,8 +238,8 @@ void DisplayItemRasterInvalidator::GenerateFullRasterInvalidation( const DisplayItemClient& client, - const FloatRect& old_visual_rect, - const FloatRect& new_visual_rect, + const IntRect& old_visual_rect, + const IntRect& new_visual_rect, PaintInvalidationReason reason) { if (!new_visual_rect.Contains(old_visual_rect)) { AddRasterInvalidation(client, old_visual_rect, reason, kClientIsNew);
diff --git a/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator.h b/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator.h index 175ef518..1f02e95 100644 --- a/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator.h +++ b/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator.h
@@ -37,25 +37,24 @@ static const auto kClientIsNew = RasterInvalidator::kClientIsNew; ALWAYS_INLINE void AddRasterInvalidation(const DisplayItemClient&, - const FloatRect&, + const IntRect&, PaintInvalidationReason, RasterInvalidator::ClientIsOldOrNew); ALWAYS_INLINE size_t MatchNewDisplayItemInOldChunk(const DisplayItem& new_item, size_t& next_old_item_to_match); - ALWAYS_INLINE void GenerateRasterInvalidation( - const DisplayItemClient&, - const FloatRect* old_visual_rect, - const FloatRect* new_visual_rect, - PaintInvalidationReason); + ALWAYS_INLINE void GenerateRasterInvalidation(const DisplayItemClient&, + const IntRect* old_visual_rect, + const IntRect* new_visual_rect, + PaintInvalidationReason); ALWAYS_INLINE void GenerateIncrementalRasterInvalidation( const DisplayItemClient&, - const FloatRect& old_visual_rect, - const FloatRect& new_visual_rect); + const IntRect& old_visual_rect, + const IntRect& new_visual_rect); ALWAYS_INLINE void GenerateFullRasterInvalidation( const DisplayItemClient&, - const FloatRect& old_visual_rect, - const FloatRect& new_visual_rect, + const IntRect& old_visual_rect, + const IntRect& new_visual_rect, PaintInvalidationReason reason); RasterInvalidator& invalidator_;
diff --git a/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator_test.cc b/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator_test.cc index 170ebdb..4b6cfb00 100644 --- a/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator_test.cc +++ b/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator_test.cc
@@ -4,6 +4,7 @@ #include "third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator.h" +#include "base/bind_helpers.h" #include "testing/gmock/include/gmock/gmock.h" #include "third_party/blink/renderer/platform/graphics/paint/paint_artifact.h" #include "third_party/blink/renderer/platform/graphics/paint/paint_controller_test.h" @@ -18,7 +19,7 @@ class DisplayItemRasterInvalidatorTest : public PaintControllerTestBase, public PaintTestConfigurations { protected: - DisplayItemRasterInvalidatorTest() : invalidator_([](const IntRect&) {}) {} + DisplayItemRasterInvalidatorTest() : invalidator_(base::DoNothing()) {} Vector<RasterInvalidationInfo> GenerateRasterInvalidations() { GetPaintController().CommitNewDisplayItems(); @@ -46,8 +47,8 @@ INSTANTIATE_PAINT_TEST_SUITE_P(DisplayItemRasterInvalidatorTest); TEST_P(DisplayItemRasterInvalidatorTest, RemoveItemInMiddle) { - FakeDisplayItemClient first("first", LayoutRect(100, 100, 300, 300)); - FakeDisplayItemClient second("second", LayoutRect(100, 100, 200, 200)); + FakeDisplayItemClient first("first", IntRect(100, 100, 300, 300)); + FakeDisplayItemClient second("second", IntRect(100, 100, 200, 200)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -69,9 +70,9 @@ } TEST_P(DisplayItemRasterInvalidatorTest, SwapOrder) { - FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); - FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); - FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10)); + FakeDisplayItemClient first("first", IntRect(100, 100, 100, 100)); + FakeDisplayItemClient second("second", IntRect(100, 100, 50, 200)); + FakeDisplayItemClient unaffected("unaffected", IntRect(300, 300, 10, 10)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -100,9 +101,9 @@ } TEST_P(DisplayItemRasterInvalidatorTest, SwapOrderAndInvalidateFirst) { - FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); - FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); - FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10)); + FakeDisplayItemClient first("first", IntRect(100, 100, 100, 100)); + FakeDisplayItemClient second("second", IntRect(100, 100, 50, 200)); + FakeDisplayItemClient unaffected("unaffected", IntRect(300, 300, 10, 10)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -126,9 +127,9 @@ } TEST_P(DisplayItemRasterInvalidatorTest, SwapOrderAndInvalidateSecond) { - FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); - FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); - FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10)); + FakeDisplayItemClient first("first", IntRect(100, 100, 100, 100)); + FakeDisplayItemClient second("second", IntRect(100, 100, 50, 200)); + FakeDisplayItemClient unaffected("unaffected", IntRect(300, 300, 10, 10)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -152,9 +153,9 @@ } TEST_P(DisplayItemRasterInvalidatorTest, SwapOrderWithIncrementalInvalidation) { - FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); - FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); - FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10)); + FakeDisplayItemClient first("first", IntRect(100, 100, 100, 100)); + FakeDisplayItemClient second("second", IntRect(100, 100, 50, 200)); + FakeDisplayItemClient unaffected("unaffected", IntRect(300, 300, 10, 10)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -165,7 +166,7 @@ invalidator_.SetTracksRasterInvalidations(true); InitRootChunk(); - first.SetVisualRect(LayoutRect(100, 100, 200, 100)); + first.SetVisualRect(IntRect(100, 100, 200, 100)); first.Invalidate(PaintInvalidationReason::kIncremental); DrawRect(context, second, kBackgroundType, FloatRect(100, 100, 50, 200)); DrawRect(context, first, kBackgroundType, FloatRect(100, 100, 100, 100)); @@ -180,9 +181,9 @@ } TEST_P(DisplayItemRasterInvalidatorTest, NewItemInMiddle) { - FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); - FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); - FakeDisplayItemClient third("third", LayoutRect(125, 100, 200, 50)); + FakeDisplayItemClient first("first", IntRect(100, 100, 100, 100)); + FakeDisplayItemClient second("second", IntRect(100, 100, 50, 200)); + FakeDisplayItemClient third("third", IntRect(125, 100, 200, 50)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -204,7 +205,7 @@ } TEST_P(DisplayItemRasterInvalidatorTest, Incremental) { - LayoutRect initial_rect(100, 100, 100, 100); + IntRect initial_rect(100, 100, 100, 100); std::unique_ptr<FakeDisplayItemClient> clients[6]; for (size_t i = 0; i < base::size(clients); i++) { clients[i] = std::make_unique<FakeDisplayItemClient>( @@ -220,12 +221,12 @@ invalidator_.SetTracksRasterInvalidations(true); InitRootChunk(); - clients[0]->SetVisualRect(LayoutRect(100, 100, 150, 100)); - clients[1]->SetVisualRect(LayoutRect(100, 100, 100, 150)); - clients[2]->SetVisualRect(LayoutRect(100, 100, 150, 80)); - clients[3]->SetVisualRect(LayoutRect(100, 100, 80, 150)); - clients[4]->SetVisualRect(LayoutRect(100, 100, 150, 150)); - clients[5]->SetVisualRect(LayoutRect(100, 100, 80, 80)); + clients[0]->SetVisualRect(IntRect(100, 100, 150, 100)); + clients[1]->SetVisualRect(IntRect(100, 100, 100, 150)); + clients[2]->SetVisualRect(IntRect(100, 100, 150, 80)); + clients[3]->SetVisualRect(IntRect(100, 100, 80, 150)); + clients[4]->SetVisualRect(IntRect(100, 100, 150, 150)); + clients[5]->SetVisualRect(IntRect(100, 100, 80, 80)); for (auto& client : clients) { client->Invalidate(PaintInvalidationReason::kIncremental); DrawRect(context, *client, kBackgroundType, @@ -269,8 +270,8 @@ TEST_P(DisplayItemRasterInvalidatorTest, AddRemoveFirstAndInvalidateSecond) { FakeDisplayItemClient chunk("chunk"); - FakeDisplayItemClient first("first", LayoutRect(100, 100, 150, 150)); - FakeDisplayItemClient second("second", LayoutRect(200, 200, 50, 50)); + FakeDisplayItemClient first("first", IntRect(100, 100, 150, 150)); + FakeDisplayItemClient second("second", IntRect(200, 200, 50, 50)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -282,7 +283,7 @@ InitRootChunk(); first.Invalidate(); second.Invalidate(); - second.SetVisualRect(LayoutRect(150, 250, 100, 100)); + second.SetVisualRect(IntRect(150, 250, 100, 100)); DrawRect(context, first, kBackgroundType, FloatRect(100, 100, 150, 150)); DrawRect(context, first, kForegroundType, FloatRect(100, 100, 150, 150)); DrawRect(context, second, kBackgroundType, FloatRect(150, 250, 100, 100)); @@ -313,8 +314,8 @@ } TEST_P(DisplayItemRasterInvalidatorTest, InvalidateFirstAndAddRemoveSecond) { - FakeDisplayItemClient first("first", LayoutRect(100, 100, 150, 150)); - FakeDisplayItemClient second("second", LayoutRect(200, 200, 50, 50)); + FakeDisplayItemClient first("first", IntRect(100, 100, 150, 150)); + FakeDisplayItemClient second("second", IntRect(200, 200, 50, 50)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -325,7 +326,7 @@ invalidator_.SetTracksRasterInvalidations(true); InitRootChunk(); first.Invalidate(); - first.SetVisualRect(LayoutRect(150, 150, 100, 100)); + first.SetVisualRect(IntRect(150, 150, 100, 100)); second.Invalidate(); DrawRect(context, first, kBackgroundType, FloatRect(150, 150, 100, 100)); DrawRect(context, first, kForegroundType, FloatRect(150, 150, 100, 100)); @@ -344,7 +345,7 @@ invalidator_.SetTracksRasterInvalidations(true); InitRootChunk(); first.Invalidate(); - first.SetVisualRect(LayoutRect(100, 100, 150, 150)); + first.SetVisualRect(IntRect(100, 100, 150, 150)); second.Invalidate(); DrawRect(context, first, kBackgroundType, FloatRect(100, 100, 150, 150)); DrawRect(context, first, kForegroundType, FloatRect(100, 100, 150, 150)); @@ -360,12 +361,10 @@ } TEST_P(DisplayItemRasterInvalidatorTest, SwapOrderWithChildren) { - FakeDisplayItemClient container1("container1", - LayoutRect(100, 100, 100, 100)); - FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); - FakeDisplayItemClient container2("container2", - LayoutRect(100, 200, 100, 100)); - FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); + FakeDisplayItemClient container1("container1", IntRect(100, 100, 100, 100)); + FakeDisplayItemClient content1("content1", IntRect(100, 100, 50, 200)); + FakeDisplayItemClient container2("container2", IntRect(100, 200, 100, 100)); + FakeDisplayItemClient content2("content2", IntRect(100, 200, 50, 200)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -404,12 +403,10 @@ } TEST_P(DisplayItemRasterInvalidatorTest, SwapOrderWithChildrenAndInvalidation) { - FakeDisplayItemClient container1("container1", - LayoutRect(100, 100, 100, 100)); - FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); - FakeDisplayItemClient container2("container2", - LayoutRect(100, 200, 100, 100)); - FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); + FakeDisplayItemClient container1("container1", IntRect(100, 100, 100, 100)); + FakeDisplayItemClient content1("content1", IntRect(100, 100, 50, 200)); + FakeDisplayItemClient container2("container2", IntRect(100, 200, 100, 100)); + FakeDisplayItemClient content2("content2", IntRect(100, 200, 50, 200)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -452,12 +449,10 @@ } TEST_P(DisplayItemRasterInvalidatorTest, SwapOrderCrossingChunks) { - FakeDisplayItemClient container1("container1", - LayoutRect(100, 100, 100, 100)); - FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); - FakeDisplayItemClient container2("container2", - LayoutRect(100, 200, 100, 100)); - FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); + FakeDisplayItemClient container1("container1", IntRect(100, 100, 100, 100)); + FakeDisplayItemClient content1("content1", IntRect(100, 100, 50, 200)); + FakeDisplayItemClient container2("container2", IntRect(100, 200, 100, 100)); + FakeDisplayItemClient content2("content2", IntRect(100, 200, 50, 200)); GraphicsContext context(GetPaintController()); auto container1_effect = CreateOpacityEffect(e0(), 0.5); @@ -501,8 +496,8 @@ } TEST_P(DisplayItemRasterInvalidatorTest, SkipCache) { - FakeDisplayItemClient multicol("multicol", LayoutRect(100, 100, 200, 200)); - FakeDisplayItemClient content("content", LayoutRect(100, 100, 100, 100)); + FakeDisplayItemClient multicol("multicol", IntRect(100, 100, 200, 200)); + FakeDisplayItemClient content("content", IntRect(100, 100, 100, 100)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -558,7 +553,7 @@ } TEST_P(DisplayItemRasterInvalidatorTest, PartialSkipCache) { - FakeDisplayItemClient content("content", LayoutRect(100, 100, 250, 250)); + FakeDisplayItemClient content("content", IntRect(100, 100, 250, 250)); GraphicsContext context(GetPaintController()); FloatRect rect1(100, 100, 50, 50); @@ -590,7 +585,7 @@ } TEST_P(DisplayItemRasterInvalidatorTest, Partial) { - FakeDisplayItemClient client("client", LayoutRect(100, 100, 300, 300)); + FakeDisplayItemClient client("client", IntRect(100, 100, 300, 300)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -600,7 +595,7 @@ // Test partial rect invalidation without other invalidations. invalidator_.SetTracksRasterInvalidations(true); InitRootChunk(); - client.SetPartialInvalidationVisualRect(LayoutRect(150, 160, 170, 180)); + client.SetPartialInvalidationVisualRect(IntRect(150, 160, 170, 180)); DrawRect(context, client, kBackgroundType, FloatRect(100, 100, 300, 300)); // Partial invalidation. @@ -608,13 +603,13 @@ UnorderedElementsAre(RasterInvalidationInfo{ &client, "client", IntRect(150, 160, 170, 180), PaintInvalidationReason::kRectangle})); - EXPECT_EQ(LayoutRect(), client.PartialInvalidationVisualRect()); + EXPECT_EQ(IntRect(), client.PartialInvalidationVisualRect()); invalidator_.SetTracksRasterInvalidations(false); // Test partial rect invalidation with full invalidation. invalidator_.SetTracksRasterInvalidations(true); InitRootChunk(); - client.SetPartialInvalidationVisualRect(LayoutRect(150, 160, 170, 180)); + client.SetPartialInvalidationVisualRect(IntRect(150, 160, 170, 180)); client.Invalidate(); DrawRect(context, client, kBackgroundType, FloatRect(100, 100, 300, 300)); @@ -623,14 +618,14 @@ UnorderedElementsAre(RasterInvalidationInfo{ &client, "client", IntRect(100, 100, 300, 300), PaintInvalidationReason::kFull})); - EXPECT_EQ(LayoutRect(), client.PartialInvalidationVisualRect()); + EXPECT_EQ(IntRect(), client.PartialInvalidationVisualRect()); invalidator_.SetTracksRasterInvalidations(false); // Test partial rect invalidation with incremental invalidation. invalidator_.SetTracksRasterInvalidations(true); InitRootChunk(); - client.SetPartialInvalidationVisualRect(LayoutRect(150, 160, 170, 180)); - client.SetVisualRect(LayoutRect(100, 100, 300, 400)); + client.SetPartialInvalidationVisualRect(IntRect(150, 160, 170, 180)); + client.SetVisualRect(IntRect(100, 100, 300, 400)); DrawRect(context, client, kBackgroundType, FloatRect(100, 100, 300, 400)); // Both partial invalidation and incremental invalidation.
diff --git a/third_party/blink/renderer/platform/graphics/paint/drawing_display_item.cc b/third_party/blink/renderer/platform/graphics/paint/drawing_display_item.cc index 750ac8d..0ab4e34 100644 --- a/third_party/blink/renderer/platform/graphics/paint/drawing_display_item.cc +++ b/third_party/blink/renderer/platform/graphics/paint/drawing_display_item.cc
@@ -68,7 +68,7 @@ if (!record || !other_record) return false; - const auto& bounds = this->VisualRect(); + auto bounds = this->VisualRect(); const auto& other_bounds = other.VisualRect(); if (bounds != other_bounds) return false; @@ -78,10 +78,9 @@ // Sometimes the client may produce different records for the same visual // result, which should be treated as equal. - IntRect int_bounds = EnclosingIntRect(bounds); // Limit the bounds to prevent OOM. - int_bounds.Intersect(IntRect(int_bounds.X(), int_bounds.Y(), 6000, 6000)); - return BitmapsEqual(std::move(record), std::move(other_record), int_bounds); + bounds.Intersect(IntRect(bounds.X(), bounds.Y(), 6000, 6000)); + return BitmapsEqual(std::move(record), std::move(other_record), bounds); } } // namespace blink
diff --git a/third_party/blink/renderer/platform/graphics/paint/drawing_display_item_test.cc b/third_party/blink/renderer/platform/graphics/paint/drawing_display_item_test.cc index bde9029..c0e12fe 100644 --- a/third_party/blink/renderer/platform/graphics/paint/drawing_display_item_test.cc +++ b/third_party/blink/renderer/platform/graphics/paint/drawing_display_item_test.cc
@@ -7,6 +7,7 @@ #include "cc/paint/display_item_list.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/blink/renderer/platform/geometry/float_rect.h" #include "third_party/blink/renderer/platform/graphics/paint/paint_flags.h" #include "third_party/blink/renderer/platform/graphics/paint/paint_recorder.h" #include "third_party/blink/renderer/platform/graphics/skia/skia_utils.h" @@ -47,12 +48,11 @@ TEST_F(DrawingDisplayItemTest, DrawsContent) { FloatRect record_bounds(5.5, 6.6, 7.7, 8.8); - LayoutRect drawing_bounds(record_bounds); - client_.SetVisualRect(drawing_bounds); + client_.SetVisualRect(EnclosingIntRect(record_bounds)); DrawingDisplayItem item(client_, DisplayItem::Type::kDocumentBackground, CreateRectRecord(record_bounds)); - EXPECT_EQ(FloatRect(drawing_bounds), item.VisualRect()); + EXPECT_EQ(EnclosingIntRect(record_bounds), item.VisualRect()); EXPECT_TRUE(item.DrawsContent()); } @@ -70,7 +70,7 @@ TEST_F(DrawingDisplayItemTest, Equals) { FloatRect bounds1(100.1, 100.2, 100.3, 100.4); - client_.SetVisualRect(LayoutRect(bounds1)); + client_.SetVisualRect(EnclosingIntRect(bounds1)); DrawingDisplayItem item1(client_, DisplayItem::kDocumentBackground, CreateRectRecord(bounds1)); DrawingDisplayItem translated(client_, DisplayItem::kDocumentBackground, @@ -82,7 +82,7 @@ CreateRectRecordWithTranslate(bounds1, 0, 0)); FloatRect bounds2(100.5, 100.6, 100.7, 100.8); - client_.SetVisualRect(LayoutRect(bounds2)); + client_.SetVisualRect(EnclosingIntRect(bounds2)); DrawingDisplayItem item2(client_, DisplayItem::kDocumentBackground, CreateRectRecord(bounds2));
diff --git a/third_party/blink/renderer/platform/graphics/paint/foreign_layer_display_item.cc b/third_party/blink/renderer/platform/graphics/paint/foreign_layer_display_item.cc index 7fdeabc..1a3851cb 100644 --- a/third_party/blink/renderer/platform/graphics/paint/foreign_layer_display_item.cc +++ b/third_party/blink/renderer/platform/graphics/paint/foreign_layer_display_item.cc
@@ -26,10 +26,11 @@ DOMNodeId OwnerNodeId() const final { return layer_->owner_node_id(); } - LayoutRect VisualRect() const final { + IntRect VisualRect() const final { const auto& offset = layer_->offset_to_transform_parent(); - return LayoutRect(LayoutPoint(offset.x(), offset.y()), - LayoutSize(IntSize(layer_->bounds()))); + const auto& bounds = layer_->bounds(); + return EnclosingIntRect( + FloatRect(offset.x(), offset.y(), bounds.width(), bounds.height())); } cc::Layer* GetLayer() const { return layer_.get(); }
diff --git a/third_party/blink/renderer/platform/graphics/paint/paint_artifact.cc b/third_party/blink/renderer/platform/graphics/paint/paint_artifact.cc index 6d488e2..753fe20 100644 --- a/third_party/blink/renderer/platform/graphics/paint/paint_artifact.cc +++ b/third_party/blink/renderer/platform/graphics/paint/paint_artifact.cc
@@ -58,9 +58,8 @@ item.IsDrawing()) { const auto& drawing = static_cast<const DrawingDisplayItem&>(item); if (drawing.GetPaintRecord() && drawing.KnownToBeOpaque()) { - known_to_be_opaque_region.op( - SkIRect(EnclosedIntRect(drawing.VisualRect())), - SkRegion::kUnion_Op); + known_to_be_opaque_region.op(SkIRect(drawing.VisualRect()), + SkRegion::kUnion_Op); } } @@ -72,7 +71,7 @@ } } - if (known_to_be_opaque_region.contains(EnclosingIntRect(chunk.bounds))) + if (known_to_be_opaque_region.contains(chunk.bounds)) chunk.known_to_be_opaque = true; if (items.begin() != items.end()) { @@ -86,9 +85,7 @@ public: DebugDrawingClient() { Invalidate(PaintInvalidationReason::kUncacheable); } String DebugName() const final { return "DebugDrawing"; } - LayoutRect VisualRect() const final { - return LayoutRect(LayoutRect::InfiniteIntRect()); - } + IntRect VisualRect() const final { return LayoutRect::InfiniteIntRect(); } }; } // namespace
diff --git a/third_party/blink/renderer/platform/graphics/paint/paint_chunk.h b/third_party/blink/renderer/platform/graphics/paint/paint_chunk.h index def3c9f..8747b7fe 100644 --- a/third_party/blink/renderer/platform/graphics/paint/paint_chunk.h +++ b/third_party/blink/renderer/platform/graphics/paint/paint_chunk.h
@@ -7,7 +7,7 @@ #include <iosfwd> #include <memory> -#include "third_party/blink/renderer/platform/geometry/float_rect.h" +#include "third_party/blink/renderer/platform/geometry/int_rect.h" #include "third_party/blink/renderer/platform/graphics/paint/display_item.h" #include "third_party/blink/renderer/platform/graphics/paint/hit_test_data.h" #include "third_party/blink/renderer/platform/graphics/paint/raster_invalidation_tracking.h" @@ -98,7 +98,7 @@ // The total bounds of this paint chunk's contents, in the coordinate space of // the containing transform node. - FloatRect bounds; + IntRect bounds; // Some raster effects can exceed |bounds| in the rasterization space. This // is the maximum DisplayItemClient::VisualRectOutsetForRasterEffects() of
diff --git a/third_party/blink/renderer/platform/graphics/paint/paint_chunker_test.cc b/third_party/blink/renderer/platform/graphics/paint/paint_chunker_test.cc index c9d5e399..2aeedf8f 100644 --- a/third_party/blink/renderer/platform/graphics/paint/paint_chunker_test.cc +++ b/third_party/blink/renderer/platform/graphics/paint/paint_chunker_test.cc
@@ -19,7 +19,7 @@ protected: class TestDisplayItemClient : public DisplayItemClient { String DebugName() const final { return "Test"; } - LayoutRect VisualRect() const final { return LayoutRect(); } + IntRect VisualRect() const final { return IntRect(); } }; TestDisplayItemClient client_; };
diff --git a/third_party/blink/renderer/platform/graphics/paint/paint_controller.cc b/third_party/blink/renderer/platform/graphics/paint/paint_controller.cc index 51241b7..45f00a1 100644 --- a/third_party/blink/renderer/platform/graphics/paint/paint_controller.cc +++ b/third_party/blink/renderer/platform/graphics/paint/paint_controller.cc
@@ -388,8 +388,7 @@ #endif // Ensure our paint invalidation tests don't trigger the less performant // situation which should be rare. - LOG(WARNING) << "Can't find cached display item: " << id.client.DebugName() - << " " << id.ToString(); + DLOG(WARNING) << "Can't find cached display item: " << id; } return kNotFound; } @@ -433,12 +432,11 @@ // Visual rect change should not happen in a cached subsequence. // However, because of different method of pixel snapping in different // paths, there are false positives. Just log an error. - if (cached_item->VisualRect() != - FloatRect(cached_item->Client().VisualRect())) { - LOG(ERROR) << "Visual rect changed in a cached subsequence: " - << cached_item->Client().DebugName() - << " old=" << cached_item->VisualRect().ToString() - << " new=" << cached_item->Client().VisualRect().ToString(); + if (cached_item->VisualRect() != cached_item->Client().VisualRect()) { + DLOG(ERROR) << "Visual rect changed in a cached subsequence: " + << cached_item->Client().DebugName() + << " old=" << cached_item->VisualRect() + << " new=" << cached_item->Client().VisualRect(); } #endif @@ -734,9 +732,8 @@ const auto& chunk = new_paint_chunks_.PaintChunkAt(index); if (chunk.id == id) { ShowDebugData(); - NOTREACHED() << "New paint chunk id " << id.ToString().Utf8().data() - << " has duplicated id with previous chuck " - << chunk.ToString().Utf8().data(); + NOTREACHED() << "New paint chunk id " << id + << " has duplicated id with previous chuck " << chunk; } } }
diff --git a/third_party/blink/renderer/platform/graphics/paint/paint_controller_test.cc b/third_party/blink/renderer/platform/graphics/paint/paint_controller_test.cc index 50aee41..64e5b63 100644 --- a/third_party/blink/renderer/platform/graphics/paint/paint_controller_test.cc +++ b/third_party/blink/renderer/platform/graphics/paint/paint_controller_test.cc
@@ -42,7 +42,7 @@ TEST_P(PaintControllerTest, NestedRecorders) { GraphicsContext context(GetPaintController()); - FakeDisplayItemClient client("client", LayoutRect(100, 100, 200, 200)); + FakeDisplayItemClient client("client", IntRect(100, 100, 200, 200)); InitRootChunk(); DrawRect(context, client, kBackgroundType, FloatRect(100, 100, 200, 200)); @@ -54,8 +54,8 @@ } TEST_P(PaintControllerTest, UpdateBasic) { - FakeDisplayItemClient first("first", LayoutRect(100, 100, 300, 300)); - FakeDisplayItemClient second("second", LayoutRect(100, 100, 200, 200)); + FakeDisplayItemClient first("first", IntRect(100, 100, 300, 300)); + FakeDisplayItemClient second("second", IntRect(100, 100, 200, 200)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -95,9 +95,9 @@ } TEST_P(PaintControllerTest, UpdateSwapOrder) { - FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); - FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); - FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10)); + FakeDisplayItemClient first("first", IntRect(100, 100, 100, 100)); + FakeDisplayItemClient second("second", IntRect(100, 100, 50, 200)); + FakeDisplayItemClient unaffected("unaffected", IntRect(300, 300, 10, 10)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -147,9 +147,9 @@ } TEST_P(PaintControllerTest, UpdateSwapOrderWithInvalidation) { - FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); - FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); - FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10)); + FakeDisplayItemClient first("first", IntRect(100, 100, 100, 100)); + FakeDisplayItemClient second("second", IntRect(100, 100, 50, 200)); + FakeDisplayItemClient unaffected("unaffected", IntRect(300, 300, 10, 10)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -199,9 +199,9 @@ } TEST_P(PaintControllerTest, UpdateNewItemInMiddle) { - FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); - FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); - FakeDisplayItemClient third("third", LayoutRect(125, 100, 200, 50)); + FakeDisplayItemClient first("first", IntRect(100, 100, 100, 100)); + FakeDisplayItemClient second("second", IntRect(100, 100, 50, 200)); + FakeDisplayItemClient third("third", IntRect(125, 100, 200, 50)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -237,9 +237,9 @@ } TEST_P(PaintControllerTest, UpdateInvalidationWithPhases) { - FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); - FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); - FakeDisplayItemClient third("third", LayoutRect(300, 100, 50, 50)); + FakeDisplayItemClient first("first", IntRect(100, 100, 100, 100)); + FakeDisplayItemClient second("second", IntRect(100, 100, 50, 200)); + FakeDisplayItemClient third("third", IntRect(300, 100, 50, 50)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -290,8 +290,8 @@ } TEST_P(PaintControllerTest, UpdateAddFirstOverlap) { - FakeDisplayItemClient first("first", LayoutRect(100, 100, 150, 150)); - FakeDisplayItemClient second("second", LayoutRect(200, 200, 50, 50)); + FakeDisplayItemClient first("first", IntRect(100, 100, 150, 150)); + FakeDisplayItemClient second("second", IntRect(200, 200, 50, 50)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -307,7 +307,7 @@ first.Invalidate(); second.Invalidate(); - second.SetVisualRect(LayoutRect(150, 250, 100, 100)); + second.SetVisualRect(IntRect(150, 250, 100, 100)); DrawRect(context, first, kBackgroundType, FloatRect(100, 100, 150, 150)); DrawRect(context, first, kForegroundType, FloatRect(100, 100, 150, 150)); DrawRect(context, second, kBackgroundType, FloatRect(150, 250, 100, 100)); @@ -344,8 +344,8 @@ } TEST_P(PaintControllerTest, UpdateAddLastOverlap) { - FakeDisplayItemClient first("first", LayoutRect(100, 100, 150, 150)); - FakeDisplayItemClient second("second", LayoutRect(200, 200, 50, 50)); + FakeDisplayItemClient first("first", IntRect(100, 100, 150, 150)); + FakeDisplayItemClient second("second", IntRect(200, 200, 50, 50)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -360,7 +360,7 @@ InitRootChunk(); first.Invalidate(); - first.SetVisualRect(LayoutRect(150, 150, 100, 100)); + first.SetVisualRect(IntRect(150, 150, 100, 100)); second.Invalidate(); DrawRect(context, first, kBackgroundType, FloatRect(150, 150, 100, 100)); DrawRect(context, first, kForegroundType, FloatRect(150, 150, 100, 100)); @@ -379,7 +379,7 @@ InitRootChunk(); first.Invalidate(); - first.SetVisualRect(LayoutRect(100, 100, 150, 150)); + first.SetVisualRect(IntRect(100, 100, 150, 150)); second.Invalidate(); DrawRect(context, first, kBackgroundType, FloatRect(100, 100, 150, 150)); DrawRect(context, first, kForegroundType, FloatRect(100, 100, 150, 150)); @@ -450,12 +450,10 @@ } TEST_P(PaintControllerTest, UpdateSwapOrderWithChildren) { - FakeDisplayItemClient container1("container1", - LayoutRect(100, 100, 100, 100)); - FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); - FakeDisplayItemClient container2("container2", - LayoutRect(100, 200, 100, 100)); - FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); + FakeDisplayItemClient container1("container1", IntRect(100, 100, 100, 100)); + FakeDisplayItemClient content1("content1", IntRect(100, 100, 50, 200)); + FakeDisplayItemClient container2("container2", IntRect(100, 200, 100, 100)); + FakeDisplayItemClient content2("content2", IntRect(100, 200, 50, 200)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -506,12 +504,10 @@ } TEST_P(PaintControllerTest, UpdateSwapOrderWithChildrenAndInvalidation) { - FakeDisplayItemClient container1("container1", - LayoutRect(100, 100, 100, 100)); - FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); - FakeDisplayItemClient container2("container2", - LayoutRect(100, 200, 100, 100)); - FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); + FakeDisplayItemClient container1("container1", IntRect(100, 100, 100, 100)); + FakeDisplayItemClient content1("content1", IntRect(100, 100, 50, 200)); + FakeDisplayItemClient container2("container2", IntRect(100, 200, 100, 100)); + FakeDisplayItemClient content2("content2", IntRect(100, 200, 50, 200)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -619,12 +615,10 @@ } TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder) { - FakeDisplayItemClient container1("container1", - LayoutRect(100, 100, 100, 100)); - FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); - FakeDisplayItemClient container2("container2", - LayoutRect(100, 200, 100, 100)); - FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); + FakeDisplayItemClient container1("container1", IntRect(100, 100, 100, 100)); + FakeDisplayItemClient content1("content1", IntRect(100, 100, 50, 200)); + FakeDisplayItemClient container2("container2", IntRect(100, 200, 100, 100)); + FakeDisplayItemClient content2("content2", IntRect(100, 200, 50, 200)); GraphicsContext context(GetPaintController()); PaintChunk::Id container1_id(container1, kBackgroundType); @@ -771,11 +765,10 @@ } TEST_P(PaintControllerTest, CachedSubsequenceAndDisplayItemsSwapOrder) { - FakeDisplayItemClient root("root", LayoutRect(0, 0, 300, 300)); - FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); - FakeDisplayItemClient container2("container2", - LayoutRect(100, 200, 100, 100)); - FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); + FakeDisplayItemClient root("root", IntRect(0, 0, 300, 300)); + FakeDisplayItemClient content1("content1", IntRect(100, 100, 50, 200)); + FakeDisplayItemClient container2("container2", IntRect(100, 200, 100, 100)); + FakeDisplayItemClient content2("content2", IntRect(100, 200, 50, 200)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -929,12 +922,10 @@ } TEST_P(PaintControllerTest, UpdateSwapOrderCrossingChunks) { - FakeDisplayItemClient container1("container1", - LayoutRect(100, 100, 100, 100)); - FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); - FakeDisplayItemClient container2("container2", - LayoutRect(100, 200, 100, 100)); - FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); + FakeDisplayItemClient container1("container1", IntRect(100, 100, 100, 100)); + FakeDisplayItemClient content1("content1", IntRect(100, 100, 50, 200)); + FakeDisplayItemClient container2("container2", IntRect(100, 200, 100, 100)); + FakeDisplayItemClient content2("content2", IntRect(100, 200, 50, 200)); GraphicsContext context(GetPaintController()); PaintChunk::Id container1_id(container1, kBackgroundType); @@ -1030,12 +1021,10 @@ } TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) { - FakeDisplayItemClient container1("container1", - LayoutRect(100, 100, 100, 100)); - FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); - FakeDisplayItemClient container2("container2", - LayoutRect(100, 200, 100, 100)); - FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); + FakeDisplayItemClient container1("container1", IntRect(100, 100, 100, 100)); + FakeDisplayItemClient content1("content1", IntRect(100, 100, 50, 200)); + FakeDisplayItemClient container2("container2", IntRect(100, 200, 100, 100)); + FakeDisplayItemClient content2("content2", IntRect(100, 200, 50, 200)); GraphicsContext context(GetPaintController()); PaintChunk::Id container1_background_id(container1, kBackgroundType); @@ -1224,8 +1213,8 @@ } TEST_P(PaintControllerTest, SkipCache) { - FakeDisplayItemClient multicol("multicol", LayoutRect(100, 100, 200, 200)); - FakeDisplayItemClient content("content", LayoutRect(100, 100, 100, 100)); + FakeDisplayItemClient multicol("multicol", IntRect(100, 100, 200, 200)); + FakeDisplayItemClient content("content", IntRect(100, 100, 100, 100)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -1484,7 +1473,7 @@ EXPECT_TRUE(GetPaintController().GetPaintArtifact().IsEmpty()); EXPECT_FALSE(GetPaintController().CacheIsAllInvalid()); - FakeDisplayItemClient client("client", LayoutRect(1, 2, 3, 4)); + FakeDisplayItemClient client("client", IntRect(1, 2, 3, 4)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -1499,10 +1488,10 @@ } TEST_P(PaintControllerTest, InsertValidItemInFront) { - FakeDisplayItemClient first("first", LayoutRect(100, 100, 300, 300)); - FakeDisplayItemClient second("second", LayoutRect(100, 100, 200, 200)); - FakeDisplayItemClient third("third", LayoutRect(100, 100, 100, 100)); - FakeDisplayItemClient fourth("fourth", LayoutRect(100, 100, 50, 50)); + FakeDisplayItemClient first("first", IntRect(100, 100, 300, 300)); + FakeDisplayItemClient second("second", IntRect(100, 100, 200, 200)); + FakeDisplayItemClient third("third", IntRect(100, 100, 100, 100)); + FakeDisplayItemClient fourth("fourth", IntRect(100, 100, 50, 50)); GraphicsContext context(GetPaintController()); InitRootChunk(); @@ -1580,7 +1569,7 @@ auto paint_controller = std::make_unique<PaintController>(PaintController::kTransient); GraphicsContext context(*paint_controller); - FakeDisplayItemClient client("client", LayoutRect(100, 100, 50, 50)); + FakeDisplayItemClient client("client", IntRect(100, 100, 50, 50)); InitRootChunk(*paint_controller); DrawRect(context, client, kBackgroundType, FloatRect(100, 100, 50, 50)); // The client of a transient paint controller can abort without @@ -1592,7 +1581,7 @@ if (RuntimeEnabledFeatures::PaintUnderInvalidationCheckingEnabled()) return; - LayoutRect r(100, 100, 300, 300); + IntRect r(100, 100, 300, 300); FakeDisplayItemClient cacheable("cacheable", r); FakeDisplayItemClient uncacheable("uncacheable", r); GraphicsContext context(GetPaintController()); @@ -1631,7 +1620,7 @@ #if defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) TEST_P(PaintControllerTest, DuplicatedSubsequences) { - FakeDisplayItemClient client("test", LayoutRect(100, 100, 100, 100)); + FakeDisplayItemClient client("test", IntRect(100, 100, 100, 100)); GraphicsContext context(GetPaintController()); auto paint_duplicated_subsequences = [&]() { @@ -1691,13 +1680,13 @@ GraphicsContext context(GetPaintController()); InitRootChunk(); - first.SetVisualRect(LayoutRect(100, 100, 300, 300)); + first.SetVisualRect(IntRect(100, 100, 300, 300)); DrawRect(context, first, kBackgroundType, FloatRect(100, 100, 300, 300)); DrawRect(context, first, kForegroundType, FloatRect(100, 100, 300, 300)); CommitAndFinishCycle(); InitRootChunk(); - first.SetVisualRect(LayoutRect(200, 200, 300, 300)); + first.SetVisualRect(IntRect(200, 200, 300, 300)); DrawRect(context, first, kBackgroundType, FloatRect(200, 200, 300, 300)); DrawRect(context, first, kForegroundType, FloatRect(100, 100, 300, 300)); CommitAndFinishCycle(); @@ -1737,7 +1726,7 @@ InitRootChunk(); { SubsequenceRecorder r(context, first); - first.SetVisualRect(LayoutRect(100, 100, 300, 300)); + first.SetVisualRect(IntRect(100, 100, 300, 300)); DrawRect(context, first, kBackgroundType, FloatRect(100, 100, 300, 300)); DrawRect(context, first, kForegroundType, FloatRect(100, 100, 300, 300)); } @@ -1748,7 +1737,7 @@ EXPECT_FALSE( SubsequenceRecorder::UseCachedSubsequenceIfPossible(context, first)); SubsequenceRecorder r(context, first); - first.SetVisualRect(LayoutRect(200, 200, 300, 300)); + first.SetVisualRect(IntRect(200, 200, 300, 300)); DrawRect(context, first, kBackgroundType, FloatRect(200, 200, 300, 300)); DrawRect(context, first, kForegroundType, FloatRect(100, 100, 300, 300)); }
diff --git a/third_party/blink/renderer/platform/graphics/paint/paint_record_builder.h b/third_party/blink/renderer/platform/graphics/paint/paint_record_builder.h index cf06d563..521dd79c 100644 --- a/third_party/blink/renderer/platform/graphics/paint/paint_record_builder.h +++ b/third_party/blink/renderer/platform/graphics/paint/paint_record_builder.h
@@ -58,7 +58,7 @@ // DisplayItemClient methods String DebugName() const final { return "PaintRecordBuilder"; } - LayoutRect VisualRect() const final { return LayoutRect(); } + IntRect VisualRect() const final { return IntRect(); } private: PaintController* paint_controller_;
diff --git a/third_party/blink/renderer/platform/graphics/paint/paint_record_builder_test.cc b/third_party/blink/renderer/platform/graphics/paint/paint_record_builder_test.cc index 712f046..467fb69 100644 --- a/third_party/blink/renderer/platform/graphics/paint/paint_record_builder_test.cc +++ b/third_party/blink/renderer/platform/graphics/paint/paint_record_builder_test.cc
@@ -18,7 +18,7 @@ TEST_F(PaintRecordBuilderTest, TransientPaintController) { PaintRecordBuilder builder; auto& context = builder.Context(); - FakeDisplayItemClient client("client", LayoutRect(10, 10, 20, 20)); + FakeDisplayItemClient client("client", IntRect(10, 10, 20, 20)); DrawRect(context, client, kBackgroundType, FloatRect(10, 10, 20, 20)); DrawRect(context, client, kForegroundType, FloatRect(15, 15, 10, 10)); EXPECT_FALSE(ClientCacheIsValid(context.GetPaintController(), client)); @@ -41,7 +41,7 @@ auto& context = builder.Context(); EXPECT_EQ(&context.GetPaintController(), &GetPaintController()); - FakeDisplayItemClient client("client", LayoutRect(10, 10, 20, 20)); + FakeDisplayItemClient client("client", IntRect(10, 10, 20, 20)); DrawRect(context, client, kBackgroundType, FloatRect(10, 10, 20, 20)); DrawRect(context, client, kForegroundType, FloatRect(15, 15, 10, 10)); EXPECT_FALSE(ClientCacheIsValid(client)); @@ -74,7 +74,7 @@ GraphicsContext context(GetPaintController()); InitRootChunk(); - FakeDisplayItemClient client("client", LayoutRect(10, 10, 20, 20)); + FakeDisplayItemClient client("client", IntRect(10, 10, 20, 20)); DrawRect(context, client, kBackgroundType, FloatRect(10, 10, 20, 20)); DrawRect(context, client, kForegroundType, FloatRect(15, 15, 10, 10)); CommitAndFinishCycle();
diff --git a/third_party/blink/renderer/platform/graphics/paint/raster_invalidator.h b/third_party/blink/renderer/platform/graphics/paint/raster_invalidator.h index 05b2205..237e04d 100644 --- a/third_party/blink/renderer/platform/graphics/paint/raster_invalidator.h +++ b/third_party/blink/renderer/platform/graphics/paint/raster_invalidator.h
@@ -5,6 +5,7 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_PAINT_RASTER_INVALIDATOR_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_PAINT_RASTER_INVALIDATOR_H_ +#include "base/callback.h" #include "third_party/blink/renderer/platform/graphics/compositing/chunk_to_layer_mapper.h" #include "third_party/blink/renderer/platform/graphics/paint/float_clip_rect.h" #include "third_party/blink/renderer/platform/graphics/paint/paint_chunk.h" @@ -23,10 +24,13 @@ USING_FAST_MALLOC(RasterInvalidator); public: - using RasterInvalidationFunction = std::function<void(const IntRect&)>; + using RasterInvalidationFunction = + base::RepeatingCallback<void(const IntRect&)>; RasterInvalidator(RasterInvalidationFunction raster_invalidation_function) - : raster_invalidation_function_(raster_invalidation_function) {} + : raster_invalidation_function_(std::move(raster_invalidation_function)) { + DCHECK(!raster_invalidation_function_.is_null()); + } void SetTracksRasterInvalidations(bool); RasterInvalidationTracking* GetTracking() const { @@ -117,7 +121,7 @@ ClientIsOldOrNew old_or_new) { if (rect.IsEmpty()) return; - raster_invalidation_function_(rect); + raster_invalidation_function_.Run(rect); if (tracking_info_) TrackRasterInvalidation(rect, client, reason, old_or_new); }
diff --git a/third_party/blink/renderer/platform/graphics/paint/raster_invalidator_test.cc b/third_party/blink/renderer/platform/graphics/paint/raster_invalidator_test.cc index 23424ae..08cc153 100644 --- a/third_party/blink/renderer/platform/graphics/paint/raster_invalidator_test.cc +++ b/third_party/blink/renderer/platform/graphics/paint/raster_invalidator_test.cc
@@ -5,6 +5,7 @@ #include "third_party/blink/renderer/platform/graphics/paint/raster_invalidator.h" #include <utility> +#include "base/bind_helpers.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h" #include "third_party/blink/renderer/platform/graphics/paint/paint_artifact.h" @@ -19,6 +20,8 @@ class RasterInvalidatorTest : public testing::Test, public PaintTestConfigurations { public: + RasterInvalidatorTest() : invalidator_(base::DoNothing()) {} + static PropertyTreeState DefaultPropertyTreeState() { return PropertyTreeState::Root(); } @@ -41,25 +44,23 @@ } } - static const Vector<RasterInvalidationInfo> TrackedRasterInvalidations( - RasterInvalidator& invalidator) { - DCHECK(invalidator.GetTracking()); - return invalidator.GetTracking()->Invalidations(); + const Vector<RasterInvalidationInfo>& TrackedRasterInvalidations() { + DCHECK(invalidator_.GetTracking()); + return invalidator_.GetTracking()->Invalidations(); } + using MapFunction = base::RepeatingCallback<void(IntRect&)>; static IntRect ChunkRectToLayer( - const FloatRect& rect, + const IntRect& rect, const IntPoint& layer_offset, - std::function<void(FloatRect&)> mapper = nullptr) { - FloatRect r = rect; - if (mapper) - mapper(r); - r.MoveBy(FloatPoint(layer_offset)); - return EnclosingIntRect(r); + const MapFunction& mapper = base::DoNothing()) { + auto r = rect; + mapper.Run(r); + r.MoveBy(layer_offset); + return r; } - RasterInvalidator::RasterInvalidationFunction kNoopRasterInvalidation = - [](const IntRect& rect) {}; + RasterInvalidator invalidator_; }; INSTANTIATE_PAINT_TEST_SUITE_P(RasterInvalidatorTest); @@ -76,7 +77,8 @@ #define EXPECT_CHUNK_INVALIDATION(invalidations, index, chunk, reason) \ EXPECT_CHUNK_INVALIDATION_CUSTOM(invalidations, index, chunk, reason, \ - -kDefaultLayerBounds.Location(), nullptr) + -kDefaultLayerBounds.Location(), \ + base::DoNothing()) #define EXPECT_INCREMENTAL_INVALIDATION(invalidations, index, chunk, \ chunk_rect) \ @@ -89,67 +91,65 @@ } while (false) TEST_P(RasterInvalidatorTest, ImplicitFullLayerInvalidation) { - RasterInvalidator invalidator(kNoopRasterInvalidation); auto artifact = TestPaintArtifact().Chunk(0).Build(); - invalidator.SetTracksRasterInvalidations(true); - invalidator.Generate(artifact, kDefaultLayerBounds, - DefaultPropertyTreeState()); - const auto& invalidations = TrackedRasterInvalidations(invalidator); + invalidator_.SetTracksRasterInvalidations(true); + invalidator_.Generate(artifact, kDefaultLayerBounds, + DefaultPropertyTreeState()); + const auto& invalidations = TrackedRasterInvalidations(); ASSERT_EQ(1u, invalidations.size()); EXPECT_EQ(IntRect(IntPoint(), kDefaultLayerBounds.Size()), invalidations[0].rect); EXPECT_EQ(PaintInvalidationReason::kFullLayer, invalidations[0].reason); FinishCycle(*artifact); - invalidator.SetTracksRasterInvalidations(false); + invalidator_.SetTracksRasterInvalidations(false); } TEST_P(RasterInvalidatorTest, LayerBounds) { - RasterInvalidator invalidator(kNoopRasterInvalidation); auto artifact = TestPaintArtifact().Chunk(0).Build(); - invalidator.Generate(artifact, kDefaultLayerBounds, - DefaultPropertyTreeState()); + invalidator_.Generate(artifact, kDefaultLayerBounds, + DefaultPropertyTreeState()); FinishCycle(*artifact); - invalidator.SetTracksRasterInvalidations(true); - invalidator.Generate(artifact, kDefaultLayerBounds, - DefaultPropertyTreeState()); + invalidator_.SetTracksRasterInvalidations(true); + invalidator_.Generate(artifact, kDefaultLayerBounds, + DefaultPropertyTreeState()); // No raster invalidations needed if layer origin doesn't change. - EXPECT_TRUE(TrackedRasterInvalidations(invalidator).IsEmpty()); + EXPECT_TRUE(TrackedRasterInvalidations().IsEmpty()); auto new_layer_bounds = kDefaultLayerBounds; new_layer_bounds.Move(66, 77); - invalidator.Generate(artifact, new_layer_bounds, DefaultPropertyTreeState()); + invalidator_.Generate(artifact, new_layer_bounds, DefaultPropertyTreeState()); // Change of layer origin causes change of chunk0's transform to layer. - const auto& invalidations = TrackedRasterInvalidations(invalidator); + const auto& invalidations = TrackedRasterInvalidations(); ASSERT_EQ(2u, invalidations.size()); EXPECT_CHUNK_INVALIDATION(invalidations, 0, artifact->PaintChunks()[0], PaintInvalidationReason::kPaintProperty); EXPECT_CHUNK_INVALIDATION_CUSTOM(invalidations, 1, artifact->PaintChunks()[0], PaintInvalidationReason::kPaintProperty, - -new_layer_bounds.Location(), nullptr); + -new_layer_bounds.Location(), + base::DoNothing()); FinishCycle(*artifact); } TEST_P(RasterInvalidatorTest, ReorderChunks) { - RasterInvalidator invalidator(kNoopRasterInvalidation); auto artifact = TestPaintArtifact().Chunk(0).Chunk(1).Chunk(2).Build(); - invalidator.Generate(artifact, kDefaultLayerBounds, - DefaultPropertyTreeState()); + invalidator_.Generate(artifact, kDefaultLayerBounds, + DefaultPropertyTreeState()); FinishCycle(*artifact); // Swap chunk 1 and 2. - invalidator.SetTracksRasterInvalidations(true); + invalidator_.SetTracksRasterInvalidations(true); auto new_artifact = TestPaintArtifact() .Chunk(0) .Chunk(2) .Chunk(1) - .Bounds(FloatRect(11, 22, 33, 44)) + .Bounds(IntRect(11, 22, 33, 44)) .Build(); - invalidator.Generate(new_artifact, kDefaultLayerBounds, - DefaultPropertyTreeState()); - const auto& invalidations = TrackedRasterInvalidations(invalidator); + invalidator_.Generate(new_artifact, kDefaultLayerBounds, + DefaultPropertyTreeState()); + const auto& invalidations = TrackedRasterInvalidations(); ASSERT_EQ(2u, invalidations.size()); // Invalidated new chunk 2's old (as artifact->PaintChunks()[1]) and new // (as new_artifact->PaintChunks()[2]) bounds. @@ -161,26 +161,25 @@ } TEST_P(RasterInvalidatorTest, ReorderChunkSubsequences) { - RasterInvalidator invalidator(kNoopRasterInvalidation); auto artifact = TestPaintArtifact().Chunk(0).Chunk(1).Chunk(2).Chunk(3).Chunk(4).Build(); - invalidator.Generate(artifact, kDefaultLayerBounds, - DefaultPropertyTreeState()); + invalidator_.Generate(artifact, kDefaultLayerBounds, + DefaultPropertyTreeState()); FinishCycle(*artifact); // Swap chunk (1,2) and (3,4). - invalidator.SetTracksRasterInvalidations(true); + invalidator_.SetTracksRasterInvalidations(true); auto new_artifact = TestPaintArtifact() .Chunk(0) .Chunk(3) .Chunk(4) .Chunk(1) - .Bounds(FloatRect(11, 22, 33, 44)) + .Bounds(IntRect(11, 22, 33, 44)) .Chunk(2) .Build(); - invalidator.Generate(new_artifact, kDefaultLayerBounds, - DefaultPropertyTreeState()); - const auto& invalidations = TrackedRasterInvalidations(invalidator); + invalidator_.Generate(new_artifact, kDefaultLayerBounds, + DefaultPropertyTreeState()); + const auto& invalidations = TrackedRasterInvalidations(); ASSERT_EQ(3u, invalidations.size()); // Invalidated new chunk 3's old (as artifact->PaintChunks()[1] and new // (as new_artifact->PaintChunks()[3]) bounds. @@ -196,18 +195,17 @@ } TEST_P(RasterInvalidatorTest, ChunkAppearAndDisappear) { - RasterInvalidator invalidator(kNoopRasterInvalidation); auto artifact = TestPaintArtifact().Chunk(0).Chunk(1).Chunk(2).Build(); - invalidator.Generate(artifact, kDefaultLayerBounds, - DefaultPropertyTreeState()); + invalidator_.Generate(artifact, kDefaultLayerBounds, + DefaultPropertyTreeState()); FinishCycle(*artifact); // Chunk 1 and 2 disappeared, 3 and 4 appeared. - invalidator.SetTracksRasterInvalidations(true); + invalidator_.SetTracksRasterInvalidations(true); auto new_artifact = TestPaintArtifact().Chunk(0).Chunk(3).Chunk(4).Build(); - invalidator.Generate(new_artifact, kDefaultLayerBounds, - DefaultPropertyTreeState()); - const auto& invalidations = TrackedRasterInvalidations(invalidator); + invalidator_.Generate(new_artifact, kDefaultLayerBounds, + DefaultPropertyTreeState()); + const auto& invalidations = TrackedRasterInvalidations(); ASSERT_EQ(4u, invalidations.size()); EXPECT_CHUNK_INVALIDATION(invalidations, 0, new_artifact->PaintChunks()[1], PaintInvalidationReason::kChunkAppeared); @@ -221,17 +219,16 @@ } TEST_P(RasterInvalidatorTest, ChunkAppearAtEnd) { - RasterInvalidator invalidator(kNoopRasterInvalidation); auto artifact = TestPaintArtifact().Chunk(0).Build(); - invalidator.Generate(artifact, kDefaultLayerBounds, - DefaultPropertyTreeState()); + invalidator_.Generate(artifact, kDefaultLayerBounds, + DefaultPropertyTreeState()); FinishCycle(*artifact); - invalidator.SetTracksRasterInvalidations(true); + invalidator_.SetTracksRasterInvalidations(true); auto new_artifact = TestPaintArtifact().Chunk(0).Chunk(1).Chunk(2).Build(); - invalidator.Generate(new_artifact, kDefaultLayerBounds, - DefaultPropertyTreeState()); - const auto& invalidations = TrackedRasterInvalidations(invalidator); + invalidator_.Generate(new_artifact, kDefaultLayerBounds, + DefaultPropertyTreeState()); + const auto& invalidations = TrackedRasterInvalidations(); ASSERT_EQ(2u, invalidations.size()); EXPECT_CHUNK_INVALIDATION(invalidations, 0, new_artifact->PaintChunks()[1], PaintInvalidationReason::kChunkAppeared); @@ -241,20 +238,19 @@ } TEST_P(RasterInvalidatorTest, UncacheableChunks) { - RasterInvalidator invalidator(kNoopRasterInvalidation); auto artifact = TestPaintArtifact().Chunk(0).Chunk(1).Uncacheable().Chunk(2).Build(); - invalidator.Generate(artifact, kDefaultLayerBounds, - DefaultPropertyTreeState()); + invalidator_.Generate(artifact, kDefaultLayerBounds, + DefaultPropertyTreeState()); FinishCycle(*artifact); - invalidator.SetTracksRasterInvalidations(true); + invalidator_.SetTracksRasterInvalidations(true); auto new_artifact = TestPaintArtifact().Chunk(0).Chunk(2).Chunk(1).Uncacheable().Build(); - invalidator.Generate(new_artifact, kDefaultLayerBounds, - DefaultPropertyTreeState()); - const auto& invalidations = TrackedRasterInvalidations(invalidator); + invalidator_.Generate(new_artifact, kDefaultLayerBounds, + DefaultPropertyTreeState()); + const auto& invalidations = TrackedRasterInvalidations(); ASSERT_EQ(2u, invalidations.size()); EXPECT_CHUNK_INVALIDATION(invalidations, 0, new_artifact->PaintChunks()[2], PaintInvalidationReason::kChunkUncacheable); @@ -265,7 +261,6 @@ // Tests the path based on ClipPaintPropertyNode::Changed(). TEST_P(RasterInvalidatorTest, ClipPropertyChangeRounded) { - RasterInvalidator invalidator(kNoopRasterInvalidation); FloatRoundedRect::Radii radii(FloatSize(1, 2), FloatSize(2, 3), FloatSize(3, 4), FloatSize(4, 5)); FloatRoundedRect clip_rect(FloatRect(-1000, -1000, 2000, 2000), radii); @@ -282,11 +277,11 @@ .Properties(t0(), *clip2, e0()) .Build(); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); FinishCycle(*artifact); // Change both clip0 and clip2. - invalidator.SetTracksRasterInvalidations(true); + invalidator_.SetTracksRasterInvalidations(true); FloatRoundedRect new_clip_rect(FloatRect(-2000, -2000, 4000, 4000), radii); clip0->Update(*clip0->Parent(), ClipPaintPropertyNode::State{&clip0->LocalTransformSpace(), @@ -295,14 +290,14 @@ ClipPaintPropertyNode::State{&clip2->LocalTransformSpace(), new_clip_rect}); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - const auto& invalidations = TrackedRasterInvalidations(invalidator); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + const auto& invalidations = TrackedRasterInvalidations(); ASSERT_EQ(1u, invalidations.size()); // Property change in the layer state should not trigger raster invalidation. // |clip2| change should trigger raster invalidation. EXPECT_CHUNK_INVALIDATION(invalidations, 0, artifact->PaintChunks()[2], PaintInvalidationReason::kPaintProperty); - invalidator.SetTracksRasterInvalidations(false); + invalidator_.SetTracksRasterInvalidations(false); FinishCycle(*artifact); // Change chunk1's properties to use a different property tree state. @@ -315,19 +310,18 @@ .Properties(artifact->PaintChunks()[2].properties) .Build(); - invalidator.SetTracksRasterInvalidations(true); - invalidator.Generate(new_artifact1, kDefaultLayerBounds, layer_state); - const auto& invalidations1 = TrackedRasterInvalidations(invalidator); + invalidator_.SetTracksRasterInvalidations(true); + invalidator_.Generate(new_artifact1, kDefaultLayerBounds, layer_state); + const auto& invalidations1 = TrackedRasterInvalidations(); ASSERT_EQ(1u, invalidations1.size()); EXPECT_CHUNK_INVALIDATION(invalidations1, 0, new_artifact1->PaintChunks()[1], PaintInvalidationReason::kPaintProperty); - invalidator.SetTracksRasterInvalidations(false); + invalidator_.SetTracksRasterInvalidations(false); FinishCycle(*new_artifact1); } // Tests the path detecting change of PaintChunkInfo::chunk_to_layer_clip. TEST_P(RasterInvalidatorTest, ClipPropertyChangeSimple) { - RasterInvalidator invalidator(kNoopRasterInvalidation); FloatRoundedRect clip_rect(-1000, -1000, 2000, 2000); auto clip0 = CreateClip(c0(), t0(), clip_rect); auto clip1 = CreateClip(*clip0, t0(), clip_rect); @@ -336,25 +330,25 @@ auto artifact = TestPaintArtifact() .Chunk(0) .Properties(t0(), *clip0, e0()) - .Bounds(clip_rect.Rect()) + .Bounds(EnclosingIntRect(clip_rect.Rect())) .Chunk(1) .Properties(t0(), *clip1, e0()) - .Bounds(clip_rect.Rect()) + .Bounds(EnclosingIntRect(clip_rect.Rect())) .Build(); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); FinishCycle(*artifact); // Change clip1 to bigger, which is still bound by clip0, resulting no actual // visual change. - invalidator.SetTracksRasterInvalidations(true); + invalidator_.SetTracksRasterInvalidations(true); FloatRoundedRect new_clip_rect1(-2000, -2000, 4000, 4000); clip1->Update(*clip1->Parent(), ClipPaintPropertyNode::State{&clip1->LocalTransformSpace(), new_clip_rect1}); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - EXPECT_TRUE(TrackedRasterInvalidations(invalidator).IsEmpty()); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + EXPECT_TRUE(TrackedRasterInvalidations().IsEmpty()); FinishCycle(*artifact); // Change clip1 to smaller. @@ -363,19 +357,19 @@ ClipPaintPropertyNode::State{&clip1->LocalTransformSpace(), new_clip_rect2}); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - const auto& invalidations = TrackedRasterInvalidations(invalidator); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + const auto& invalidations = TrackedRasterInvalidations(); ASSERT_EQ(4u, invalidations.size()); // |clip1| change should trigger incremental raster invalidation. EXPECT_INCREMENTAL_INVALIDATION(invalidations, 0, artifact->PaintChunks()[1], - FloatRect(-1000, -1000, 2000, 500)); + IntRect(-1000, -1000, 2000, 500)); EXPECT_INCREMENTAL_INVALIDATION(invalidations, 1, artifact->PaintChunks()[1], - FloatRect(-1000, -500, 500, 1000)); + IntRect(-1000, -500, 500, 1000)); EXPECT_INCREMENTAL_INVALIDATION(invalidations, 2, artifact->PaintChunks()[1], - FloatRect(500, -500, 500, 1000)); + IntRect(500, -500, 500, 1000)); EXPECT_INCREMENTAL_INVALIDATION(invalidations, 3, artifact->PaintChunks()[1], - FloatRect(-1000, 500, 2000, 500)); - invalidator.SetTracksRasterInvalidations(false); + IntRect(-1000, 500, 2000, 500)); + invalidator_.SetTracksRasterInvalidations(false); FinishCycle(*artifact); // Change clip1 bigger at one side. @@ -384,20 +378,18 @@ ClipPaintPropertyNode::State{&clip1->LocalTransformSpace(), new_clip_rect3}); - invalidator.SetTracksRasterInvalidations(true); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - const auto& invalidations1 = TrackedRasterInvalidations(invalidator); + invalidator_.SetTracksRasterInvalidations(true); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + const auto& invalidations1 = TrackedRasterInvalidations(); ASSERT_EQ(1u, invalidations1.size()); // |clip1| change should trigger incremental raster invalidation. EXPECT_INCREMENTAL_INVALIDATION(invalidations1, 0, artifact->PaintChunks()[1], - FloatRect(500, -500, 500, 1000)); - invalidator.SetTracksRasterInvalidations(false); + IntRect(500, -500, 500, 1000)); + invalidator_.SetTracksRasterInvalidations(false); FinishCycle(*artifact); } TEST_P(RasterInvalidatorTest, ClipLocalTransformSpaceChange) { - RasterInvalidator invalidator(kNoopRasterInvalidation); - auto t1 = CreateTransform(t0(), TransformationMatrix()); auto t2 = CreateTransform(*t1, TransformationMatrix()); @@ -410,29 +402,27 @@ auto artifact = TestPaintArtifact().Chunk(0).Properties(*t2, *c1, e0()).Build(); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); FinishCycle(*artifact); // Change both t1 and t2 but keep t1*t2 unchanged, to test change of // LocalTransformSpace of c1. - invalidator.SetTracksRasterInvalidations(true); + invalidator_.SetTracksRasterInvalidations(true); t1->Update(t0(), TransformPaintPropertyNode::State{FloatSize(-10, -20)}); t2->Update(*t1, TransformPaintPropertyNode::State{FloatSize(10, 20)}); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - const auto& invalidations = TrackedRasterInvalidations(invalidator); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + const auto& invalidations = TrackedRasterInvalidations(); ASSERT_EQ(1u, invalidations.size()); EXPECT_CHUNK_INVALIDATION(invalidations, 0, artifact->PaintChunks()[0], PaintInvalidationReason::kPaintProperty); - invalidator.SetTracksRasterInvalidations(false); + invalidator_.SetTracksRasterInvalidations(false); } // This is based on ClipLocalTransformSpaceChange, but tests the no-invalidation // path by letting the clip's LocalTransformSpace be the same as the chunk's // transform. TEST_P(RasterInvalidatorTest, ClipLocalTransformSpaceChangeNoInvalidation) { - RasterInvalidator invalidator(kNoopRasterInvalidation); - auto t1 = CreateTransform(t0(), TransformationMatrix()); auto t2 = CreateTransform(*t1, TransformationMatrix()); @@ -446,22 +436,20 @@ auto artifact = TestPaintArtifact().Chunk(0).Properties(*t2, *c1, e0()).Build(); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); FinishCycle(*artifact); // Change both t1 and t2 but keep t1*t2 unchanged. - invalidator.SetTracksRasterInvalidations(true); + invalidator_.SetTracksRasterInvalidations(true); t1->Update(t0(), TransformPaintPropertyNode::State{FloatSize(-10, -20)}); t2->Update(*t1, TransformPaintPropertyNode::State{FloatSize(10, 20)}); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - EXPECT_TRUE(TrackedRasterInvalidations(invalidator).IsEmpty()); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + EXPECT_TRUE(TrackedRasterInvalidations().IsEmpty()); FinishCycle(*artifact); } TEST_P(RasterInvalidatorTest, TransformPropertyChange) { - RasterInvalidator invalidator(kNoopRasterInvalidation); - auto layer_transform = CreateTransform(t0(), TransformationMatrix().Scale(5)); auto transform0 = Create2DTranslation(*layer_transform, 10, 20); auto transform1 = Create2DTranslation(*transform0, -50, -60); @@ -474,17 +462,17 @@ .Properties(*transform1, c0(), e0()) .Build(); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); FinishCycle(*artifact); // Change layer_transform should not cause raster invalidation in the layer. - invalidator.SetTracksRasterInvalidations(true); + invalidator_.SetTracksRasterInvalidations(true); layer_transform->Update( *layer_transform->Parent(), TransformPaintPropertyNode::State{TransformationMatrix().Scale(10)}); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - EXPECT_TRUE(TrackedRasterInvalidations(invalidator).IsEmpty()); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + EXPECT_TRUE(TrackedRasterInvalidations().IsEmpty()); FinishCycle(*artifact); // Inserting another node between layer_transform and transform0 and letting @@ -496,8 +484,8 @@ transform0->Update(*new_layer_transform, TransformPaintPropertyNode::State{ transform0->Translation2D()}); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - EXPECT_TRUE(TrackedRasterInvalidations(invalidator).IsEmpty()); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + EXPECT_TRUE(TrackedRasterInvalidations().IsEmpty()); FinishCycle(*artifact); // Removing transform nodes above the layer state should not cause raster @@ -506,8 +494,8 @@ transform0->Update(layer_state.Transform(), TransformPaintPropertyNode::State{ transform0->Translation2D()}); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - EXPECT_TRUE(TrackedRasterInvalidations(invalidator).IsEmpty()); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + EXPECT_TRUE(TrackedRasterInvalidations().IsEmpty()); FinishCycle(*artifact); // Change transform0 and transform1, while keeping the combined transform0 @@ -520,24 +508,24 @@ TransformPaintPropertyNode::State{ transform1->Translation2D() + FloatSize(-20, -30)}); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - const auto& invalidations = TrackedRasterInvalidations(invalidator); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + const auto& invalidations = TrackedRasterInvalidations(); ASSERT_EQ(2u, invalidations.size()); - auto mapper0 = [](FloatRect& r) { r.Move(10, 20); }; + auto mapper0 = [](IntRect& r) { r.Move(10, 20); }; EXPECT_CHUNK_INVALIDATION_CUSTOM(invalidations, 0, artifact->PaintChunks()[0], PaintInvalidationReason::kPaintProperty, - -kDefaultLayerBounds.Location(), mapper0); - auto mapper1 = [](FloatRect& r) { r.Move(30, 50); }; + -kDefaultLayerBounds.Location(), + base::BindRepeating(mapper0)); + auto mapper1 = [](IntRect& r) { r.Move(30, 50); }; EXPECT_CHUNK_INVALIDATION_CUSTOM(invalidations, 1, artifact->PaintChunks()[0], PaintInvalidationReason::kPaintProperty, - -kDefaultLayerBounds.Location(), mapper1); - invalidator.SetTracksRasterInvalidations(false); + -kDefaultLayerBounds.Location(), + base::BindRepeating(mapper1)); + invalidator_.SetTracksRasterInvalidations(false); FinishCycle(*artifact); } TEST_P(RasterInvalidatorTest, TransformPropertyTinyChange) { - RasterInvalidator invalidator(kNoopRasterInvalidation); - auto layer_transform = CreateTransform(t0(), TransformationMatrix().Scale(5)); auto chunk_transform = Create2DTranslation(*layer_transform, 10, 20); @@ -547,11 +535,11 @@ .Properties(*chunk_transform, c0(), e0()) .Build(); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); FinishCycle(*artifact); // Change chunk_transform by tiny difference, which should be ignored. - invalidator.SetTracksRasterInvalidations(true); + invalidator_.SetTracksRasterInvalidations(true); chunk_transform->Update( layer_state.Transform(), TransformPaintPropertyNode::State{chunk_transform->SlowMatrix() @@ -559,8 +547,8 @@ .Scale(1.0000001) .Rotate(0.0000001)}); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - EXPECT_TRUE(TrackedRasterInvalidations(invalidator).IsEmpty()); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + EXPECT_TRUE(TrackedRasterInvalidations().IsEmpty()); FinishCycle(*artifact); // Tiny differences should accumulate and cause invalidation when the @@ -573,20 +561,18 @@ .Translate(0.0000001, -0.0000001) .Scale(1.0000001) .Rotate(0.0000001)}); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - invalidated = !TrackedRasterInvalidations(invalidator).IsEmpty(); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + invalidated = !TrackedRasterInvalidations().IsEmpty(); FinishCycle(*artifact); } EXPECT_TRUE(invalidated); } TEST_P(RasterInvalidatorTest, TransformPropertyTinyChangeScale) { - RasterInvalidator invalidator(kNoopRasterInvalidation); - auto layer_transform = CreateTransform(t0(), TransformationMatrix().Scale(5)); auto chunk_transform = CreateTransform(*layer_transform, TransformationMatrix().Scale(1e-6)); - FloatRect chunk_bounds(0, 0, 10000000, 10000000); + IntRect chunk_bounds(0, 0, 10000000, 10000000); PropertyTreeState layer_state(*layer_transform, c0(), e0()); auto artifact = TestPaintArtifact() @@ -595,35 +581,33 @@ .Bounds(chunk_bounds) .Build(); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); FinishCycle(*artifact); // Scale change from 1e-6 to 2e-6 should be treated as significant. - invalidator.SetTracksRasterInvalidations(true); + invalidator_.SetTracksRasterInvalidations(true); chunk_transform->Update( layer_state.Transform(), TransformPaintPropertyNode::State{TransformationMatrix().Scale(2e-6)}); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - EXPECT_FALSE(TrackedRasterInvalidations(invalidator).IsEmpty()); - invalidator.SetTracksRasterInvalidations(false); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + EXPECT_FALSE(TrackedRasterInvalidations().IsEmpty()); + invalidator_.SetTracksRasterInvalidations(false); FinishCycle(*artifact); // Scale change from 2e-6 to 2e-6 + 1e-15 should be ignored. - invalidator.SetTracksRasterInvalidations(true); + invalidator_.SetTracksRasterInvalidations(true); chunk_transform->Update(layer_state.Transform(), TransformPaintPropertyNode::State{ TransformationMatrix().Scale(2e-6 + 1e-15)}); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - EXPECT_TRUE(TrackedRasterInvalidations(invalidator).IsEmpty()); - invalidator.SetTracksRasterInvalidations(false); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + EXPECT_TRUE(TrackedRasterInvalidations().IsEmpty()); + invalidator_.SetTracksRasterInvalidations(false); FinishCycle(*artifact); } TEST_P(RasterInvalidatorTest, EffectLocalTransformSpaceChange) { - RasterInvalidator invalidator(kNoopRasterInvalidation); - auto t1 = CreateTransform(t0(), TransformationMatrix()); auto t2 = CreateTransform(*t1, TransformationMatrix()); CompositorFilterOperations filter; @@ -634,23 +618,24 @@ auto artifact = TestPaintArtifact().Chunk(0).Properties(*t2, c0(), *e1).Build(); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); FinishCycle(*artifact); // Change both t1 and t2 but keep t1*t2 unchanged, to test change of // LocalTransformSpace of e1. - invalidator.SetTracksRasterInvalidations(true); + invalidator_.SetTracksRasterInvalidations(true); t1->Update(t0(), TransformPaintPropertyNode::State{FloatSize(-10, -20)}); t2->Update(*t1, TransformPaintPropertyNode::State{FloatSize(10, 20)}); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - const auto& invalidations = TrackedRasterInvalidations(invalidator); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + const auto& invalidations = TrackedRasterInvalidations(); ASSERT_EQ(1u, invalidations.size()); - auto mapper = [](FloatRect& r) { r.Inflate(60); }; + auto mapper = [](IntRect& r) { r.Inflate(60); }; EXPECT_CHUNK_INVALIDATION_CUSTOM(invalidations, 0, artifact->PaintChunks()[0], PaintInvalidationReason::kPaintProperty, - -kDefaultLayerBounds.Location(), mapper); - invalidator.SetTracksRasterInvalidations(false); + -kDefaultLayerBounds.Location(), + base::BindRepeating(mapper)); + invalidator_.SetTracksRasterInvalidations(false); FinishCycle(*artifact); } @@ -658,8 +643,6 @@ // invalidation path by letting the effect's LocalTransformSpace be the same as // the chunk's transform. TEST_P(RasterInvalidatorTest, EffectLocalTransformSpaceChangeNoInvalidation) { - RasterInvalidator invalidator(kNoopRasterInvalidation); - auto t1 = CreateTransform(t0(), TransformationMatrix()); auto t2 = CreateTransform(*t1, TransformationMatrix()); // This setup is different from EffectLocalTransformSpaceChange. @@ -671,22 +654,20 @@ auto artifact = TestPaintArtifact().Chunk(0).Properties(*t2, c0(), *e1).Build(); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); FinishCycle(*artifact); // Change both t1 and t2 but keep t1*t2 unchanged. - invalidator.SetTracksRasterInvalidations(true); + invalidator_.SetTracksRasterInvalidations(true); t1->Update(t0(), TransformPaintPropertyNode::State{FloatSize(-10, -20)}); t2->Update(*t1, TransformPaintPropertyNode::State{FloatSize(10, 20)}); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - EXPECT_TRUE(TrackedRasterInvalidations(invalidator).IsEmpty()); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + EXPECT_TRUE(TrackedRasterInvalidations().IsEmpty()); FinishCycle(*artifact); } TEST_P(RasterInvalidatorTest, AliasEffectParentChanges) { - RasterInvalidator invalidator(kNoopRasterInvalidation); - CompositorFilterOperations filter; filter.AppendOpacityFilter(0.5); // Create an effect and an alias for that effect. @@ -698,18 +679,18 @@ PropertyTreeState chunk_state(t0(), c0(), *alias_effect); auto artifact = TestPaintArtifact().Chunk(0).Properties(chunk_state).Build(); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); FinishCycle(*artifact); - invalidator.SetTracksRasterInvalidations(true); + invalidator_.SetTracksRasterInvalidations(true); // Reparent the aliased effect, so the chunk doesn't change the actual alias // node, but its parent is now different. alias_effect->Update(e0(), EffectPaintPropertyNode::State{}); // We expect to get invalidations since the effect unaliased effect is // actually different now. - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - const auto& invalidations = TrackedRasterInvalidations(invalidator); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + const auto& invalidations = TrackedRasterInvalidations(); ASSERT_EQ(1u, invalidations.size()); EXPECT_CHUNK_INVALIDATION(invalidations, 0, artifact->PaintChunks()[0], PaintInvalidationReason::kPaintProperty); @@ -717,8 +698,6 @@ } TEST_P(RasterInvalidatorTest, NestedAliasEffectParentChanges) { - RasterInvalidator invalidator(kNoopRasterInvalidation); - CompositorFilterOperations filter; filter.AppendOpacityFilter(0.5); // Create an effect and an alias for that effect. @@ -731,10 +710,10 @@ PropertyTreeState chunk_state(t0(), c0(), *alias_effect_2); auto artifact = TestPaintArtifact().Chunk(0).Properties(chunk_state).Build(); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); FinishCycle(*artifact); - invalidator.SetTracksRasterInvalidations(true); + invalidator_.SetTracksRasterInvalidations(true); // Reparent the parent aliased effect, so the chunk doesn't change the actual // alias node, but its parent is now different, this also ensures that the // nested alias is unchanged. @@ -742,8 +721,8 @@ // We expect to get invalidations since the effect unaliased effect is // actually different now. - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - const auto& invalidations = TrackedRasterInvalidations(invalidator); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + const auto& invalidations = TrackedRasterInvalidations(); ASSERT_EQ(1u, invalidations.size()); EXPECT_CHUNK_INVALIDATION(invalidations, 0, artifact->PaintChunks()[0], PaintInvalidationReason::kPaintProperty); @@ -751,8 +730,6 @@ } TEST_P(RasterInvalidatorTest, EffectWithAliasTransformWhoseParentChanges) { - RasterInvalidator invalidator(kNoopRasterInvalidation); - auto t1 = CreateTransform(t0(), TransformationMatrix().Scale(5)); auto alias_transform = TransformPaintPropertyNode::CreateAlias(*t1); @@ -766,21 +743,22 @@ PropertyTreeState chunk_state(t0(), c0(), *e1); auto artifact = TestPaintArtifact().Chunk(0).Properties(chunk_state).Build(); - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); FinishCycle(*artifact); - invalidator.SetTracksRasterInvalidations(true); + invalidator_.SetTracksRasterInvalidations(true); // Reparent the aliased effect, so the chunk doesn't change the actual alias // node, but its parent is now different. alias_transform->Update(t0(), TransformPaintPropertyNode::State{}); // We expect to get invalidations since the effect unaliased effect is // actually different now. - invalidator.Generate(artifact, kDefaultLayerBounds, layer_state); - const auto& invalidations = TrackedRasterInvalidations(invalidator); + invalidator_.Generate(artifact, kDefaultLayerBounds, layer_state); + const auto& invalidations = TrackedRasterInvalidations(); ASSERT_EQ(1u, invalidations.size()); EXPECT_CHUNK_INVALIDATION(invalidations, 0, artifact->PaintChunks()[0], PaintInvalidationReason::kPaintProperty); FinishCycle(*artifact); } + } // namespace blink
diff --git a/third_party/blink/renderer/platform/scheduler/common/cooperative_scheduling_manager.cc b/third_party/blink/renderer/platform/scheduler/common/cooperative_scheduling_manager.cc index 2fb53b5..3fee359c 100644 --- a/third_party/blink/renderer/platform/scheduler/common/cooperative_scheduling_manager.cc +++ b/third_party/blink/renderer/platform/scheduler/common/cooperative_scheduling_manager.cc
@@ -27,30 +27,31 @@ return &(*manager); } -CooperativeSchedulingManager::WhitelistedStackScope::WhitelistedStackScope( - CooperativeSchedulingManager* manager) { - cooperative_scheduling_manager_ = manager; - cooperative_scheduling_manager_->EnterWhitelistedStackScope(); +CooperativeSchedulingManager::AllowedStackScope::AllowedStackScope( + CooperativeSchedulingManager* manager) + : cooperative_scheduling_manager_(manager) { + DCHECK(cooperative_scheduling_manager_); + cooperative_scheduling_manager_->EnterAllowedStackScope(); } -CooperativeSchedulingManager::WhitelistedStackScope::~WhitelistedStackScope() { - cooperative_scheduling_manager_->LeaveWhitelistedStackScope(); +CooperativeSchedulingManager::AllowedStackScope::~AllowedStackScope() { + cooperative_scheduling_manager_->LeaveAllowedStackScope(); } CooperativeSchedulingManager::CooperativeSchedulingManager() {} -void CooperativeSchedulingManager::EnterWhitelistedStackScope() { - TRACE_EVENT_ASYNC_BEGIN0("renderer.scheduler", - "PreemptionWhitelistedStackScope", this); +void CooperativeSchedulingManager::EnterAllowedStackScope() { + TRACE_EVENT_ASYNC_BEGIN0("renderer.scheduler", "PreemptionAllowedStackScope", + this); - whitelisted_stack_scope_depth_++; + allowed_stack_scope_depth_++; } -void CooperativeSchedulingManager::LeaveWhitelistedStackScope() { - TRACE_EVENT_ASYNC_END0("renderer.scheduler", - "PreemptionWhitelistedStackScope", this); - whitelisted_stack_scope_depth_--; - DCHECK_GE(whitelisted_stack_scope_depth_, 0); +void CooperativeSchedulingManager::LeaveAllowedStackScope() { + TRACE_EVENT_ASYNC_END0("renderer.scheduler", "PreemptionAllowedStackScope", + this); + allowed_stack_scope_depth_--; + DCHECK_GE(allowed_stack_scope_depth_, 0); } void CooperativeSchedulingManager::SafepointSlow() {
diff --git a/third_party/blink/renderer/platform/scheduler/common/cooperative_scheduling_manager_unittest.cc b/third_party/blink/renderer/platform/scheduler/common/cooperative_scheduling_manager_unittest.cc index 43654f0..21da079 100644 --- a/third_party/blink/renderer/platform/scheduler/common/cooperative_scheduling_manager_unittest.cc +++ b/third_party/blink/renderer/platform/scheduler/common/cooperative_scheduling_manager_unittest.cc
@@ -11,21 +11,21 @@ namespace blink { namespace scheduler { -TEST(CooperativeSchedulingManager, WhitelistedStackScope) { +TEST(CooperativeSchedulingManager, AllowedStackScope) { std::unique_ptr<CooperativeSchedulingManager> manager = std::make_unique<CooperativeSchedulingManager>(); { - EXPECT_FALSE(manager->InWhitelistedStackScope()); - CooperativeSchedulingManager::WhitelistedStackScope scope(manager.get()); - EXPECT_TRUE(manager->InWhitelistedStackScope()); + EXPECT_FALSE(manager->InAllowedStackScope()); + CooperativeSchedulingManager::AllowedStackScope scope(manager.get()); + EXPECT_TRUE(manager->InAllowedStackScope()); { - CooperativeSchedulingManager::WhitelistedStackScope nested_scope( + CooperativeSchedulingManager::AllowedStackScope nested_scope( manager.get()); - EXPECT_TRUE(manager->InWhitelistedStackScope()); + EXPECT_TRUE(manager->InAllowedStackScope()); } - EXPECT_TRUE(manager->InWhitelistedStackScope()); + EXPECT_TRUE(manager->InAllowedStackScope()); } - EXPECT_FALSE(manager->InWhitelistedStackScope()); + EXPECT_FALSE(manager->InAllowedStackScope()); } class MockCooperativeSchedulingManager : public CooperativeSchedulingManager { @@ -45,14 +45,14 @@ std::unique_ptr<MockCooperativeSchedulingManager> manager = std::make_unique<MockCooperativeSchedulingManager>(); EXPECT_CALL(*manager, RunNestedLoop()).Times(0); - // Should not run nested loop because stack is not whitelisted + // Should not run nested loop since there is no AllowedStackScope instance. manager->Safepoint(); } { WTF::ScopedMockClock clock; std::unique_ptr<MockCooperativeSchedulingManager> manager = std::make_unique<MockCooperativeSchedulingManager>(); - CooperativeSchedulingManager::WhitelistedStackScope scope(manager.get()); + CooperativeSchedulingManager::AllowedStackScope scope(manager.get()); EXPECT_CALL(*manager, RunNestedLoop()).Times(2); // Should run nested loop manager->Safepoint();
diff --git a/third_party/blink/renderer/platform/scheduler/common/idle_helper_unittest.cc b/third_party/blink/renderer/platform/scheduler/common/idle_helper_unittest.cc index cf1205d..55b430a 100644 --- a/third_party/blink/renderer/platform/scheduler/common/idle_helper_unittest.cc +++ b/third_party/blink/renderer/platform/scheduler/common/idle_helper_unittest.cc
@@ -178,21 +178,21 @@ : message_loop_(std::move(message_loop)), test_task_runner_(base::MakeRefCounted<base::TestMockTimeTaskRunner>( base::TestMockTimeTaskRunner::Type::kStandalone)) { - std::unique_ptr<SequenceManager> sequence_manager; if (!message_loop_) { - sequence_manager = base::sequence_manager::SequenceManagerForTest::Create( - nullptr, test_task_runner_, test_task_runner_->GetMockTickClock()); + sequence_manager_ = + base::sequence_manager::SequenceManagerForTest::Create( + nullptr, test_task_runner_, + test_task_runner_->GetMockTickClock()); } else { // It's okay to use |test_task_runner_| just as a mock clock because // it isn't bound to thread and all tasks will go through a MessageLoop. - sequence_manager = + sequence_manager_ = base::sequence_manager::SequenceManagerForTest::CreateOnCurrentThread( SequenceManager::Settings{ .clock = test_task_runner_->GetMockTickClock()}); } - sequence_manager_ = sequence_manager.get(); scheduler_helper_ = std::make_unique<NonMainThreadSchedulerHelper>( - std::move(sequence_manager), nullptr, TaskType::kInternalTest); + sequence_manager_.get(), nullptr, TaskType::kInternalTest); idle_helper_ = std::make_unique<IdleHelperForTest>( scheduler_helper_.get(), required_quiescence_duration_before_long_idle_period, @@ -221,7 +221,7 @@ test_task_runner_->FastForwardUntilNoTasksRemain(); } - SequenceManager* sequence_manager() const { return sequence_manager_; } + SequenceManager* sequence_manager() const { return sequence_manager_.get(); } template <typename E> static void CallForEachEnumValue(E first, @@ -276,8 +276,8 @@ std::unique_ptr<base::MessageLoop> message_loop_; scoped_refptr<base::TestMockTimeTaskRunner> test_task_runner_; + std::unique_ptr<SequenceManager> sequence_manager_; std::unique_ptr<NonMainThreadSchedulerHelper> scheduler_helper_; - SequenceManager* sequence_manager_; // Owned by scheduler_helper_. std::unique_ptr<IdleHelperForTest> idle_helper_; scoped_refptr<base::sequence_manager::TaskQueue> default_task_queue_; scoped_refptr<base::SingleThreadTaskRunner> default_task_runner_;
diff --git a/third_party/blink/renderer/platform/scheduler/common/scheduler_helper.cc b/third_party/blink/renderer/platform/scheduler/common/scheduler_helper.cc index 6e1e5b0..3a29b803 100644 --- a/third_party/blink/renderer/platform/scheduler/common/scheduler_helper.cc +++ b/third_party/blink/renderer/platform/scheduler/common/scheduler_helper.cc
@@ -21,9 +21,8 @@ using base::sequence_manager::TaskTimeObserver; using base::sequence_manager::TimeDomain; -SchedulerHelper::SchedulerHelper( - std::unique_ptr<SequenceManager> sequence_manager) - : sequence_manager_(std::move(sequence_manager)), +SchedulerHelper::SchedulerHelper(SequenceManager* sequence_manager) + : sequence_manager_(sequence_manager), observer_(nullptr), ukm_task_sampler_(sequence_manager_->GetMetricRecordingSettings() .task_sampling_rate_for_recording_cpu_time) { @@ -53,7 +52,7 @@ return; ShutdownAllQueues(); sequence_manager_->SetObserver(nullptr); - sequence_manager_.reset(); + sequence_manager_ = nullptr; } scoped_refptr<base::SingleThreadTaskRunner> @@ -63,13 +62,13 @@ void SchedulerHelper::SetWorkBatchSizeForTesting(int work_batch_size) { CheckOnValidThread(); - DCHECK(sequence_manager_.get()); + DCHECK(sequence_manager_); sequence_manager_->SetWorkBatchSize(work_batch_size); } bool SchedulerHelper::GetAndClearSystemIsQuiescentBit() { CheckOnValidThread(); - DCHECK(sequence_manager_.get()); + DCHECK(sequence_manager_); return sequence_manager_->GetAndClearSystemIsQuiescentBit(); } @@ -78,7 +77,7 @@ CheckOnValidThread(); if (sequence_manager_) { static_cast<base::sequence_manager::internal::SequenceManagerImpl*>( - sequence_manager_.get()) + sequence_manager_) ->AddTaskObserver(task_observer); } } @@ -88,7 +87,7 @@ CheckOnValidThread(); if (sequence_manager_) { static_cast<base::sequence_manager::internal::SequenceManagerImpl*>( - sequence_manager_.get()) + sequence_manager_) ->RemoveTaskObserver(task_observer); } } @@ -162,7 +161,7 @@ void SchedulerHelper::SetTimerSlack(base::TimerSlack timer_slack) { if (sequence_manager_) { static_cast<base::sequence_manager::internal::SequenceManagerImpl*>( - sequence_manager_.get()) + sequence_manager_) ->SetTimerSlack(timer_slack); } }
diff --git a/third_party/blink/renderer/platform/scheduler/common/scheduler_helper.h b/third_party/blink/renderer/platform/scheduler/common/scheduler_helper.h index 12a0e92..6f4d8c3d 100644 --- a/third_party/blink/renderer/platform/scheduler/common/scheduler_helper.h +++ b/third_party/blink/renderer/platform/scheduler/common/scheduler_helper.h
@@ -20,12 +20,14 @@ namespace scheduler { // Common scheduler functionality for default tasks. +// TODO(carlscab): This class is not really needed and should be removed class PLATFORM_EXPORT SchedulerHelper : public base::sequence_manager::SequenceManager::Observer { public: + // |sequence_manager| must remain valid until Shutdown() is called or the + // object is destroyed. explicit SchedulerHelper( - std::unique_ptr<base::sequence_manager::SequenceManager> - sequence_manager); + base::sequence_manager::SequenceManager* sequence_manager); ~SchedulerHelper() override; // SequenceManager::Observer implementation: @@ -66,7 +68,7 @@ void Shutdown(); // Returns true if Shutdown() has been called. Otherwise returns false. - bool IsShutdown() const { return !sequence_manager_.get(); } + bool IsShutdown() const { return !sequence_manager_; } inline void CheckOnValidThread() const { DCHECK(thread_checker_.CalledOnValidThread()); @@ -119,7 +121,7 @@ virtual void ShutdownAllQueues() {} base::ThreadChecker thread_checker_; - std::unique_ptr<base::sequence_manager::SequenceManager> sequence_manager_; + base::sequence_manager::SequenceManager* sequence_manager_; // NOT OWNED private: friend class SchedulerHelperTest;
diff --git a/third_party/blink/renderer/platform/scheduler/common/scheduler_helper_unittest.cc b/third_party/blink/renderer/platform/scheduler/common/scheduler_helper_unittest.cc index b260c0c..e827a19 100644 --- a/third_party/blink/renderer/platform/scheduler/common/scheduler_helper_unittest.cc +++ b/third_party/blink/renderer/platform/scheduler/common/scheduler_helper_unittest.cc
@@ -55,14 +55,11 @@ base::test::ScopedTaskEnvironment::ExecutionMode::QUEUED) { // Null clock triggers some assertions. task_environment_.FastForwardBy(base::TimeDelta::FromMilliseconds(5)); - std::unique_ptr<base::sequence_manager::SequenceManagerForTest> - sequence_manager = - base::sequence_manager::SequenceManagerForTest::Create( - nullptr, task_environment_.GetMainThreadTaskRunner(), - task_environment_.GetMockTickClock()); - sequence_manager_ = sequence_manager.get(); + sequence_manager_ = base::sequence_manager::SequenceManagerForTest::Create( + nullptr, task_environment_.GetMainThreadTaskRunner(), + task_environment_.GetMockTickClock()); scheduler_helper_ = std::make_unique<NonMainThreadSchedulerHelper>( - std::move(sequence_manager), nullptr, TaskType::kInternalTest); + sequence_manager_.get(), nullptr, TaskType::kInternalTest); default_task_runner_ = scheduler_helper_->DefaultTaskRunner(); } @@ -86,9 +83,9 @@ protected: base::test::ScopedTaskEnvironment task_environment_; + std::unique_ptr<base::sequence_manager::SequenceManagerForTest> + sequence_manager_; std::unique_ptr<NonMainThreadSchedulerHelper> scheduler_helper_; - base::sequence_manager::SequenceManagerForTest* - sequence_manager_; // Owned by scheduler_helper. scoped_refptr<base::SingleThreadTaskRunner> default_task_runner_; DISALLOW_COPY_AND_ASSIGN(SchedulerHelperTest);
diff --git a/third_party/blink/renderer/platform/scheduler/main_thread/auto_advancing_virtual_time_domain_unittest.cc b/third_party/blink/renderer/platform/scheduler/main_thread/auto_advancing_virtual_time_domain_unittest.cc index 96faab2b..9a453826 100644 --- a/third_party/blink/renderer/platform/scheduler/main_thread/auto_advancing_virtual_time_domain_unittest.cc +++ b/third_party/blink/renderer/platform/scheduler/main_thread/auto_advancing_virtual_time_domain_unittest.cc
@@ -32,10 +32,10 @@ // A null clock triggers some assertions. test_task_runner_->AdvanceMockTickClock( base::TimeDelta::FromMilliseconds(5)); + sequence_manager_ = base::sequence_manager::SequenceManagerForTest::Create( + nullptr, test_task_runner_, test_task_runner_->GetMockTickClock()); scheduler_helper_.reset(new NonMainThreadSchedulerHelper( - base::sequence_manager::SequenceManagerForTest::Create( - nullptr, test_task_runner_, test_task_runner_->GetMockTickClock()), - nullptr, TaskType::kInternalTest)); + sequence_manager_.get(), nullptr, TaskType::kInternalTest)); scheduler_helper_->AddTaskTimeObserver(&test_task_time_observer_); task_queue_ = scheduler_helper_->DefaultNonMainThreadTaskQueue(); @@ -56,6 +56,8 @@ scoped_refptr<base::TestMockTimeTaskRunner> test_task_runner_; base::Time initial_time_; base::TimeTicks initial_time_ticks_; + std::unique_ptr<base::sequence_manager::SequenceManagerForTest> + sequence_manager_; std::unique_ptr<NonMainThreadSchedulerHelper> scheduler_helper_; scoped_refptr<base::sequence_manager::TaskQueue> task_queue_; std::unique_ptr<AutoAdvancingVirtualTimeDomain> auto_advancing_time_domain_;
diff --git a/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_helper.cc b/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_helper.cc index 962954d..9700a0f 100644 --- a/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_helper.cc +++ b/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_helper.cc
@@ -12,9 +12,9 @@ using base::sequence_manager::TaskQueue; MainThreadSchedulerHelper::MainThreadSchedulerHelper( - std::unique_ptr<base::sequence_manager::SequenceManager> sequence_manager, + base::sequence_manager::SequenceManager* sequence_manager, MainThreadSchedulerImpl* main_thread_scheduler) - : SchedulerHelper(std::move(sequence_manager)), + : SchedulerHelper(sequence_manager), main_thread_scheduler_(main_thread_scheduler), // TODO(hajimehoshi): Forbid V8 execution at |default_task_queue_| // (crbug.com/870606).
diff --git a/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_helper.h b/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_helper.h index 41e19c5..802edf4 100644 --- a/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_helper.h +++ b/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_helper.h
@@ -14,10 +14,14 @@ class MainThreadSchedulerImpl; +// TODO(carlscab): This class is not really needed and should be removed class PLATFORM_EXPORT MainThreadSchedulerHelper : public SchedulerHelper { public: + // |sequence_manager| must remain valid until Shutdown() is called or the + // object is destroyed. |main_thread_scheduler| must remain valid for the + // entire lifetime of this object. MainThreadSchedulerHelper( - std::unique_ptr<base::sequence_manager::SequenceManager> sequence_manager, + base::sequence_manager::SequenceManager* sequence_manager, MainThreadSchedulerImpl* main_thread_scheduler); ~MainThreadSchedulerHelper() override;
diff --git a/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.cc b/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.cc index b50c0de..e921e057f 100644 --- a/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.cc +++ b/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.cc
@@ -186,7 +186,8 @@ MainThreadSchedulerImpl::MainThreadSchedulerImpl( std::unique_ptr<base::sequence_manager::SequenceManager> sequence_manager, base::Optional<base::Time> initial_virtual_time) - : helper_(std::move(sequence_manager), this), + : sequence_manager_(std::move(sequence_manager)), + helper_(sequence_manager_.get(), this), idle_helper_(&helper_, this, "MainThreadSchedulerIdlePeriod", @@ -622,6 +623,7 @@ task_queue_throttler_.reset(); idle_helper_.Shutdown(); helper_.Shutdown(); + sequence_manager_.reset(); main_thread_only().rail_mode_observers.Clear(); was_shutdown_ = true; }
diff --git a/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.h b/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.h index f0e97f0a..5facd4f8 100644 --- a/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.h +++ b/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.h
@@ -726,6 +726,7 @@ // initialized first and can be used everywhere. const SchedulingSettings scheduling_settings_; + std::unique_ptr<base::sequence_manager::SequenceManager> sequence_manager_; MainThreadSchedulerHelper helper_; IdleHelper idle_helper_; std::unique_ptr<TaskQueueThrottler> task_queue_throttler_;
diff --git a/third_party/blink/renderer/platform/scheduler/public/cooperative_scheduling_manager.h b/third_party/blink/renderer/platform/scheduler/public/cooperative_scheduling_manager.h index 9c53d56..1bc471f2 100644 --- a/third_party/blink/renderer/platform/scheduler/public/cooperative_scheduling_manager.h +++ b/third_party/blink/renderer/platform/scheduler/public/cooperative_scheduling_manager.h
@@ -13,22 +13,23 @@ namespace scheduler { // This class manages the states for cooperative scheduling and decides whether -// or not to run a nested loop or not. +// or not to run a nested loop for reentrant JS execution in cross-site frames. class PLATFORM_EXPORT CooperativeSchedulingManager { USING_FAST_MALLOC(CooperativeSchedulingManager); public: - // This class is used to mark JS executions that have a C++ stack that has - // been whitelisted for reentry. - class PLATFORM_EXPORT WhitelistedStackScope { + // Reentrant JS execution is not allowed unless there is an instance of this + // scoper alive. This is to ensure that reentrant JS execution can only happen + // in C++ stacks with a simple, known state. + class PLATFORM_EXPORT AllowedStackScope { STACK_ALLOCATED(); public: - WhitelistedStackScope(CooperativeSchedulingManager*); - ~WhitelistedStackScope(); + explicit AllowedStackScope(CooperativeSchedulingManager*); + ~AllowedStackScope(); private: - CooperativeSchedulingManager* cooperative_scheduling_manager_; + CooperativeSchedulingManager* const cooperative_scheduling_manager_; }; // Returns an shared instance for the current thread. @@ -37,10 +38,8 @@ CooperativeSchedulingManager(); virtual ~CooperativeSchedulingManager() = default; - // Returns true if the C++ stack has been whitelisted for reentry. - bool InWhitelistedStackScope() const { - return whitelisted_stack_scope_depth_ > 0; - } + // Returns true if reentry is allowed in the current C++ stack. + bool InAllowedStackScope() const { return allowed_stack_scope_depth_ > 0; } // Calls to this should be inserted where nested loops can be run safely. // Typically this is is where Blink has not modified any global state that the @@ -51,11 +50,11 @@ virtual void RunNestedLoop(); private: - void EnterWhitelistedStackScope(); - void LeaveWhitelistedStackScope(); + void EnterAllowedStackScope(); + void LeaveAllowedStackScope(); void SafepointSlow(); - int whitelisted_stack_scope_depth_ = 0; + int allowed_stack_scope_depth_ = 0; bool running_nested_loop_ = false; WTF::TimeTicks wait_until_; @@ -63,7 +62,7 @@ }; inline void CooperativeSchedulingManager::Safepoint() { - if (!InWhitelistedStackScope()) + if (!InAllowedStackScope()) return; if (WTF::CurrentTimeTicks() < wait_until_)
diff --git a/third_party/blink/renderer/platform/scheduler/worker/compositor_thread.cc b/third_party/blink/renderer/platform/scheduler/worker/compositor_thread.cc index 71724a3..25befe5 100644 --- a/third_party/blink/renderer/platform/scheduler/worker/compositor_thread.cc +++ b/third_party/blink/renderer/platform/scheduler/worker/compositor_thread.cc
@@ -16,12 +16,9 @@ CompositorThread::~CompositorThread() = default; std::unique_ptr<NonMainThreadSchedulerImpl> -CompositorThread::CreateNonMainThreadScheduler() { - return std::make_unique<CompositorThreadScheduler>( - base::sequence_manager::CreateSequenceManagerOnCurrentThread( - base::sequence_manager::SequenceManager::Settings{ - base::MessageLoop::TYPE_DEFAULT, - /*randomised_sampling_enabled=*/true})); +CompositorThread::CreateNonMainThreadScheduler( + base::sequence_manager::SequenceManager* sequence_manager) { + return std::make_unique<CompositorThreadScheduler>(sequence_manager); } } // namespace scheduler
diff --git a/third_party/blink/renderer/platform/scheduler/worker/compositor_thread.h b/third_party/blink/renderer/platform/scheduler/worker/compositor_thread.h index d6c7025a..0c894171 100644 --- a/third_party/blink/renderer/platform/scheduler/worker/compositor_thread.h +++ b/third_party/blink/renderer/platform/scheduler/worker/compositor_thread.h
@@ -17,8 +17,8 @@ ~CompositorThread() override; private: - std::unique_ptr<NonMainThreadSchedulerImpl> CreateNonMainThreadScheduler() - override; + std::unique_ptr<NonMainThreadSchedulerImpl> CreateNonMainThreadScheduler( + base::sequence_manager::SequenceManager* sequence_manager) override; DISALLOW_COPY_AND_ASSIGN(CompositorThread); };
diff --git a/third_party/blink/renderer/platform/scheduler/worker/compositor_thread_scheduler.cc b/third_party/blink/renderer/platform/scheduler/worker/compositor_thread_scheduler.cc index 6ce154e..d2f0720 100644 --- a/third_party/blink/renderer/platform/scheduler/worker/compositor_thread_scheduler.cc +++ b/third_party/blink/renderer/platform/scheduler/worker/compositor_thread_scheduler.cc
@@ -31,8 +31,8 @@ } CompositorThreadScheduler::CompositorThreadScheduler( - std::unique_ptr<base::sequence_manager::SequenceManager> sequence_manager) - : NonMainThreadSchedulerImpl(std::move(sequence_manager), + base::sequence_manager::SequenceManager* sequence_manager) + : NonMainThreadSchedulerImpl(sequence_manager, TaskType::kCompositorThreadTaskQueueDefault), input_task_queue_( base::FeatureList::IsEnabled(kHighPriorityInputOnCompositorThread)
diff --git a/third_party/blink/renderer/platform/scheduler/worker/compositor_thread_scheduler.h b/third_party/blink/renderer/platform/scheduler/worker/compositor_thread_scheduler.h index 11fd3c4..900a0a7 100644 --- a/third_party/blink/renderer/platform/scheduler/worker/compositor_thread_scheduler.h +++ b/third_party/blink/renderer/platform/scheduler/worker/compositor_thread_scheduler.h
@@ -23,8 +23,7 @@ public SingleThreadIdleTaskRunner::Delegate { public: explicit CompositorThreadScheduler( - std::unique_ptr<base::sequence_manager::SequenceManager> - sequence_manager); + base::sequence_manager::SequenceManager* sequence_manager); ~CompositorThreadScheduler() override;
diff --git a/third_party/blink/renderer/platform/scheduler/worker/compositor_thread_scheduler_unittest.cc b/third_party/blink/renderer/platform/scheduler/worker/compositor_thread_scheduler_unittest.cc index 71debe2..319cdd9 100644 --- a/third_party/blink/renderer/platform/scheduler/worker/compositor_thread_scheduler_unittest.cc +++ b/third_party/blink/renderer/platform/scheduler/worker/compositor_thread_scheduler_unittest.cc
@@ -3,6 +3,7 @@ // found in the LICENSE file. #include "third_party/blink/renderer/platform/scheduler/worker/compositor_thread_scheduler.h" +#include <algorithm> #include <memory> #include "base/bind.h" #include "base/macros.h" @@ -15,8 +16,8 @@ #include "third_party/blink/renderer/platform/scheduler/common/features.h" #include "third_party/blink/renderer/platform/wtf/functional.h" -using testing::ElementsAreArray; using testing::ElementsAre; +using testing::ElementsAreArray; namespace blink { namespace scheduler { @@ -39,10 +40,10 @@ mock_task_runner_ = base::MakeRefCounted<base::TestMockTimeTaskRunner>(); mock_task_runner_->AdvanceMockTickClock( base::TimeDelta::FromMicroseconds(5000)); - - scheduler_ = std::make_unique<CompositorThreadScheduler>( - base::sequence_manager::SequenceManagerForTest::Create( - nullptr, mock_task_runner_, mock_task_runner_->GetMockTickClock())); + sequence_manager_ = base::sequence_manager::SequenceManagerForTest::Create( + nullptr, mock_task_runner_, mock_task_runner_->GetMockTickClock()); + scheduler_ = + std::make_unique<CompositorThreadScheduler>(sequence_manager_.get()); scheduler_->Init(); } @@ -52,6 +53,8 @@ base::test::ScopedFeatureList feature_list_; scoped_refptr<base::TestMockTimeTaskRunner> mock_task_runner_; + std::unique_ptr<base::sequence_manager::SequenceManagerForTest> + sequence_manager_; std::unique_ptr<CompositorThreadScheduler> scheduler_; DISALLOW_COPY_AND_ASSIGN(CompositorThreadSchedulerTest);
diff --git a/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_scheduler_helper.cc b/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_scheduler_helper.cc index 9bed99b55..661ec723 100644 --- a/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_scheduler_helper.cc +++ b/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_scheduler_helper.cc
@@ -13,10 +13,10 @@ using base::sequence_manager::TaskQueue; NonMainThreadSchedulerHelper::NonMainThreadSchedulerHelper( - std::unique_ptr<base::sequence_manager::SequenceManager> sequence_manager, + base::sequence_manager::SequenceManager* sequence_manager, NonMainThreadSchedulerImpl* non_main_thread_scheduler, TaskType default_task_type) - : SchedulerHelper(std::move(sequence_manager)), + : SchedulerHelper(sequence_manager), non_main_thread_scheduler_(non_main_thread_scheduler), default_task_queue_(NewTaskQueue(TaskQueue::Spec("subthread_default_tq") .SetShouldMonitorQuiescence(true))),
diff --git a/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_scheduler_helper.h b/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_scheduler_helper.h index c6aa1aa..012d8c92 100644 --- a/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_scheduler_helper.h +++ b/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_scheduler_helper.h
@@ -15,10 +15,14 @@ class NonMainThreadSchedulerImpl; +// TODO(carlscab): This class is not really needed and should be removed class PLATFORM_EXPORT NonMainThreadSchedulerHelper : public SchedulerHelper { public: + // |sequence_manager| must remain valid until Shutdown() is called or the + // object is destroyed. |main_thread_scheduler| must remain valid for the + // entire lifetime of this object. NonMainThreadSchedulerHelper( - std::unique_ptr<base::sequence_manager::SequenceManager> manager, + base::sequence_manager::SequenceManager* manager, NonMainThreadSchedulerImpl* non_main_thread_scheduler, TaskType default_task_type); ~NonMainThreadSchedulerHelper() override;
diff --git a/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_scheduler_impl.cc b/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_scheduler_impl.cc index 84ea95f..a73024f 100644 --- a/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_scheduler_impl.cc +++ b/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_scheduler_impl.cc
@@ -14,23 +14,19 @@ namespace scheduler { NonMainThreadSchedulerImpl::NonMainThreadSchedulerImpl( - std::unique_ptr<base::sequence_manager::SequenceManager> manager, + base::sequence_manager::SequenceManager* manager, TaskType default_task_type) - : helper_(std::move(manager), this, default_task_type) {} + : helper_(manager, this, default_task_type) {} NonMainThreadSchedulerImpl::~NonMainThreadSchedulerImpl() = default; // static std::unique_ptr<NonMainThreadSchedulerImpl> NonMainThreadSchedulerImpl::Create( WebThreadType thread_type, + base::sequence_manager::SequenceManager* sequence_manager, WorkerSchedulerProxy* proxy) { - return std::make_unique<WorkerThreadScheduler>( - thread_type, - base::sequence_manager::CreateSequenceManagerOnCurrentThread( - base::sequence_manager::SequenceManager::Settings{ - base::MessageLoop::TYPE_DEFAULT, - /*randomised_sampling_enabled=*/true}), - proxy); + return std::make_unique<WorkerThreadScheduler>(thread_type, sequence_manager, + proxy); } void NonMainThreadSchedulerImpl::Init() {
diff --git a/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_scheduler_impl.h b/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_scheduler_impl.h index 466d1f72..d8c1e15 100644 --- a/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_scheduler_impl.h +++ b/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_scheduler_impl.h
@@ -8,6 +8,7 @@ #include <memory> #include "base/macros.h" +#include "base/task/sequence_manager/sequence_manager.h" #include "base/task/sequence_manager/task_queue.h" #include "third_party/blink/public/platform/scheduler/web_thread_scheduler.h" #include "third_party/blink/public/platform/web_thread_type.h" @@ -28,8 +29,11 @@ public: ~NonMainThreadSchedulerImpl() override; + // |sequence_manager| and |proxy| must remain valid for the entire lifetime of + // this object. static std::unique_ptr<NonMainThreadSchedulerImpl> Create( WebThreadType thread_type, + base::sequence_manager::SequenceManager* sequence_manager, WorkerSchedulerProxy* proxy); // Blink should use NonMainThreadSchedulerImpl::DefaultTaskQueue instead of @@ -91,8 +95,10 @@ protected: static void RunIdleTask(Thread::IdleTask task, base::TimeTicks deadline); + // |sequence_manager| must remain valid for the entire lifetime of + // this object. explicit NonMainThreadSchedulerImpl( - std::unique_ptr<base::sequence_manager::SequenceManager> sequence_manager, + base::sequence_manager::SequenceManager* sequence_manager, TaskType default_task_type); friend class WorkerScheduler;
diff --git a/third_party/blink/renderer/platform/scheduler/worker/worker_scheduler_proxy_unittest.cc b/third_party/blink/renderer/platform/scheduler/worker/worker_scheduler_proxy_unittest.cc index 88de56f..40bca2e 100644 --- a/third_party/blink/renderer/platform/scheduler/worker/worker_scheduler_proxy_unittest.cc +++ b/third_party/blink/renderer/platform/scheduler/worker/worker_scheduler_proxy_unittest.cc
@@ -24,13 +24,10 @@ class WorkerThreadSchedulerForTest : public WorkerThreadScheduler { public: - WorkerThreadSchedulerForTest( - std::unique_ptr<base::sequence_manager::SequenceManager> manager, - WorkerSchedulerProxy* proxy, - base::WaitableEvent* throtting_state_changed) - : WorkerThreadScheduler(WebThreadType::kTestThread, - std::move(manager), - proxy), + WorkerThreadSchedulerForTest(base::sequence_manager::SequenceManager* manager, + WorkerSchedulerProxy* proxy, + base::WaitableEvent* throtting_state_changed) + : WorkerThreadScheduler(WebThreadType::kTestThread, manager, proxy), throtting_state_changed_(throtting_state_changed) {} void OnLifecycleStateChanged( @@ -58,7 +55,7 @@ base::WaitableEvent completion( base::WaitableEvent::ResetPolicy::AUTOMATIC, base::WaitableEvent::InitialState::NOT_SIGNALED); - thread_task_runner_->PostTask( + GetTaskRunner()->PostTask( FROM_HERE, base::BindOnce(&WorkerThreadForTest::DisposeWorkerSchedulerOnThread, base::Unretained(this), &completion)); @@ -66,7 +63,6 @@ } void DisposeWorkerSchedulerOnThread(base::WaitableEvent* completion) { - DCHECK(thread_task_runner_->BelongsToCurrentThread()); if (worker_scheduler_) { worker_scheduler_->Dispose(); worker_scheduler_ = nullptr; @@ -74,14 +70,10 @@ completion->Signal(); } - std::unique_ptr<NonMainThreadSchedulerImpl> CreateNonMainThreadScheduler() - override { + std::unique_ptr<NonMainThreadSchedulerImpl> CreateNonMainThreadScheduler( + base::sequence_manager::SequenceManager* manager) override { auto scheduler = std::make_unique<WorkerThreadSchedulerForTest>( - base::sequence_manager::CreateSequenceManagerOnCurrentThread( - base::sequence_manager::SequenceManager::Settings{ - base::MessageLoop::TYPE_DEFAULT, - /*randomised_sampling_enabled=*/true}), - worker_scheduler_proxy(), throtting_state_changed_); + manager, worker_scheduler_proxy(), throtting_state_changed_); scheduler_ = scheduler.get(); worker_scheduler_ = std::make_unique<scheduler::WorkerScheduler>( scheduler_, worker_scheduler_proxy());
diff --git a/third_party/blink/renderer/platform/scheduler/worker/worker_scheduler_unittest.cc b/third_party/blink/renderer/platform/scheduler/worker/worker_scheduler_unittest.cc index 6031c69..b267b9b4 100644 --- a/third_party/blink/renderer/platform/scheduler/worker/worker_scheduler_unittest.cc +++ b/third_party/blink/renderer/platform/scheduler/worker/worker_scheduler_unittest.cc
@@ -16,8 +16,8 @@ #include "third_party/blink/renderer/platform/scheduler/worker/worker_thread_scheduler.h" #include "third_party/blink/renderer/platform/wtf/functional.h" -using testing::ElementsAreArray; using testing::ElementsAre; +using testing::ElementsAreArray; namespace blink { namespace scheduler { @@ -52,11 +52,12 @@ class WorkerThreadSchedulerForTest : public WorkerThreadScheduler { public: - WorkerThreadSchedulerForTest( - WebThreadType thread_type, - std::unique_ptr<base::sequence_manager::SequenceManager> manager, - WorkerSchedulerProxy* proxy) - : WorkerThreadScheduler(thread_type, std::move(manager), proxy) {} + // |manager|and |proxy| must remain valid for the entire lifetime of this + // object. + WorkerThreadSchedulerForTest(WebThreadType thread_type, + base::sequence_manager::SequenceManager* manager, + WorkerSchedulerProxy* proxy) + : WorkerThreadScheduler(thread_type, manager, proxy) {} const std::unordered_set<WorkerScheduler*>& worker_schedulers() { return GetWorkerSchedulersForTesting(); @@ -80,13 +81,14 @@ public: WorkerSchedulerTest() : mock_task_runner_(new base::TestMockTimeTaskRunner()), - scheduler_(new WorkerThreadSchedulerForTest( - WebThreadType::kTestThread, + sequence_manager_( base::sequence_manager::SequenceManagerForTest::Create( nullptr, mock_task_runner_, - mock_task_runner_->GetMockTickClock()), - nullptr /* proxy */)) { + mock_task_runner_->GetMockTickClock())), + scheduler_(new WorkerThreadSchedulerForTest(WebThreadType::kTestThread, + sequence_manager_.get(), + nullptr /* proxy */)) { mock_task_runner_->AdvanceMockTickClock( base::TimeDelta::FromMicroseconds(5000)); } @@ -123,7 +125,8 @@ protected: scoped_refptr<base::TestMockTimeTaskRunner> mock_task_runner_; - + std::unique_ptr<base::sequence_manager::SequenceManagerForTest> + sequence_manager_; std::unique_ptr<WorkerThreadSchedulerForTest> scheduler_; std::unique_ptr<WorkerSchedulerForTest> worker_scheduler_;
diff --git a/third_party/blink/renderer/platform/scheduler/worker/worker_thread.cc b/third_party/blink/renderer/platform/scheduler/worker/worker_thread.cc index be6f9cf..b6e6fe3f 100644 --- a/third_party/blink/renderer/platform/scheduler/worker/worker_thread.cc +++ b/third_party/blink/renderer/platform/scheduler/worker/worker_thread.cc
@@ -58,7 +58,13 @@ void WorkerThread::InitOnThread(base::WaitableEvent* completion) { // TODO(alexclarke): Do we need to unify virtual time for workers and the // main thread? - non_main_thread_scheduler_ = CreateNonMainThreadScheduler(); + sequence_manager_ = + base::sequence_manager::CreateSequenceManagerOnCurrentThread( + base::sequence_manager::SequenceManager::Settings{ + base::MessageLoop::TYPE_DEFAULT, + /*randomised_sampling_enabled=*/true}); + non_main_thread_scheduler_ = + CreateNonMainThreadScheduler(sequence_manager_.get()); non_main_thread_scheduler_->Init(); task_queue_ = non_main_thread_scheduler_->DefaultTaskQueue(); task_runner_ = @@ -73,14 +79,16 @@ task_queue_ = nullptr; task_runner_ = nullptr; non_main_thread_scheduler_ = nullptr; + sequence_manager_.reset(); if (completion) completion->Signal(); } std::unique_ptr<NonMainThreadSchedulerImpl> -WorkerThread::CreateNonMainThreadScheduler() { - return NonMainThreadSchedulerImpl::Create(thread_type_, +WorkerThread::CreateNonMainThreadScheduler( + base::sequence_manager::SequenceManager* sequence_manager) { + return NonMainThreadSchedulerImpl::Create(thread_type_, sequence_manager, worker_scheduler_proxy_.get()); }
diff --git a/third_party/blink/renderer/platform/scheduler/worker/worker_thread.h b/third_party/blink/renderer/platform/scheduler/worker/worker_thread.h index ae2150e..684472f 100644 --- a/third_party/blink/renderer/platform/scheduler/worker/worker_thread.h +++ b/third_party/blink/renderer/platform/scheduler/worker/worker_thread.h
@@ -10,6 +10,7 @@ #include "base/single_thread_task_runner.h" #include "base/synchronization/atomic_flag.h" #include "base/synchronization/waitable_event.h" +#include "base/task/sequence_manager/sequence_manager.h" #include "base/threading/thread.h" #include "third_party/blink/public/platform/web_private_ptr.h" #include "third_party/blink/renderer/platform/scheduler/public/thread.h" @@ -61,7 +62,8 @@ protected: virtual std::unique_ptr<NonMainThreadSchedulerImpl> - CreateNonMainThreadScheduler(); + CreateNonMainThreadScheduler( + base::sequence_manager::SequenceManager* sequence_manager); base::Thread* GetThread() const { return thread_.get(); } @@ -75,6 +77,7 @@ std::unique_ptr<base::Thread> thread_; const WebThreadType thread_type_; std::unique_ptr<scheduler::WorkerSchedulerProxy> worker_scheduler_proxy_; + std::unique_ptr<base::sequence_manager::SequenceManager> sequence_manager_; std::unique_ptr<scheduler::NonMainThreadSchedulerImpl> non_main_thread_scheduler_; scoped_refptr<NonMainThreadTaskQueue> task_queue_;
diff --git a/third_party/blink/renderer/platform/scheduler/worker/worker_thread_scheduler.cc b/third_party/blink/renderer/platform/scheduler/worker/worker_thread_scheduler.cc index c177a90..159a5cf 100644 --- a/third_party/blink/renderer/platform/scheduler/worker/worker_thread_scheduler.cc +++ b/third_party/blink/renderer/platform/scheduler/worker/worker_thread_scheduler.cc
@@ -97,9 +97,9 @@ WorkerThreadScheduler::WorkerThreadScheduler( WebThreadType thread_type, - std::unique_ptr<base::sequence_manager::SequenceManager> sequence_manager, + base::sequence_manager::SequenceManager* sequence_manager, WorkerSchedulerProxy* proxy) - : NonMainThreadSchedulerImpl(std::move(sequence_manager), + : NonMainThreadSchedulerImpl(sequence_manager, TaskType::kWorkerThreadTaskQueueDefault), thread_type_(thread_type), idle_helper_(helper(), @@ -205,6 +205,7 @@ base::TimeDelta::FromDays(1), 50 /* bucket count */); task_queue_throttler_.reset(); idle_helper_.Shutdown(); + helper()->RemoveTaskTimeObserver(this); helper()->Shutdown(); }
diff --git a/third_party/blink/renderer/platform/scheduler/worker/worker_thread_scheduler.h b/third_party/blink/renderer/platform/scheduler/worker/worker_thread_scheduler.h index 9568322f..21f6fc2 100644 --- a/third_party/blink/renderer/platform/scheduler/worker/worker_thread_scheduler.h +++ b/third_party/blink/renderer/platform/scheduler/worker/worker_thread_scheduler.h
@@ -46,9 +46,11 @@ public IdleHelper::Delegate, public base::sequence_manager::TaskTimeObserver { public: + // |sequence_manager|and |proxy| must remain valid for the entire lifetime of + // this object. WorkerThreadScheduler( WebThreadType thread_type, - std::unique_ptr<base::sequence_manager::SequenceManager> sequence_manager, + base::sequence_manager::SequenceManager* sequence_manager, WorkerSchedulerProxy* proxy); ~WorkerThreadScheduler() override;
diff --git a/third_party/blink/renderer/platform/scheduler/worker/worker_thread_scheduler_unittest.cc b/third_party/blink/renderer/platform/scheduler/worker/worker_thread_scheduler_unittest.cc index 0428317..e3a34776 100644 --- a/third_party/blink/renderer/platform/scheduler/worker/worker_thread_scheduler_unittest.cc +++ b/third_party/blink/renderer/platform/scheduler/worker/worker_thread_scheduler_unittest.cc
@@ -55,24 +55,18 @@ class WorkerThreadSchedulerForTest : public WorkerThreadScheduler { public: - WorkerThreadSchedulerForTest( - std::unique_ptr<base::sequence_manager::SequenceManager> manager, - const base::TickClock* clock_, - std::vector<std::string>* timeline) - : WorkerThreadScheduler(WebThreadType::kTestThread, - std::move(manager), - nullptr), + WorkerThreadSchedulerForTest(base::sequence_manager::SequenceManager* manager, + const base::TickClock* clock_, + std::vector<std::string>* timeline) + : WorkerThreadScheduler(WebThreadType::kTestThread, manager, nullptr), clock_(clock_), timeline_(timeline) {} - WorkerThreadSchedulerForTest( - std::unique_ptr<base::sequence_manager::SequenceManager> manager, - const base::TickClock* clock_, - std::vector<std::string>* timeline, - WorkerSchedulerProxy* proxy) - : WorkerThreadScheduler(WebThreadType::kTestThread, - std::move(manager), - proxy), + WorkerThreadSchedulerForTest(base::sequence_manager::SequenceManager* manager, + const base::TickClock* clock_, + std::vector<std::string>* timeline, + WorkerSchedulerProxy* proxy) + : WorkerThreadScheduler(WebThreadType::kTestThread, manager, proxy), clock_(clock_), timeline_(timeline) {} @@ -109,11 +103,13 @@ : task_environment_( base::test::ScopedTaskEnvironment::MainThreadType::MOCK_TIME, base::test::ScopedTaskEnvironment::ExecutionMode::QUEUED), - scheduler_(new WorkerThreadSchedulerForTest( + sequence_manager_( base::sequence_manager::SequenceManagerForTest::Create( nullptr, task_environment_.GetMainThreadTaskRunner(), - task_environment_.GetMockTickClock()), + task_environment_.GetMockTickClock())), + scheduler_(new WorkerThreadSchedulerForTest( + sequence_manager_.get(), task_environment_.GetMockTickClock(), &timeline_)) { // Null clock might trigger some assertions. @@ -176,6 +172,8 @@ protected: base::test::ScopedTaskEnvironment task_environment_; + std::unique_ptr<base::sequence_manager::SequenceManagerForTest> + sequence_manager_; std::vector<std::string> timeline_; std::unique_ptr<WorkerThreadSchedulerForTest> scheduler_; scoped_refptr<base::sequence_manager::TaskQueue> default_task_queue_; @@ -416,7 +414,12 @@ WorkerThreadSchedulerWithProxyTest() : task_environment_( base::test::ScopedTaskEnvironment::MainThreadType::MOCK_TIME, - base::test::ScopedTaskEnvironment::ExecutionMode::QUEUED) { + base::test::ScopedTaskEnvironment::ExecutionMode::QUEUED), + sequence_manager_( + base::sequence_manager::SequenceManagerForTest::Create( + nullptr, + task_environment_.GetMainThreadTaskRunner(), + task_environment_.GetMockTickClock())) { frame_scheduler_delegate_ = std::make_unique<FrameSchedulerDelegateWithUkmSourceId>(42); frame_scheduler_ = FakeFrameScheduler::Builder() @@ -431,11 +434,8 @@ std::make_unique<WorkerSchedulerProxy>(frame_scheduler_.get()); scheduler_ = std::make_unique<WorkerThreadSchedulerForTest>( - base::sequence_manager::SequenceManagerForTest::Create( - nullptr, task_environment_.GetMainThreadTaskRunner(), - task_environment_.GetMockTickClock()), - task_environment_.GetMockTickClock(), &timeline_, - worker_scheduler_proxy_.get()); + sequence_manager_.get(), task_environment_.GetMockTickClock(), + &timeline_, worker_scheduler_proxy_.get()); task_environment_.FastForwardBy(base::TimeDelta::FromMilliseconds(5)); @@ -450,6 +450,8 @@ protected: base::test::ScopedTaskEnvironment task_environment_; + std::unique_ptr<base::sequence_manager::SequenceManagerForTest> + sequence_manager_; std::vector<std::string> timeline_; std::unique_ptr<FrameScheduler::Delegate> frame_scheduler_delegate_; std::unique_ptr<FrameScheduler> frame_scheduler_;
diff --git a/third_party/blink/renderer/platform/testing/fake_display_item_client.h b/third_party/blink/renderer/platform/testing/fake_display_item_client.h index a9c45621..b2032a1c 100644 --- a/third_party/blink/renderer/platform/testing/fake_display_item_client.h +++ b/third_party/blink/renderer/platform/testing/fake_display_item_client.h
@@ -5,7 +5,6 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_FAKE_DISPLAY_ITEM_CLIENT_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_FAKE_DISPLAY_ITEM_CLIENT_H_ -#include "third_party/blink/renderer/platform/geometry/layout_rect.h" #include "third_party/blink/renderer/platform/graphics/paint/display_item_client.h" #include "third_party/blink/renderer/platform/wtf/forward.h" @@ -15,20 +14,20 @@ class FakeDisplayItemClient : public DisplayItemClient { public: FakeDisplayItemClient(const String& name = "FakeDisplayItemClient", - const LayoutRect& visual_rect = LayoutRect()) + const IntRect& visual_rect = IntRect()) : name_(name), visual_rect_(visual_rect) {} String DebugName() const final { return name_; } - LayoutRect VisualRect() const override { return visual_rect_; } - LayoutRect PartialInvalidationVisualRect() const override { + IntRect VisualRect() const override { return visual_rect_; } + IntRect PartialInvalidationVisualRect() const override { return partial_invalidation_visual_rect_; } void ClearPartialInvalidationVisualRect() const override { - partial_invalidation_visual_rect_ = LayoutRect(); + partial_invalidation_visual_rect_ = IntRect(); } - void SetVisualRect(const LayoutRect& r) { visual_rect_ = r; } - void SetPartialInvalidationVisualRect(const LayoutRect& r) { + void SetVisualRect(const IntRect& r) { visual_rect_ = r; } + void SetPartialInvalidationVisualRect(const IntRect& r) { Invalidate(PaintInvalidationReason::kRectangle); partial_invalidation_visual_rect_ = r; } @@ -38,8 +37,8 @@ private: String name_; - LayoutRect visual_rect_; - mutable LayoutRect partial_invalidation_visual_rect_; + IntRect visual_rect_; + mutable IntRect partial_invalidation_visual_rect_; }; } // namespace blink
diff --git a/third_party/blink/renderer/platform/testing/test_paint_artifact.cc b/third_party/blink/renderer/platform/testing/test_paint_artifact.cc index 9514346..2e8bf79c 100644 --- a/third_party/blink/renderer/platform/testing/test_paint_artifact.cc +++ b/third_party/blink/renderer/platform/testing/test_paint_artifact.cc
@@ -21,11 +21,11 @@ class TestPaintArtifact::DummyRectClient : public FakeDisplayItemClient { public: - LayoutRect VisualRect() const final { return EnclosingLayoutRect(rect_); } - void SetVisualRect(const FloatRect& rect) { rect_ = rect; } + IntRect VisualRect() const final { return rect_; } + void SetVisualRect(const IntRect& rect) { rect_ = rect; } sk_sp<PaintRecord> MakeRecord(const FloatRect& rect, Color color) { - rect_ = rect; + rect_ = EnclosingIntRect(rect); PaintRecorder recorder; cc::PaintCanvas* canvas = recorder.beginRecording(rect); PaintFlags flags; @@ -35,7 +35,7 @@ } private: - FloatRect rect_; + IntRect rect_; }; TestPaintArtifact::TestPaintArtifact() : display_item_list_(0) {} @@ -51,7 +51,7 @@ // invalidation rects of chunks. The actual values don't matter. If the chunk // has display items, we will recalculate the bounds from the display items // when constructing the PaintArtifact. - Bounds(FloatRect(id * 110, id * 220, id * 220 + 200, id * 110 + 200)); + Bounds(IntRect(id * 110, id * 220, id * 220 + 200, id * 110 + 200)); return *this; } @@ -112,7 +112,7 @@ return *this; } -TestPaintArtifact& TestPaintArtifact::Bounds(const FloatRect& bounds) { +TestPaintArtifact& TestPaintArtifact::Bounds(const IntRect& bounds) { paint_chunks_.back().bounds = bounds; return *this; }
diff --git a/third_party/blink/renderer/platform/testing/test_paint_artifact.h b/third_party/blink/renderer/platform/testing/test_paint_artifact.h index d9a8b927..a648fff 100644 --- a/third_party/blink/renderer/platform/testing/test_paint_artifact.h +++ b/third_party/blink/renderer/platform/testing/test_paint_artifact.h
@@ -109,7 +109,7 @@ // Sets fake bounds for the last paint chunk. Note that the bounds will be // overwritten when the PaintArtifact is constructed if the chunk has any // display items. - TestPaintArtifact& Bounds(const FloatRect&); + TestPaintArtifact& Bounds(const IntRect&); TestPaintArtifact& KnownToBeOpaque(); TestPaintArtifact& Uncacheable();
diff --git a/third_party/blink/web_tests/SlowTests b/third_party/blink/web_tests/SlowTests index 683e5b6..ceece4e6 100644 --- a/third_party/blink/web_tests/SlowTests +++ b/third_party/blink/web_tests/SlowTests
@@ -938,3 +938,5 @@ crbug.com/914981 [ Mac ] virtual/mouseevent_fractional/fast/events/no-fake-mousemove.html [ Slow ] crbug.com/914981 [ Mac ] virtual/video-surface-layer/media/controls/overflow-menu-pointer-selection.html [ Slow ] crbug.com/914981 [ Mac ] fast/events/no-fake-mousemove.html [ Slow ] + +crbug.com/951895 [ Mac Debug ] transforms/2d/transform-2d.html [ Slow ]
diff --git a/third_party/blink/web_tests/TestExpectations b/third_party/blink/web_tests/TestExpectations index ee4878ff..d298eed 100644 --- a/third_party/blink/web_tests/TestExpectations +++ b/third_party/blink/web_tests/TestExpectations
@@ -6270,3 +6270,4 @@ # Sheriff 2019-04-11 crbug.com/951774 [ Linux ] virtual/video-surface-layer/media/controls/modern/overlay-play-button-tap-to-hide.html [ Pass Timeout ] crbug.com/951811 [ Mac10.13 ] external/wpt/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/open-features-tokenization-top-left.html [ Pass Timeout ] +crbug.com/802029 [ Mac10.13 Debug ] fast/dom/shadow/focus-controller-recursion-crash.html [ Pass Timeout ]
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 168fe69..9cc4f1d0 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
@@ -58787,6 +58787,18 @@ {} ] ], + "css/css-scoping/reslot-text-inheritance.html": [ + [ + "/css/css-scoping/reslot-text-inheritance.html", + [ + [ + "/css/css-scoping/reference/green-text.html", + "==" + ] + ], + {} + ] + ], "css/css-scoping/shadow-assign-dynamic-001.html": [ [ "/css/css-scoping/shadow-assign-dynamic-001.html", @@ -144283,6 +144295,11 @@ {} ] ], + "css/css-scoping/reference/green-text.html": [ + [ + {} + ] + ], "css/css-scoping/resources/host-green-box.css": [ [ {} @@ -198333,16 +198350,6 @@ {} ] ], - "wasm/jsapi/constructor/compile.any-expected.txt": [ - [ - {} - ] - ], - "wasm/jsapi/constructor/compile.any.worker-expected.txt": [ - [ - {} - ] - ], "wasm/jsapi/global/value-set.any-expected.txt": [ [ {} @@ -370766,6 +370773,14 @@ "24b5e0d5f53d8fab39a2d1699f77ccef417ef6b6", "support" ], + "css/css-scoping/reference/green-text.html": [ + "95736b4484dc020f02000fc327ae87494f491d48", + "support" + ], + "css/css-scoping/reslot-text-inheritance.html": [ + "43711c83bd160825caf1d89c7599f3df1ae64508", + "reftest" + ], "css/css-scoping/resources/host-green-box.css": [ "a77b3fdc6432ea324e1601b99e901611d76098b0", "support" @@ -474947,7 +474962,7 @@ "support" ], "tools/wptrunner/wptrunner/update/metadata.py": [ - "d7e8ba2b47c12731ac80dc33ade34cc03299d582", + "62569fbd9ff27e44adacc652b3f9c409f6ce8df6", "support" ], "tools/wptrunner/wptrunner/update/state.py": [ @@ -475307,7 +475322,7 @@ "testharness" ], "trusted-types/block-string-assignment-to-Document-write.tentative.html": [ - "5fa0b194df60c28dad98da828f5d22694d966e0f", + "845df475fa0c8833c63b4db7992cde1a804635f9", "testharness" ], "trusted-types/block-string-assignment-to-Element-insertAdjacentHTML.tentative.html": [ @@ -476635,27 +476650,19 @@ "support" ], "wasm/jsapi/bad-imports.js": [ - "f076baacca8b3e6addf49f6841874d11bfcfe5a2", - "support" - ], - "wasm/jsapi/constructor/compile.any-expected.txt": [ - "978320b4f8187b8835dad0ded44bf47c73176a1c", + "6c7d8056c7ba7076bbbccedc6ca9c4e9d2b73f1c", "support" ], "wasm/jsapi/constructor/compile.any.js": [ - "f0d6f7aee4cc21169fb715e3fd1e652cd699ca7e", + "1442cfccdf1b9c6aaeda2c1fa5af30ff0c89ea09", "testharness" ], - "wasm/jsapi/constructor/compile.any.worker-expected.txt": [ - "978320b4f8187b8835dad0ded44bf47c73176a1c", - "support" - ], "wasm/jsapi/constructor/instantiate-bad-imports.any.js": [ "86700298dfae66de6f4d026baa29e6e3584320f7", "testharness" ], "wasm/jsapi/constructor/instantiate.any.js": [ - "97350c5acd2c4e7d6380538ed7983ff5c53e5bf5", + "356f87d02d34b0483944f993146927985e5867f6", "testharness" ], "wasm/jsapi/constructor/validate.any.js": [ @@ -488675,7 +488682,7 @@ "support" ], "xhr/resources/authentication.py": [ - "f5bef5ba8262fbd51c4d907a9805a271cc19baa9", + "618d285cf6e305cc301a821a9e89012dd5ca559e", "support" ], "xhr/resources/base.xml": [
diff --git a/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/update/metadata.py b/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/update/metadata.py index d7e8ba2..62569fb 100644 --- a/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/update/metadata.py +++ b/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/update/metadata.py
@@ -11,7 +11,7 @@ def create(self, state): property_order, boolean_properties = products.load_product_update( state.config, state.product) - state.property_order = property_order + state.extra_properties + state.property_order = (property_order or []) + state.extra_properties state.boolean_properties = boolean_properties
diff --git a/third_party/blink/web_tests/external/wpt/wasm/jsapi/bad-imports.js b/third_party/blink/web_tests/external/wpt/wasm/jsapi/bad-imports.js index f076baa..6c7d805 100644 --- a/third_party/blink/web_tests/external/wpt/wasm/jsapi/bad-imports.js +++ b/third_party/blink/web_tests/external/wpt/wasm/jsapi/bad-imports.js
@@ -1,3 +1,15 @@ +/** + * `t` should be a function that takes at least three arguments: + * + * - the name of the test; + * - the expected error (to be passed to `assert_throws` or similar); + * - a function that takes a `WasmModuleBuilder` and initializes it; + * - (optionally) an options object. + * + * The function is expected to create a test that checks if instantiating a + * module with the result of the `WasmModuleBuilder` and the options object + * (if any) yields the correct error. + */ function test_bad_imports(t) { for (const value of [null, true, "", Symbol(), 1, 0.1, NaN]) { t(`Non-object imports argument: ${format_value(value)}`, @@ -15,7 +27,7 @@ builder => { builder.addImport("module", "fn", kSig_v_v); }, - value); + imports); } t(`Missing imports argument`,
diff --git a/third_party/blink/web_tests/external/wpt/wasm/jsapi/constructor/compile.any-expected.txt b/third_party/blink/web_tests/external/wpt/wasm/jsapi/constructor/compile.any-expected.txt deleted file mode 100644 index 978320b..0000000 --- a/third_party/blink/web_tests/external/wpt/wasm/jsapi/constructor/compile.any-expected.txt +++ /dev/null
@@ -1,13 +0,0 @@ -This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = WebAssembly.compile(): expected string length @+10 -PASS Missing argument -PASS Invalid arguments -PASS Branding -PASS Promise type -PASS Empty buffer -FAIL Invalid code assert_throws: function "() => WebAssembly.compile(buffer)" did not throw -PASS Result type -PASS Stray argument -PASS Changing the buffer -Harness: the test ran to completion. -
diff --git a/third_party/blink/web_tests/external/wpt/wasm/jsapi/constructor/compile.any.js b/third_party/blink/web_tests/external/wpt/wasm/jsapi/constructor/compile.any.js index f0d6f7a..1442cfc 100644 --- a/third_party/blink/web_tests/external/wpt/wasm/jsapi/constructor/compile.any.js +++ b/third_party/blink/web_tests/external/wpt/wasm/jsapi/constructor/compile.any.js
@@ -64,9 +64,9 @@ return promise_rejects(t, new WebAssembly.CompileError(), WebAssembly.compile(buffer)); }, "Empty buffer"); -test(() => { +promise_test(t => { const buffer = new Uint8Array(Array.from(emptyModuleBinary).concat([0, 0])); - assert_throws(new WebAssembly.CompileError(), () => WebAssembly.compile(buffer)); + return promise_rejects(t, new WebAssembly.CompileError(), WebAssembly.compile(buffer)); }, "Invalid code"); promise_test(() => {
diff --git a/third_party/blink/web_tests/external/wpt/wasm/jsapi/constructor/compile.any.worker-expected.txt b/third_party/blink/web_tests/external/wpt/wasm/jsapi/constructor/compile.any.worker-expected.txt deleted file mode 100644 index 978320b..0000000 --- a/third_party/blink/web_tests/external/wpt/wasm/jsapi/constructor/compile.any.worker-expected.txt +++ /dev/null
@@ -1,13 +0,0 @@ -This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = WebAssembly.compile(): expected string length @+10 -PASS Missing argument -PASS Invalid arguments -PASS Branding -PASS Promise type -PASS Empty buffer -FAIL Invalid code assert_throws: function "() => WebAssembly.compile(buffer)" did not throw -PASS Result type -PASS Stray argument -PASS Changing the buffer -Harness: the test ran to completion. -
diff --git a/third_party/blink/web_tests/external/wpt/wasm/jsapi/constructor/instantiate.any.js b/third_party/blink/web_tests/external/wpt/wasm/jsapi/constructor/instantiate.any.js index 97350c5..356f87d 100644 --- a/third_party/blink/web_tests/external/wpt/wasm/jsapi/constructor/instantiate.any.js +++ b/third_party/blink/web_tests/external/wpt/wasm/jsapi/constructor/instantiate.any.js
@@ -76,6 +76,64 @@ }, `${name}: Module argument`); } +promise_test(() => { + const builder = new WasmModuleBuilder(); + builder.addImportedGlobal("module", "global", kWasmI32); + const buffer = builder.toBuffer(); + const order = []; + + const imports = { + get module() { + order.push("module getter"); + return { + get global() { + order.push("global getter"); + return 0; + }, + } + }, + }; + + const expected = [ + "module getter", + "global getter", + ]; + const p = WebAssembly.instantiate(buffer, imports); + assert_array_equals(order, []); + return p.then(result => { + assert_WebAssemblyInstantiatedSource(result); + assert_array_equals(order, expected); + }); +}, "Synchronous options handling: Buffer argument"); + +promise_test(() => { + const builder = new WasmModuleBuilder(); + builder.addImportedGlobal("module", "global", kWasmI32); + const buffer = builder.toBuffer(); + const module = new WebAssembly.Module(buffer); + const order = []; + + const imports = { + get module() { + order.push("module getter"); + return { + get global() { + order.push("global getter"); + return 0; + }, + } + }, + }; + + const expected = [ + "module getter", + "global getter", + ]; + const p = WebAssembly.instantiate(module, imports); + assert_array_equals(order, expected); + return p.then(instance => assert_Instance(instance, {})); +}, "Synchronous options handling: Module argument"); + promise_test(t => { const buffer = new Uint8Array(); return promise_rejects(t, new WebAssembly.CompileError(), WebAssembly.instantiate(buffer));
diff --git a/third_party/blink/web_tests/external/wpt/xhr/resources/authentication.py b/third_party/blink/web_tests/external/wpt/xhr/resources/authentication.py index f5bef5ba..618d285 100644 --- a/third_party/blink/web_tests/external/wpt/xhr/resources/authentication.py +++ b/third_party/blink/web_tests/external/wpt/xhr/resources/authentication.py
@@ -11,9 +11,7 @@ if token is not None: request.server.stash.put(token, "1") status = (401, 'Unauthorized') - headers = [('WWW-Authenticate', 'Basic realm="test"'), - ('XHR-USER', expected_user_name), - ('SES-USER', session_user)] + headers = [('WWW-Authenticate', 'Basic realm="test"')] return status, headers, 'FAIL (should be transparent)' else: if request.server.stash.take(token) == "1":
diff --git a/third_party/blink/web_tests/fast/css/containment/compositing-inputs-root-sticky-crash-expected.txt b/third_party/blink/web_tests/fast/css/containment/compositing-inputs-root-sticky-crash-expected.txt new file mode 100644 index 0000000..5f1872e --- /dev/null +++ b/third_party/blink/web_tests/fast/css/containment/compositing-inputs-root-sticky-crash-expected.txt
@@ -0,0 +1 @@ +The test passes if it doesn't crash in debug.
diff --git a/third_party/blink/web_tests/fast/css/containment/compositing-inputs-root-sticky-crash.html b/third_party/blink/web_tests/fast/css/containment/compositing-inputs-root-sticky-crash.html new file mode 100644 index 0000000..3602fab8 --- /dev/null +++ b/third_party/blink/web_tests/fast/css/containment/compositing-inputs-root-sticky-crash.html
@@ -0,0 +1,14 @@ +<!DOCTYPE html> +<script> + if (window.testRunner) + testRunner.dumpAsText(); + onload = () => { + document.body.style.color = "blue"; + document.caretRangeFromPoint(); + document.body.removeChild(myul); + }; +</script> +<p>The test passes if it doesn't crash in debug.</p> +<ul id="myul" style="contain: strict; position: sticky; bottom: 0; overflow: scroll;"> + <li id="myli" style="position: sticky;"></li> +</ul>
diff --git a/third_party/harfbuzz-ng/BUILD.gn b/third_party/harfbuzz-ng/BUILD.gn index b295a83..f0efd1e 100644 --- a/third_party/harfbuzz-ng/BUILD.gn +++ b/third_party/harfbuzz-ng/BUILD.gn
@@ -215,6 +215,9 @@ "HAVE_ICU_BUILTIN", "HAVE_INTEL_ATOMIC_PRIMITIVES", "HB_NO_MMAP", + + # TODO(https://crbug.com/949962): Remove once this is fixed upstream. + "U_DISABLE_VERSION_SUFFIX=0", ] if (is_component_build) {
diff --git a/third_party/libvpx/README.chromium b/third_party/libvpx/README.chromium index 710c8085c..112a0ed 100644 --- a/third_party/libvpx/README.chromium +++ b/third_party/libvpx/README.chromium
@@ -5,9 +5,9 @@ License File: source/libvpx/LICENSE Security Critical: yes -Date: Thursday April 04 2019 +Date: Wednesday April 10 2019 Branch: master -Commit: 4117995a8ecef413849bdc51ddaa82c77f5967bd +Commit: c46694c1d93ccfa40cb1c3b7c04c167be59fded4 Description: Contains the sources used to compile libvpx binaries used by Google Chrome and
diff --git a/third_party/libvpx/source/config/vpx_version.h b/third_party/libvpx/source/config/vpx_version.h index 0841b9b..3bf4107 100644 --- a/third_party/libvpx/source/config/vpx_version.h +++ b/third_party/libvpx/source/config/vpx_version.h
@@ -2,7 +2,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 8 #define VERSION_PATCH 0 -#define VERSION_EXTRA "336-g4117995a8e" +#define VERSION_EXTRA "366-gc46694c1d9" #define VERSION_PACKED ((VERSION_MAJOR<<16)|(VERSION_MINOR<<8)|(VERSION_PATCH)) -#define VERSION_STRING_NOSP "v1.8.0-336-g4117995a8e" -#define VERSION_STRING " v1.8.0-336-g4117995a8e" +#define VERSION_STRING_NOSP "v1.8.0-366-gc46694c1d9" +#define VERSION_STRING " v1.8.0-366-gc46694c1d9"
diff --git a/tools/mb/mb_config.pyl b/tools/mb/mb_config.pyl index 87cbc3e8..dbbb518e 100644 --- a/tools/mb/mb_config.pyl +++ b/tools/mb/mb_config.pyl
@@ -363,6 +363,14 @@ 'Chromium Android ARM 32-bit Goma RBE LoadTest (debug)': 'release_bot', 'Chromium Android ARM 32-bit Goma RBE LoadTest (clobber)': 'release_bot', 'Chromium Android ARM 32-bit Goma RBE LoadTest (clobber) (debug)': 'release_bot', + + # RBE FYI + 'Cast Linux (Goma RBE FYI)': 'cast_release_bot', + 'chromeos-amd64-generic-rel (Goma RBE FYI)': 'cros_chrome_sdk_headless_ozone', + 'fuchsia-fyi-arm64-rel (Goma RBE FYI)': 'release_bot_fuchsia_arm64', + 'fuchsia-fyi-x64-rel (Goma RBE FYI)': 'release_bot_fuchsia', + 'Linux ASan LSan Builder (Goma RBE FYI)': 'asan_lsan_release_trybot', + 'Linux MSan Builder (Goma RBE FYI)': 'msan_release_bot', }, 'chromium.gpu': { @@ -721,9 +729,9 @@ 'dawn-mac-x64-deps-rel': 'dawn_tests_release_trybot', 'dawn-win10-x86-deps-rel': 'dawn_tests_release_trybot_x86', 'dawn-win10-x64-deps-rel': 'dawn_tests_release_trybot', - 'linux-dawn-rel': 'gpu_fyi_tests_release_trybot', - 'mac-dawn-rel': 'gpu_fyi_tests_release_trybot', - 'win-dawn-rel': 'gpu_fyi_tests_release_trybot_x86', + 'linux-dawn-rel': 'dawn_tests_release_trybot', + 'mac-dawn-rel': 'dawn_tests_release_trybot', + 'win-dawn-rel': 'dawn_tests_release_trybot', }, 'tryserver.chromium.linux': {
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index 98ca28a..b9c431bbc 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -16480,6 +16480,7 @@ <int value="543" label="DeviceQuickFixBuildToken"/> <int value="544" label="ExtensionInstallListsMergeEnabled"/> <int value="545" label="SamlInSessionPasswordChangeEnabled"/> + <int value="546" label="UninstallBlacklistedExtensions"/> </enum> <enum name="EnterprisePolicyInvalidations"> @@ -32576,6 +32577,8 @@ <int value="-1302904242" label="enable-navigation-tracing"/> <int value="-1302859198" label="enable-stylus-virtual-keyboard:disabled"/> <int value="-1294050129" label="ContentFullscreen:disabled"/> + <int value="-1292615467" + label="OmniboxSuggestionTransparencyOptions:disabled"/> <int value="-1290053302" label="OfflinePagesInDownloadHomeOpenInCct:disabled"/> <int value="-1289678848" label="SystemDownloadManager:enabled"/> @@ -33457,6 +33460,7 @@ label="DataReductionProxyEnabledWithNetworkService:disabled"/> <int value="91938915" label="enable-suggestions-service"/> <int value="92327255" label="DisplayMoveWindowAccels:disabled"/> + <int value="93832899" label="NtpCustomizationMenuV2:enabled"/> <int value="98134240" label="material-design-ink-drop-animation-speed"/> <int value="103932290" label="show-autofill-type-predictions"/> <int value="105046382" label="ParallelDownloading:disabled"/> @@ -33551,6 +33555,7 @@ <int value="293134455" label="AutofillSendBillingCustomerNumber:disabled"/> <int value="293996306" label="ArrayPrototypeValues:disabled"/> <int value="296215399" label="WindowsMixedReality:disabled"/> + <int value="299792415" label="OmniboxSuggestionTransparencyOptions:enabled"/> <int value="300095239" label="FCMInvalidations:enabled"/> <int value="301869874" label="NTPPhysicalWebPageSuggestions:disabled"/> <int value="303058039" label="AccountConsistency:disabled"/> @@ -34086,6 +34091,7 @@ <int value="1142515376" label="enable-nacl"/> <int value="1142788238" label="FontCacheScaling:disabled"/> <int value="1148284632" label="NewTabPageUIMd:disabled"/> + <int value="1149417604" label="StreamlinedUsbPrinterSetup:disabled"/> <int value="1149823105" label="enable-input-ime-api"/> <int value="1150622273" label="enable-apps-file-associations"/> <int value="1152491093" label="MediaSessionService:disabled"/> @@ -34328,6 +34334,7 @@ <int value="1496571153" label="enable-webapk"/> <int value="1497924954" label="js-flags"/> <int value="1499163193" label="PostScriptPrinting:disabled"/> + <int value="1500390299" label="NtpCustomizationMenuV2:disabled"/> <int value="1505194447" label="disable-transition-compositing"/> <int value="1508761653" label="disable-site-isolation-trials"/> <int value="1509901380" label="disable-drive-search-in-app-launcher"/> @@ -34708,6 +34715,7 @@ <int value="2092605092" label="ChromeHomeShowGoogleGWhenUrlCleared:disabled"/> <int value="2093235103" label="default-tile-width"/> <int value="2093949489" label="ArrayPrototypeValues:enabled"/> + <int value="2094335682" label="StreamlinedUsbPrinterSetup:enabled"/> <int value="2097048479" label="disable-auto-hiding-toolbar-threshold"/> <int value="2098714203" label="enable-generic-sensors"/> <int value="2098907258" label="UseSurfaceLayerForVideo:disabled"/> @@ -41575,6 +41583,9 @@ <int value="3" label="Should suspend, not implemented"/> <int value="4" label="Should suspend, not allowed"/> <int value="5" label="Should suspend, blocked by administrator"/> + <int value="6" label="Forbidden because of server filter rule"/> + <int value="7" label="Newly forbidden because of server filter rule"/> + <int value="8" label="Successful empty request"/> </enum> <enum name="OfflineStatus"> @@ -42255,6 +42266,15 @@ <int value="2" label="NV12"/> </enum> +<enum name="OverlayFullScreenTypes"> + <int value="0" label="Window Mode"/> + <int value="1" label="Full Screen Mode"/> + <int value="2" label="Full Screen in Width Only"/> + <int value="3" label="Full Screen in Height Only"/> + <int value="4" label="Oversized Full Screen"/> + <int value="5" label="Not Available"/> +</enum> + <enum name="OverlayPanel.StateChangeReason"> <int value="0" label="Unknown"/> <int value="1" label="Reset"/>
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index c898909..f32f333 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml
@@ -13277,6 +13277,20 @@ <histogram name="Bluetooth.Availability" enum="BluetoothAvailability" expires_after="2019-12-31"> + <obsolete> + Deprecated as of 04/2019, and replaced by Bluetooth.Availability.v2. This + metric was double-reporting on an error condition. + </obsolete> + <owner>kenrb@chromium.org</owner> + <owner>kpaulhamus@chromium.org</owner> + <summary> + Determines the availability and capabilities of the Bluetooth driver. This + metric is logged on startup. + </summary> +</histogram> + +<histogram name="Bluetooth.Availability.v2" enum="BluetoothAvailability" + expires_after="2019-12-31"> <owner>kenrb@chromium.org</owner> <owner>kpaulhamus@chromium.org</owner> <summary> @@ -41863,6 +41877,17 @@ </summary> </histogram> +<histogram + name="GPU.DirectComposition.DisableLargerThanScreenOverlaysWorkaround" + enum="BooleanActive" expires_after="2019-7-31"> + <owner>magchen@chromium.org</owner> + <owner>zmo@chromium.org</owner> + <summary> + Recorded for each overlay frame during the video playback whether the + workaround that reduces the swap chain size to fit the screen is active. + </summary> +</histogram> + <histogram name="GPU.DirectComposition.FramesSinceColorSpaceChange" units="frames"> <owner>sunnyps@chromium.org</owner> @@ -41873,7 +41898,10 @@ </histogram> <histogram name="GPU.DirectComposition.FullScreenOverlay" - enum="BooleanFullScreen" expires_after="2020-12-31"> + enum="BooleanFullScreen" expires_after="2019-04-08"> + <obsolete> + Deprecated 4/2019. Replaced by GPU.DirectComposition.OverlayFullScreenTypes. + </obsolete> <owner>magchen@chromium.org</owner> <owner>zmo@chromium.org</owner> <summary> @@ -41911,6 +41939,16 @@ </summary> </histogram> +<histogram name="GPU.DirectComposition.OverlayFullScreenTypes" + enum="OverlayFullScreenTypes" expires_after="2019-12-31"> + <owner>magchen@chromium.org</owner> + <owner>zmo@chromium.org</owner> + <summary> + The overlay size types in comparison to the full screen size. Recorded for + each overlay quad during the video playback. + </summary> +</histogram> + <histogram name="GPU.DirectComposition.OverlayNV12Rec709Supported" enum="BooleanColorSpaceSupported" expires_after="2020-09-30"> <obsolete> @@ -96066,6 +96104,15 @@ </summary> </histogram> +<histogram name="Printing.PrinterCapabilities" units="ms" expires_after="M77"> + <owner>vkuzkokov@chromium.org</owner> + <owner>skau@chromium.org</owner> + <summary> + Records the time it takes to pull capabilities of a single printer from + OS-specific backend. Recorded immediately on completion. + </summary> +</histogram> + <histogram name="PrintPreview.DestinationAction" enum="PrintPreviewPrintDestinationBuckets"> <owner>avi@chromium.org</owner> @@ -114766,13 +114813,6 @@ <summary>Number of accounts in tokens sent to Gaia Multilogin.</summary> </histogram> -<histogram name="Signin.Multilogin.ResponseStatus" - enum="OAuthMultiloginResponseStatus" expires_after="2019-11-01"> - <owner>droger@chromium.org</owner> - <owner>msarda@chromium.org</owner> - <summary>Response status received from gaia Multilogin.</summary> -</histogram> - <histogram name="Signin.MultiloginFinished" enum="GoogleServiceAuthError" expires_after="2019-11-01"> <owner>droger@chromium.org</owner> @@ -114810,6 +114850,13 @@ </summary> </histogram> +<histogram name="Signin.OAuthMultiloginResponseStatus" + enum="OAuthMultiloginResponseStatus" expires_after="2019-11-01"> + <owner>droger@chromium.org</owner> + <owner>msarda@chromium.org</owner> + <summary>Response status received from gaia Multilogin.</summary> +</histogram> + <histogram name="Signin.OneClickConfirmation" enum="SigninFlowConfirmations"> <owner>noms@chromium.org</owner> <summary> @@ -141720,6 +141767,18 @@ <affected-histogram name="Autofill.SaveCreditCardPrompt"/> </histogram_suffixes> +<histogram_suffixes name="AutofillSaveCreditCardPromptFromDynamicChangeForm" + separator="."> + <suffix name="FromDynamicChangeForm" + label="Prompt shown from dynamic change forms"/> + <affected-histogram name="Autofill.CreditCardInfoBar.Local"/> + <affected-histogram name="Autofill.CreditCardInfoBar.Server"/> + <affected-histogram name="Autofill.SaveCreditCardPrompt.Local.FirstShow"/> + <affected-histogram name="Autofill.SaveCreditCardPrompt.Local.Reshows"/> + <affected-histogram name="Autofill.SaveCreditCardPrompt.Upload.FirstShow"/> + <affected-histogram name="Autofill.SaveCreditCardPrompt.Upload.Reshows"/> +</histogram_suffixes> + <histogram_suffixes name="AutofillSaveCreditCardPromptFromNonFocusableForm" separator="."> <suffix name="FromNonFocusableForm"
diff --git a/tools/perf/expectations.config b/tools/perf/expectations.config index b56102a..5a56707f 100644 --- a/tools/perf/expectations.config +++ b/tools/perf/expectations.config
@@ -232,9 +232,6 @@ # crbug.com/894744 [ Android ] startup.mobile/cct:coldish:bbc [ Skip ] crbug.com/948789 [ Nexus_5 ] startup.mobile/maps_pwa:with_http_cache [ Skip ] crbug.com/948789 [ Nexus_5X ] startup.mobile/maps_pwa:with_http_cache [ Skip ] -crbug.com/950754 [ Android_Go ] startup.mobile/cct:coldish:bbc [ Skip ] -crbug.com/950754 [ Android_Go ] startup.mobile/intent:coldish:bbc [ Skip ] -crbug.com/950754 [ Android_Go ] startup.mobile/intent:warm:bbc [ Skip ] # Benchmark: system_health.common_desktop crbug.com/773084 [ Mac ] system_health.common_desktop/browse:tools:maps [ Skip ]
diff --git a/ui/base/ime/win/tsf_text_store.cc b/ui/base/ime/win/tsf_text_store.cc index 5ff63417..1b40f9b 100644 --- a/ui/base/ime/win/tsf_text_store.cc +++ b/ui/base/ime/win/tsf_text_store.cc
@@ -593,7 +593,8 @@ // the replacement text is coming from on-screen keyboard, we should replace // current selection with new text. if (((new_composition_start > last_composition_start) || - (wparam_keydown_fired_ == 0 && !has_composition_range_)) && + (wparam_keydown_fired_ == 0 && !has_composition_range_ && + !text_input_client_->HasCompositionText())) && text_input_client_) { CommitTextAndEndCompositionIfAny(last_composition_start, new_composition_start); @@ -606,16 +607,21 @@ // Only need to set composition if the current composition string // (composition_string) is not the same as previous composition string // (prev_composition_string_) during same composition or the composition - // string is the same for different composition. If composition_string is - // empty and there is an existing composition going on, we still need to call - // into blink to complete the composition started by TSF. - if ((previous_composition_start_ != composition_range_.start() || - previous_composition_string_ != composition_string) || + // string is the same for different composition or selection is changed during + // composition. If composition_string is empty and there is an existing + // composition going on, we still need to call into blink to complete the + // composition started by TSF. + if ((has_composition_range_ && + (previous_composition_start_ != composition_range_.start() || + previous_composition_string_ != composition_string || + !previous_composition_selection_range_.EqualsIgnoringDirection( + selection_))) || ((wparam_keydown_fired_ != 0) && text_input_client_->HasCompositionText() && composition_string.empty())) { previous_composition_string_ = composition_string; previous_composition_start_ = composition_range_.start(); + previous_composition_selection_range_ = selection_; StartCompositionOnNewText(new_composition_start, composition_string); } @@ -866,6 +872,7 @@ composition_range_.set_end(0); previous_composition_string_.clear(); previous_composition_start_ = 0; + previous_composition_selection_range_ = gfx::Range::InvalidRange(); } } } @@ -1129,6 +1136,7 @@ previous_composition_string_.clear(); previous_composition_start_ = 0; + previous_composition_selection_range_ = gfx::Range::InvalidRange(); const size_t previous_buffer_size = string_buffer_document_.size(); string_pending_insertion_.clear(); composition_start_ = selection_.start(); @@ -1163,6 +1171,7 @@ previous_composition_string_.clear(); previous_composition_start_ = 0; + previous_composition_selection_range_ = gfx::Range::InvalidRange(); const size_t previous_buffer_size = string_buffer_document_.size(); string_pending_insertion_.clear(); composition_start_ = selection_.start();
diff --git a/ui/base/ime/win/tsf_text_store.h b/ui/base/ime/win/tsf_text_store.h index 51f7261..2605a96 100644 --- a/ui/base/ime/win/tsf_text_store.h +++ b/ui/base/ime/win/tsf_text_store.h
@@ -340,9 +340,13 @@ // edit session during same composition. |previous_composition_start_| // indicates composition start in last session during same composition. If // RequestLock() is called during two edit sessions, we don't want to set same - // composition string twice. + // composition string twice. |previous_composition_selection_range_| indicates + // the selection range during composition. We want to send the selection + // change to blink if IME only change the selection range but not the + // composition text. base::string16 previous_composition_string_; size_t previous_composition_start_ = 0; + gfx::Range previous_composition_selection_range_ = gfx::Range::InvalidRange(); // |new_text_inserted_| indicates there is text to be inserted // into blink during ITextStoreACP::SetText().
diff --git a/ui/base/ime/win/tsf_text_store_unittest.cc b/ui/base/ime/win/tsf_text_store_unittest.cc index 7446c62..7616372 100644 --- a/ui/base/ime/win/tsf_text_store_unittest.cc +++ b/ui/base/ime/win/tsf_text_store_unittest.cc
@@ -1134,6 +1134,7 @@ EXPECT_EQ(5u, composition.ime_text_spans[0].end_offset); EXPECT_EQ(ImeTextSpan::Thickness::kThin, composition.ime_text_spans[0].thickness); + has_composition_text_ = true; } HRESULT LockGranted2(DWORD flags) { @@ -1149,25 +1150,26 @@ text_spans()->push_back(text_span); *edit_flag() = true; - *composition_start() = 7; - composition_range()->set_start(0); + *composition_start() = 3; + composition_range()->set_start(3); composition_range()->set_end(7); return S_OK; } - void InsertText2(const base::string16& text) { EXPECT_EQ(L"axyZCPc", text); } + void InsertText2(const base::string16& text) { EXPECT_EQ(L"axy", text); } void SetCompositionText2(const ui::CompositionText& composition) { - EXPECT_EQ(L"axyZCPc", composition.text); + EXPECT_EQ(L"ZCPc", composition.text); EXPECT_EQ(0u, composition.selection.start()); - EXPECT_EQ(0u, composition.selection.end()); + EXPECT_EQ(4u, composition.selection.end()); ASSERT_EQ(1u, composition.ime_text_spans.size()); // There is no styling applied from TSF in English typing } HRESULT LockGranted3(DWORD flags) { GetTextTest(0, -1, L"axyZCPc", 7); + SetSelectionTest(7, 7, S_OK); text_spans()->clear(); *edit_flag() = true; @@ -1175,10 +1177,80 @@ composition_range()->set_start(0); composition_range()->set_end(0); + *has_composition_range() = false; return S_OK; } + void InsertText3(const base::string16& text) { + EXPECT_EQ(L"ZCPc", text); + has_composition_text_ = false; + } + + HRESULT LockGranted4(DWORD flags) { + GetTextTest(0, -1, L"axyZCPc", 7); + SetTextTest(7, 7, L"EFGH", S_OK); + GetTextTest(0, -1, L"axyZCPcEFGH", 11); + SetSelectionTest(11, 11, S_OK); + + text_spans()->clear(); + ImeTextSpan text_span; + text_span.start_offset = 0; + text_span.end_offset = 4; + text_span.underline_color = SK_ColorBLACK; + text_span.thickness = ImeTextSpan::Thickness::kThick; + text_spans()->push_back(text_span); + + *edit_flag() = true; + *composition_start() = 7; + composition_range()->set_start(7); + composition_range()->set_end(11); + + *has_composition_range() = true; + return S_OK; + } + + void SetCompositionText4(const ui::CompositionText& composition) { + EXPECT_EQ(L"EFGH", composition.text); + EXPECT_EQ(4u, composition.selection.start()); + EXPECT_EQ(4u, composition.selection.end()); + ASSERT_EQ(1u, composition.ime_text_spans.size()); + *has_composition_range() = true; + has_composition_text_ = true; + } + + HRESULT LockGranted5(DWORD flags) { + GetTextTest(0, -1, L"axyZCPcEFGH", 11); + SetSelectionTest(9, 9, S_OK); + + text_spans()->clear(); + ImeTextSpan text_span; + text_span.start_offset = 0; + text_span.end_offset = 4; + text_span.underline_color = SK_ColorBLACK; + text_span.thickness = ImeTextSpan::Thickness::kThick; + text_spans()->push_back(text_span); + + *edit_flag() = true; + *composition_start() = 7; + composition_range()->set_start(7); + composition_range()->set_end(11); + + return S_OK; + } + + // still need to call into TextInputClient to set composition text + // to update selection range even though composition text is unchanged. + void SetCompositionText5(const ui::CompositionText& composition) { + EXPECT_EQ(L"EFGH", composition.text); + EXPECT_EQ(2u, composition.selection.start()); + EXPECT_EQ(2u, composition.selection.end()); + ASSERT_EQ(1u, composition.ime_text_spans.size()); + } + + bool ClientHasCompositionText() { return has_composition_text_; } + private: + bool has_composition_text_; DISALLOW_COPY_AND_ASSIGN(ScenarioTestCallback); }; @@ -1186,14 +1258,24 @@ ScenarioTestCallback callback(text_store_.get()); EXPECT_CALL(text_input_client_, SetCompositionText(_)) .WillOnce(Invoke(&callback, &ScenarioTestCallback::SetCompositionText1)) - .WillOnce(Invoke(&callback, &ScenarioTestCallback::SetCompositionText2)); + .WillOnce(Invoke(&callback, &ScenarioTestCallback::SetCompositionText2)) + .WillOnce(Invoke(&callback, &ScenarioTestCallback::SetCompositionText4)) + .WillOnce(Invoke(&callback, &ScenarioTestCallback::SetCompositionText5)); EXPECT_CALL(text_input_client_, InsertText(_)) - .WillOnce(Invoke(&callback, &ScenarioTestCallback::InsertText2)); + .WillOnce(Invoke(&callback, &ScenarioTestCallback::InsertText2)) + .WillOnce(Invoke(&callback, &ScenarioTestCallback::InsertText3)); EXPECT_CALL(*sink_, OnLockGranted(_)) .WillOnce(Invoke(&callback, &ScenarioTestCallback::LockGranted1)) - .WillOnce(Invoke(&callback, &ScenarioTestCallback::LockGranted2)); + .WillOnce(Invoke(&callback, &ScenarioTestCallback::LockGranted2)) + .WillOnce(Invoke(&callback, &ScenarioTestCallback::LockGranted3)) + .WillOnce(Invoke(&callback, &ScenarioTestCallback::LockGranted4)) + .WillOnce(Invoke(&callback, &ScenarioTestCallback::LockGranted5)); + + EXPECT_CALL(text_input_client_, HasCompositionText()) + .WillRepeatedly( + Invoke(&callback, &ScenarioTestCallback::ClientHasCompositionText)); HRESULT result = kInvalidResult; EXPECT_EQ(S_OK, text_store_->RequestLock(TS_LF_READWRITE, &result)); @@ -1202,6 +1284,14 @@ EXPECT_EQ(S_OK, text_store_->RequestLock(TS_LF_READWRITE, &result)); EXPECT_EQ(S_OK, result); result = kInvalidResult; + EXPECT_EQ(S_OK, text_store_->RequestLock(TS_LF_READWRITE, &result)); + EXPECT_EQ(S_OK, result); + result = kInvalidResult; + EXPECT_EQ(S_OK, text_store_->RequestLock(TS_LF_READWRITE, &result)); + EXPECT_EQ(S_OK, result); + result = kInvalidResult; + EXPECT_EQ(S_OK, text_store_->RequestLock(TS_LF_READWRITE, &result)); + EXPECT_EQ(S_OK, result); } class GetTextExtTestCallback : public TSFTextStoreTestCallback { @@ -1500,13 +1590,6 @@ SetHasCompositionText(false); } - void SetCompositionText3(const ui::CompositionText& composition) { - EXPECT_EQ(L"", composition.text); - EXPECT_EQ(0u, composition.selection.start()); - EXPECT_EQ(0u, composition.selection.end()); - EXPECT_EQ(0u, composition.ime_text_spans.size()); - } - ui::EventDispatchDetails DispatchKeyEventPostIME3b( KeyEvent* key, base::OnceCallback<void(bool, bool)> ack_callback) { @@ -1529,8 +1612,7 @@ KeyEventTestCallback callback(text_store_.get()); EXPECT_CALL(text_input_client_, SetCompositionText(_)) .WillOnce(Invoke(&callback, &KeyEventTestCallback::SetCompositionText1)) - .WillOnce(Invoke(&callback, &KeyEventTestCallback::SetCompositionText2)) - .WillOnce(Invoke(&callback, &KeyEventTestCallback::SetCompositionText3)); + .WillOnce(Invoke(&callback, &KeyEventTestCallback::SetCompositionText2)); EXPECT_CALL(text_input_client_, InsertText(_)) .WillOnce(Invoke(&callback, &KeyEventTestCallback::InsertText2)) @@ -2392,13 +2474,6 @@ SetHasCompositionText(false); } - void SetCompositionText3(const ui::CompositionText& composition) { - EXPECT_EQ(L"", composition.text); - EXPECT_EQ(0u, composition.selection.start()); - EXPECT_EQ(0u, composition.selection.end()); - EXPECT_EQ(0u, composition.ime_text_spans.size()); - } - // Insert new composition text using SetText(). // We also fire key events here. HRESULT LockGranted4(DWORD flags) { @@ -2503,13 +2578,6 @@ SetHasCompositionText(false); } - void SetCompositionText6(const ui::CompositionText& composition) { - EXPECT_EQ(L"", composition.text); - EXPECT_EQ(0u, composition.selection.start()); - EXPECT_EQ(0u, composition.selection.end()); - EXPECT_EQ(0u, composition.ime_text_spans.size()); - } - private: DISALLOW_COPY_AND_ASSIGN(RegressionTestCallback); }; @@ -2519,10 +2587,8 @@ EXPECT_CALL(text_input_client_, SetCompositionText(_)) .WillOnce(Invoke(&callback, &RegressionTestCallback::SetCompositionText1)) .WillOnce(Invoke(&callback, &RegressionTestCallback::SetCompositionText2)) - .WillOnce(Invoke(&callback, &RegressionTestCallback::SetCompositionText3)) - .WillOnce(Invoke(&callback, &RegressionTestCallback::SetCompositionText5)) .WillOnce( - Invoke(&callback, &RegressionTestCallback::SetCompositionText6)); + Invoke(&callback, &RegressionTestCallback::SetCompositionText5)); EXPECT_CALL(input_method_delegate_, DispatchKeyEventPostIME(_, _)) .WillOnce(
diff --git a/ui/login/account_picker/chromeos_user_pod_row.css b/ui/login/account_picker/chromeos_user_pod_row.css index 88c4092c..1fd79275 100644 --- a/ui/login/account_picker/chromeos_user_pod_row.css +++ b/ui/login/account_picker/chromeos_user_pod_row.css
@@ -573,12 +573,12 @@ } .action-box-area .action-box-icon { - /* overriden in chrome/browser/resources/md_user_manager/user_manager.css */ + /* overriden in chrome/browser/resources/user_manager/user_manager.css */ display: none; } .user-image-gradient-area { - /* overriden in chrome/browser/resources/md_user_manager/user_manager.css */ + /* overriden in chrome/browser/resources/user_manager/user_manager.css */ display: none; }
diff --git a/ui/login/account_picker/user_pod_row.css b/ui/login/account_picker/user_pod_row.css index d8c0301..1ebba2cd 100644 --- a/ui/login/account_picker/user_pod_row.css +++ b/ui/login/account_picker/user_pod_row.css
@@ -500,12 +500,12 @@ } .action-box-area .action-box-icon { - /* overriden in chrome/browser/resources/md_user_manager/user_manager.css */ + /* overriden in chrome/browser/resources/user_manager/user_manager.css */ display: none; } .user-image-gradient-area { - /* overriden in chrome/browser/resources/md_user_manager/user_manager.css */ + /* overriden in chrome/browser/resources/user_manager/user_manager.css */ display: none; }