0

517 Commits

Author SHA1 Message Date
cd98c2e633 Remove some superfluous //ui/gfx includes from //components headers
With the exception of ui/gfx/color_utils.h, code in //ui/gfx use
namespace gfx, so if "gfx::" does not appear in a header, then it does
not need the //ui/gfx includes. The command below generated the list of
edited files:

git grep -l '^#include "ui/gfx' components|grep '\.h$'|xargs grep -L gfx::

Clean up those headers and then do IWYU to fix the build.

Bug: 40318405
Change-Id: I89122602c3aa7d09ac1490b48297bf09366f01e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6558849
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1462366}
2025-05-19 11:59:38 -07:00
edf5748269 Exported things should always be visible
This changes our COMPONENT_EXPORT macros to make the things they export
visible all the time on non-windows, rather than making them visible in
the named component only. This avoids subtle bugs where things defined
in multiple components end up with one copy per component, only one of
which is visible, and so the linker doesn't know it's supposed to dedup
them.

Some, but not all, of these issues are detected by the new clang warning
-Wunique-object-duplication. This change addresses some instances of that
warning firing on chromium code, but not all. Conversely, there are likely
instances which the warning does not catch, which are fixed by this CL.

Bug: 368047728
Change-Id: I829a9bd84e57e3c7d80ec33aea0408951019bde7
AX-Relnotes: n/a.
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6264795
Owners-Override: Avi Drissman <avi@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Devon Loehr <dloehr@google.com>
Cr-Commit-Position: refs/heads/main@{#1456614}
2025-05-06 14:23:23 -07:00
7d2964dd55 Modernize equality operators
This CL is pure clean-up and contains no functionality changes.
Depending on the files covered in the CL (since the CL was generated
using git cl split), it does a subset of the following:
- Remove unneeded operator!= declarations/definitions since C++20 can
  automatically derive those from operator==.
- Default operator== where this is equivalent to the current behavior.
- Default operator<=> where this is equivalent to the current
  behavior.

This CL was uploaded by git cl split.

R=dljames@chromium.org

Bug: 40256175
Change-Id: If9c5a170ffb29dc20a4e78a8b97fd901451369eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6513635
Auto-Submit: Jan Keitel <jkeitel@google.com>
Reviewed-by: Darryl James <dljames@chromium.org>
Commit-Queue: Jan Keitel <jkeitel@google.com>
Cr-Commit-Position: refs/heads/main@{#1456470}
2025-05-06 11:18:57 -07:00
a318cef371 Move MockTabRestoreService to the core sessions component.
Moves the general mock for sessions::TabRestoreService to the sessions
component for easier reuse by clients outside of components/commerce.

Bug: 406904337
Change-Id: Ifa33239283ed679769c35fa9c41e988383f35151
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6450341
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Nohemi Fernandez <fernandex@google.com>
Cr-Commit-Position: refs/heads/main@{#1446480}
2025-04-14 06:13:31 -07:00
04881257ed wayland: session-management: Implement window removal
This implements window removal in ozone/wayland as well as adds the
required plumbing code in //chrome and //components. As mentioned in the
linked crbug and the design notes [1], for the experimental prototocol
which ships currently in Mutter 47 and 48, supporting window removals at
browser startup was more challenging than it's supposed to be in the
final protocol. That's because xdg_session_v1.remove_toplevel [2] is not
present there, leading to the hackish dummy window based approach. All
in all, it should be ok for this stage (experimental).

[1] https://notes.nickdiego.dev/chromium/wayland-session-management
[2] https://wayland.app/protocols/wayland-protocols/18#xdg_session_v1:request:remove_toplevel

R=dljames, fangzhoug, orko@igalia.com

Fixed: 352081012
Test: Manually with chrome on Gnome 48.0.
Change-Id: Ic2eb3b7a0f8586939f45820093857da395fc9f62
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6435570
Reviewed-by: Darryl James <dljames@chromium.org>
Reviewed-by: Orko Garai <orko@igalia.com>
Reviewed-by: Kramer Ge <fangzhoug@chromium.org>
Commit-Queue: Nick Yamane <nickdiego@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1444315}
2025-04-08 12:53:51 -07:00
f5b1ac6d9a [TabRestore] Update AddRestoreTab parameter name
Updates the boolean parameter restored_from_group_or_window_context to
is_restoring_group_or_window which better reflects what it is capturing.

Adds an additional comment TabRestoreServiceHelper::RestoreTab which
describes what is_restoring_group_or_window does. This comment is
similar to the one that can be found in live_tab_context.h already.

Includes other small comment updates for clarity.

Change-Id: I7a048671e3d91f315b9fc60062367d687beedc10
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6409453
Reviewed-by: Shakti Sahu <shaktisahu@chromium.org>
Reviewed-by: Gauthier Ambard <gambard@chromium.org>
Commit-Queue: Darryl James <dljames@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1440476}
2025-03-31 12:27:50 -07:00
624e0e97d3 [TabRestore] Rewrite BrowserLiveTabContext::AddRestoredTab
AddRestoredTab does not take into account the context for which we are
restoring a tab. This change makes it so we know if the tab being
restored is by itself, or restored alongside other tabs within its
group or window.

This change is necessary to prevent tab duplication for saved groups as
we want SavedTabGroups to be the source of truth for restored groups.

Tab duplication was happening anytime there was a conflict between the
SavedTabGroup and the tab group persisted in TabRestore.

Now we only rely on the SavedTabGroup if we have one.

Change-Id: I6266e63f281832341a2b2cdc96de727f20b22882
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6381720
Reviewed-by: Eshwar Stalin <estalin@chromium.org>
Reviewed-by: Gauthier Ambard <gambard@chromium.org>
Commit-Queue: Darryl James <dljames@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1438261}
2025-03-26 11:03:50 -07:00
9e5585fdb2 [TabRestore] Represent single tab windows as window entries in the UI
Windows that are closed with a single tab are now represented as
window entries with a single tab in the recent tabs submenu.

