OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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. |
| 4 |
| 5 #ifndef COMPONENTS_WEB_RESTRICTION_WEB_RESTRICTION_GIN_WRAPPER_H_ |
| 6 #define COMPONENTS_WEB_RESTRICTION_WEB_RESTRICTION_GIN_WRAPPER_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 #include "components/web_restrictions/interfaces/web_restrictions.mojom.h" |
| 11 #include "content/public/renderer/render_frame_observer.h" |
| 12 #include "gin/wrappable.h" |
| 13 #include "url/gurl.h" |
| 14 |
| 15 namespace content { |
| 16 class RenderFrame; |
| 17 } |
| 18 |
| 19 namespace supervised_user_error_page { |
| 20 |
| 21 class SupervisedUserGinWrapper |
| 22 : public gin::Wrappable<SupervisedUserGinWrapper>, |
| 23 public content::RenderFrameObserver { |
| 24 public: |
| 25 static gin::WrapperInfo kWrapperInfo; |
| 26 |
| 27 static void Install(content::RenderFrame* render_frame, |
| 28 const std::string& url, |
| 29 const web_restrictions::mojom::WebRestrictionsPtr& |
| 30 web_restrictions_service); |
| 31 |
| 32 private: |
| 33 SupervisedUserGinWrapper(content::RenderFrame* render_frame, |
| 34 const std::string& url, |
| 35 const web_restrictions::mojom::WebRestrictionsPtr& |
| 36 web_restrictions_service); |
| 37 ~SupervisedUserGinWrapper() override; |
| 38 |
| 39 // Override OnDestruct to prevent the wrapper going away when the |
| 40 // RenderFrame does |
| 41 void OnDestruct() override; |
| 42 |
| 43 // Request permission to allow visiting the currently blocked site. |
| 44 bool RequestPermission(); |
| 45 |
| 46 void OnAccessRequestAdded(bool success); |
| 47 |
| 48 // gin::WrappableBase |
| 49 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
| 50 v8::Isolate* isolate) override; |
| 51 |
| 52 const std::string url_; |
| 53 const web_restrictions::mojom::WebRestrictionsPtr& web_restrictions_service_; |
| 54 base::WeakPtrFactory<SupervisedUserGinWrapper> weak_ptr_factory_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(SupervisedUserGinWrapper); |
| 57 }; |
| 58 |
| 59 } // namespace web_restrictions. |
| 60 |
| 61 #endif // COMPONENTS_WEB_RESTRICTION_WEB_RESTRICTION_GIN_WRAPPER_H_ |
OLD | NEW |