Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Unified Diff: chrome/renderer/net/net_error_page_controller.cc

Issue 207553008: Surface button for loading stale cache copy on net error page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix incorrect spelling of iOS. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/net/net_error_page_controller.cc
diff --git a/chrome/renderer/net/net_error_page_controller.cc b/chrome/renderer/net/net_error_page_controller.cc
new file mode 100644
index 0000000000000000000000000000000000000000..66ca54f511d5674ec218549b510a1ea47bb21a0b
--- /dev/null
+++ b/chrome/renderer/net/net_error_page_controller.cc
@@ -0,0 +1,89 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/net/net_error_page_controller.h"
+
+#include "base/strings/string_piece.h"
+#include "chrome/renderer/net/net_error_helper.h"
+#include "content/public/renderer/render_frame.h"
+#include "gin/handle.h"
+#include "gin/object_template_builder.h"
+#include "third_party/WebKit/public/web/WebFrame.h"
+#include "third_party/WebKit/public/web/WebKit.h"
+
+gin::WrapperInfo NetErrorPageController::kWrapperInfo = {
+ gin::kEmbedderNativeGin};
+
+// static
+void NetErrorPageController::Install(content::RenderFrame* render_frame) {
+ v8::Isolate* isolate = blink::mainThreadIsolate();
+ v8::HandleScope handle_scope(isolate);
+ v8::Handle<v8::Context> context =
+ render_frame->GetWebFrame()->mainWorldScriptContext();
+ if (context.IsEmpty())
+ return;
+
+ v8::Context::Scope context_scope(context);
+
+ gin::Handle<NetErrorPageController> controller = gin::CreateHandle(
+ isolate, new NetErrorPageController(render_frame));
+ v8::Handle<v8::Object> global = context->Global();
+ global->Set(gin::StringToV8(isolate, "errorPageController"),
+ controller.ToV8());
+}
+
+bool NetErrorPageController::LoadStaleButtonClick() {
+ if (!render_frame())
+ return false;
+
+ NetErrorHelper* net_error_helper =
+ content::RenderFrameObserverTracker<NetErrorHelper>::Get(render_frame());
+ DCHECK(net_error_helper);
+ net_error_helper->LoadStaleButtonPressed();
+
+ return true;
+}
+
+bool NetErrorPageController::ReloadButtonClick() {
+ if (!render_frame())
+ return false;
+
+ NetErrorHelper* net_error_helper =
+ content::RenderFrameObserverTracker<NetErrorHelper>::Get(render_frame());
+ DCHECK(net_error_helper);
+ net_error_helper->ReloadButtonPressed();
+
+ return true;
+}
+
+bool NetErrorPageController::MoreButtonClick() {
+ if (!render_frame())
+ return false;
+
+ NetErrorHelper* net_error_helper =
+ content::RenderFrameObserverTracker<NetErrorHelper>::Get(render_frame());
+ DCHECK(net_error_helper);
+ net_error_helper->MoreButtonPressed();
+
+ return true;
+}
+
+NetErrorPageController::NetErrorPageController(
+ content::RenderFrame* render_frame) : RenderFrameObserver(render_frame) {}
+
+NetErrorPageController::~NetErrorPageController() {}
+
+gin::ObjectTemplateBuilder NetErrorPageController::GetObjectTemplateBuilder(
+ v8::Isolate* isolate) {
+ return gin::Wrappable<NetErrorPageController>::GetObjectTemplateBuilder(
+ isolate)
jar (doing other things) 2014/04/21 23:48:19 nit: This should only be indented 4 from the start
Randy Smith (Not in Mondays) 2014/04/22 20:40:02 Done.
+ .SetMethod("loadStaleButtonClick",
+ &NetErrorPageController::LoadStaleButtonClick)
+ .SetMethod("reloadButtonClick",
+ &NetErrorPageController::ReloadButtonClick)
+ .SetMethod("moreButtonClick",
+ &NetErrorPageController::MoreButtonClick);
+}
+
+void NetErrorPageController::OnDestruct() {}

Powered by Google App Engine
This is Rietveld 408576698