File: profile_picker_web_contents_host.h

package info (click to toggle)
chromium 139.0.7258.138-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,120,676 kB
  • sloc: cpp: 35,100,869; 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 (85 lines) | stat: -rw-r--r-- 3,438 bytes parent folder | download | duplicates (5)
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
// 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) = 0;
  // Like ShowScreen() but uses the picker WebContents.
  virtual void ShowScreenInPickerContents(
      const GURL& url,
      base::OnceClosure navigation_finished_closure) = 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_