This CL removes the logic from the service meaning other platforms
using it the service are not subject to desktop specific logic.

Removes SessionRestoreTest.WindowWithOneTab since it is no longer
applicable.

Updates remaining tests to account for this change.

Change-Id: I0168dbadfecd4e9b611b91989180e3900d40627b
Bug: 41227458, 40438075, 40846749
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6387072
Reviewed-by: David Pennington <dpenning@chromium.org>
Commit-Queue: Darryl James <dljames@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1437715}
2025-03-25 13:55:49 -07:00
d0faf7d8b4 wayland: xdg-session-management: Add command for platform_session_id
Some platforms support window-related session management at display
server side. Such as, Linux/Wayland with xdg-session-management protocol
extension. In that case, 1 new piece of data must be requested and
persisted by the client application in order to be able to ask the
windowing system to restore window states when needed:

- platform_session_id: a string that identifies a platform session,
  generated by the display server (eg: the Wayland compositor
  implementing the xdg-session-management protocol), stored by chromium
  in the session commands backing storage, and sent back to the display
  server when restoring a browser session.

Further design notes available at
https://notes.nickdiego.dev/chromium/wayland-session-management

The upcoming CLs will add the remaining bits, including:

- UI/Views framework API required additions.
- Ozone/Wayland implementation based on xdg-toplevel-drag-v1 protocol.
- Chrome required plumbing and required changes.

Bug: 352081012
Change-Id: I5d2d7c5755c1cf5848bffd6231cc75f3fda2def3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6329136
Reviewed-by: Darryl James <dljames@chromium.org>
Commit-Queue: Nick Yamane <nickdiego@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1437661}
2025-03-25 12:14:54 -07:00
e9c9bd287a [Sessions] Remove Group and Window entries when the last tab is restored
Pass the SessionId of the window or group to remove when they become
empty after a restore.

This prevents a bug where the recent tabs menu could show entries with
0 restorable tabs. See bug for screenshot.

Change-Id: I44c4364121d14061079df06cebd86db450531eaf
Bug: 405426765
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6382275
Reviewed-by: Eshwar Stalin <estalin@chromium.org>
Commit-Queue: Darryl James <dljames@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1436327}
2025-03-21 15:31:14 -07:00
a8d5beb257 Update base::FilePath::StringPieceType usage outside of //base
Replace StringPieceType with StringViewType, since base::StringPiece has
been replaced by std::string_view.

Change-Id: I22826fb9df1a71d4ec1fadecaef969db52971d3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6235785
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Auto-Submit: Lei Zhang <thestig@chromium.org>
Owners-Override: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1416425}
2025-02-05 13:18:29 -08:00
8726d30ed0 Suppress unsafe_libc_call warning for initial identified files.
See docs/unsafe_buffers.md for details. Enforcement is not yet
enabled, but this set of files are not in compliance with the
new warnings.

Bug: 390223051
Change-Id: I4e24c2141b9399f572678302c833947494098b29
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6187925
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1412673}
2025-01-28 18:11:08 -08:00
ccea09835f [cleanup] Replace base::ranges with std::ranges: components/
Done entirely with `git grep` and `sed` + `git cl format`, no
hand-editing.

Bug: 386918226
Change-Id: I7377af2f9c3758c68a249b421d98bd3fd5c2c1fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6201377
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1411730}
2025-01-27 10:38:22 -08:00
525df6f097 Use RemoveEntryById to erase the entry when restore recent closed tabs
This CL will use the method RemoveEntryById to remove the entry from
entries list of tab restore. Because the iterator may be invaild after
the time-consuming operation.

