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

Side by Side Diff: chrome/renderer/extensions/app_window_custom_bindings.cc

Issue 16975007: Run shim's watchForTag on document.DOMContentLoaded (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/app_window_custom_bindings.h" 5 #include "chrome/renderer/extensions/app_window_custom_bindings.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "chrome/common/extensions/extension_messages.h" 9 #include "chrome/common/extensions/extension_messages.h"
10 #include "chrome/renderer/extensions/chrome_v8_context.h" 10 #include "chrome/renderer/extensions/chrome_v8_context.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 AppWindowCustomBindings::AppWindowCustomBindings( 53 AppWindowCustomBindings::AppWindowCustomBindings(
54 Dispatcher* dispatcher, 54 Dispatcher* dispatcher,
55 ChromeV8Context* context) : ChromeV8Extension(dispatcher, context) { 55 ChromeV8Context* context) : ChromeV8Extension(dispatcher, context) {
56 RouteFunction("GetView", 56 RouteFunction("GetView",
57 base::Bind(&AppWindowCustomBindings::GetView, 57 base::Bind(&AppWindowCustomBindings::GetView,
58 base::Unretained(this))); 58 base::Unretained(this)));
59 RouteFunction("OnContextReady", 59 RouteFunction("OnContextReady",
60 base::Bind(&AppWindowCustomBindings::OnContextReady, 60 base::Bind(&AppWindowCustomBindings::OnContextReady,
61 base::Unretained(this))); 61 base::Unretained(this)));
62 RouteFunction("OnCurrentContextReady",
63 base::Bind(&AppWindowCustomBindings::OnCurrentContextReady,
64 base::Unretained(this)));
62 } 65 }
63 66
64 namespace { 67 namespace {
65 class LoadWatcher : public content::RenderViewObserver { 68 class LoadWatcher : public content::RenderViewObserver {
66 public: 69 public:
67 LoadWatcher(v8::Isolate* isolate, 70 LoadWatcher(v8::Isolate* isolate,
not at google - send to devlin 2013/06/13 22:08:32 looks like isolate isn't used
lazyboy 2013/06/14 00:09:50 Removed.
68 content::RenderView* view, 71 content::RenderView* view,
69 v8::Handle<v8::Function> cb) 72 v8::Handle<v8::Function> cb)
70 : content::RenderViewObserver(view), 73 : content::RenderViewObserver(view),
71 callback_(cb) { 74 callback_(cb) {
72 } 75 }
73 76
74 virtual void DidCreateDocumentElement(WebKit::WebFrame* frame) OVERRIDE { 77 virtual void DidCreateDocumentElement(WebKit::WebFrame* frame) OVERRIDE {
75 CallbackAndDie(frame, true); 78 CallbackAndDie(frame, true);
76 } 79 }
77 80
(...skipping 16 matching lines...) Expand all
94 v8::Handle<v8::Value> args[] = { 97 v8::Handle<v8::Value> args[] = {
95 succeeded ? v8::True() : v8::False() 98 succeeded ? v8::True() : v8::False()
96 }; 99 };
97 callback_->Call(global, 1, args); 100 callback_->Call(global, 1, args);
98 } 101 }
99 delete this; 102 delete this;
100 } 103 }
101 }; 104 };
102 } // namespace 105 } // namespace
103 106
104 v8::Handle<v8::Value> AppWindowCustomBindings::OnContextReady( 107 v8::Handle<v8::Value> AppWindowCustomBindings::OnContextReady(
not at google - send to devlin 2013/06/13 22:08:32 this doesn't actually have anything to do with app
lazyboy 2013/06/14 00:09:50 I've moved to a separate class RenderViewObserverN
105 const v8::Arguments& args) { 108 const v8::Arguments& args) {
106 if (args.Length() != 2) 109 if (args.Length() != 2)
107 return v8::Undefined(); 110 return v8::Undefined();
108 111
109 if (!args[0]->IsInt32()) 112 if (!args[0]->IsInt32())
110 return v8::Undefined(); 113 return v8::Undefined();
111 if (!args[1]->IsFunction()) 114 if (!args[1]->IsFunction())
112 return v8::Undefined(); 115 return v8::Undefined();
113 116
114 int view_id = args[0]->Int32Value(); 117 int view_id = args[0]->Int32Value();
115 118
116 content::RenderView* view = content::RenderView::FromRoutingID(view_id); 119 content::RenderView* view = content::RenderView::FromRoutingID(view_id);
117 if (!view) 120 if (!view)
118 return v8::Undefined(); 121 return v8::Undefined();
119 122
120 v8::Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(args[1]); 123 v8::Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(args[1]);
121 new LoadWatcher(args.GetIsolate(), view, func); 124 new LoadWatcher(args.GetIsolate(), view, func);
122 125
123 return v8::True(); 126 return v8::True();
124 } 127 }
125 128
129 v8::Handle<v8::Value> AppWindowCustomBindings::OnCurrentContextReady(
130 const v8::Arguments& args) {
131 printf("+++ %s\n", __PRETTY_FUNCTION__);
132 if (args.Length() != 1)
133 return v8::Undefined();
134
135 if (!args[0]->IsFunction())
136 return v8::Undefined();
not at google - send to devlin 2013/06/13 22:08:32 just CHECK these, we call the method and it'd be a
lazyboy 2013/06/14 00:09:50 Done.
137
138 int routing_id = context()->GetRenderView()->GetRoutingID();
139 printf("found routing_id: %d\n", routing_id);
140
141 //int view_id = args[0]->Int32Value();
142 int view_id = routing_id;
143
144 content::RenderView* view = content::RenderView::FromRoutingID(view_id);
not at google - send to devlin 2013/06/13 22:08:32 why go render view -> routing id -> render view he
lazyboy 2013/06/14 00:09:50 Ah I was quick hacking, fixed.
145 if (!view)
146 return v8::Undefined();
147
148 v8::Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(args[0]);
149 new LoadWatcher(args.GetIsolate(), view, func);
150
151 return v8::True();
not at google - send to devlin 2013/06/13 22:08:32 might as well return undefined again I see that c
lazyboy 2013/06/14 00:09:50 Looks like the return value is used in https://cod
152 }
153
126 v8::Handle<v8::Value> AppWindowCustomBindings::GetView( 154 v8::Handle<v8::Value> AppWindowCustomBindings::GetView(
127 const v8::Arguments& args) { 155 const v8::Arguments& args) {
128 // TODO(jeremya): convert this to IDL nocompile to get validation, and turn 156 // TODO(jeremya): convert this to IDL nocompile to get validation, and turn
129 // these argument checks into CHECK(). 157 // these argument checks into CHECK().
130 if (args.Length() != 2) 158 if (args.Length() != 2)
131 return v8::Undefined(); 159 return v8::Undefined();
132 160
133 if (!args[0]->IsInt32()) 161 if (!args[0]->IsInt32())
134 return v8::Undefined(); 162 return v8::Undefined();
135 163
(...skipping 25 matching lines...) Expand all
161 WebKit::WebFrame* frame = view->GetWebView()->mainFrame(); 189 WebKit::WebFrame* frame = view->GetWebView()->mainFrame();
162 frame->setOpener(opener); 190 frame->setOpener(opener);
163 content::RenderThread::Get()->Send( 191 content::RenderThread::Get()->Send(
164 new ExtensionHostMsg_ResumeRequests(view->GetRoutingID())); 192 new ExtensionHostMsg_ResumeRequests(view->GetRoutingID()));
165 193
166 v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global(); 194 v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global();
167 return window; 195 return window;
168 } 196 }
169 197
170 } // namespace extensions 198 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698