1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_RENDERER_NET_NET_ERROR_PAGE_CONTROLLER_H_
6 #define CHROME_RENDERER_NET_NET_ERROR_PAGE_CONTROLLER_H_
8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h"
10 #include "components/error_page/renderer/net_error_helper_core.h"
11 #include "gin/arguments.h"
12 #include "gin/wrappable.h"
19 // This class makes various helper functions available to the
20 // error page loaded by NetErrorHelper. It is bound to the JavaScript
21 // window.errorPageController object.
22 class NetErrorPageController
: public gin::Wrappable
<NetErrorPageController
> {
24 static gin::WrapperInfo kWrapperInfo
;
26 // Interface used to notify creator of user actions invoked on the error page.
29 // Button press notification from error page.
30 virtual void ButtonPressed(
31 error_page::NetErrorHelperCore::Button button
) = 0;
33 // Called when a link with the given tracking ID is pressed.
34 virtual void TrackClick(int tracking_id
) = 0;
40 DISALLOW_COPY_AND_ASSIGN(Delegate
);
43 // Will invoke methods on |delegate| in response to user actions taken on the
44 // error page. May call delegate methods even after the page has been
45 // navigated away from, so it is recommended consumers make sure the weak
46 // pointers are destroyed in response to navigations.
47 static void Install(content::RenderFrame
* render_frame
,
48 base::WeakPtr
<Delegate
> delegate
);
51 explicit NetErrorPageController(base::WeakPtr
<Delegate
> delegate
);
52 ~NetErrorPageController() override
;
54 // Execute a "Show saved copy" button click.
55 bool ShowSavedCopyButtonClick();
57 // Execute a "Reload" button click.
58 bool ReloadButtonClick();
60 // Execute a "Details" button click.
61 bool DetailsButtonClick();
63 // Track easter egg plays.
64 bool TrackEasterEgg();
66 // Execute a "Diagnose Errors" button click.
67 bool DiagnoseErrorsButtonClick();
69 // Track "Show cached copy" button clicks.
70 bool TrackCachedCopyButtonClick();
72 // Track a click when the page has suggestions from the navigation correction
74 bool TrackClick(const gin::Arguments
& args
);
76 // Used internally by other button click methods.
77 bool ButtonClick(error_page::NetErrorHelperCore::Button button
);
80 gin::ObjectTemplateBuilder
GetObjectTemplateBuilder(
81 v8::Isolate
* isolate
) override
;
83 base::WeakPtr
<Delegate
> delegate_
;
85 DISALLOW_COPY_AND_ASSIGN(NetErrorPageController
);
88 #endif // CHROME_RENDERER_NET_NET_ERROR_PAGE_CONTROLLER_H_