Change-Id: I70fc581f41fea1a9f88d496b92d367458b77f865
Bug: 390075226
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6176858
Reviewed-by: Calder Kitagawa <ckitagawa@chromium.org>
Commit-Queue: Calder Kitagawa <ckitagawa@chromium.org>
Reviewed-by: Stefan Kuhne <skuhne@chromium.org>
Reviewed-by: Sky Malice <skym@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1408035}
2025-01-17 10:47:20 -08:00
40d45a6c13 [STG] Fix data duplications for shared tab groups on crash/power down.
When a window is created via TabRestore as the first tab restore
entry, the tabs in the window (and group) are not populated with
saved information if the browser had crashed or powered down in an
unclean state. This causes new groups to be created, even though they
should be mapped to saved groups.

This Cl adds methods that assign the correct saved information to the
tabs so they dont duplicate groups.

Fixed: 389107698
Change-Id: Ic6f387c533263def3102e35d013abf8c903feeee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6177194
Reviewed-by: Eshwar Stalin <estalin@chromium.org>
Reviewed-by: Stefan Kuhne <skuhne@chromium.org>
Commit-Queue: David Pennington <dpenning@chromium.org>
Reviewed-by: Darryl James <dljames@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1407984}
2025-01-17 09:19:34 -08:00
b8540520c0 Add dljames as OWNER of components/sessions/core
Upgrading myself to OWNER of this subdirectory since I have made quite
a few contributions in this area already and have an understanding of
the structure of this system and how it works.

Already an OWNER of chrome/browser/sessions/

Change-Id: I9f5047d0c888bc3c1297e326a2f0f3d42494f292
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6174068
Reviewed-by: Erik Chen <erikchen@chromium.org>
Reviewed-by: Stefan Kuhne <skuhne@chromium.org>
Commit-Queue: Darryl James <dljames@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1407644}
2025-01-16 16:29:37 -08:00
f0f11392a4 Clean up compatibility code for last_active_time
This code has been here for one year now. It is time to remove it.
It was added in http://crrev.com/c/5071355.

Fixed: 40946710
Change-Id: Ic2aef138b5709dbe6da441f24472c2c86f7d7abc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6175029
Reviewed-by: Stefan Kuhne <skuhne@chromium.org>
Reviewed-by: Marc Treib <treib@chromium.org>
Auto-Submit: Gauthier Ambard <gambard@chromium.org>
Commit-Queue: Stefan Kuhne <skuhne@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1406812}
2025-01-15 10:09:07 -08:00
764f01d25d Remove IS_CHROMEOS_ASH from //components/*
This cleans up the following subdirectories: sessions,
soda, storage_monitor, supervised_user, sync_preferences,
system_media_controls, translate, trusted_vault,
unified_consent, update_client, user_manager,
vector_icons, version_ui, web_resource

1) Removed IS_CHROMEOS_LACROS usages and code it guarded
2) Renamed IS_CHROMEOS_ASH to IS_CHROMEOS
3) Removed chromeos_buildflags.h includes
4) Cleaned up *.gn files from IS_CHROMEOS_*.

Bug: 375523816, 373972275, 373971535
Change-Id: I973920d2078526bede68a84dbea53029d202c22d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6097194
Reviewed-by: Georg Neis <neis@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1397771}
2024-12-18 00:34:42 -08:00
b7c1fd51e1 C++11 std::array rewrite for memory safety [4/19]
Split from:
https://chromium-review.googlesource.com/c/chromium/src/+/6004959/21

Generated patch
---------------
- Tool: ./tool/clang/spanify/rewrite-multiple-platform.sh
- Platform: Linux.
- Filter: This includes 2400/4222 patches. I included the std::array
      ones and excluded build errors.

Google announcement:
--------------------
https://groups.google.com/a/google.com/g/chrome-memory-safety/c/RMiO4gaVLQA/m/Yz-3NCObAgAJ

Benchmarks:
----------
See design doc and
https://chromium-review.googlesource.com/c/chromium/src/+/6004959/21

Description
-----------
The consensus during the memory safety summit was to begin rewriting
relevant C-style arrays to C++11 std::array. It can be done immediately,
offers better developer ergonomics, and fix large chunks of the
-Wunsafe-buffer-usage errors in Chrome.

To clarify, this effort is complementary to the longer plan work with
enabling -fsanitize=array-bounds, and we plan to leverage both,
especially for protecting 3p code.

[Attached] is a document detailing the rationale, benefits, and
considerations for potential compile-time and performance impacts.

