Return Windows error code when create-process fails.
[chromium-blink-merge.git] / chrome / renderer / net / net_error_page_controller.h
blob27637bb293e1ebc716cdef4c9024fe2817e2c65e
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"
15 namespace content {
16 class RenderFrame;
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> {
23 public:
24 static gin::WrapperInfo kWrapperInfo;
26 // Interface used to notify creator of user actions invoked on the error page.
27 class Delegate {
28 public:
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;
36 protected:
37 Delegate();
38 virtual ~Delegate();
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);
50 private:
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/page" button clicks.
70 bool TrackCachedCopyButtonClick(bool is_default_label);
72 // Track a click when the page has suggestions from the navigation correction
73 // service.
74 bool TrackClick(const gin::Arguments& args);
76 // Used internally by other button click methods.
77 bool ButtonClick(error_page::NetErrorHelperCore::Button button);
79 // gin::WrappableBase
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_