File: intro_handler.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; 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,811; 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 (83 lines) | stat: -rw-r--r-- 3,277 bytes parent folder | download | duplicates (4)
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
// Copyright 2022 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_WEBUI_INTRO_INTRO_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_INTRO_INTRO_HANDLER_H_

#include <string_view>

#include "base/functional/callback_forward.h"
#include "components/policy/core/common/cloud/cloud_policy_store.h"
#include "components/signin/public/base/signin_buildflags.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "content/public/browser/web_ui_message_handler.h"

#if !BUILDFLAG(ENABLE_DICE_SUPPORT)
#error "This file should only be included if DICE support."
#endif

enum class IntroChoice;
enum class DefaultBrowserChoice;

class IntroHandler : public content::WebUIMessageHandler {
 public:
  explicit IntroHandler(
      base::RepeatingCallback<void(IntroChoice)> intro_callback,
      base::OnceCallback<void(DefaultBrowserChoice)> default_browser_callback,
      bool is_device_managed,
      std::string_view source_name);

  IntroHandler(const IntroHandler&) = delete;
  IntroHandler& operator=(const IntroHandler&) = delete;

  ~IntroHandler() override;

  // content::WebUIMessageHandler:
  void RegisterMessages() override;
  void OnJavascriptAllowed() override;
  void ResetIntroButtons();
  void ResetDefaultBrowserButtons();

  // This updates the strings displayed in the set as default page of the first
  // run experience to indicate that it will also pin Chrome to the taskbar.
  void SetCanPinToTaskbar(bool can_pin);

 private:
  // Handles "continueWithAccount" message from the page. No arguments.
  // This message is sent when the user confirms that they want to sign in to
  // Chrome.
  void HandleContinueWithAccount(const base::Value::List& args);

  // Handles "continueWithoutAccount" message from the page. No arguments.
  // This message is sent when the user declines signing in to Chrome.
  void HandleContinueWithoutAccount(const base::Value::List& args);

  // Handles "initializeMainView" message from the page. No arguments.
  // This message is sent when the view is created.
  void HandleInitializeMainView(const base::Value::List& args);

  // Handles "setAsDefaultBrowser" message from the page. No arguments.
  // This message is sent when the user confirms that they want to set Chrome as
  // their default browser.
  void HandleSetAsDefaultBrowser(const base::Value::List& args);

  // Handles "skipDefaultBrowser" message from the page. No arguments.
  // This message is sent when the user skips the prompt to set Chrome as their
  // default browser.
  void HandleSkipDefaultBrowser(const base::Value::List& args);

  // Fires the `managed-device-disclaimer-updated` event with the disclaimer
  // that will be caught and handled in the ts file.
  void FireManagedDisclaimerUpdate(std::string disclaimer);

  const base::RepeatingCallback<void(IntroChoice)> intro_callback_;
  base::OnceCallback<void(DefaultBrowserChoice)> default_browser_callback_;
  const bool is_device_managed_ = false;
  std::unique_ptr<policy::CloudPolicyStore::Observer> policy_store_observer_;

  // Name of the WebUIDataSource to update.
  std::string source_name_;
};

#endif  // CHROME_BROWSER_UI_WEBUI_INTRO_INTRO_HANDLER_H_