[Attached]:https://docs.google.com/document/d/1z5aBDg26lHmNDjXRCysElWKx7E4PAJXqykI_k7ondJI/edit?tab=t.0#heading=h.cqgo7wvp0kzt

NO_IFTTT=No need to update base/debug/stack_trace.h

Bug: 378069401
Change-Id: I838a8c44e82ed27dc75e771acec31d84992860af
R: dcheng@chromium.org
AX-Relnotes: n/a.
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6038951
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1394163}
2024-12-10 09:58:59 +00:00
d82594fc3a Remove usage of base::make_span(): components/, part 2
Replace with span() CTAD use, or more targeted helpers.

Bug: 341907909
Change-Id: If17945eb0811b5d171c1fd443b567b0990a9587f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6061144
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Cait Phillips <caitkp@google.com>
Reviewed-by: Cait Phillips <caitkp@google.com>
Cr-Commit-Position: refs/heads/main@{#1390403}
2024-12-02 17:12:59 +00:00
77d2135a33 Migrate remaining NOTREACHED()s in components/
NOTREACHED() and NOTREACHED_IN_MIGRATION() are both CHECK-fatal now.
The former is [[noreturn]] so this CL also performs dead-code removal
after the NOTREACHED().

This CL does not attempt to do additional rewrites of any surrounding
code, like:

if (!foo) {
  NOTREACHED();
}

to CHECK(foo);

Those transforms take a non-trivial amount of time (and there are
thousands of instances). Cleanup can be left as an exercise for the
reader.

Bug: 40580068
Change-Id: I72205fb77747957c6bf33dbea93656fd20085a42
Low-Coverage-Reason: OTHER Should-be-unreachable code
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6010008
Reviewed-by: Rick Byers <rbyers@chromium.org>
Owners-Override: Rick Byers <rbyers@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1382618}
2024-11-13 22:26:11 +00:00
03a0548e74 removes sky from OWNERs files
Bug: none
Change-Id: I72f8d9aa103cd243dce3135996e5631f8fa2296a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5972519
Owners-Override: Rick Byers <rbyers@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: Rick Byers <rbyers@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1374817}
2024-10-28 19:51:27 +00:00
97f7346697 components: default the user-defined empty ctor and dtor where possible
I need an owner's approval please for changes under:
components/sessions

This is a mechanical change. There are a few instances (but not all)
of empty user-defined constructors and destructors which can be
defaulted in the /components code.

A few of these have been missed by previous CLs and are being changed
now.

This CL was uploaded by git cl split.

R=dljames@chromium.org

Bug: 374110115
Change-Id: Ie694b0f8dec4d5392e0de42f61733415ccc0ee26
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5963211
Auto-Submit: Sorin Jianu <sorin@chromium.org>
Commit-Queue: Darryl James <dljames@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Darryl James <dljames@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1373981}
2024-10-25 17:06:03 +00:00
c0a5c38911 [SessionService] Adding debug information & fixing app reparenting.
This fixes the app reparenting issue introduced by this CL:
https://chromium-review.googlesource.com/c/chromium/src/+/5899682

That CL deleted some session restore stuff that seemed unnecessary.
Unfortunately there are no tests in this area. So this CL adds that
logic back due to the below bug being found.

This CL also adds a lot more helpful information to
chrome://internals/session-service.

Bug: 373461941
Change-Id: I701e0588c02a2ef5beb59516ad5ffc79dc93f585
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5938537
Auto-Submit: Daniel Murphy <dmurph@chromium.org>
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1369633}
2024-10-16 21:11:14 +00:00
592d5754fa components: default the user-defined empty ctor and dtor where possible
I need an owner's approval please for changes under:
['components/favicon', 'components/favicon_base', 'components/query_parser', 'components/sessions', 'components/visitedlink']

This is a mechanical change. There are a few instances (but not all)
of empty user-defined constructors and destructors which can be
defaulted in the /components code.

This CL was uploaded by git cl split.

R=sky@chromium.org

Bug: 371316188
Change-Id: If2b363c364d8437b6a65434bacc49a73a033152f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5918669
Auto-Submit: Sorin Jianu <sorin@chromium.org>
Commit-Queue: Sorin Jianu <sorin@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1366386}
2024-10-09 19:46:41 +00:00
0d930717b9 [TabGroups] Fix crash when restoring grouped tab in app like browsers
The crash happens when a grouped tab is restored into a browser that
does not support tab groups. In this scenario, we will touch multiple
different kinds of CHECKS / nullptr dereferences which will crash the
browser.

Changes:
- CHECK TabGroupModel, TabStripModel, and TabGroup have values before
use in BrowserLiveTabContext::SetVisualDataForGroup and
BrowserLiveTabContext::GetVisualDataForGroup
- Restore the grouped tab as an ungrouped tab if there is no
TabGroupModel for the browser
- Adds a regression test for this specific scenario

