File: tab_group_deletion_dialog_controller.cc

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (501 lines) | stat: -rw-r--r-- 20,125 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/tabs/tab_group_deletion_dialog_controller.h"

#include <string>

#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/i18n/message_formatter.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/browser_window/public/browser_window_interface.h"
#include "chrome/browser/ui/tabs/saved_tab_groups/saved_tab_group_pref_names.h"
#include "chrome/browser/ui/tabs/saved_tab_groups/saved_tab_group_utils.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "components/prefs/pref_service.h"
#include "components/saved_tab_groups/public/types.h"
#include "components/signin/public/base/consent_level.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/dialog_model.h"

namespace tab_groups {

namespace {
// The text that shows on the checkbox.
constexpr int kDontAskId = IDS_TAB_GROUP_DELETION_DIALOG_DONT_ASK;

// Body text for all delete actions.
constexpr int kDeleteBodySyncedId =
    IDS_TAB_GROUP_DELETION_DIALOG_BODY_SYNCED_DELETE;
constexpr int kDeleteBodyNotSyncedId =
    IDS_TAB_GROUP_DELETION_DIALOG_BODY_NOT_SYNCED_DELETE;

// For deletion, the text that shows on the dialog.
constexpr int kDeleteTitleId = IDS_TAB_GROUP_DELETION_DIALOG_TITLE_DELETE;
constexpr int kDeleteOkTextId = IDS_TAB_GROUP_DELETION_DIALOG_OK_TEXT_DELETE;

// For ungrouping, the text that shows on the dialog.
constexpr int kUngroupTitleId = IDS_TAB_GROUP_DELETION_DIALOG_TITLE_UNGROUP;
constexpr int kUngroupBodySyncedId =
    IDS_TAB_GROUP_DELETION_DIALOG_BODY_SYNCED_UNGROUP;
constexpr int kUngroupBodyNotSyncedId =
    IDS_TAB_GROUP_DELETION_DIALOG_BODY_NOT_SYNCED_UNGROUP;
constexpr int kUngroupOkTextId = IDS_TAB_GROUP_DELETION_DIALOG_OK_TEXT_UNGROUP;

// For closing the last tab, the text that shows on the dialog.
constexpr int kCloseTabAndDeleteTitleId =
    IDS_TAB_GROUP_DELETION_DIALOG_TITLE_CLOSE_TAB_AND_DELETE;

// For removing the last tab, the text that shows on the dialog.
constexpr int kRemoveTabAndDeleteTitleId =
    IDS_TAB_GROUP_DELETION_DIALOG_TITLE_REMOVE_TAB_AND_DELETE;

struct DialogText {
  const std::u16string title;
  const std::u16string body;
  const std::u16string ok_text;
  const std::optional<std::u16string> cancel_text = std::nullopt;
};

// Returns the list of strings that are needed for a given dialog type.
DialogText GetDialogText(
    Profile* profile,
    const DeletionDialogController::DialogMetadata& dialog_metadata) {
  tab_groups::TabGroupSyncService* tab_group_service =
      tab_groups::SavedTabGroupUtils::GetServiceForProfile(profile);

  const bool is_sync_enabled =
      tab_group_service &&
      tab_groups::SavedTabGroupUtils::AreSavedTabGroupsSyncedForProfile(
          profile);

  std::u16string email =
      l10n_util::GetStringUTF16(IDS_TAB_GROUP_DELETION_DIALOG_MISSING_EMAIL);
  signin::IdentityManager* identity_manager =
      IdentityManagerFactory::GetForProfile(profile);
  if (profile && identity_manager) {
    email = base::UTF8ToUTF16(
        identity_manager->GetPrimaryAccountInfo(signin::ConsentLevel::kSignin)
            .email);
  }

  const int closing_group_count = dialog_metadata.closing_group_count;
  const int closing_multiple_groups = closing_group_count > 1;
  const int plural_type_count =
      dialog_metadata.closing_multiple_tabs + closing_multiple_groups;

  switch (dialog_metadata.type) {
    case DeletionDialogController::DialogType::DeleteSingle: {
      return DialogText{
          base::i18n::MessageFormatter::FormatWithNumberedArgs(
              l10n_util::GetStringUTF16(kDeleteTitleId), closing_group_count),
          base::i18n::MessageFormatter::FormatWithNumberedArgs(
              is_sync_enabled
                  ? l10n_util::GetStringFUTF16(kDeleteBodySyncedId, email)
                  : l10n_util::GetStringUTF16(kDeleteBodyNotSyncedId),
              closing_group_count),
          base::i18n::MessageFormatter::FormatWithNumberedArgs(
              l10n_util::GetStringUTF16(kDeleteOkTextId), closing_group_count)};
    }
    case DeletionDialogController::DialogType::UngroupSingle: {
      return DialogText{
          base::i18n::MessageFormatter::FormatWithNumberedArgs(
              l10n_util::GetStringUTF16(kUngroupTitleId), closing_group_count),
          base::i18n::MessageFormatter::FormatWithNumberedArgs(
              is_sync_enabled
                  ? l10n_util::GetStringFUTF16(kUngroupBodySyncedId, email)
                  : l10n_util::GetStringUTF16(kUngroupBodyNotSyncedId),
              closing_group_count),
          l10n_util::GetStringUTF16(kUngroupOkTextId)};
    }
    case DeletionDialogController::DialogType::RemoveTabAndDelete: {
      return DialogText{
          base::i18n::MessageFormatter::FormatWithNumberedArgs(
              l10n_util::GetStringUTF16(kRemoveTabAndDeleteTitleId),
              plural_type_count),
          base::i18n::MessageFormatter::FormatWithNumberedArgs(
              is_sync_enabled
                  ? l10n_util::GetStringFUTF16(kDeleteBodySyncedId, email)
                  : l10n_util::GetStringUTF16(kDeleteBodyNotSyncedId),
              closing_group_count),
          base::i18n::MessageFormatter::FormatWithNumberedArgs(
              l10n_util::GetStringUTF16(kDeleteOkTextId), closing_group_count)};
    }
    case DeletionDialogController::DialogType::CloseTabAndDelete: {
      return DialogText{
          base::i18n::MessageFormatter::FormatWithNumberedArgs(
              l10n_util::GetStringUTF16(kCloseTabAndDeleteTitleId),
              plural_type_count),
          base::i18n::MessageFormatter::FormatWithNumberedArgs(
              is_sync_enabled
                  ? l10n_util::GetStringFUTF16(kDeleteBodySyncedId, email)
                  : l10n_util::GetStringUTF16(kDeleteBodyNotSyncedId),
              closing_group_count),
          base::i18n::MessageFormatter::FormatWithNumberedArgs(
              l10n_util::GetStringUTF16(kDeleteOkTextId), closing_group_count)};
    }
    case DeletionDialogController::DialogType::DeleteSingleShared: {
      const bool title_is_empty =
          !dialog_metadata.title_of_closing_group.has_value() ||
          dialog_metadata.title_of_closing_group->empty();
      std::u16string body_text =
          title_is_empty
              ? l10n_util::GetStringUTF16(
                    IDS_DATA_SHARING_OWNER_DELETE_DIALOG_BODY_NO_GROUP_TITLE)
              : l10n_util::GetStringFUTF16(
                    IDS_DATA_SHARING_OWNER_DELETE_DIALOG_BODY,
                    dialog_metadata.title_of_closing_group.value());
      return DialogText{
          l10n_util::GetStringUTF16(IDS_DATA_SHARING_OWNER_DELETE_DIALOG_TITLE),
          std::move(body_text),
          l10n_util::GetStringUTF16(
              IDS_DATA_SHARING_OWNER_DELETE_DIALOG_CONFIRM)};
    }
    case DeletionDialogController::DialogType::CloseTabAndKeepOrLeaveGroup: {
      return DialogText{
          l10n_util::GetPluralStringFUTF16(
              IDS_DATA_SHARING_DELETE_LAST_TAB_TITLE,
              dialog_metadata.closing_group_count),
          l10n_util::GetPluralStringFUTF16(
              IDS_DATA_SHARING_MEMBER_DELETE_LAST_TAB_BODY,
              dialog_metadata.closing_group_count),
          l10n_util::GetPluralStringFUTF16(
              IDS_DATA_SHARING_DELETE_LAST_TAB_CONFIRM,
              dialog_metadata.closing_group_count),
          l10n_util::GetPluralStringFUTF16(
              IDS_DATA_SHARING_MEMBER_DELETE_LAST_TAB_CANCEL,
              dialog_metadata.closing_group_count),
      };
    }
    case DeletionDialogController::DialogType::CloseTabAndKeepOrDeleteGroup: {
      return DialogText{
          l10n_util::GetPluralStringFUTF16(
              IDS_DATA_SHARING_DELETE_LAST_TAB_TITLE,
              dialog_metadata.closing_group_count),
          l10n_util::GetPluralStringFUTF16(
              IDS_DATA_SHARING_OWNER_DELETE_LAST_TAB_BODY,
              dialog_metadata.closing_group_count),
          l10n_util::GetPluralStringFUTF16(
              IDS_DATA_SHARING_DELETE_LAST_TAB_CONFIRM,
              dialog_metadata.closing_group_count),
          l10n_util::GetPluralStringFUTF16(
              IDS_DATA_SHARING_OWNER_DELETE_LAST_TAB_CANCEL,
              dialog_metadata.closing_group_count),
      };
    }
    case DeletionDialogController::DialogType::LeaveGroup: {
      const bool title_is_empty =
          !dialog_metadata.title_of_closing_group.has_value() ||
          dialog_metadata.title_of_closing_group->empty();
      std::u16string body_text =
          title_is_empty
              ? l10n_util::GetStringUTF16(
                    IDS_DATA_SHARING_LEAVE_DIALOG_BODY_NO_GROUP_TITLE)
              : l10n_util::GetStringFUTF16(
                    IDS_DATA_SHARING_LEAVE_DIALOG_BODY,
                    dialog_metadata.title_of_closing_group.value());

      return DialogText{
          l10n_util::GetStringUTF16(IDS_DATA_SHARING_LEAVE_DIALOG_TITLE),
          std::move(body_text),
          l10n_util::GetStringUTF16(IDS_DATA_SHARING_LEAVE_DIALOG_CONFIRM)};
    }
  }
}

bool IsDialogSkippable(DeletionDialogController::DialogType type) {
  switch (type) {
    // Saved tab group dialogs are skippable.
    case DeletionDialogController::DialogType::DeleteSingle:
    case DeletionDialogController::DialogType::UngroupSingle:
    case DeletionDialogController::DialogType::RemoveTabAndDelete:
    case DeletionDialogController::DialogType::CloseTabAndDelete: {
      return true;
    }
    // Shared tab group dialogs aren't skippable.
    case DeletionDialogController::DialogType::DeleteSingleShared:
    case DeletionDialogController::DialogType::CloseTabAndKeepOrLeaveGroup:
    case DeletionDialogController::DialogType::CloseTabAndKeepOrDeleteGroup:
    case DeletionDialogController::DialogType::LeaveGroup: {
      return false;
    }
  }
}

// Returns the the value from the settings pref for a given dialog type.
bool IsDialogSkippedByUserSettings(Profile* profile,
                                   DeletionDialogController::DialogType type) {
  if (!profile) {
    return false;
  }
  PrefService* pref_service = profile->GetPrefs();
  switch (type) {
    case DeletionDialogController::DialogType::DeleteSingle: {
      return pref_service->GetBoolean(
          saved_tab_groups::prefs::kTabGroupsDeletionSkipDialogOnDelete);
    }
    case DeletionDialogController::DialogType::UngroupSingle: {
      return pref_service->GetBoolean(
          saved_tab_groups::prefs::kTabGroupsDeletionSkipDialogOnUngroup);
    }
    case DeletionDialogController::DialogType::RemoveTabAndDelete: {
      return pref_service->GetBoolean(
          saved_tab_groups::prefs::kTabGroupsDeletionSkipDialogOnRemoveTab);
    }
    case DeletionDialogController::DialogType::CloseTabAndDelete: {
      return pref_service->GetBoolean(
          saved_tab_groups::prefs::kTabGroupsDeletionSkipDialogOnCloseTab);
    }
    // Shared tab groups dialogs aren't skippable.
    case DeletionDialogController::DialogType::DeleteSingleShared:
    case DeletionDialogController::DialogType::CloseTabAndKeepOrLeaveGroup:
    case DeletionDialogController::DialogType::CloseTabAndKeepOrDeleteGroup:
    case DeletionDialogController::DialogType::LeaveGroup: {
      return false;
    }
  }
}

void SetSkipDialogForType(Profile* profile,
                          DeletionDialogController::DialogType type,
                          bool new_value) {
  if (!profile) {
    return;
  }

  PrefService* pref_service = profile->GetPrefs();
  switch (type) {
    case DeletionDialogController::DialogType::DeleteSingle: {
      return pref_service->SetBoolean(
          saved_tab_groups::prefs::kTabGroupsDeletionSkipDialogOnDelete,
          new_value);
    }
    case DeletionDialogController::DialogType::UngroupSingle: {
      return pref_service->SetBoolean(
          saved_tab_groups::prefs::kTabGroupsDeletionSkipDialogOnUngroup,
          new_value);
    }
    case DeletionDialogController::DialogType::RemoveTabAndDelete: {
      return pref_service->SetBoolean(
          saved_tab_groups::prefs::kTabGroupsDeletionSkipDialogOnRemoveTab,
          new_value);
    }
    case DeletionDialogController::DialogType::CloseTabAndDelete: {
      return pref_service->SetBoolean(
          saved_tab_groups::prefs::kTabGroupsDeletionSkipDialogOnCloseTab,
          new_value);
    }
    // Shared tab group dialogs aren't skippable.
    case DeletionDialogController::DialogType::DeleteSingleShared:
    case DeletionDialogController::DialogType::CloseTabAndKeepOrLeaveGroup:
    case DeletionDialogController::DialogType::CloseTabAndKeepOrDeleteGroup:
    case DeletionDialogController::DialogType::LeaveGroup: {
      // We should never try to set the skip pref for these dialog types.
      NOTREACHED();
    }
  }
}

// Keep type dialogs don't let the user cancel their action; instead, they
// choose whether the group should stick around or go away.
bool IsDialogKeepType(DeletionDialogController::DialogType type) {
  return type == DeletionDialogController::DialogType::
                     CloseTabAndKeepOrDeleteGroup ||
         type ==
             DeletionDialogController::DialogType::CloseTabAndKeepOrLeaveGroup;
}

}  // anonymous namespace

// DialogMetadata
DeletionDialogController::DialogMetadata::DialogMetadata(
    DialogType type,
    int closing_group_count,
    bool closing_multiple_tabs)
    : type(type),
      closing_group_count(closing_group_count),
      closing_multiple_tabs(closing_multiple_tabs) {}

DeletionDialogController::DialogMetadata::DialogMetadata(DialogType type)
    : type(type) {}

DeletionDialogController::DialogMetadata::~DialogMetadata() = default;

// DialogState
DeletionDialogController::DialogState::DialogState(
    DialogType type_,
    ui::DialogModel* dialog_model_,
    base::OnceCallback<void(DeletionDialogTiming)> callback_,
    std::optional<base::OnceCallback<void()>> keep_groups_)
    : type(type_),
      dialog_model(dialog_model_),
      callback(std::move(callback_)),
      keep_groups(std::move(keep_groups_)) {}

DeletionDialogController::DialogState::~DialogState() = default;

DeletionDialogController::DeletionDialogController(
    BrowserWindowInterface* browser)
    : profile_(browser->GetProfile()),
      show_dialog_model_fn_(base::BindRepeating(
          &DeletionDialogController::CreateDialogFromBrowser,
          base::Unretained(this),
          browser)),
      tab_strip_model_(browser->GetTabStripModel()) {
  tab_strip_model_->AddObserver(this);
}

DeletionDialogController::DeletionDialogController(
    BrowserWindowInterface* browser,
    ShowDialogModelCallback show_dialog_model_fn)
    : profile_(browser->GetProfile()),
      show_dialog_model_fn_(show_dialog_model_fn),
      tab_strip_model_(browser->GetTabStripModel()) {}

DeletionDialogController::~DeletionDialogController() {
  tab_strip_model_->RemoveObserver(this);
}

bool DeletionDialogController::CanShowDialog() const {
  return !IsShowingDialog();
}

bool DeletionDialogController::IsShowingDialog() const {
  return !!state_;
}

void DeletionDialogController::CreateDialogFromBrowser(
    BrowserWindowInterface* browser,
    std::unique_ptr<ui::DialogModel> dialog_model) {
  widget_ = chrome::ShowBrowserModal(browser->GetBrowserForMigrationOnly(),
                                     std::move(dialog_model));
}

bool DeletionDialogController::MaybeShowDialog(
    const DialogMetadata& metadata,
    base::OnceCallback<void(DeletionDialogTiming)> callback,
    std::optional<base::OnceCallback<void()>> keep_groups) {
  if (IsDialogKeepType(metadata.type)) {
    CHECK(keep_groups.has_value());
  } else {
    CHECK(!keep_groups.has_value());
  }

  if (!CanShowDialog()) {
    return false;
  }

  if (IsDialogSkippedByUserSettings(profile_, metadata.type)) {
    std::move(callback).Run(DeletionDialogTiming::Synchronous);
    return false;
  }

  std::unique_ptr<ui::DialogModel> dialog_model = BuildDialogModel(metadata);

  state_.emplace(metadata.type, dialog_model.get(), std::move(callback),
                 std::move(keep_groups));

  show_dialog_model_fn_.Run(std::move(dialog_model));
  return true;
}

void DeletionDialogController::OnTabStripModelChanged(
    TabStripModel* tab_strip_model,
    const TabStripModelChange& change,
    const TabStripSelectionChange& selection) {
  if (widget_) {
    widget_->Close();
  }
}

void DeletionDialogController::SetPrefsPreventShowingDialogForTesting(
    bool should_prevent_dialog) {
  auto* prefs = profile_->GetPrefs();
  prefs->SetBoolean(
      saved_tab_groups::prefs::kTabGroupsDeletionSkipDialogOnDelete,
      should_prevent_dialog);
  prefs->SetBoolean(
      saved_tab_groups::prefs::kTabGroupsDeletionSkipDialogOnUngroup,
      should_prevent_dialog);
  prefs->SetBoolean(
      saved_tab_groups::prefs::kTabGroupsDeletionSkipDialogOnRemoveTab,
      should_prevent_dialog);
  prefs->SetBoolean(
      saved_tab_groups::prefs::kTabGroupsDeletionSkipDialogOnCloseTab,
      should_prevent_dialog);
}

void DeletionDialogController::OnDialogOk() {
  if (state_->dialog_model &&
      state_->dialog_model->HasField(kDeletionDialogDontAskCheckboxId) &&
      state_->dialog_model
          ->GetCheckboxByUniqueId(kDeletionDialogDontAskCheckboxId)
          ->is_checked()) {
    SetSkipDialogForType(profile_, state_->type, true);
  }
  if (IsDialogKeepType(state_->type)) {
    std::move(state_->keep_groups.value()).Run();
  }
  std::move(state_->callback).Run(DeletionDialogTiming::Asynchronous);
  state_.reset();
}

void DeletionDialogController::OnDialogCancel() {
  if (IsDialogKeepType(state_->type)) {
    std::move(state_->callback).Run(DeletionDialogTiming::Asynchronous);
  }
  state_.reset();
}

std::unique_ptr<ui::DialogModel> DeletionDialogController::BuildDialogModel(
    const DialogMetadata& metadata) {
  DialogText strings = GetDialogText(profile_, metadata);

  ui::DialogModel::Button::Params cancel_button_params;
  cancel_button_params.SetEnabled(true).SetId(kDeletionDialogCancelButtonId);
  if (strings.cancel_text.has_value()) {
    cancel_button_params.SetLabel(strings.cancel_text.value());
  }

  ui::DialogModel::Builder dialog_builder = ui::DialogModel::Builder();
  dialog_builder.SetTitle(strings.title)
      .AddParagraph(ui::DialogModelLabel(strings.body))
      .AddCancelButton(base::BindOnce(&DeletionDialogController::OnDialogCancel,
                                      base::Unretained(this)),
                       cancel_button_params)
      .AddOkButton(base::BindOnce(&DeletionDialogController::OnDialogOk,
                                  base::Unretained(this)),
                   ui::DialogModel::Button::Params()
                       .SetLabel(strings.ok_text)
                       .SetEnabled(true)
                       .SetId(kDeletionDialogOkButtonId))
      .SetCloseActionCallback(base::BindOnce(
          [](DeletionDialogController* dialog_controller) {
            dialog_controller->state_.reset();
          },
          base::Unretained(this)))
      .SetDialogDestroyingCallback(base::BindOnce(
          [](DeletionDialogController* dialog_controller) {
            dialog_controller->widget_ = nullptr;
            dialog_controller->state_.reset();
          },
          base::Unretained(this)));
  if (IsDialogSkippable(metadata.type)) {
    dialog_builder.AddCheckbox(
        kDeletionDialogDontAskCheckboxId,
        ui::DialogModelLabel(l10n_util::GetStringUTF16(kDontAskId)));
  }
  return dialog_builder.Build();
}

}  // namespace tab_groups