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

Unified Diff: chrome/renderer/extensions/app_window_custom_bindings.cc

Issue 10896032: HTML titlebars for v2 apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move function call logic into ModuleSystem Created 8 years, 4 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/extensions/app_window_custom_bindings.cc
diff --git a/chrome/renderer/extensions/app_window_custom_bindings.cc b/chrome/renderer/extensions/app_window_custom_bindings.cc
index 5337e8dfb5190656ba9c9047ec52dd063c9b6ea0..70dc133bfe386a8ede60f0bc51e5cc6e83025ee5 100644
--- a/chrome/renderer/extensions/app_window_custom_bindings.cc
+++ b/chrome/renderer/extensions/app_window_custom_bindings.cc
@@ -10,16 +10,17 @@
#include "chrome/common/extensions/extension_action.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/url_constants.h"
+#include "chrome/renderer/extensions/chrome_v8_context.h"
#include "chrome/renderer/extensions/dispatcher.h"
#include "chrome/renderer/extensions/extension_helper.h"
#include "content/public/renderer/render_thread.h"
#include "content/public/renderer/render_view.h"
#include "grit/renderer_resources.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRequest.h"
Mihai Parparita -not on Chrome 2012/08/31 23:12:56 Nit: this seems unused (as does WebNavigationPolic
jeremya 2012/09/01 01:42:30 Done.
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNavigationPolicy.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRequest.h"
#include "v8/include/v8.h"
#include "webkit/glue/webkit_glue.h"
@@ -28,9 +29,37 @@
namespace extensions {
+class DidCreateDocumentElementObserver : public content::RenderViewObserver {
+ public:
+ DidCreateDocumentElementObserver(
+ content::RenderView* view, Dispatcher* dispatcher)
+ : content::RenderViewObserver(view), dispatcher_(dispatcher) {
+ }
+ virtual void DidCreateDocumentElement(WebKit::WebFrame* frame) OVERRIDE {
Mihai Parparita -not on Chrome 2012/08/31 23:12:56 Nit: newline before this.
jeremya 2012/09/01 01:42:30 Done.
+ v8::HandleScope handle_scope;
+ DCHECK(frame);
+ DCHECK(dispatcher_);
+ ChromeV8Context* v8_context =
+ dispatcher_->v8_context_set().GetByV8Context(
+ frame->mainWorldScriptContext());
+
+ if (!v8_context)
+ return;
+ v8::Context::Scope context_scope(v8_context->v8_context());
+ v8_context->module_system()->CallModuleMethod(
+ "injectAppTitlebar", "didCreateDocumentElement");
+ }
+
+ private:
+ Dispatcher* dispatcher_;
+ bool inject_titlebar_;
Mihai Parparita -not on Chrome 2012/08/31 23:12:56 Seems to be unused. Though to be honest, I liked t
jeremya 2012/09/01 01:42:30 Done. Yeah, I wasn't really sure which was cleaner
+};
+
AppWindowCustomBindings::AppWindowCustomBindings(Dispatcher* dispatcher)
: ChromeV8Extension(dispatcher) {
- RouteStaticFunction("GetView", &GetView);
+ RouteFunction("GetView",
+ base::Bind(&AppWindowCustomBindings::GetView,
+ base::Unretained(this)));
}
namespace {
@@ -82,6 +111,8 @@ v8::Handle<v8::Value> AppWindowCustomBindings::GetView(
if (!view)
return v8::Undefined();
+ new DidCreateDocumentElementObserver(view, dispatcher());
+
// TODO(jeremya): it doesn't really make sense to set the opener here, but we
// need to make sure the security origin is set up before returning the DOM
// reference. A better way to do this would be to have the browser pass the

Powered by Google App Engine
This is Rietveld 408576698