Change-Id: I0230b7a7c86c31c77740488ce8959de77bd20865
Bug: 368139715
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5888488
Commit-Queue: Darryl James <dljames@chromium.org>
Reviewed-by: Eshwar Stalin <estalin@chromium.org>
Reviewed-by: Steven Luong <stluong@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1360585}
2024-09-26 16:44:32 +00:00
9ccb791c33 Avoid unsafe forms for base::File::WriteAtCurrentPos()
Use the span based forms instead. Adjust callers to accommodate
an optional<size_t> return.

This CL was uploaded by git cl split.

R=jzw@chromium.org, khorimoto@chromium.org, skuhne@chromium.org, waffles@chromium.org, wtlee@chromium.org

Bug: 42271176
Change-Id: I7b1c5869e8660b017e036ce407c93b02a64c4878
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5819272
Reviewed-by: Wei Lee <wtlee@chromium.org>
Auto-Submit: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Joshua Pawlicki <waffles@chromium.org>
Reviewed-by: Kyle Horimoto <khorimoto@chromium.org>
Reviewed-by: Stefan Kuhne <skuhne@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: John Wu <jzw@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1358864}
2024-09-23 16:52:15 +00:00
3994f2536d [UI] Use mojo enum for WindowShowState in components/
This CL removes `WindowShowState` enum from ui_base_types.h.
Replaces the uses of `WindowShowState` with the mojo version in
components folder.
Created an alias for previous style with mojom to be usable for now
in other places. When every instance is replaced, alias will be
removed.

`WindowShowState` is moved from ui_base_types.mojom to it's own
mojom due to circular dependency between `ui/base/mojom` and `ui/base`.
`WindowShowState` will be moved back to ui_base_types.mojom once
the circular dependency is gone.

A modified version of the following script is used for replacing
with different folder name.
Script: https://issues.chromium.org/issues/355460976#comment2

AX-Relnotes: N/A
Bug: 355460976
Change-Id: I92999c064fba2fd9d5a1619c49009785ca5ccb83
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5793019
Reviewed-by: Peter Boström <pbos@chromium.org>
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: Erik Chen <erikchen@chromium.org>
Auto-Submit: Md Hasibul Hasan <hasibulhasan873@gmail.com>
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: Ahmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1354297}
2024-09-12 01:13:46 +00:00
69e4bbf012 Exclude top of NOTREACHED tail still hit in stable
This includes the top ~30 in M128 and ~20 in M127 on ChromeOS.
... except the few ones I can't find due to ICF, or ones that have
already been fixed or removed as erroneous.

This is to further derisk NOTREACHED-fatal rollout. Per crash-reporting
volumes on Windows we should be about 1/50 as crashy as CHECK failures
after this has landed.

     40264195, 40895492, 354661907, 363109548, 361609999, 352381196,
     361612971, 362124606, 355803743, 41369768, 345232410, 346893376,
     40910294

Bug: 40580068, 332263206, 40942310, 40948203, 355803743, 362506636,
Change-Id: I56e42b3b7c8ce17d6dabb5d7edb48db925240e34
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5824114
Owners-Override: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1349061}
2024-08-30 06:26:16 +00:00
db85e2b6ff fixes two restore bugs with windows with titles
1. If a window with a single tab has a user supplied title,
   when closing we shouldn't add the tab. Instead we should
   add the window. Adding the tab means we lose the title.
2. SessionService::WindowOpened should set the user title.
   Otherwise it won't be saved.

Bug: None
Test: None
Change-Id: Ia2bef8a6a655eeffe5f417f5366d2a29975d8ecf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5763166
Reviewed-by: Elly FJ <ellyjones@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1338487}
2024-08-07 15:26:57 +00:00
da292fb29d Convert WebContents::LastActiveTime to base::Time
TimeTicks should only be used to measure local duration (same machine,
same process) and not absolute time. TimeTicks may not increment during
process suspension (this is platform dependent) and so TimeTicks created
at different time do not share a common reference. As a consequence, it
is not possible to convert them to absolute times.

WebContents::LastActiveTime is intended to represent the date of the
last activation time, that will be persisted and sent to sync. Because
it uses TimeTicks, this field is incorrectly synced for WebContents
created on Mac or ChromeOS machines. Convert the field to a base::Time
to fix it.
Convert the field to a base::Time to fix it.


