File: profile_picker_web_contents_host.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (86 lines) | stat: -rw-r--r-- 3,449 bytes parent folder | download | duplicates (2)
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
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_PICKER_WEB_CONTENTS_HOST_H_
#define CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_PICKER_WEB_CONTENTS_HOST_H_

#include "base/functional/callback.h"
#include "base/types/strong_alias.h"
#include "chrome/browser/ui/views/profiles/profile_management_types.h"
#include "components/signin/public/base/signin_buildflags.h"
#include "components/web_modal/web_contents_modal_dialog_host.h"

#if BUILDFLAG(ENABLE_DICE_SUPPORT)
#include "ui/views/controls/webview/web_contents_set_background_color.h"
#endif

class GURL;
class ForceSigninUIError;

namespace content {
class WebContents;
class WebContentsDelegate;
}  // namespace content

namespace web_modal {
class WebContentsModalDialogHost;
}

// Type for a callback that is used to close the `ProfilePickerWebContentsHost`.
// It is the owner's responsibility to make sure that the issuing host is still
// alive and that the callback is valid, before running it.
using ClearHostClosure =
    base::StrongAlias<class ClearHostClosureTag, base::OnceClosure>;

// Class responsible for embedding a web contents in the profile picker and
// providing extra UI such as a back button.
class ProfilePickerWebContentsHost {
 public:
  // Shows a screen with `url` in `contents`. If `url` is empty, it only shows
  // `contents` with its currently loaded url. If both
  // `navigation_finished_closure` and `url` is non-empty, the closure is called
  // when the navigation commits (if it never commits such as when the
  // navigation is replaced by another navigation or if an internal page fails
  // to load, the closure is never called).
  virtual void ShowScreen(
      content::WebContents* contents,
      const GURL& url,
      base::OnceClosure navigation_finished_closure = base::OnceClosure()) = 0;
  // Like ShowScreen() but uses the picker WebContents.
  virtual void ShowScreenInPickerContents(
      const GURL& url,
      base::OnceClosure navigation_finished_closure = base::OnceClosure()) = 0;

  // Returns whether dark colors should be used (based on native theme).
  virtual bool ShouldUseDarkColors() const = 0;

  // Returns the picker WebContents.
  virtual content::WebContents* GetPickerContents() const = 0;

  virtual content::WebContentsDelegate* GetWebContentsDelegate() = 0;

  virtual web_modal::WebContentsModalDialogHost*
  GetWebContentsModalDialogHost() = 0;

  // Clears the current state an Shows the main screen.
  // `callback` is run when the main screen is shown.
  virtual void Reset(StepSwitchFinishedCallback callback) = 0;

  // Used as a callback of type `StepSwitchFinishedCallback`. Allows to show the
  // ForceSignin error dialog after completing a step switch.
  virtual void ShowForceSigninErrorDialog(const ForceSigninUIError& error,
                                          bool success) = 0;

#if BUILDFLAG(ENABLE_DICE_SUPPORT)
  // Changes the visibility of the host's native toolbar, which shows a back
  // button.
  virtual void SetNativeToolbarVisible(bool visible) = 0;

  // Returns the background colors that other `content::WebContents` that are
  // rendered by this host should use to match the toolbar.
  virtual SkColor GetPreferredBackgroundColor() const = 0;
#endif
};

#endif  // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_PICKER_WEB_CONTENTS_HOST_H_