OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/renderer/net/net_error_page_controller.h" | 5 #include "chrome/renderer/net/net_error_page_controller.h" |
6 | 6 |
7 #include "base/strings/string_piece.h" | 7 #include "base/strings/string_piece.h" |
8 #include "chrome/renderer/net/net_error_helper.h" | 8 #include "chrome/renderer/net/net_error_helper.h" |
9 #include "content/public/renderer/render_frame.h" | 9 #include "content/public/renderer/render_frame.h" |
10 #include "gin/handle.h" | 10 #include "gin/handle.h" |
11 #include "gin/object_template_builder.h" | 11 #include "gin/object_template_builder.h" |
12 #include "third_party/WebKit/public/web/WebKit.h" | 12 #include "third_party/WebKit/public/web/WebKit.h" |
13 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 13 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
14 | 14 |
15 gin::WrapperInfo NetErrorPageController::kWrapperInfo = { | 15 gin::WrapperInfo NetErrorPageController::kWrapperInfo = { |
16 gin::kEmbedderNativeGin}; | 16 gin::kEmbedderNativeGin}; |
17 | 17 |
18 // static | 18 // static |
19 void NetErrorPageController::Install(content::RenderFrame* render_frame) { | 19 void NetErrorPageController::Install(content::RenderFrame* render_frame) { |
20 v8::Isolate* isolate = blink::mainThreadIsolate(); | 20 v8::Isolate* isolate = blink::mainThreadIsolate(); |
21 v8::HandleScope handle_scope(isolate); | 21 v8::HandleScope handle_scope(isolate); |
22 v8::Handle<v8::Context> context = | 22 v8::Local<v8::Context> context = |
23 render_frame->GetWebFrame()->mainWorldScriptContext(); | 23 render_frame->GetWebFrame()->mainWorldScriptContext(); |
24 if (context.IsEmpty()) | 24 if (context.IsEmpty()) |
25 return; | 25 return; |
26 | 26 |
27 v8::Context::Scope context_scope(context); | 27 v8::Context::Scope context_scope(context); |
28 | 28 |
29 gin::Handle<NetErrorPageController> controller = gin::CreateHandle( | 29 gin::Handle<NetErrorPageController> controller = gin::CreateHandle( |
30 isolate, new NetErrorPageController(render_frame)); | 30 isolate, new NetErrorPageController(render_frame)); |
31 if (controller.IsEmpty()) | 31 if (controller.IsEmpty()) |
32 return; | 32 return; |
33 | 33 |
34 v8::Handle<v8::Object> global = context->Global(); | 34 v8::Local<v8::Object> global = context->Global(); |
35 global->Set(gin::StringToV8(isolate, "errorPageController"), | 35 global->Set(gin::StringToV8(isolate, "errorPageController"), |
36 controller.ToV8()); | 36 controller.ToV8()); |
37 } | 37 } |
38 | 38 |
39 bool NetErrorPageController::ShowSavedCopyButtonClick() { | 39 bool NetErrorPageController::ShowSavedCopyButtonClick() { |
40 if (!render_frame()) | 40 if (!render_frame()) |
41 return false; | 41 return false; |
42 | 42 |
43 NetErrorHelper* net_error_helper = | 43 NetErrorHelper* net_error_helper = |
44 content::RenderFrameObserverTracker<NetErrorHelper>::Get(render_frame()); | 44 content::RenderFrameObserverTracker<NetErrorHelper>::Get(render_frame()); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 &NetErrorPageController::ReloadButtonClick) | 111 &NetErrorPageController::ReloadButtonClick) |
112 .SetMethod("detailsButtonClick", | 112 .SetMethod("detailsButtonClick", |
113 &NetErrorPageController::DetailsButtonClick) | 113 &NetErrorPageController::DetailsButtonClick) |
114 .SetMethod("trackClick", | 114 .SetMethod("trackClick", |
115 &NetErrorPageController::TrackClick) | 115 &NetErrorPageController::TrackClick) |
116 .SetMethod("trackEasterEgg", | 116 .SetMethod("trackEasterEgg", |
117 &NetErrorPageController::TrackEasterEgg); | 117 &NetErrorPageController::TrackEasterEgg); |
118 } | 118 } |
119 | 119 |
120 void NetErrorPageController::OnDestruct() {} | 120 void NetErrorPageController::OnDestruct() {} |
OLD | NEW |