Bug: 349542284
Change-Id: Iba85b1579f8ee9ec22d60219c8f8f444eef3336d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5735384
Commit-Queue: Olivier Robin <olivierrobin@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1338463}
2024-08-07 14:32:29 +00:00
aaf7e86769 [ios] Cleanup IOSChromeSyncedTabDelegate
The EnableSessionSerializationOptimizations feature has launched
and SessionRestorationServiceImpl is returned by the factory. It
requires to enable placeholder tabs support. The placeholder tab
support also work with LegacySessionRestorationService (it is
not required, but it works).

Thus clean IOSChromeSyncedTabDelegate to assumes placeholder tab
support is always enabled and remove dead code.

Bug: 40945317
Change-Id: Ia08205f56d5ee9ff02dac5dfc074a30cc9eeb2c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5746956
Auto-Submit: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: Gauthier Ambard <gambard@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1335420}
2024-07-31 14:03:30 +00:00
b948e67a9c spanification: Add #pragma allow_unsafe_buffers to component/*
See `//docs/unsafe_buffers.md`

This is a preparation to fix each files.
This CL has no behavior changes.

This patch was fully automated using script:
https://paste.googleplex.com/5614491201175552

See internal doc about it:
https://docs.google.com/document/d/1erdcokeh6rfBqs_h0drHqSLtbDbB61j7j3O2Pz8NH78/edit?resourcekey=0-hNe6w1hYAYyVXGEpWI7HVA&tab=t.0

AX-Relnotes: n/a.
Bug: 40285824
Change-Id: I24ff0aee7a6cbe6da11a08830135449ccf8f2ae2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5717711
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Cait Phillips <caitkp@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1335315}
2024-07-31 08:29:04 +00:00
5d08744a14 Set the restored most recently closed tab as current tab.
On other desktop platforms(linux, mac, chromeos,etc), when
user uses keyboard shortcut "ctrl-shift-t" to re-open the
most recently closed tab, after the tab is restored, it is
set as the current tab. On Clank, however, the restored tab
is inactive. This makes the user experience inconsistent
on clank. This cl fixes this issue by always setting the
tab(most recently closed) restored as the current tab.

This cl fixes the case for restoring a tab without snackbar
showing up, i.e. from tab restore service.

Bug: 348478081
Change-Id: I912143efb508a6ab4bec4cfd50e37eb3d6a964c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5669932
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Nico Weber <thakis@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Calder Kitagawa <ckitagawa@chromium.org>
Reviewed-by: David Roger <droger@chromium.org>
Commit-Queue: Jenny Zhang <jennyz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1332509}
2024-07-24 19:02:12 +00:00
e70c29e773 [SavedTabGroups] Default save unsaved when updating from V1 to V2
This CL addresses 4 different issues with enabling default save in V2,

1) Enabled default save of groups restored from session
2) Fixed to support asynchronous saving of groups at startup since
the model initialization might have not completed
3) Fixed an issue where session data wasn't restored correctly for the
saved GUID when there were multiple records in the append log
4) Tab Group session metadata was only updated when there was a change
in visual data. This led to cases where the saved GUID wasn't updated.
This was updated to listen for saved tab group model changes when groups
were saved or unsaved

Change-Id: I4d2255c11ad4022be701f0ee32115f5d8977ae6a
Bug: 344016224
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5608434
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: David Pennington <dpenning@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Darryl James <dljames@chromium.org>
Commit-Queue: Eshwar Stalin <estalin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1313032}
2024-06-10 20:47:30 +00:00
dccb3c31b4 Activate proper tab on restoring window from session
This fixes a regression introduced in
https://chromium-review.googlesource.com/c/chromium/src/+/5460410

TabRestoreServiceHelper is saving selected_tab_index in
TabRestoreServiceHelper::BrowserClosing() but the saved index wasn't
used later and TabRestoreServiceHelper was always activating the first
tab when the whole window was restored.

This CL adds a test TabRestoreTest.RestoreWindow_ActiveTabIndex that
verifies that the active tab is still active after closing and
restoring the window.

Bug: 344606398
Change-Id: I6c3262a465b8d902a4ba9a7213fdad6142a38723
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5594032
Commit-Queue: Tomasz Moniuszko <tmoniuszko@opera.com>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Darryl James <dljames@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1311219}
2024-06-06 13:49:36 +00:00
aaf19db38d Use NOTREACHED_IN_MIGRATION() in components/
This was generated by replacing "  NOTREACHED()" with
"  NOTREACHED_IN_MIGRATION()" and running git cl format.

This prepares for making NOTREACHED() [[noreturn]] alongside
NotReachedIsFatal migration of existing inventory.

