diff --git a/DEPS b/DEPS index cc7b255ead6063..a4964f4d80a6e6 100644 --- a/DEPS +++ b/DEPS @@ -239,7 +239,7 @@ vars = { # 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': '33c28b9fa98634d36dbb5f404a3be33decc35463', + 'skia_revision': 'd26057a2c0e1e35a2f3a498769a27d8f8b6b1e62', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other. @@ -314,7 +314,7 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling devtools-frontend # and whatever else without interference from each other. - 'devtools_frontend_revision': 'ebad3a4739fd8170cf9b8b91496cf8b866972d0a', + 'devtools_frontend_revision': 'a84185e6b5be9c88f8aad0fa589ab7c213d77e5d', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libprotobuf-mutator # and whatever else without interference from each other. @@ -354,7 +354,7 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. - 'dawn_revision': 'b7e2f3654264515c50b10308afb70626ef22bce1', + 'dawn_revision': '4682ae0034e7929dbea9b064ff39f6953eec406b', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. @@ -1700,7 +1700,7 @@ deps = { Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'), 'src-internal': { - 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@df7c46c625a3bb971a83b1469c8e82f7db00eeca', + 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@d49909553bd8838195664ca9df5b36229c2582da', 'condition': 'checkout_src_internal', }, diff --git a/android_webview/browser/permission/media_access_permission_request_unittest.cc b/android_webview/browser/permission/media_access_permission_request_unittest.cc index 02213a03d7e6ac..22e548b033b14a 100644 --- a/android_webview/browser/permission/media_access_permission_request_unittest.cc +++ b/android_webview/browser/permission/media_access_permission_request_unittest.cc @@ -59,7 +59,8 @@ class MediaAccessPermissionRequestTest : public testing::Test { video_id, blink::mojom::MediaStreamType::DEVICE_AUDIO_CAPTURE, blink::mojom::MediaStreamType::DEVICE_VIDEO_CAPTURE, false /* disable_local_echo */, - false /* request_pan_tilt_zoom_permission */); + false /* request_pan_tilt_zoom_permission */, + false /* region_capture_capable */); std::unique_ptr permission_request; permission_request = std::make_unique( diff --git a/android_webview/tools/remove_preinstalled_webview.py b/android_webview/tools/remove_preinstalled_webview.py index 2a5f1f5788ac55..4bf3305a13d2d1 100755 --- a/android_webview/tools/remove_preinstalled_webview.py +++ b/android_webview/tools/remove_preinstalled_webview.py @@ -1,4 +1,4 @@ -#!/usr/bin/env vpython +#!/usr/bin/env vpython3 # # Copyright 2018 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/ash/app_list/BUILD.gn b/ash/app_list/BUILD.gn index 503e1cf0f1f86d..a84d0a8fae0309 100644 --- a/ash/app_list/BUILD.gn +++ b/ash/app_list/BUILD.gn @@ -182,6 +182,7 @@ source_set("app_list") { "//components/prefs", "//components/services/app_service/public/cpp:app_update", "//components/sync", + "//components/vector_icons", "//extensions/common:common_constants", "//mojo/public/cpp/bindings", "//skia", diff --git a/ash/app_list/views/search_box_view.cc b/ash/app_list/views/search_box_view.cc index 45509280f70c0d..c3ad1a6c057202 100644 --- a/ash/app_list/views/search_box_view.cc +++ b/ash/app_list/views/search_box_view.cc @@ -34,6 +34,7 @@ #include "base/metrics/user_metrics.h" #include "base/notreached.h" #include "chromeos/ui/vector_icons/vector_icons.h" +#include "components/vector_icons/vector_icons.h" #include "ui/accessibility/ax_node_data.h" #include "ui/base/ime/composition_text.h" #include "ui/base/l10n/l10n_util.h" @@ -209,8 +210,9 @@ void SearchBoxView::UpdateModel(bool initiated_by_user) { void SearchBoxView::UpdateSearchIcon() { const bool search_engine_is_google = AppListModelProvider::Get()->search_model()->search_engine_is_google(); - const gfx::VectorIcon& google_icon = - is_search_box_active() ? kGoogleColorIcon : kGoogleBlackIcon; + const gfx::VectorIcon& google_icon = is_search_box_active() + ? vector_icons::kGoogleColorIcon + : kGoogleBlackIcon; const gfx::VectorIcon& icon = search_engine_is_google ? google_icon : kSearchEngineNotGoogleIcon; SetSearchIconImage( diff --git a/ash/app_list/views/search_box_view_unittest.cc b/ash/app_list/views/search_box_view_unittest.cc index b04f432f15500f..216c32429f0d85 100644 --- a/ash/app_list/views/search_box_view_unittest.cc +++ b/ash/app_list/views/search_box_view_unittest.cc @@ -34,6 +34,7 @@ #include "base/strings/utf_string_conversions.h" #include "base/test/metrics/user_action_tester.h" #include "base/test/scoped_feature_list.h" +#include "components/vector_icons/vector_icons.h" #include "ui/base/ime/composition_text.h" #include "ui/base/l10n/l10n_util.h" #include "ui/compositor/layer.h" @@ -284,8 +285,9 @@ TEST_F(SearchBoxViewTest, SearchBoxInactiveSearchBoxGoogle) { TEST_F(SearchBoxViewTest, SearchBoxActiveSearchEngineGoogle) { SetSearchEngineIsGoogle(true); SetSearchBoxActive(true, ui::ET_MOUSE_PRESSED); - const gfx::ImageSkia expected_icon = gfx::CreateVectorIcon( - kGoogleColorIcon, kSearchBoxIconSize, kDefaultSearchboxColor); + const gfx::ImageSkia expected_icon = + gfx::CreateVectorIcon(vector_icons::kGoogleColorIcon, kSearchBoxIconSize, + kDefaultSearchboxColor); const gfx::ImageSkia actual_icon = view()->search_icon()->GetImage(); diff --git a/ash/public/cpp/app_list/vector_icons/BUILD.gn b/ash/public/cpp/app_list/vector_icons/BUILD.gn index 7128b26f74ec44..b285730769bb05 100644 --- a/ash/public/cpp/app_list/vector_icons/BUILD.gn +++ b/ash/public/cpp/app_list/vector_icons/BUILD.gn @@ -18,7 +18,6 @@ aggregate_vector_icons("app_list_vector_icons") { "bookmark.icon", "equal.icon", "google_black.icon", - "google_color.icon", "history.icon", "mic_black.icon", "omnibox_generic.icon", diff --git a/ash/resources/vector_icons/BUILD.gn b/ash/resources/vector_icons/BUILD.gn index 5290bc23986417..a5b1861150b59b 100644 --- a/ash/resources/vector_icons/BUILD.gn +++ b/ash/resources/vector_icons/BUILD.gn @@ -73,7 +73,6 @@ aggregate_vector_icons("ash_vector_icons") { "dictation_on.icon", "dictation_on_newui.icon", "do_not_disturb_disabled.icon", - "dogfood.icon", "eight_files.icon", "files_app.icon", "five_files.icon", @@ -408,7 +407,6 @@ aggregate_vector_icons("ash_vector_icons") { "unified_menu_rotation_lock_auto.icon", "unified_menu_rotation_lock_landscape.icon", "unified_menu_rotation_lock_portrait.icon", - "unified_menu_settings.icon", "unified_menu_volume_high.icon", "unified_menu_volume_low.icon", "unified_menu_volume_medium.icon", diff --git a/ash/system/time/calendar_event_list_item_view.cc b/ash/system/time/calendar_event_list_item_view.cc index b855f2a22d6ab0..07a15632d3d320 100644 --- a/ash/system/time/calendar_event_list_item_view.cc +++ b/ash/system/time/calendar_event_list_item_view.cc @@ -98,7 +98,6 @@ CalendarEventListItemView::CalendarEventListItemView( time_range_(new views::Label()) { SetLayoutManager(std::make_unique()); GetViewAccessibility().OverrideName(GetClassName()); - SetFocusBehavior(FocusBehavior::ALWAYS); summary_->SetText(base::UTF8ToUTF16(event.summary())); SetUpLabel(summary_); diff --git a/ash/system/time/calendar_event_list_view.h b/ash/system/time/calendar_event_list_view.h index edd990e11e3181..a0c6f9bf5b0258 100644 --- a/ash/system/time/calendar_event_list_view.h +++ b/ash/system/time/calendar_event_list_view.h @@ -34,7 +34,6 @@ class ASH_EXPORT CalendarEventListView private: friend class CalendarViewEventListViewTest; - friend class CalendarViewTest; // Updates the event list entries. void UpdateListItems(); diff --git a/ash/system/time/calendar_view.cc b/ash/system/time/calendar_view.cc index 3f262d3eb052ae..9f1e49a4818fc4 100644 --- a/ash/system/time/calendar_view.cc +++ b/ash/system/time/calendar_view.cc @@ -306,8 +306,6 @@ CalendarView::CalendarView(DetailedViewDelegate* delegate, scroll_view_->SetDrawOverflowIndicator(false); scroll_view_->SetVerticalScrollBarMode( views::ScrollView::ScrollBarMode::kHiddenButEnabled); - scroll_view_->GetViewAccessibility().OverrideName(GetClassName()); - scroll_view_->SetFocusBehavior(FocusBehavior::ALWAYS); on_contents_scrolled_subscription_ = scroll_view_->AddContentsScrolledCallback(base::BindRepeating( &CalendarView::OnContentsScrolled, base::Unretained(this))); @@ -412,7 +410,7 @@ int CalendarView::PositionOfSelectedDate() const { } void CalendarView::ResetToToday() { - if (event_list_container_) + if (event_list_) return; calendar_view_controller_->UpdateMonth(base::Time::Now()); @@ -518,11 +516,6 @@ void CalendarView::MaybeResetContentViewFocusBehavior() { } content_view_->SetFocusBehavior(FocusBehavior::ALWAYS); - - // Also disable the focus behavior of the `event_list_container_`, since now - // the focusing ring is out of the date cells. - if (event_list_container_) - event_list_container_->SetFocusBehavior(FocusBehavior::NEVER); } void CalendarView::OnViewBoundsChanged(views::View* observed_view) { @@ -542,24 +535,12 @@ void CalendarView::OnViewFocused(View* observed_view) { if (observed_view != content_view_ || IsDateCellViewFocused()) return; - auto* focus_manager = GetFocusManager(); + // When focusing on the `content_view_`, we decide which is the to-be-focued + // cell based on the current position. previous_month_->EnableFocus(); current_month_->EnableFocus(); next_month_->EnableFocus(); - - // If the event list is showing, focus on the first cell in the current row or - // today's cell if today is in this row. - if (event_list_container_) { - focus_manager->SetFocusedView( - current_month_->focused_cells()[calendar_view_controller_ - ->GetExpandedRowIndex()]); - content_view_->SetFocusBehavior(FocusBehavior::NEVER); - event_list_container_->SetFocusBehavior(FocusBehavior::ALWAYS); - return; - } - - // When focusing on the `content_view_`, we decide which is the to-be-focued - // cell based on the current position. + auto* focus_manager = GetFocusManager(); const int position = scroll_view_->GetVisibleRect().y(); const int row_height = calendar_view_controller_->row_height(); @@ -666,12 +647,9 @@ void CalendarView::OnEventsFetched( } void CalendarView::OpenEventList() { - if (event_list_container_) + if (event_list_) return; - scroll_view_->SetVerticalScrollBarMode( - views::ScrollView::ScrollBarMode::kHiddenButEnabled); - if (!calendar_view_controller_->IsSelectedDateInCurrentMonth()) ScrollDownOneMonth(); base::AutoReset is_resetting_scrolling(&is_resetting_scroll_, true); @@ -682,20 +660,8 @@ void CalendarView::OpenEventList() { calendar_view_controller_->row_height()); scroll_view_->SetVerticalScrollBarMode( views::ScrollView::ScrollBarMode::kDisabled); - - // The event list is in a container, which will be used for escaping the - // focusing from the date cells. - event_list_container_ = AddChildView(std::make_unique()); - event_list_container_->SetLayoutManager(std::make_unique( - views::BoxLayout::Orientation::kVertical)); - event_list_container_->GetViewAccessibility().OverrideName(GetClassName()); - event_list_container_->SetFocusBehavior( - IsDateCellViewFocused() ? FocusBehavior::ALWAYS : FocusBehavior::NEVER); - - event_list_ = event_list_container_->AddChildView( + event_list_ = AddChildView( std::make_unique(calendar_view_controller_.get())); - event_list_->GetViewAccessibility().OverrideName(GetClassName()); - event_list_->SetFocusBehavior(FocusBehavior::ALWAYS); calendar_view_controller_->OnEventListOpened(); } @@ -703,8 +669,7 @@ void CalendarView::CloseEventList() { scroll_view_->ClipHeightTo(0, INT_MAX); scroll_view_->SetVerticalScrollBarMode( views::ScrollView::ScrollBarMode::kHiddenButEnabled); - RemoveChildViewT(event_list_container_); - event_list_container_ = nullptr; + RemoveChildViewT(event_list_); event_list_ = nullptr; calendar_view_controller_->OnEventListClosed(); } @@ -802,7 +767,7 @@ void CalendarView::ScrollOneMonthWithAnimation(bool is_scrolling_up) { if (is_resetting_scroll_) return; - if (event_list_container_) { + if (event_list_) { ScrollOneRowWithAnimation(is_scrolling_up); return; } @@ -956,23 +921,13 @@ void CalendarView::OnEvent(ui::Event* event) { // goes to the next focusable button in the header. if (key_event->type() == ui::EventType::ET_KEY_PRESSED && views::FocusManager::IsTabTraversalKeyEvent(*key_event)) { - // Set focus on `scroll_view_`/`event_list_` or null pointer to escape the - // focusing on the date cell. - if (key_event->IsShiftDown()) { - scroll_view_->RequestFocus(); - } else if (event_list_container_) { - event_list_container_->RequestFocus(); - event_list_container_->SetFocusBehavior(FocusBehavior::NEVER); - } else { - focus_manager->SetFocusedView(nullptr); - } - + // Set focus on null pointer first. Otherwise the it will auto + // `AdvanceFocus` when the focused cell is on blur. + focus_manager->SetFocusedView(nullptr); current_month_->DisableFocus(); previous_month_->DisableFocus(); next_month_->DisableFocus(); - TrayDetailedView::OnEvent(event); - content_view_->SetFocusBehavior(FocusBehavior::ALWAYS); return; } @@ -988,10 +943,6 @@ void CalendarView::OnEvent(ui::Event* event) { case ui::VKEY_UP: case ui::VKEY_DOWN: { auto* current_focusable_view = focus_manager->GetFocusedView(); - // Enable the scroll bar mode, in case it is disabled when the event list - // is showing. - scroll_view_->SetVerticalScrollBarMode( - views::ScrollView::ScrollBarMode::kHiddenButEnabled); // Moving 7 (`kDateInOneWeek`) steps will focus on the cell which is right // above or below the current cell, since each row has 7 days. @@ -1043,36 +994,13 @@ void CalendarView::OnEvent(ui::Event* event) { } } focus_manager->SetFocusedView(current_focusable_view); - // After focusing on the new cell the view should have scrolled already - // if needed, disable the scroll bar mode if the even list is showing. - if (event_list_container_) - scroll_view_->SetVerticalScrollBarMode( - views::ScrollView::ScrollBarMode::kDisabled); - const int current_height = - scroll_view_->GetVisibleRect().y() - PositionOfCurrentMonth(); - calendar_view_controller_->set_expanded_row_index( - current_height / calendar_view_controller_->row_height()); return; } case ui::VKEY_LEFT: case ui::VKEY_RIGHT: { - // Enable the scroll bar mode, in case it is disabled when the event list - // is showing. - scroll_view_->SetVerticalScrollBarMode( - views::ScrollView::ScrollBarMode::kHiddenButEnabled); bool is_reverse = base::i18n::IsRTL() ? key_code == ui::VKEY_RIGHT : key_code == ui::VKEY_LEFT; focus_manager->AdvanceFocus(/*reverse=*/is_reverse); - // After focusing on the new cell the view should have scrolled already - // if needed, disable the scroll bar mode if the even list is showing. - if (event_list_container_) - scroll_view_->SetVerticalScrollBarMode( - views::ScrollView::ScrollBarMode::kDisabled); - - const int current_height = - scroll_view_->GetVisibleRect().y() - PositionOfCurrentMonth(); - calendar_view_controller_->set_expanded_row_index( - current_height / calendar_view_controller_->row_height()); return; } default: diff --git a/ash/system/time/calendar_view.h b/ash/system/time/calendar_view.h index 90bebb41c13551..3de16a91560600 100644 --- a/ash/system/time/calendar_view.h +++ b/ash/system/time/calendar_view.h @@ -210,7 +210,6 @@ class ASH_EXPORT CalendarView : public CalendarViewController::Observer, views::Button* settings_button_ = nullptr; IconButton* up_button_ = nullptr; IconButton* down_button_ = nullptr; - views::View* event_list_container_ = nullptr; CalendarEventListView* event_list_ = nullptr; // If it `is_resetting_scroll_`, we don't calculate the scroll position and we diff --git a/ash/system/time/calendar_view_unittest.cc b/ash/system/time/calendar_view_unittest.cc index b29ae9169d31b0..c43a15febd9368 100644 --- a/ash/system/time/calendar_view_unittest.cc +++ b/ash/system/time/calendar_view_unittest.cc @@ -6,7 +6,6 @@ #include "ash/shell.h" #include "ash/style/icon_button.h" -#include "ash/system/time/calendar_event_list_view.h" #include "ash/system/time/calendar_month_view.h" #include "ash/system/time/calendar_unittest_utils.h" #include "ash/system/time/calendar_utils.h" @@ -61,16 +60,12 @@ class CalendarViewTest : public AshTestBase { } CalendarView* calendar_view() { return calendar_view_; } - views::ScrollView* scroll_view() { return calendar_view_->scroll_view_; } + views::ScrollView* scroll_view_() { return calendar_view_->scroll_view_; } views::View* previous_label() { return calendar_view_->previous_label_; } views::View* current_label() { return calendar_view_->current_label_; } views::View* next_label() { return calendar_view_->next_label_; } - views::ScrollView::ScrollBarMode GetScrollBarMode() { - return scroll_view()->GetVerticalScrollBarMode(); - } - // The position of the `next_month_`. int NextMonthPosition() { return previous_label()->GetPreferredSize().height() + @@ -121,9 +116,6 @@ class CalendarViewTest : public AshTestBase { views::Button* settings_button() { return calendar_view_->settings_button_; } IconButton* up_button() { return calendar_view_->up_button_; } IconButton* down_button() { return calendar_view_->down_button_; } - views::ImageButton* close_button() { - return calendar_view_->event_list_->close_button_; - } void ScrollUpOneMonth() { calendar_view_->ScrollUpOneMonthAndAutoScroll(); } void ScrollDownOneMonth() { @@ -136,11 +128,6 @@ class CalendarViewTest : public AshTestBase { generator.PressKey(ui::KeyboardCode::VKEY_TAB, ui::EventFlags::EF_NONE); } - void PressEnter() { - ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); - generator.PressKey(ui::KeyboardCode::VKEY_RETURN, ui::EventFlags::EF_NONE); - } - void PressUp() { ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); generator.PressKey(ui::KeyboardCode::VKEY_UP, ui::EventFlags::EF_NONE); @@ -255,8 +242,8 @@ TEST_F(CalendarViewTest, Scroll) { EXPECT_EQ(u"2021", header_year()->GetText()); // Scrolls to the next month. - scroll_view()->ScrollToPosition(scroll_view()->vertical_scroll_bar(), - NextMonthPosition()); + scroll_view_()->ScrollToPosition(scroll_view_()->vertical_scroll_bar(), + NextMonthPosition()); EXPECT_EQ(u"October", GetPreviousLabelText()); EXPECT_EQ(u"November", GetCurrentLabelText()); @@ -264,8 +251,8 @@ TEST_F(CalendarViewTest, Scroll) { EXPECT_EQ(u"November", month_header()->GetText()); EXPECT_EQ(u"2021", header_year()->GetText()); - scroll_view()->ScrollToPosition(scroll_view()->vertical_scroll_bar(), - NextMonthPosition()); + scroll_view_()->ScrollToPosition(scroll_view_()->vertical_scroll_bar(), + NextMonthPosition()); EXPECT_EQ(u"November", GetPreviousLabelText()); EXPECT_EQ(u"December", GetCurrentLabelText()); @@ -273,8 +260,8 @@ TEST_F(CalendarViewTest, Scroll) { EXPECT_EQ(u"December", month_header()->GetText()); EXPECT_EQ(u"2021", header_year()->GetText()); - scroll_view()->ScrollToPosition(scroll_view()->vertical_scroll_bar(), - NextMonthPosition()); + scroll_view_()->ScrollToPosition(scroll_view_()->vertical_scroll_bar(), + NextMonthPosition()); EXPECT_EQ(u"December", GetPreviousLabelText()); EXPECT_EQ(u"January2022", GetCurrentLabelText()); @@ -416,9 +403,8 @@ TEST_F(CalendarViewTest, FocusingToDateCell) { EXPECT_EQ(reset_to_today_button(), focus_manager->GetFocusedView()); PressTab(); // Settings button. - PressTab(); // Moves to the down button. - PressTab(); // Moves to the up button. - PressTab(); // Moves to the scroll view. + PressTab(); // Moves to down button. + PressTab(); // Moves to up button. // Moves to the the 7th date cell, which is the date of "today". PressTab(); @@ -433,7 +419,6 @@ TEST_F(CalendarViewTest, FocusingToDateCell) { PressTab(); // Moves to settings button. PressTab(); // Moves to down button. PressTab(); // Moves to up button. - PressTab(); // Moves to the scroll view. // Moves to the the 7th date cell, which is the date of "today". PressTab(); @@ -461,7 +446,6 @@ TEST_F(CalendarViewTest, MonthViewFocusing) { PressTab(); // Settings button. PressTab(); // Moves to down button. PressTab(); // Moves to up button. - PressTab(); // Moves to the scroll view. auto* focus_manager = calendar_view()->GetFocusManager(); // Moves to the the 7th date cell, which is the date of "today". @@ -533,7 +517,6 @@ TEST_F(CalendarViewTest, FocusingToNavigate) { PressTab(); // Settings button. PressTab(); // Moves to down button. PressTab(); // Moves to up button. - PressTab(); // Moves to the scroll view. auto* focus_manager = calendar_view()->GetFocusManager(); // Moves to the the 7th date cell, which is the date of "today". @@ -578,66 +561,6 @@ TEST_F(CalendarViewTest, FocusingToNavigate) { EXPECT_EQ(u"April", GetCurrentLabelText()); } -TEST_F(CalendarViewTest, ExpandableViewFocusing) { - base::Time date; - // Create a monthview based on Jun,7th 2021. - ASSERT_TRUE(base::Time::FromString("7 Jun 2021 10:00 GMT", &date)); - - // Set time override. - SetFakeNow(date); - base::subtle::ScopedTimeClockOverrides time_override( - &CalendarViewTest::FakeTimeNow, /*time_ticks_override=*/nullptr, - /*thread_ticks_override=*/nullptr); - - CreateCalendarView(); - - EXPECT_EQ(views::ScrollView::ScrollBarMode::kHiddenButEnabled, - GetScrollBarMode()); - - // Generates a tab key press. - PressTab(); // Focusing on the back button. - PressTab(); // Today's button. - PressTab(); // Settings button. - PressTab(); // Moves to down button. - PressTab(); // Moves to up button. - PressTab(); // Moves to the scroll view. - - EXPECT_EQ(views::ScrollView::ScrollBarMode::kHiddenButEnabled, - GetScrollBarMode()); - - auto* focus_manager = calendar_view()->GetFocusManager(); - // Moves to the the 7th date cell, which is the date of "today". - PressTab(); - EXPECT_EQ(u"7", - static_cast(focus_manager->GetFocusedView()) - ->GetText()); - EXPECT_EQ(u"June", GetCurrentLabelText()); - - // Opens the event list. - PressEnter(); - EXPECT_EQ(views::ScrollView::ScrollBarMode::kDisabled, GetScrollBarMode()); - - // Tapping on up arrow keys should go to the previous month, which mens the - // scroll bar is enabled during the key pressed. - PressUp(); - EXPECT_EQ(u"31", - static_cast(focus_manager->GetFocusedView()) - ->GetText()); - EXPECT_EQ(u"May", GetCurrentLabelText()); - EXPECT_EQ(views::ScrollView::ScrollBarMode::kDisabled, GetScrollBarMode()); - - // Moves to the event list. - PressTab(); - EXPECT_EQ(close_button(), focus_manager->GetFocusedView()); - - // Goes back to back button. - PressTab(); - - // Moves to the next focusable view. Today's button. - PressTab(); - EXPECT_EQ(reset_to_today_button(), focus_manager->GetFocusedView()); -} - // A test class for testing animation. This class cannot set fake now since it's // using `MOCK_TIME` to test the animations. class CalendarViewAnimationTest : public AshTestBase { diff --git a/ash/system/tray/detailed_view_delegate.cc b/ash/system/tray/detailed_view_delegate.cc index ec6064729c1acf..a9d520a41b7506 100644 --- a/ash/system/tray/detailed_view_delegate.cc +++ b/ash/system/tray/detailed_view_delegate.cc @@ -190,9 +190,9 @@ views::Button* DetailedViewDelegate::CreateInfoButton( views::Button* DetailedViewDelegate::CreateSettingsButton( views::Button::PressedCallback callback, int setting_accessible_name_id) { - auto* button = - new IconButton(std::move(callback), IconButton::Type::kSmall, - &kUnifiedMenuSettingsIcon, setting_accessible_name_id); + auto* button = new IconButton(std::move(callback), IconButton::Type::kSmall, + &vector_icons::kSettingsOutlineIcon, + setting_accessible_name_id); if (!TrayPopupUtils::CanOpenWebUISettings()) button->SetEnabled(false); return button; diff --git a/ash/system/unified/top_shortcuts_view.cc b/ash/system/unified/top_shortcuts_view.cc index ada6d09a9d63d5..0d0fea765d6896 100644 --- a/ash/system/unified/top_shortcuts_view.cc +++ b/ash/system/unified/top_shortcuts_view.cc @@ -28,6 +28,7 @@ #include "base/cxx17_backports.h" #include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_service.h" +#include "components/vector_icons/vector_icons.h" #include "ui/gfx/paint_vector_icon.h" #include "ui/views/border.h" #include "ui/views/controls/button/button.h" @@ -224,7 +225,7 @@ TopShortcutsView::TopShortcutsView(UnifiedSystemTrayController* controller) { settings_button_ = new IconButton( base::BindRepeating(&UnifiedSystemTrayController::HandleSettingsAction, base::Unretained(controller)), - IconButton::Type::kSmall, &kUnifiedMenuSettingsIcon, + IconButton::Type::kSmall, &vector_icons::kSettingsOutlineIcon, IDS_ASH_STATUS_TRAY_SETTINGS); container_->AddChildView(settings_button_); local_state_pref_change_registrar_.Init(Shell::Get()->local_state()); diff --git a/ash/webui/camera_app_ui/resources/js/app_window.js b/ash/webui/camera_app_ui/resources/js/app_window.js deleted file mode 100644 index 2d6e42cefe719a..00000000000000 --- a/ash/webui/camera_app_ui/resources/js/app_window.js +++ /dev/null @@ -1,215 +0,0 @@ -// Copyright 2020 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 { - ErrorInfo, // eslint-disable-line no-unused-vars - PerfEntry, // eslint-disable-line no-unused-vars - PerfEvent, - Resolution, -} from './type.js'; -import {WaitableEvent} from './waitable_event.js'; - -const TOP_BAR_HEIGHT = 32; - -const DEFAULT_WINDOW_WIDTH = 764; - -/** - * Gets default window size which minimizes the letterbox area for given preview - * aspect ratio. - * @param {number} aspectRatio Preview aspect ratio. - * @return {!Resolution} - */ -export function getDefaultWindowSize(aspectRatio) { - // For the call site from background.js cannot access letterbox space reserved - // for controls on 3 sides around #preview-box directly from dom. The - // letterbox size number is hard coded here. - // TODO(b/172345161): Reference these number from left, right, bottom of - // #preview-box's bounding client rect after background.js being removed. - const bottom = 88; - const left = 88; - const right = 100; - - return new Resolution( - DEFAULT_WINDOW_WIDTH, - Math.round( - (DEFAULT_WINDOW_WIDTH - (left + right)) / aspectRatio + bottom + - TOP_BAR_HEIGHT)); -} - -/** - * Class which is used to coordinate the setup of window between Tast side and - * CCA side. Note that the methods in this class are all marked with "async" - * since the instance of this class will be wrapped by Comlink, which makes - * all synchronous calls asynchronous. Making them async will make type check - * easier. - */ -export class AppWindow { - /** - * @param {boolean} fromColdStart Whether this app is launched from a cold - * start. It is used for performance measurement. - * @public - */ - constructor(fromColdStart) { - /** - * @type {boolean} - * @private - */ - this.fromColdStart_ = fromColdStart; - - /** - * A waitable event which will resolve to the URL of the CCA instance just - * launched. - * @type {!WaitableEvent} - * @private - */ - this.readyOnCCASide_ = new WaitableEvent(); - - /** - * @type {!WaitableEvent} - * @private - */ - this.readyOnTastSide_ = new WaitableEvent(); - - /** - * @type {!WaitableEvent} - * @private - */ - this.onClosed_ = new WaitableEvent(); - - /** - * @type {boolean} - * @private - */ - this.inClosingItself_ = false; - - /** - * @type {!Array} - */ - this.errors_ = []; - - /** - * @type {!Array} - */ - this.perfs_ = []; - - /** - * @type {number} - */ - this.launchedTime_ = performance.now(); - } - - /** - * Waits until the window is bound and returns the URL of the window. - * @return {!Promise} The URL of the window. - */ - async waitUntilWindowBound() { - return this.readyOnCCASide_.wait(); - } - - /** - * Binds the URL to the window. - * @param {string} url - * @return {!Promise} - */ - async bindUrl(url) { - this.readyOnCCASide_.signal(url); - } - - /** - * Notifies the listener that the window setup is done on Tast side. - * @return {!Promise} - */ - async notifyReadyOnTastSide() { - this.readyOnTastSide_.signal(); - } - - /** - * Waits until the setup for the window is done on Tast side. - * @return {!Promise} - */ - async waitUntilReadyOnTastSide() { - return this.readyOnTastSide_.wait(); - } - - /** - * Triggers when CCA is fully launched. - * @return {!Promise} - */ - async onAppLaunched() { - const event = this.fromColdStart_ ? - PerfEvent.LAUNCHING_FROM_LAUNCH_APP_COLD : - PerfEvent.LAUNCHING_FROM_LAUNCH_APP_WARM; - this.perfs_.push({ - event: event, - duration: (performance.now() - this.launchedTime_), - }); - } - - /** - * Notifies the listener that the window is closed. - * @return {!Promise} - */ - async notifyClosed() { - this.onClosed_.signal(); - } - - /** - * Waits until the window is closed. - * @return {!Promise} - */ - async waitUntilClosed() { - return this.onClosed_.wait(); - } - - /** - * Notifies the listener that the window is about to close itself. - * @return {!Promise} - */ - async notifyClosingItself() { - this.inClosingItself_ = true; - } - - /** - * Check if it has received the signal that the window is about to close - * itself. - * @return {!Promise} - */ - async isClosingItself() { - return this.inClosingItself_; - } - - /** - * Reports error and makes it visible on Tast side. - * @param {!ErrorInfo} errorInfo Information of the error. - * @return {!Promise} - */ - async reportError(errorInfo) { - this.errors_.push(errorInfo); - } - - /** - * Gets all the errors. - * @return {!Promise>} - */ - async getErrors() { - return this.errors_; - } - - /** - * Reports perf information and makes it visible on Tast side. - * @param {!PerfEntry} perfEntry Information of the perf event. - * @return {!Promise} - */ - async reportPerf(perfEntry) { - this.perfs_.push(perfEntry); - } - - /** - * Gets all the perf information. - * @return {!Promise>} - */ - async getPerfs() { - return this.perfs_; - } -} diff --git a/ash/webui/camera_app_ui/resources/js/app_window.ts b/ash/webui/camera_app_ui/resources/js/app_window.ts new file mode 100644 index 00000000000000..1755a819931d94 --- /dev/null +++ b/ash/webui/camera_app_ui/resources/js/app_window.ts @@ -0,0 +1,162 @@ +// Copyright 2020 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 { + ErrorInfo, + PerfEntry, + PerfEvent, + Resolution, +} from './type.js'; +import {WaitableEvent} from './waitable_event.js'; + +const TOP_BAR_HEIGHT = 32; + +const DEFAULT_WINDOW_WIDTH = 764; + +/** + * Gets default window size which minimizes the letterbox area for given preview + * aspect ratio. + * @param {number} aspectRatio Preview aspect ratio. + * @return {!Resolution} + */ +export function getDefaultWindowSize(aspectRatio: number): Resolution { + // For the call site from background.js cannot access letterbox space reserved + // for controls on 3 sides around #preview-box directly from dom. The + // letterbox size number is hard coded here. + // TODO(b/172345161): Reference these number from left, right, bottom of + // #preview-box's bounding client rect after background.js being removed. + const bottom = 88; + const left = 88; + const right = 100; + + return new Resolution( + DEFAULT_WINDOW_WIDTH, + Math.round( + (DEFAULT_WINDOW_WIDTH - (left + right)) / aspectRatio + bottom + + TOP_BAR_HEIGHT)); +} + +/** + * Class which is used to coordinate the setup of window between Tast side and + * CCA side. + */ +export class AppWindow { + /** + * A waitable event which will resolve to the URL of the CCA instance just + * launched. + */ + private readonly readyOnCCASide = new WaitableEvent(); + private readonly readyOnTastSide = new WaitableEvent(); + private readonly onClosed = new WaitableEvent(); + private inClosingItself = false; + private readonly errors: ErrorInfo[] = []; + private readonly perfs: PerfEntry[] = []; + private launchedTime = performance.now(); + /** + * @param fromColdStart Whether this app is launched from a cold start. It is + * used for performance measurement. + */ + constructor(private readonly fromColdStart: boolean) {} + + /** + * Waits until the window is bound and returns the URL of the window. + * @return The URL of the window. + */ + waitUntilWindowBound(): Promise { + return this.readyOnCCASide.wait(); + } + + /** + * Binds the URL to the window. + */ + bindUrl(url: string): void { + this.readyOnCCASide.signal(url); + } + + /** + * Notifies the listener that the window setup is done on Tast side. + */ + notifyReadyOnTastSide(): void { + this.readyOnTastSide.signal(); + } + + /** + * Waits until the setup for the window is done on Tast side. + */ + waitUntilReadyOnTastSide(): Promise { + return this.readyOnTastSide.wait(); + } + + /** + * Triggers when CCA is fully launched. + */ + onAppLaunched(): void { + const event = this.fromColdStart ? + PerfEvent.LAUNCHING_FROM_LAUNCH_APP_COLD : + PerfEvent.LAUNCHING_FROM_LAUNCH_APP_WARM; + this.perfs.push({ + event: event, + duration: (performance.now() - this.launchedTime), + }); + } + + /** + * Notifies the listener that the window is closed. + */ + notifyClosed(): void { + this.onClosed.signal(); + } + + /** + * Waits until the window is closed. + */ + waitUntilClosed(): Promise { + return this.onClosed.wait(); + } + + /** + * Notifies the listener that the window is about to close itself. + */ + notifyClosingItself(): void { + this.inClosingItself = true; + } + + /** + * Check if it has received the signal that the window is about to close + * itself. + */ + isClosingItself(): boolean { + return this.inClosingItself; + } + + /** + * Reports error and makes it visible on Tast side. + * @param errorInfo Information of the error. + */ + reportError(errorInfo: ErrorInfo): void { + this.errors.push(errorInfo); + } + + /** + * Gets all the errors. + */ + getErrors(): ErrorInfo[] { + return this.errors; + } + + /** + * Reports perf information and makes it visible on Tast side. + * @param perfEntry Information of the perf event. + */ + reportPerf(perfEntry: PerfEntry): void { + this.perfs.push(perfEntry); + } + + /** + * Gets all the perf information. + */ + getPerfs(): PerfEntry[] { + return this.perfs; + } +} diff --git a/ash/webui/camera_app_ui/resources/js/error.ts b/ash/webui/camera_app_ui/resources/js/error.ts index 71178d7ecfc9ea..912b22060728ef 100644 --- a/ash/webui/camera_app_ui/resources/js/error.ts +++ b/ash/webui/camera_app_ui/resources/js/error.ts @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import {AppWindow} from './app_window.js'; import {assertInstanceof} from './assert.js'; import * as metrics from './metrics.js'; import { @@ -94,7 +93,7 @@ function formatErrorStack(error: Error, frames: StackFrame[]|null): string { .join(''); } -const appWindow: AppWindow|null = window['appWindow']; +const appWindow = window.appWindow; /** * Initializes error collecting functions. diff --git a/ash/webui/camera_app_ui/resources/js/init.ts b/ash/webui/camera_app_ui/resources/js/init.ts index a94c989fce1245..2dd2e017c53f84 100644 --- a/ash/webui/camera_app_ui/resources/js/init.ts +++ b/ash/webui/camera_app_ui/resources/js/init.ts @@ -11,17 +11,26 @@ */ import '/strings.m.js'; +import {AppWindow} from './app_window.js'; import * as Comlink from './lib/comlink.js'; import {TestBridge} from './test_bridge.js'; + +declare global { + interface Window { + // TODO(crbug.com/980846): Refactor to use a better way rather than window + // properties to pass data to other modules. + appWindow: Comlink.Remote|null; + } +} + + document.addEventListener('DOMContentLoaded', async () => { const workerPath = '/js/test_bridge.js'; const sharedWorker = new SharedWorker(workerPath, {type: 'module'}); const testBridge = Comlink.wrap(sharedWorker.port); const appWindow = await testBridge.bindWindow(window.location.href); - // TODO(crbug.com/980846): Refactor to use a better way rather than window - // properties to pass data to other modules. - window['appWindow'] = appWindow; + window.appWindow = appWindow; window['windowCreationTime'] = performance.now(); if (appWindow !== null) { await appWindow.waitUntilReadyOnTastSide(); diff --git a/ash/webui/camera_app_ui/resources/js/js.gni b/ash/webui/camera_app_ui/resources/js/js.gni index 8b86210afd1238..0ace6fa22a7660 100644 --- a/ash/webui/camera_app_ui/resources/js/js.gni +++ b/ash/webui/camera_app_ui/resources/js/js.gni @@ -4,7 +4,7 @@ compile_js_files = [ "animation.js", - "app_window.js", + "app_window.ts", "assert.ts", "async_job_queue.ts", "barcode_chip.js", @@ -65,7 +65,7 @@ compile_js_files = [ "toast.js", "tooltip.js", "type.ts", - "unload.js", + "unload.ts", "untrusted_ga_helper.js", "untrusted_helper_interfaces.js", "untrusted_script_loader.js", diff --git a/ash/webui/camera_app_ui/resources/js/main.js b/ash/webui/camera_app_ui/resources/js/main.js index 623b2ddf3cea68..0e1b3c5c9b8087 100644 --- a/ash/webui/camera_app_ui/resources/js/main.js +++ b/ash/webui/camera_app_ui/resources/js/main.js @@ -3,7 +3,6 @@ // found in the LICENSE file. import { - AppWindow, // eslint-disable-line no-unused-vars getDefaultWindowSize, } from './app_window.js'; import {assert, assertInstanceof} from './assert.js'; @@ -51,9 +50,8 @@ import {WaitableEvent} from './waitable_event.js'; /** * The app window instance which is used for communication with Tast tests. For * non-test sessions, it should be null. - * @type {?AppWindow} */ -const appWindow = window['appWindow']; +const appWindow = window.appWindow; /** * Creates the Camera App main object. diff --git a/ash/webui/camera_app_ui/resources/js/test_bridge.ts b/ash/webui/camera_app_ui/resources/js/test_bridge.ts index bd010a7c0abb0b..9553c987f0f98f 100644 --- a/ash/webui/camera_app_ui/resources/js/test_bridge.ts +++ b/ash/webui/camera_app_ui/resources/js/test_bridge.ts @@ -33,7 +33,7 @@ let fromColdStart = true; * later once the window is created. This method is expected to be called in * Tast tests. */ -export function registerUnboundWindow(): AppWindow { +export function registerUnboundWindow(): AppWindow&Comlink.ProxyMarked { assert(pendingAppWindow === null); const appWindow = new AppWindow(fromColdStart); pendingAppWindow = appWindow; @@ -44,7 +44,7 @@ export function registerUnboundWindow(): AppWindow { * Binds the URL to pending AppWindow and exposes AppWindow using the URL. * @param url The URL to bind. */ -function bindWindow(url: string): AppWindow|null { +function bindWindow(url: string): (AppWindow&Comlink.ProxyMarked)|null { fromColdStart = false; if (pendingAppWindow !== null) { const appWindow = pendingAppWindow; diff --git a/ash/webui/camera_app_ui/resources/js/unload.js b/ash/webui/camera_app_ui/resources/js/unload.ts similarity index 76% rename from ash/webui/camera_app_ui/resources/js/unload.js rename to ash/webui/camera_app_ui/resources/js/unload.ts index a1c41550436b9c..3251cf8280fc30 100644 --- a/ash/webui/camera_app_ui/resources/js/unload.js +++ b/ash/webui/camera_app_ui/resources/js/unload.ts @@ -2,10 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -/** - * @type {!Array} - */ -const callbacks = []; +const callbacks: Array<(() => void)> = []; const onWindowUnload = () => { for (const callback of callbacks) { @@ -18,8 +15,7 @@ window.addEventListener('unload', onWindowUnload); /** * Adds a callback into the callback list. It follows the FIFO order. - * @param {function(): void} callback */ -export function addUnloadCallback(callback) { +export function addUnloadCallback(callback: () => void): void { callbacks.push(callback); } diff --git a/ash/webui/camera_app_ui/resources/js/views/camera_intent.js b/ash/webui/camera_app_ui/resources/js/views/camera_intent.js index 537d97f1c39155..8a2b65282b2605 100644 --- a/ash/webui/camera_app_ui/resources/js/views/camera_intent.js +++ b/ash/webui/camera_app_ui/resources/js/views/camera_intent.js @@ -183,7 +183,7 @@ export class CameraIntent extends Camera { if (confirmed) { await this.intent_.finish(); - const appWindow = window['appWindow']; + const appWindow = window.appWindow; if (appWindow === null) { window.close(); } else { diff --git a/cc/paint/clear_for_opaque_raster.cc b/cc/paint/clear_for_opaque_raster.cc index fb3865fcf510e3..7465dde6e530f4 100644 --- a/cc/paint/clear_for_opaque_raster.cc +++ b/cc/paint/clear_for_opaque_raster.cc @@ -65,8 +65,10 @@ bool CalculateClearForOpaqueRasterRects(const gfx::Vector2dF& translation, if (inner_rect.Contains(adjusted_playback_rect)) return false; + if (!outer_rect.Intersects(adjusted_playback_rect)) + return false; + outer_rect.Intersect(adjusted_playback_rect); - DCHECK(!outer_rect.IsEmpty()); inner_rect.Intersect(adjusted_playback_rect); // inner_rect can be empty if the content is very small. diff --git a/cc/paint/clear_for_opaque_raster_unittest.cc b/cc/paint/clear_for_opaque_raster_unittest.cc index 136a9eecb4abce..cb6ff04a72340a 100644 --- a/cc/paint/clear_for_opaque_raster_unittest.cc +++ b/cc/paint/clear_for_opaque_raster_unittest.cc @@ -172,4 +172,18 @@ TEST(ClearForOpaqueRasterTest, WithTranslationAndScale) { EXPECT_EQ(gfx::Rect(25, 25, 49, 49), inner_rect); } +TEST(ClearForOpaqueRasterTest, PlaybackRectBelowContentRect) { + const gfx::Vector2dF translation(0.0f, 0.1f); + const gfx::Vector2dF scale(1.0f, 1.0f); + const gfx::Size content_size(100, 100); + const gfx::Rect bitmap_rect(50, 50, 100, 100); + const gfx::Rect playback_rect(50, 100, 100, 3); + gfx::Rect inner_rect; + gfx::Rect outer_rect; + + EXPECT_FALSE(CalculateClearForOpaqueRasterRects( + translation, scale, content_size, bitmap_rect, playback_rect, outer_rect, + inner_rect)); +} + } // namespace cc diff --git a/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantDependencyUtilsChrome.java b/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantDependencyUtilsChrome.java new file mode 100644 index 00000000000000..ed72166f715675 --- /dev/null +++ b/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantDependencyUtilsChrome.java @@ -0,0 +1,40 @@ +// Copyright 2021 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.autofill_assistant; + +import android.app.Activity; +import android.content.Intent; + +import androidx.annotation.Nullable; + +import org.chromium.chrome.browser.IntentHandler; +import org.chromium.chrome.browser.IntentHandler.ExternalAppId; + +/** + * Chrome specific dependency methods used by the Autofill Assistant outside of it's module. + */ +public class AssistantDependencyUtilsChrome { + /** + * Returns whether the activity was launched by GSA. + * */ + public static boolean isGsa(@Nullable Activity activity) { + // This can fail for certain tabs (e.g., hidden background tabs). + if (activity == null) { + return false; + } + + Intent intent = activity.getIntent(); + if (intent == null) { + // This should never happen, this is just a failsafe. + return false; + } + + // TODO(crbug.com/1139479): Once determineExternalIntentSource() is moved to //components + // remove the injection. + return IntentHandler.determineExternalIntentSource(intent) == ExternalAppId.GSA; + } + + private AssistantDependencyUtilsChrome() {} +} diff --git a/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantIsGsaFunction.java b/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantIsGsaFunction.java new file mode 100644 index 00000000000000..f0b9b1e7a4d9d8 --- /dev/null +++ b/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantIsGsaFunction.java @@ -0,0 +1,14 @@ +// Copyright 2021 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.autofill_assistant; + +import android.app.Activity; + +import org.chromium.base.Function; + +/** + * Determines whether the activity was launched by GSA. + */ +public interface AssistantIsGsaFunction extends Function {} diff --git a/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantTabHelper.java b/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantTabHelper.java index 90d33a2d11357f..36c955e7cfa00a 100644 --- a/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantTabHelper.java +++ b/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantTabHelper.java @@ -17,8 +17,8 @@ public class AutofillAssistantTabHelper { * the tab as observer and connect to its native counterpart in order to fulfill startup * requests from either side. */ - public static void createForTab(Tab tab) { - Starter starter = new Starter(tab); + public static void createForTab(Tab tab, AssistantIsGsaFunction isGsaFunction) { + Starter starter = new Starter(tab, isGsaFunction); tab.addObserver(starter); tab.getUserDataHost().setUserData(USER_DATA_KEY, starter); } @@ -26,4 +26,4 @@ public static void createForTab(Tab tab) { public static Starter get(Tab tab) { return tab.getUserDataHost().getUserData(USER_DATA_KEY); } -} \ No newline at end of file +} diff --git a/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/Starter.java b/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/Starter.java index a1b86250718915..df189628b5c614 100644 --- a/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/Starter.java +++ b/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/Starter.java @@ -4,8 +4,6 @@ package org.chromium.chrome.browser.autofill_assistant; -import android.content.Intent; - import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; @@ -13,8 +11,6 @@ import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.NativeMethods; -import org.chromium.chrome.browser.IntentHandler; -import org.chromium.chrome.browser.IntentHandler.ExternalAppId; import org.chromium.chrome.browser.autofill_assistant.metrics.FeatureModuleInstallation; import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.signin.services.UnifiedConsentServiceBridge; @@ -36,6 +32,8 @@ public class Starter extends EmptyTabObserver implements UserData { /** The tab that this starter tracks. */ private final Tab mTab; + private final AssistantIsGsaFunction mIsGsaFunction; + /** * The WebContents associated with the Tab which this starter is monitoring, unless detached. */ @@ -67,8 +65,9 @@ public class Starter extends EmptyTabObserver implements UserData { * * This will wait for dependencies to become available and then create the native-side starter. */ - public Starter(Tab tab) { + public Starter(Tab tab, AssistantIsGsaFunction isGsaFunction) { mTab = tab; + mIsGsaFunction = isGsaFunction; detectWebContentsChange(tab); } @@ -309,16 +308,7 @@ private Object[] getOrCreateDependenciesAndOnboardingHelper() { @CalledByNative private boolean getIsTabCreatedByGSA() { - // This can fail for certain tabs (e.g., hidden background tabs). - if (TabUtils.getActivity(mTab) == null) { - return false; - } - Intent intent = TabUtils.getActivity(mTab).getIntent(); - if (intent == null) { - // This should never happen, this is just a failsafe. - return false; - } - return IntentHandler.determineExternalIntentSource(intent) == ExternalAppId.GSA; + return mIsGsaFunction.apply(TabUtils.getActivity(mTab)); } @NativeMethods diff --git a/chrome/android/features/autofill_assistant/public/java_sources.gni b/chrome/android/features/autofill_assistant/public/java_sources.gni index d7ad13e51a7e2f..86b5c0bb31e422 100644 --- a/chrome/android/features/autofill_assistant/public/java_sources.gni +++ b/chrome/android/features/autofill_assistant/public/java_sources.gni @@ -5,7 +5,9 @@ public_autofill_assistant_java_sources = [ "//chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantDependencies.java", "//chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantDependenciesFactory.java", + "//chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantDependencyUtilsChrome.java", "//chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantFeatures.java", + "//chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantIsGsaFunction.java", "//chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantOnboardingHelper.java", "//chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantSnackbar.java", "//chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantSnackbarFactory.java", diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/DEPS b/chrome/android/java/src/org/chromium/chrome/browser/tab/DEPS index 553931ceaa478c..1ecf0430e26dec 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/tab/DEPS +++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/DEPS @@ -12,6 +12,7 @@ include_rules = [ "+chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/ReaderModeManager.java", "+chrome/android/java/src/org/chromium/chrome/browser/feedback/HelpAndFeedbackLauncherImpl.java", "+chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantTabHelper.java", + "+chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantDependencyUtilsChrome.java", "+chrome/android/java/src/org/chromium/chrome/browser/incognito/IncognitoUtils.java", "+chrome/android/java/src/org/chromium/chrome/browser/media/MediaCaptureNotificationServiceImpl.java", "+chrome/android/java/src/org/chromium/chrome/browser/metrics/UkmRecorder.java", diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabHelpers.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabHelpers.java index 1a771c3a5327b4..761dc7e4971d11 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabHelpers.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabHelpers.java @@ -5,6 +5,7 @@ package org.chromium.chrome.browser.tab; import org.chromium.chrome.browser.SwipeRefreshHandler; +import org.chromium.chrome.browser.autofill_assistant.AssistantDependencyUtilsChrome; import org.chromium.chrome.browser.autofill_assistant.AutofillAssistantTabHelper; import org.chromium.chrome.browser.complex_tasks.TaskTabHelper; import org.chromium.chrome.browser.contextualsearch.ContextualSearchTabHelper; @@ -37,7 +38,7 @@ static void initTabHelpers(Tab tab, Tab parentTab) { TabBrowserControlsConstraintsHelper.createForTab(tab); ContinuousSearchTabHelper.createForTab(tab); if (ReaderModeManager.isEnabled()) ReaderModeManager.createForTab(tab); - AutofillAssistantTabHelper.createForTab(tab); + AutofillAssistantTabHelper.createForTab(tab, AssistantDependencyUtilsChrome::isGsa); // The following will start prefetching data for the price drops feature, so // we should only do it if the user is eligible for the feature (e.g. has sync enabled). diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 86358022129ac9..3a537f2b69f83b 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn @@ -2020,6 +2020,8 @@ static_library("browser") { "//components/autofill/content/browser", "//components/autofill/core/browser", "//components/autofill_assistant/browser/public:public", + "//components/autofill_assistant/content/browser", + "//components/autofill_assistant/content/common:mojo_interfaces", "//components/back_forward_cache", "//components/background_fetch", "//components/background_sync", diff --git a/chrome/browser/ash/crosapi/dlp_ash.cc b/chrome/browser/ash/crosapi/dlp_ash.cc index 7db6523d772561..75ca477af26ecf 100644 --- a/chrome/browser/ash/crosapi/dlp_ash.cc +++ b/chrome/browser/ash/crosapi/dlp_ash.cc @@ -4,8 +4,54 @@ #include "chrome/browser/ash/crosapi/dlp_ash.h" +#include "base/logging.h" +#include "chrome/browser/ash/crosapi/window_util.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager.h" +#include "chrome/browser/chromeos/policy/dlp/dlp_content_restriction_set.h" +#include "chrome/browser/chromeos/policy/dlp/dlp_rules_manager.h" + namespace crosapi { +namespace { + +policy::DlpRulesManager::Level ConvertMojoToDlpRulesManagerLevel( + crosapi::mojom::DlpRestrictionLevel level) { + switch (level) { + case crosapi::mojom::DlpRestrictionLevel::kReport: + return policy::DlpRulesManager::Level::kReport; + case crosapi::mojom::DlpRestrictionLevel::kWarn: + return policy::DlpRulesManager::Level::kWarn; + case crosapi::mojom::DlpRestrictionLevel::kBlock: + return policy::DlpRulesManager::Level::kBlock; + case crosapi::mojom::DlpRestrictionLevel::kAllow: + return policy::DlpRulesManager::Level::kAllow; + } +} + +policy::DlpContentRestrictionSet ConvertMojoToDlpContentRestrictionSet( + const mojom::DlpRestrictionSetPtr& restrictions) { + policy::DlpContentRestrictionSet result; + result.SetRestriction( + policy::DlpContentRestriction::kScreenshot, + ConvertMojoToDlpRulesManagerLevel(restrictions->screenshot->level), + restrictions->screenshot->url); + result.SetRestriction( + policy::DlpContentRestriction::kPrivacyScreen, + ConvertMojoToDlpRulesManagerLevel(restrictions->privacy_screen->level), + restrictions->privacy_screen->url); + result.SetRestriction( + policy::DlpContentRestriction::kPrint, + ConvertMojoToDlpRulesManagerLevel(restrictions->print->level), + restrictions->print->url); + result.SetRestriction( + policy::DlpContentRestriction::kScreenShare, + ConvertMojoToDlpRulesManagerLevel(restrictions->screen_share->level), + restrictions->screen_share->url); + return result; +} + +} // namespace + DlpAsh::DlpAsh() = default; DlpAsh::~DlpAsh() = default; @@ -16,7 +62,16 @@ void DlpAsh::BindReceiver(mojo::PendingReceiver receiver) { void DlpAsh::DlpRestrictionsUpdated(const std::string& window_id, mojom::DlpRestrictionSetPtr restrictions) { - // TODO(crbug.com/1260467): Pass information to DlpContentManager in Ash. + aura::Window* window = GetShellSurfaceWindow(window_id); + if (!window) { + LOG(WARNING) << "Didn't find Lacros window with id: " << window_id; + return; + } + policy::DlpContentManager* dlp_content_manager = + policy::DlpContentManager::Get(); + DCHECK(dlp_content_manager); + dlp_content_manager->OnWindowRestrictionChanged( + window, ConvertMojoToDlpContentRestrictionSet(restrictions)); } } // namespace crosapi diff --git a/chrome/browser/ash/policy/dlp/dlp_content_manager.cc b/chrome/browser/ash/policy/dlp/dlp_content_manager.cc index 543f56d1979597..70b6906086a876 100644 --- a/chrome/browser/ash/policy/dlp/dlp_content_manager.cc +++ b/chrome/browser/ash/policy/dlp/dlp_content_manager.cc @@ -127,6 +127,11 @@ void DlpContentManager::OnWindowOcclusionChanged(aura::Window* window) { CheckRunningVideoCapture(); } +void DlpContentManager::OnWindowDestroying(aura::Window* window) { + window_observers_.erase(window); + MaybeChangeOnScreenRestrictions(); +} + DlpContentRestrictionSet DlpContentManager::GetConfidentialRestrictions( content::WebContents* web_contents) const { if (!base::Contains(confidential_web_contents_, web_contents)) @@ -341,6 +346,14 @@ void DlpContentManager::OnScreenCaptureStopped( }); } +void DlpContentManager::OnWindowRestrictionChanged( + aura::Window* window, + const DlpContentRestrictionSet& restrictions) { + confidential_windows_[window] = restrictions; + window_observers_[window] = std::make_unique(window, this); + MaybeChangeOnScreenRestrictions(); +} + /* static */ void DlpContentManager::SetDlpContentManagerForTesting( DlpContentManager* dlp_content_manager) { @@ -475,8 +488,9 @@ void DlpContentManager::OnConfidentialityChanged( RemoveFromConfidential(web_contents); } else { confidential_web_contents_[web_contents] = restriction_set; - window_observers_[web_contents] = std::make_unique( - web_contents->GetNativeView(), this); + web_contents_window_observers_[web_contents] = + std::make_unique(web_contents->GetNativeView(), + this); if (web_contents->GetVisibility() == content::Visibility::VISIBLE) { MaybeChangeOnScreenRestrictions(); } @@ -497,17 +511,24 @@ void DlpContentManager::OnVisibilityChanged( void DlpContentManager::RemoveFromConfidential( content::WebContents* web_contents) { confidential_web_contents_.erase(web_contents); - window_observers_.erase(web_contents); + web_contents_window_observers_.erase(web_contents); MaybeChangeOnScreenRestrictions(); } void DlpContentManager::MaybeChangeOnScreenRestrictions() { DlpContentRestrictionSet new_restriction_set; + // Check each visible WebContents. for (const auto& entry : confidential_web_contents_) { if (entry.first->GetVisibility() == content::Visibility::VISIBLE) { new_restriction_set.UnionWith(entry.second); } } + // Check each visible Lacros window. + for (const auto& entry : confidential_windows_) { + if (entry.first->IsVisible()) { + new_restriction_set.UnionWith(entry.second); + } + } if (on_screen_restrictions_ != new_restriction_set) { DlpContentRestrictionSet added_restrictions = new_restriction_set.DifferenceWith(on_screen_restrictions_); @@ -603,6 +624,7 @@ DlpContentManager::GetAreaConfidentialContentsInfo( // Window - restricted if the window contains confidential data. if (area.type == ScreenshotType::kWindow) { DCHECK(area.window); + // Check whether the captured window contains any confidential WebContents. for (auto& entry : confidential_web_contents_) { aura::Window* web_contents_window = entry.first->GetNativeView(); if (area.window->Contains(web_contents_window)) { @@ -617,14 +639,33 @@ DlpContentManager::GetAreaConfidentialContentsInfo( } } } + // Check whether the captured window is a confidential Lacros window. + auto window_entry = confidential_windows_.find(area.window); + if (window_entry != confidential_windows_.end()) { + if (window_entry->second.GetRestrictionLevel(restriction) == + info.restriction_info.level) { + info.confidential_contents.Add( + window_entry->first, + window_entry->second.GetRestrictionUrl(restriction)); + } else if (window_entry->second.GetRestrictionLevel(restriction) > + info.restriction_info.level) { + info.restriction_info = + window_entry->second.GetRestrictionLevelAndUrl(restriction); + info.confidential_contents.ClearAndAdd( + window_entry->first, + window_entry->second.GetRestrictionUrl(restriction)); + } + } return info; } DCHECK_EQ(area.type, ScreenshotType::kPartialWindow); DCHECK(area.rect); DCHECK(area.window); - // Partial - restricted if any visible confidential WebContents intersects + // Partial - restricted if any visible confidential content intersects // with the area. + + // Intersect the captured area with all confidential WebContents. for (auto& entry : confidential_web_contents_) { if (entry.first->GetVisibility() != content::Visibility::VISIBLE || entry.second.GetRestrictionLevel(restriction) == @@ -661,6 +702,44 @@ DlpContentManager::GetAreaConfidentialContentsInfo( info.confidential_contents.ClearAndAdd(entry.first); } } + + // Intersect the captured area with all confidential Lacros windows. + for (auto& entry : confidential_windows_) { + if (!entry.first->IsVisible() || + entry.first->GetOcclusionState() == + aura::Window::OcclusionState::OCCLUDED || + entry.second.GetRestrictionLevel(restriction) == + DlpRulesManager::Level::kNotSet) { + continue; + } + aura::Window* root_window = entry.first->GetRootWindow(); + // If no root window, then the Window shouldn't be visible. + if (!root_window) + continue; + // Not allowing if the area intersects with confidential Window, + // but the intersection doesn't belong to occluded area. + gfx::Rect intersection(*area.rect); + aura::Window::ConvertRectToTarget(area.window, root_window, &intersection); + intersection.Intersect(entry.first->GetBoundsInRootWindow()); + + if (intersection.IsEmpty() || + entry.first->occluded_region_in_root().contains( + gfx::RectToSkIRect(intersection))) + continue; + + if (entry.second.GetRestrictionLevel(restriction) == + info.restriction_info.level) { + info.confidential_contents.Add( + entry.first, entry.second.GetRestrictionUrl(restriction)); + } else if (entry.second.GetRestrictionLevel(restriction) > + info.restriction_info.level) { + info.restriction_info = + entry.second.GetRestrictionLevelAndUrl(restriction); + info.confidential_contents.ClearAndAdd( + entry.first, entry.second.GetRestrictionUrl(restriction)); + } + } + return info; } @@ -691,6 +770,7 @@ DlpContentManager::GetScreenShareConfidentialContentsInfo( ConfidentialContentsInfo info; aura::Window* window = content::DesktopMediaID::GetNativeWindowById(media_id); if (window) { + // Check whether the captured window contains any confidential WebContents. for (auto& entry : confidential_web_contents_) { aura::Window* web_contents_window = entry.first->GetNativeView(); if (!window->Contains(web_contents_window)) @@ -707,6 +787,25 @@ DlpContentManager::GetScreenShareConfidentialContentsInfo( info.confidential_contents.ClearAndAdd(entry.first); } } + // Check whether the captured window is a confidential Lacros window. + auto window_entry = confidential_windows_.find(window); + if (window_entry != confidential_windows_.end()) { + if (window_entry->second.GetRestrictionLevel( + DlpContentRestriction::kScreenShare) == + info.restriction_info.level) { + info.confidential_contents.Add( + window_entry->first, window_entry->second.GetRestrictionUrl( + DlpContentRestriction::kScreenShare)); + } else if (window_entry->second.GetRestrictionLevel( + DlpContentRestriction::kScreenShare) > + info.restriction_info.level) { + info.restriction_info = window_entry->second.GetRestrictionLevelAndUrl( + DlpContentRestriction::kScreenShare); + info.confidential_contents.ClearAndAdd( + window_entry->first, window_entry->second.GetRestrictionUrl( + DlpContentRestriction::kScreenShare)); + } + } } return info; } diff --git a/chrome/browser/ash/policy/dlp/dlp_content_manager.h b/chrome/browser/ash/policy/dlp/dlp_content_manager.h index 599686f79d3949..f96feb8aae6485 100644 --- a/chrome/browser/ash/policy/dlp/dlp_content_manager.h +++ b/chrome/browser/ash/policy/dlp/dlp_content_manager.h @@ -58,6 +58,7 @@ class DlpContentManager : public DlpContentObserver, // DlpWindowObserver::Delegate overrides: void OnWindowOcclusionChanged(aura::Window* window) override; + void OnWindowDestroying(aura::Window* window) override; // Returns which restrictions are applied to the |web_contents| according to // the policy. @@ -137,6 +138,10 @@ class DlpContentManager : public DlpContentObserver, void OnScreenCaptureStopped(const std::string& label, const content::DesktopMediaID& media_id); + // Called when an updated restrictions are received for Lacros window. + void OnWindowRestrictionChanged(aura::Window* window, + const DlpContentRestrictionSet& restrictions); + // The caller (test) should manage |dlp_content_manager| lifetime. // Reset doesn't delete the object. // Please use ScopedDlpContentManagerForTesting instead of these methods, @@ -343,6 +348,13 @@ class DlpContentManager : public DlpContentObserver, // Map of window observers for the current confidential WebContents. base::flat_map> + web_contents_window_observers_; + + // Map from currently known Lacros Windows to their restrictions. + base::flat_map confidential_windows_; + + // Map of observers for currently known Lacros Windows. + base::flat_map> window_observers_; // Set of restriction applied to the currently visible content. diff --git a/chrome/browser/ash/policy/dlp/dlp_content_manager_browsertest.cc b/chrome/browser/ash/policy/dlp/dlp_content_manager_browsertest.cc index 9b0ad981b6f5cc..f5941225d965d4 100644 --- a/chrome/browser/ash/policy/dlp/dlp_content_manager_browsertest.cc +++ b/chrome/browser/ash/policy/dlp/dlp_content_manager_browsertest.cc @@ -668,7 +668,8 @@ IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, ScreenShareReporting) { blink::mojom::MediaStreamType::NO_SERVICE, blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE, /*disable_local_echo=*/false, - /*request_pan_tilt_zoom_permission=*/false); + /*request_pan_tilt_zoom_permission=*/false, + /*region_capture_capable=*/false); base::test::TestFuture< std::reference_wrapper, diff --git a/chrome/browser/ash/policy/dlp/dlp_window_observer.cc b/chrome/browser/ash/policy/dlp/dlp_window_observer.cc index 827eeb527c4718..c6203c1e9de5b6 100644 --- a/chrome/browser/ash/policy/dlp/dlp_window_observer.cc +++ b/chrome/browser/ash/policy/dlp/dlp_window_observer.cc @@ -23,6 +23,7 @@ void DlpWindowObserver::OnWindowDestroying(aura::Window* window) { DCHECK_EQ(window_, window); window_->RemoveObserver(this); window_ = nullptr; + delegate_->OnWindowDestroying(window); } void DlpWindowObserver::OnWindowOcclusionChanged(aura::Window* window) { diff --git a/chrome/browser/ash/policy/dlp/dlp_window_observer.h b/chrome/browser/ash/policy/dlp/dlp_window_observer.h index c2799a3d08a21f..24326707ffd448 100644 --- a/chrome/browser/ash/policy/dlp/dlp_window_observer.h +++ b/chrome/browser/ash/policy/dlp/dlp_window_observer.h @@ -22,6 +22,8 @@ class DlpWindowObserver : public aura::WindowObserver { virtual ~Delegate() = default; virtual void OnWindowOcclusionChanged(aura::Window* window) = 0; + + virtual void OnWindowDestroying(aura::Window* window) = 0; }; DlpWindowObserver(aura::Window* window, Delegate* delegate); diff --git a/chrome/browser/chrome_content_browser_client_receiver_bindings.cc b/chrome/browser/chrome_content_browser_client_receiver_bindings.cc index 272ddb9af626c5..6f31680da732d3 100644 --- a/chrome/browser/chrome_content_browser_client_receiver_bindings.cc +++ b/chrome/browser/chrome_content_browser_client_receiver_bindings.cc @@ -28,6 +28,8 @@ #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" #include "chrome/common/buildflags.h" #include "components/autofill/content/browser/content_autofill_driver_factory.h" +#include "components/autofill_assistant/content/browser/content_autofill_assistant_driver.h" +#include "components/autofill_assistant/content/common/autofill_assistant_driver.mojom.h" #include "components/content_capture/browser/onscreen_content_provider.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" @@ -393,6 +395,15 @@ bool ChromeContentBrowserClient::BindAssociatedReceiverFromFrame( content::RenderFrameHost* render_frame_host, const std::string& interface_name, mojo::ScopedInterfaceEndpointHandle* handle) { + if (interface_name == + autofill_assistant::mojom::AutofillAssistantDriver::Name_) { + autofill_assistant::ContentAutofillAssistantDriver::BindDriver( + mojo::PendingAssociatedReceiver< + autofill_assistant::mojom::AutofillAssistantDriver>( + std::move(*handle)), + render_frame_host); + return true; + } if (interface_name == autofill::mojom::AutofillDriver::Name_) { autofill::ContentAutofillDriverFactory::BindAutofillDriver( mojo::PendingAssociatedReceiver( diff --git a/chrome/browser/chromeos/policy/dlp/dlp_confidential_contents.cc b/chrome/browser/chromeos/policy/dlp/dlp_confidential_contents.cc index d61e6cb9f39277..e46ac4d5892086 100644 --- a/chrome/browser/chromeos/policy/dlp/dlp_confidential_contents.cc +++ b/chrome/browser/chromeos/policy/dlp/dlp_confidential_contents.cc @@ -14,9 +14,22 @@ #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" +#include "ui/aura/client/aura_constants.h" +#include "ui/aura/window.h" namespace policy { +namespace { + +gfx::ImageSkia GetWindowIcon(aura::Window* window) { + gfx::ImageSkia* image = window->GetProperty(aura::client::kWindowIconKey); + if (!image) + image = window->GetProperty(aura::client::kAppIconKey); + return image ? *image : gfx::ImageSkia(); +} + +} // namespace + // The maximum number of entries that can be kept in the // DlpConfidentialContentsCache. // TODO(crbug.com/1275926): determine the value to use @@ -26,12 +39,23 @@ static constexpr size_t kDefaultCacheSizeLimit = 100; // DlpConfidentialContentsCache. static constexpr base::TimeDelta kDefaultCacheTimeout = base::Days(7); +DlpConfidentialContent::DlpConfidentialContent() = default; + DlpConfidentialContent::DlpConfidentialContent( content::WebContents* web_contents) : icon(favicon::TabFaviconFromWebContents(web_contents).AsImageSkia()), title(web_contents->GetTitle()), url(web_contents->GetLastCommittedURL()) {} +DlpConfidentialContent::DlpConfidentialContent(aura::Window* window, + const GURL& url) + : icon(GetWindowIcon(window)), title(window->GetTitle()), url(url) {} + +DlpConfidentialContent::DlpConfidentialContent( + const DlpConfidentialContent& other) = default; +DlpConfidentialContent& DlpConfidentialContent::operator=( + const DlpConfidentialContent& other) = default; + bool DlpConfidentialContent::operator==( const DlpConfidentialContent& other) const { return url.EqualsIgnoringRef(other.url); @@ -91,6 +115,10 @@ void DlpConfidentialContents::Add(content::WebContents* web_contents) { contents_.insert(DlpConfidentialContent(web_contents)); } +void DlpConfidentialContents::Add(aura::Window* window, const GURL& url) { + contents_.insert(DlpConfidentialContent(window, url)); +} + void DlpConfidentialContents::Add(const DlpConfidentialContent& content) { contents_.insert(content); } @@ -100,6 +128,12 @@ void DlpConfidentialContents::ClearAndAdd(content::WebContents* web_contents) { Add(web_contents); } +void DlpConfidentialContents::ClearAndAdd(aura::Window* window, + const GURL& url) { + contents_.clear(); + Add(window, url); +} + bool DlpConfidentialContents::IsEmpty() const { return contents_.empty(); } diff --git a/chrome/browser/chromeos/policy/dlp/dlp_confidential_contents.h b/chrome/browser/chromeos/policy/dlp/dlp_confidential_contents.h index 0eb8ce95c316e2..e3c4e2997d4bd7 100644 --- a/chrome/browser/chromeos/policy/dlp/dlp_confidential_contents.h +++ b/chrome/browser/chromeos/policy/dlp/dlp_confidential_contents.h @@ -17,9 +17,13 @@ #include "ui/gfx/image/image_skia.h" #include "url/gurl.h" +namespace aura { +class Window; +} // namespace aura + namespace content { class WebContents; -} +} // namespace content namespace policy { @@ -27,13 +31,15 @@ namespace policy { // Used to cache and later show information about observed confidential contents // to the user. struct DlpConfidentialContent { - DlpConfidentialContent() = default; + DlpConfidentialContent(); // Constructs DlpConfidentialContent from the title and icon obtained from // |web_contents|, which cannot be null. explicit DlpConfidentialContent(content::WebContents* web_contents); - DlpConfidentialContent(const DlpConfidentialContent& other) = default; - DlpConfidentialContent& operator=(const DlpConfidentialContent& other) = - default; + // Constructs DlpConfidentialContent from the title and icon obtained from + // |window|, which cannot be null and |url|. + DlpConfidentialContent(aura::Window* window, const GURL& url); + DlpConfidentialContent(const DlpConfidentialContent& other); + DlpConfidentialContent& operator=(const DlpConfidentialContent& other); ~DlpConfidentialContent() = default; // Contents with the same url are considered equal, ignoring the ref (part @@ -70,12 +76,16 @@ class DlpConfidentialContents { // Converts |web_contents| to a DlpConfidentialContent and adds it to the // underlying container. void Add(content::WebContents* web_contents); + // Same for |window| and |url| pair. + void Add(aura::Window* window, const GURL& url); void Add(const DlpConfidentialContent& content); // Removes all stored confidential content, if there was any, and adds // |web_contents| converted to a DlpConfidentialContent. void ClearAndAdd(content::WebContents* web_contents); + // Same for |window| and |url| pair. + void ClearAndAdd(aura::Window* web_contents, const GURL& url); // Returns whether there is any content stored or not. bool IsEmpty() const; diff --git a/chrome/browser/chromeos/policy/dlp/dlp_content_restriction_set.cc b/chrome/browser/chromeos/policy/dlp/dlp_content_restriction_set.cc index 72d9d32192e898..81a586585f1bef 100644 --- a/chrome/browser/chromeos/policy/dlp/dlp_content_restriction_set.cc +++ b/chrome/browser/chromeos/policy/dlp/dlp_content_restriction_set.cc @@ -62,6 +62,11 @@ DlpRulesManager::Level DlpContentRestrictionSet::GetRestrictionLevel( return restrictions_[restriction].level; } +const GURL& DlpContentRestrictionSet::GetRestrictionUrl( + DlpContentRestriction restriction) const { + return restrictions_[restriction].url; +} + RestrictionLevelAndUrl DlpContentRestrictionSet::GetRestrictionLevelAndUrl( DlpContentRestriction restriction) const { return restrictions_[restriction]; diff --git a/chrome/browser/chromeos/policy/dlp/dlp_content_restriction_set.h b/chrome/browser/chromeos/policy/dlp/dlp_content_restriction_set.h index 28ce59f7621f4b..cf592bdfc8f140 100644 --- a/chrome/browser/chromeos/policy/dlp/dlp_content_restriction_set.h +++ b/chrome/browser/chromeos/policy/dlp/dlp_content_restriction_set.h @@ -75,6 +75,9 @@ class DlpContentRestrictionSet { DlpRulesManager::Level GetRestrictionLevel( DlpContentRestriction restriction) const; + // Returns the url for most restrictive level for the |restriction|. + const GURL& GetRestrictionUrl(DlpContentRestriction restriction) const; + // Returns the level and url for the |restriction|. RestrictionLevelAndUrl GetRestrictionLevelAndUrl( DlpContentRestriction restriction) const; diff --git a/chrome/browser/media/webrtc/desktop_capture_access_handler_unittest.cc b/chrome/browser/media/webrtc/desktop_capture_access_handler_unittest.cc index 15c040fe226b16..e44ebcc46f548c 100644 --- a/chrome/browser/media/webrtc/desktop_capture_access_handler_unittest.cc +++ b/chrome/browser/media/webrtc/desktop_capture_access_handler_unittest.cc @@ -76,7 +76,8 @@ class DesktopCaptureAccessHandlerTest : public ChromeRenderViewHostTestHarness { blink::mojom::MediaStreamType::NO_SERVICE, blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE, /*disable_local_echo=*/false, - /*request_pan_tilt_zoom_permission=*/false); + /*request_pan_tilt_zoom_permission=*/false, + /*region_capture_capable=*/false); base::RunLoop wait_loop; content::MediaResponseCallback callback = base::BindOnce( [](base::RunLoop* wait_loop, @@ -115,7 +116,8 @@ class DesktopCaptureAccessHandlerTest : public ChromeRenderViewHostTestHarness { std::string(), audio_type, blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE, /*disable_local_echo=*/false, - /*request_pan_tilt_zoom_permission=*/false); + /*request_pan_tilt_zoom_permission=*/false, + /*region_capture_capable=*/false); base::RunLoop wait_loop; content::MediaResponseCallback callback = base::BindOnce( @@ -216,7 +218,8 @@ TEST_F(DesktopCaptureAccessHandlerTest, render_process_id, render_frame_id, page_request_id, GURL(kOrigin), false, blink::MEDIA_DEVICE_UPDATE, std::string(), std::string(), blink::mojom::MediaStreamType::NO_SERVICE, stream_type, - /*disable_local_echo=*/false, /*request_pan_tilt_zoom_permission=*/false); + /*disable_local_echo=*/false, /*request_pan_tilt_zoom_permission=*/false, + /*region_capture_capable=*/false); content::MediaResponseCallback callback; access_handler_->HandleRequest(web_contents(), request, std::move(callback), nullptr /* extension */); @@ -248,7 +251,8 @@ TEST_F(DesktopCaptureAccessHandlerTest, ChangeSourceWebContentsDestroyed) { 0, 0, 0, GURL(kOrigin), false, blink::MEDIA_DEVICE_UPDATE, std::string(), std::string(), blink::mojom::MediaStreamType::NO_SERVICE, blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE, - /*disable_local_echo=*/false, /*request_pan_tilt_zoom_permission=*/false); + /*disable_local_echo=*/false, /*request_pan_tilt_zoom_permission=*/false, + /*region_capture_capable=*/false); content::MediaResponseCallback callback; access_handler_->HandleRequest(web_contents(), request, std::move(callback), nullptr /* extension */); @@ -289,7 +293,8 @@ TEST_F(DesktopCaptureAccessHandlerTest, ChangeSourceMultipleRequests) { std::string(), std::string(), blink::mojom::MediaStreamType::NO_SERVICE, blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE, /*disable_local_echo=*/false, - /*request_pan_tilt_zoom_permission=*/false); + /*request_pan_tilt_zoom_permission=*/false, + /*region_capture_capable=*/false); content::MediaResponseCallback callback = base::BindOnce( [](base::RunLoop* wait_loop, blink::mojom::MediaStreamRequestResult* request_result, diff --git a/chrome/browser/media/webrtc/display_media_access_handler_unittest.cc b/chrome/browser/media/webrtc/display_media_access_handler_unittest.cc index 6e07e8a436b42b..2593c9e7731e0f 100644 --- a/chrome/browser/media/webrtc/display_media_access_handler_unittest.cc +++ b/chrome/browser/media/webrtc/display_media_access_handler_unittest.cc @@ -75,7 +75,8 @@ class DisplayMediaAccessHandlerTest : public ChromeRenderViewHostTestHarness { : blink::mojom::MediaStreamType::NO_SERVICE, blink::mojom::MediaStreamType::DISPLAY_VIDEO_CAPTURE, /*disable_local_echo=*/false, - /*request_pan_tilt_zoom_permission=*/false); + /*request_pan_tilt_zoom_permission=*/false, + /*region_capture_capable=*/false); } content::MediaStreamRequest MakeMediaDeviceUpdateRequest(bool request_audio) { @@ -294,7 +295,8 @@ TEST_F(DisplayMediaAccessHandlerTest, UpdateMediaRequestStateWithClosing) { render_process_id, render_frame_id, page_request_id, GURL("http://origin/"), false, blink::MEDIA_GENERATE_STREAM, std::string(), std::string(), audio_stream_type, video_stream_type, - /*disable_local_echo=*/false, /*request_pan_tilt_zoom_permission=*/false); + /*disable_local_echo=*/false, /*request_pan_tilt_zoom_permission=*/false, + /*region_capture_capable=*/false); content::MediaResponseCallback callback; access_handler_->HandleRequest(web_contents(), request, std::move(callback), nullptr /* extension */); @@ -332,7 +334,8 @@ TEST_F(DisplayMediaAccessHandlerTest, CorrectHostAsksForPermissions) { render_process_id, render_frame_id, page_request_id, GURL("http://origin/"), false, blink::MEDIA_GENERATE_STREAM, std::string(), std::string(), audio_stream_type, video_stream_type, - /*disable_local_echo=*/false, /*request_pan_tilt_zoom_permission=*/false); + /*disable_local_echo=*/false, /*request_pan_tilt_zoom_permission=*/false, + /*region_capture_capable=*/false); content::MediaResponseCallback callback; content::WebContents* test_web_contents = web_contents(); std::unique_ptr navigation = @@ -366,7 +369,8 @@ TEST_F(DisplayMediaAccessHandlerTest, CorrectHostAsksForPermissionsNormalURLs) { render_process_id, render_frame_id, page_request_id, GURL("http://origin/"), false, blink::MEDIA_GENERATE_STREAM, std::string(), std::string(), audio_stream_type, video_stream_type, - /*disable_local_echo=*/false, /*request_pan_tilt_zoom_permission=*/false); + /*disable_local_echo=*/false, /*request_pan_tilt_zoom_permission=*/false, + /*region_capture_capable=*/false); content::MediaResponseCallback callback; content::WebContents* test_web_contents = web_contents(); std::unique_ptr navigation = @@ -393,7 +397,8 @@ TEST_F(DisplayMediaAccessHandlerTest, WebContentsDestroyed) { false, blink::MEDIA_GENERATE_STREAM, std::string(), std::string(), blink::mojom::MediaStreamType::NO_SERVICE, blink::mojom::MediaStreamType::DISPLAY_VIDEO_CAPTURE, - /*disable_local_echo=*/false, /*request_pan_tilt_zoom_permission=*/false); + /*disable_local_echo=*/false, /*request_pan_tilt_zoom_permission=*/false, + /*region_capture_capable=*/false); content::MediaResponseCallback callback; access_handler_->HandleRequest(web_contents(), request, std::move(callback), nullptr /* extension */); @@ -434,7 +439,8 @@ TEST_F(DisplayMediaAccessHandlerTest, MultipleRequests) { std::string(), std::string(), blink::mojom::MediaStreamType::NO_SERVICE, blink::mojom::MediaStreamType::DISPLAY_VIDEO_CAPTURE, /*disable_local_echo=*/false, - /*request_pan_tilt_zoom_permission=*/false); + /*request_pan_tilt_zoom_permission=*/false, + /*region_capture_capable=*/false); content::MediaResponseCallback callback = base::BindOnce( [](base::RunLoop* wait_loop, blink::mojom::MediaStreamRequestResult* request_result, diff --git a/chrome/browser/media/webrtc/media_stream_devices_controller_browsertest.cc b/chrome/browser/media/webrtc/media_stream_devices_controller_browsertest.cc index d53cee0c0f8183..6a95b6b4d59f68 100644 --- a/chrome/browser/media/webrtc/media_stream_devices_controller_browsertest.cc +++ b/chrome/browser/media/webrtc/media_stream_devices_controller_browsertest.cc @@ -164,7 +164,8 @@ class MediaStreamDevicesControllerTest : public WebRtcTestBase { return content::MediaStreamRequest( render_process_id, render_frame_id, 0, example_url(), false, request_type, audio_id, video_id, audio_type, video_type, - /*disable_local_echo=*/false, request_pan_tilt_zoom_permission); + /*disable_local_echo=*/false, request_pan_tilt_zoom_permission, + /*region_capture_capable=*/false); } content::MediaStreamRequest CreateRequest( diff --git a/chrome/browser/media/webrtc/tab_capture_access_handler_unittest.cc b/chrome/browser/media/webrtc/tab_capture_access_handler_unittest.cc index c185961fcaea05..9434a04b6d1ffe 100644 --- a/chrome/browser/media/webrtc/tab_capture_access_handler_unittest.cc +++ b/chrome/browser/media/webrtc/tab_capture_access_handler_unittest.cc @@ -51,7 +51,8 @@ class TabCaptureAccessHandlerTest : public ChromeRenderViewHostTestHarness { blink::mojom::MediaStreamType::NO_SERVICE, blink::mojom::MediaStreamType::GUM_TAB_VIDEO_CAPTURE, /*disable_local_echo=*/false, - /*request_pan_tilt_zoom_permission=*/false); + /*request_pan_tilt_zoom_permission=*/false, + /*region_capture_capable=*/false); base::RunLoop wait_loop; content::MediaResponseCallback callback = base::BindOnce( diff --git a/chrome/browser/policy/test/media_stream_policy_browsertest.cc b/chrome/browser/policy/test/media_stream_policy_browsertest.cc index debe3ea69cd141..d028048c1076f1 100644 --- a/chrome/browser/policy/test/media_stream_policy_browsertest.cc +++ b/chrome/browser/policy/test/media_stream_policy_browsertest.cc @@ -72,7 +72,8 @@ class MediaStreamDevicesControllerBrowserTest request_url_.DeprecatedGetOriginAsURL(), false, blink::MEDIA_DEVICE_ACCESS, std::string(), std::string(), audio_request_type, video_request_type, /*disable_local_echo=*/false, - /*request_pan_tilt_zoom_permission=*/false); + /*request_pan_tilt_zoom_permission=*/false, + /*region_capture_capable=*/false); } // Configure a given policy map. The |policy_name| is the name of either the diff --git a/chrome/browser/ui/ash/quick_answers/ui/quick_answers_view.cc b/chrome/browser/ui/ash/quick_answers/ui/quick_answers_view.cc index b23abcefb5008e..6a25b74bd36119 100644 --- a/chrome/browser/ui/ash/quick_answers/ui/quick_answers_view.cc +++ b/chrome/browser/ui/ash/quick_answers/ui/quick_answers_view.cc @@ -4,15 +4,13 @@ #include "chrome/browser/ui/ash/quick_answers/ui/quick_answers_view.h" -#include "ash/public/cpp/app_list/vector_icons/vector_icons.h" -#include "ash/resources/vector_icons/vector_icons.h" #include "base/bind.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/ash/quick_answers/quick_answers_ui_controller.h" #include "chrome/browser/ui/ash/quick_answers/ui/quick_answers_pre_target_handler.h" #include "chromeos/components/quick_answers/quick_answers_model.h" #include "chromeos/strings/grit/chromeos_strings.h" -#include "chromeos/ui/vector_icons/vector_icons.h" +#include "components/vector_icons/vector_icons.h" #include "ui/aura/window.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/metadata/metadata_header_macros.h" @@ -201,7 +199,7 @@ class ReportQueryView : public views::Button { dogfood_icon->SetBorder( views::CreateEmptyBorder(gfx::Insets(kDogfoodIconBorderDip))); dogfood_icon->SetImage(gfx::CreateVectorIcon( - kDogfoodIcon, kDogfoodIconSizeDip, gfx::kGoogleBlue600)); + vector_icons::kDogfoodIcon, kDogfoodIconSizeDip, gfx::kGoogleBlue600)); auto* description_label = AddChildView(std::make_unique