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_SUPERVISED_USER_ERROR_PAGE_GIN_WRAPPER_H_ |
| 6 #define COMPONENTS_SUPERVISED_USER_ERROR_PAGE_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 #include "v8/include/v8.h" |
| 15 |
| 16 namespace content { |
| 17 class RenderFrame; |
| 18 } |
| 19 |
| 20 namespace supervised_user_error_page { |
| 21 |
| 22 class GinWrapper : public gin::Wrappable<GinWrapper> { |
| 23 public: |
| 24 static gin::WrapperInfo kWrapperInfo; |
| 25 |
| 26 static void InstallWhenFrameReady( |
| 27 content::RenderFrame* render_frame, |
| 28 const std::string& url, |
| 29 const web_restrictions::mojom::WebRestrictionsPtr& |
| 30 web_restrictions_service); |
| 31 |
| 32 private: |
| 33 class Loader : public content::RenderFrameObserver { |
| 34 public: |
| 35 Loader(content::RenderFrame* render_frame, |
| 36 const std::string& url, |
| 37 const web_restrictions::mojom::WebRestrictionsPtr& |
| 38 web_restrictions_service); |
| 39 ~Loader() override = default; |
| 40 |
| 41 void DidClearWindowObject() override; |
| 42 void OnDestruct() override; |
| 43 |
| 44 private: |
| 45 void InstallGinWrapper(); |
| 46 |
| 47 std::string url_; |
| 48 const web_restrictions::mojom::WebRestrictionsPtr& |
| 49 web_restrictions_service_; |
| 50 DISALLOW_COPY_AND_ASSIGN(Loader); |
| 51 }; |
| 52 |
| 53 GinWrapper(content::RenderFrame* render_frame, |
| 54 const std::string& url, |
| 55 const web_restrictions::mojom::WebRestrictionsPtr& |
| 56 web_restrictions_service); |
| 57 ~GinWrapper() override; |
| 58 |
| 59 // Request permission to allow visiting the currently blocked site. |
| 60 bool RequestPermission(v8::Local<v8::Function> setRequestStatusCallback); |
| 61 |
| 62 void OnAccessRequestAdded(bool success); |
| 63 |
| 64 // gin::WrappableBase |
| 65 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
| 66 v8::Isolate* isolate) override; |
| 67 |
| 68 const std::string url_; |
| 69 const web_restrictions::mojom::WebRestrictionsPtr& web_restrictions_service_; |
| 70 v8::Global<v8::Function> setRequestStatusCallback_; |
| 71 base::WeakPtrFactory<GinWrapper> weak_ptr_factory_; |
| 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(GinWrapper); |
| 74 }; |
| 75 |
| 76 } // namespace supervised_user_error_page. |
| 77 |
| 78 #endif // COMPONENTS_SUPERVISED_USER_ERROR_PAGE_GIN_WRAPPER_H_ |
OLD | NEW |