Bug: 40580068
Change-Id: I92e83d0b564d44267f003147a1ce6ba3674621a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5539175
Owners-Override: Lei Zhang <thestig@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1300923}
2024-05-14 22:08:09 +00:00
64c73bc173 [ Tab Restore ] Fix crash caused by empty field in tab_restore::Window
When the last session of a browser is loaded it does not take the traditional route of adding an entry into the TabRestoreService. Instead of going through the helper classes (TabRestoreServiceHelper, TabRestoerServiceImpl) which provide all of the setup for the tab_restore::Window object, loading the last sessions immediately adds the entry to the TabRestoreService.

This means that any fields that require pre-processing will be empty. To fix this, we add an additional check when a WINDOW entry is added to populate its tab_groups field. This ultimately prevents a CHECK crash that will happen when a user clicks on the 3-dot (app menu) button.

Change-Id: Ia27673d6f5a82cdbff6cbb84977daf84075ad8bf
Bug: 338555375
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5515918
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Darryl James <dljames@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1296295}
2024-05-03 19:50:54 +00:00
939685f4a4 [ios] Remove ios/web/public dependency from public_deps in ios/web:web
change in ios_internal/: https://chrome-internal-review.googlesource.com/c/chrome/ios_internal/+/7241376

public_deps in ios/web/BUILD.gn should not have private files.
See the best practice: https://g3doc.corp.google.com/home/g3doc/devices/platforms/cast/reference/build-gn-best-practices.md?cl=head#public-deps-vs-deps

This CL removes "//ios/web/public" from ios/web:web and updates other
BUILD.gn to explicitly include "//ios/web/public" and other
dependencies.

Bug: 338033944
Change-Id: I5ad84c69823d1d5bee05178838d75aa133ee1ad7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5498364
Commit-Queue: Éric Noyau <noyau@chromium.org>
Auto-Submit: Asami Doi <asamidoi@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Reviewed-by: Éric Noyau <noyau@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1295969}
2024-05-03 07:26:11 +00:00
30ca657612 [ TabRestore ] Remove duplicate group data from Window object
Consolidates the tab group mappings into one structure in
tab_restore::Window. This prevents the duplication of group data.

Change-Id: I34fcb4028b409b954d7e2296ceb2ea503cc8c456
Bug: 333425400, 333425400
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5502733
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Darryl James <dljames@chromium.org>
Reviewed-by: Eshwar Stalin <estalin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1295842}
2024-05-02 23:26:02 +00:00
3ae90009a0 Convert base::StringPiece to std::string_view in //components 3/5
The changes of this CL are made using the following script.
Script: https://issues.chromium.org/issues/40506050#comment343

Bug: 40506050
Change-Id: I7b21541a0723d312206c786d3af570f552ceef4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5498922
Auto-Submit: Helmut Januschka <helmut@januschka.com>
Commit-Queue: Helmut Januschka <helmut@januschka.com>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1295637}
2024-05-02 18:42:28 +00:00
3bd1462c88 [ TabRestore ] Serialize Saved Group Id for saved groups / tabs
Update the tab restore Tab and Group pickles to keep track of the saved group id. This must be done to prevent duplicating a saved group when we restore an entry after the browser has been restarted.

Change-Id: I90a6724e7890bb8a8b1502e95e5d2adb427f1f3b
Bug: 330769691, 330769723
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5498867
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Eshwar Stalin <estalin@chromium.org>
Commit-Queue: Darryl James <dljames@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1294912}
2024-05-01 16:39:27 +00:00
29c001bb23 [ TabRestore ] Restore groups all at once from inside window objects
Adds the menu item "Restore group" and a separator to groups within a
window object. Previously it was not possible to restore an entire group
within a window. Users had to manually select each tab they wanted to
restore.

Instead they can click a single menu item!

Screencast available at crbug.com/331230893

Change-Id: I3310c5aa551305b1065211404d1efbe3277bc819
Bug: 331230893, 332721077
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5480409
Commit-Queue: Darryl James <dljames@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Eshwar Stalin <estalin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1293917}
2024-04-29 20:11:13 +00:00
45c4058fd0 Migrate TODOs referencing old crbug IDs to the new issue tracker IDs
The canonical bug format is TODO(crbug.com/<id>). TODOs of the
following forms will all be migrated to the new format:

