summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/ui/webui/settings/change_password_handler.cc
blob: d847d122e183126f1e2eda35d2ddddfb0f56b87f (plain)
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
// Copyright 2017 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.

#include "chrome/browser/ui/webui/settings/change_password_handler.h"

#include "chrome/browser/browser_process.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/password_protection/password_protection_service.h"
#include "content/public/browser/page_navigator.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"


namespace settings {

ChangePasswordHandler::ChangePasswordHandler(Profile* profile)
    : profile_(profile), service_(nullptr) {
  if (g_browser_process && g_browser_process->safe_browsing_service()) {
    service_ = g_browser_process->safe_browsing_service()
                   ->GetPasswordProtectionService(profile_);
  }
}

ChangePasswordHandler::~ChangePasswordHandler() {}

void ChangePasswordHandler::RegisterMessages() {
  web_ui()->RegisterMessageCallback(
      "onChangePasswordPageShown",
      base::Bind(&ChangePasswordHandler::HandleChangePasswordPageShown,
                 base::Unretained(this)));
  web_ui()->RegisterMessageCallback(
      "changePassword", base::Bind(&ChangePasswordHandler::HandleChangePassword,
                                   base::Unretained(this)));
}

void ChangePasswordHandler::HandleChangePasswordPageShown(
    const base::ListValue* args) {
  if (service_) {
    service_->OnWarningShown(
        web_ui()->GetWebContents(),
        safe_browsing::PasswordProtectionService::CHROME_SETTINGS);
  }
}

void ChangePasswordHandler::HandleChangePassword(const base::ListValue* args) {
  if (service_) {
    service_->OnWarningDone(
        web_ui()->GetWebContents(),
        safe_browsing::PasswordProtectionService::CHROME_SETTINGS,
        safe_browsing::PasswordProtectionService::CHANGE_PASSWORD);
  }
}

}  // namespace settings