summaryrefslogtreecommitdiff
path: root/chromium/chrome/renderer/supervised_user/supervised_user_error_page_controller_delegate_impl.h
blob: 43f47086688f08254588e2c85f97bbe68db88f9d (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
57
58
59
60
61
// Copyright 2019 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_RENDERER_SUPERVISED_USER_SUPERVISED_USER_ERROR_PAGE_CONTROLLER_DELEGATE_IMPL_H_
#define CHROME_RENDERER_SUPERVISED_USER_SUPERVISED_USER_ERROR_PAGE_CONTROLLER_DELEGATE_IMPL_H_

#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "chrome/common/supervised_user_commands.mojom.h"
#include "chrome/renderer/supervised_user/supervised_user_error_page_controller_delegate.h"
#include "content/public/renderer/render_frame_observer.h"
#include "content/public/renderer/render_frame_observer_tracker.h"
#include "mojo/public/cpp/bindings/associated_remote.h"

namespace content {
class RenderFrame;
}  // namespace content

class SupervisedUserErrorPageControllerDelegateImpl
    : public content::RenderFrameObserver,
      public content::RenderFrameObserverTracker<
          SupervisedUserErrorPageControllerDelegateImpl>,
      public SupervisedUserErrorPageControllerDelegate {
 public:
  explicit SupervisedUserErrorPageControllerDelegateImpl(
      content::RenderFrame* render_frame);
  ~SupervisedUserErrorPageControllerDelegateImpl() override;

  // Notifies us that a navigation error has occurred and will be committed.
  void PrepareForErrorPage();

  // SupervisedUserErrorPageControllerDelegate:
  void GoBack() override;
  void RequestPermission(base::OnceCallback<void(bool)> callback) override;
  void Feedback() override;

  // content::RenderFrameObserver:
  void OnDestruct() override;
  void DidFinishLoad() override;
  void ReadyToCommitNavigation(
      blink::WebDocumentLoader* document_loader) override;

 private:
  mojo::AssociatedRemote<supervised_user::mojom::SupervisedUserCommands>
      supervised_user_interface_;

  // Whether there is an error page pending to be committed.
  bool pending_error_ = false;

  // Whether the committed page is an error page.
  bool committed_error_ = false;

  base::WeakPtrFactory<SupervisedUserErrorPageControllerDelegate>
      weak_supervised_user_error_controller_delegate_factory_{this};

  DISALLOW_COPY_AND_ASSIGN(SupervisedUserErrorPageControllerDelegateImpl);
};

#endif  // CHROME_RENDERER_SUPERVISED_USER_SUPERVISED_USER_ERROR_PAGE_CONTROLLER_DELEGATE_IMPL_H_