- TODO(crbug.com/<old id>)
- TODO(https://crbug.com/<old id>)
- TODO(crbug/<old id>)
- TODO(crbug/monorail/<old id>)
- TODO(<old id>)
- TODO(issues.chromium.org/<old id>)
- TODO(https://issues.chromium.org/<old id>)
- TODO(https://issues.chromium.org/u/1/issues/<old id>)
- TODO(bugs.chromium.org/<old id>)

Bug id mapping is sourced from go/chrome-on-buganizer-prod-issues.
See go/crbug-todo-migration for details.

#crbug-todo-migration

Bug: b/321899722
Change-Id: I8a9934c8837b7e99594af4d63d4343128b70f7fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5493246
Auto-Submit: Alison Gale <agale@chromium.org>
Owners-Override: Alison Gale <agale@chromium.org>
Commit-Queue: Alison Gale <agale@chromium.org>
Reviewed-by: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1293200}
2024-04-26 19:30:02 +00:00
ae5419e0b2 [ SavedTabGroups ] Tab Restore implementation for SavedTabGroups
Initial implementation for restoring SavedTabGroups and their tabs.

List of Changes:
- Ungrouped tabs will restore normally
- Restored tabs which are grouped will be restored normally then saved
- Restored groups will be restored normally and saved
- Restore saved groups will open the saved group and add any tabs that are not in the list of tabs already
- The first index of restored windows will be activated instead of the last index
- The first index of restored groups will be activated instead of the last index

Change-Id: I15c6a2f22b20cd2a01704d31286e253af05de16d
Bug: 335270082
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5460410
Commit-Queue: Darryl James <dljames@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Eshwar Stalin <estalin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1291461}
2024-04-23 19:01:47 +00:00
988d7c5218 [ TabRestore ] Use TabRestoreTypes in LiveTabContext
Because of the changes in this cl: https://chromium-review.googlesource.com/c/chromium/src/+/5449978, we are able to use the TabRestoreTypes directly in LiveTabContext. This reduces the parameters we need to pass to functions such as AddRestoredTab and ReplaceRestoredTab.

We also no longer need to independently update the parameters if an addition is made to sessions::tab_restore::Tab.

Change-Id: I46594b45a2dab5e1ac8eacea7b44ea7b5552a209
Bug: 335281443
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5458785
Reviewed-by: Gauthier Ambard <gambard@chromium.org>
Commit-Queue: Darryl James <dljames@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1289448}
2024-04-18 18:04:31 +00:00
71303418b7 [ TabRestore ] Move restore types out of TabRestoreService
Moves the tab restore structs Entry, Tab, Group, and Window out
of the TabRestoreService and into its own file.

The goal of this CL is to decouple LiveTabContext from
TabRestoreService, which includes LiveTabContext. Doing this will allow
us to pass the Tab, Group, and Window types as parameters to functions
such as LiveTabContext::AddRestoredTab instead of passing all the fields
of the objects individually.

Change-Id: I2f30bb25f934806112333d67ed3586dade09fe46
Bug: 334170377
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5449978
Commit-Queue: Darryl James <dljames@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1288110}
2024-04-16 16:48:36 +00:00
b8be952f6c Migrate TODOs referencing old crbug IDs to the new issue tracker IDs
The canonical bug format is TODO(crbug.com/<id>). TODOs of the
following forms will all be migrated to the new format:

- TODO(crbug.com/<old id>)
- TODO(https://crbug.com/<old id>)
- TODO(crbug/<old id>)
- TODO(crbug/monorail/<old id>)
- TODO(<old id>)
- TODO(issues.chromium.org/<old id>)
- TODO(https://issues.chromium.org/<old id>)
- TODO(https://issues.chromium.org/u/1/issues/<old id>)
- TODO(bugs.chromium.org/<old id>)

Bug id mapping is sourced from go/chrome-on-buganizer-prod-issues.
See go/crbug-todo-migration for details.

#crbug-todo-migration

Bug: b/321899722
Change-Id: I89f0a4d7ddeb7c9585f3a0e5421aef8ce5a6f0f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5455854
Reviewed-by: Taylor Bergquist <tbergquist@chromium.org>
Commit-Queue: Alison Gale <agale@chromium.org>
Owners-Override: Alison Gale <agale@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1287738}
2024-04-16 00:00:31 +00:00
38102e0843 [base] Drop unused deps on dynamic_annotations
Bug: 1282422
Change-Id: Id5e94e53ddb08ae95eee22deb2e5c61b75ce9264
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3398908
Reviewed-by: Nico Weber <thakis@chromium.org>
Owners-Override: Nico Weber <thakis@chromium.org>
Reviewed-by: Hans Wennborg <hans@chromium.org>
Commit-Queue: Nathaniel Manista <nathaniel@google.com>
Cr-Commit-Position: refs/heads/main@{#1286330}
2024-04-12 06:52:20 +00:00
cb1116dc1a [ TabRestore ] Initial Window Restore Implementation
Implements the ability to restore windows with saved tab groups in their saved state when using the keyboard shortcut (ctrl+shift+t).

Does not implement the ability to restore windows with saved tab groups through the recent tabs submenu.

Change-Id: I0aa356c6aabf1b9957b05680572a3946561141f7
Bug: 330769406, 330769367, 333425400
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5411104
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Darryl James <dljames@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1284789}
2024-04-10 00:04:32 +00:00