File: user_manager.h

package info (click to toggle)
chromium-browser 57.0.2987.98-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,637,852 kB
  • ctags: 2,544,394
  • sloc: cpp: 12,815,961; ansic: 3,676,222; python: 1,147,112; asm: 526,608; java: 523,212; xml: 286,794; perl: 92,654; sh: 86,408; objc: 73,271; makefile: 27,698; cs: 18,487; yacc: 13,031; tcl: 12,957; pascal: 4,875; ml: 4,716; lex: 3,904; sql: 3,862; ruby: 1,982; lisp: 1,508; php: 1,368; exp: 404; awk: 325; csh: 117; jsp: 39; sed: 37
file content (122 lines) | stat: -rw-r--r-- 4,785 bytes parent folder | download
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
// Copyright (c) 2014 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.

#ifndef CHROME_BROWSER_UI_USER_MANAGER_H_
#define CHROME_BROWSER_UI_USER_MANAGER_H_

#include "base/callback_forward.h"
#include "base/macros.h"
#include "chrome/browser/profiles/profile_window.h"
#include "components/signin/core/browser/signin_metrics.h"
#include "content/public/browser/web_contents_delegate.h"

namespace base {
class FilePath;
}

// Cross-platform methods for displaying the user manager.
class UserManager {
 public:
  // TODO(noms): Figure out if this size can be computed dynamically or adjusted
  // for smaller screens.
  static constexpr int kWindowWidth = 800;
  static constexpr int kWindowHeight = 600;

  // Shows the User Manager or re-activates an existing one, focusing the
  // profile given by |profile_path_to_focus|; passing an empty base::FilePath
  // focuses no user pod. Based on the value of |tutorial_mode|, a tutorial
  // could be shown, in which case |profile_path_to_focus| is ignored. Depending
  // on the value of |user_manager_action|, executes an action once the user
  // manager displays or after a profile is opened.
  static void Show(const base::FilePath& profile_path_to_focus,
                   profiles::UserManagerTutorialMode tutorial_mode,
                   profiles::UserManagerAction user_manager_action);

  // Hides the User Manager.
  static void Hide();

  // Returns whether the User Manager is showing and active.
  // TODO(zmin): Rename the function to something less confusing.
  // https://crbug.com/649380.
  static bool IsShowing();

  // To be called once the User Manager's contents are showing.
  static void OnUserManagerShown();

  // Add a callback that will be called when OnUserManagerShown is called.
  static void AddOnUserManagerShownCallbackForTesting(
      const base::Closure& callback);

  // Get the path of profile that is being signed in.
  static base::FilePath GetSigninProfilePath();

 private:
  DISALLOW_IMPLICIT_CONSTRUCTORS(UserManager);
};

// Dialog that will be displayed when a profile is selected in UserManager.
class UserManagerProfileDialog {
 public:
  // Dimensions of the reauth dialog displaying the old-style signin flow with
  // the username and password challenge on the same form.
  static constexpr int kPasswordCombinedDialogHeight = 440;
  static constexpr int kPasswordCombinedDialogWidth = 360;

  // Dimensions of the reauth dialog displaying the password-separated signin
  // flow.
  static constexpr int kDialogHeight = 512;
  static constexpr int kDialogWidth = 448;

  // Shows a dialog where the user can re-authenticate the profile with the
  // given |email|. This is called in the following scenarios:
  //  -From the user manager when a profile is locked and the user's password is
  //   detected to have been changed.
  //  -From the user manager when a custodian account needs to be
  //   reauthenticated.
  // |reason| can be REASON_UNLOCK or REASON_REAUTHENTICATION to indicate
  // whether this is a reauth or unlock scenario.
  static void ShowReauthDialog(content::BrowserContext* browser_context,
                               const std::string& email,
                               signin_metrics::Reason reason);

  // Shows a dialog where the user logs into their profile for the first time
  // via the user manager.
  static void ShowSigninDialog(content::BrowserContext* browser_context,
                               const base::FilePath& profile_path);

  // Show the dialog and display local sign in error message without browser.
  static void ShowDialogAndDisplayErrorMessage(
      content::BrowserContext* browser_context);

  // Display local sign in error message without browser.
  static void DisplayErrorMessage();

  // Hides the dialog if it is showing.
  static void HideDialog();

  // Abstract base class for performing online reauthentication of profiles in
  // the User Manager. It is concretely implemented in UserManagerMac and
  // UserManagerView to specialize the closing of the UI's dialog widgets.
  class BaseDialogDelegate : public content::WebContentsDelegate {
   public:
    BaseDialogDelegate();

    // content::WebContentsDelegate:
    bool HandleContextMenu(const content::ContextMenuParams& params) override;

    // content::WebContentsDelegate:
    void LoadingStateChanged(content::WebContents* source,
                             bool to_different_document) override;

   protected:
    virtual void CloseDialog() = 0;

    // WebContents of the embedded WebView.
    content::WebContents* guest_web_contents_;

    DISALLOW_COPY_AND_ASSIGN(BaseDialogDelegate);
  };
};

#endif  // CHROME_BROWSER_UI_USER_MANAGER_H_