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

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

Issue 234413005: Move most of ChromeV8Context to a base ScriptContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: factor feature_channel out of module_system 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/render_view_observer_natives.h" 5 #include "chrome/renderer/extensions/render_view_observer_natives.h"
6 6
7 #include "chrome/renderer/extensions/dispatcher.h" 7 #include "chrome/renderer/extensions/dispatcher.h"
8 #include "content/public/renderer/render_view.h" 8 #include "content/public/renderer/render_view.h"
9 #include "content/public/renderer/render_view_observer.h" 9 #include "content/public/renderer/render_view_observer.h"
10 #include "extensions/common/extension_api.h" 10 #include "extensions/common/extension_api.h"
11 #include "extensions/renderer/script_context.h"
11 #include "third_party/WebKit/public/web/WebFrame.h" 12 #include "third_party/WebKit/public/web/WebFrame.h"
12 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" 13 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
13 14
14 namespace extensions { 15 namespace extensions {
15 16
16 namespace { 17 namespace {
17 18
18 // Deletes itself when done. 19 // Deletes itself when done.
19 class LoadWatcher : public content::RenderViewObserver { 20 class LoadWatcher : public content::RenderViewObserver {
20 public: 21 public:
21 LoadWatcher(ChromeV8Context* context, 22 LoadWatcher(ScriptContext* context,
22 content::RenderView* view, 23 content::RenderView* view,
23 v8::Handle<v8::Function> cb) 24 v8::Handle<v8::Function> cb)
24 : content::RenderViewObserver(view), 25 : content::RenderViewObserver(view), context_(context), callback_(cb) {}
25 context_(context),
26 callback_(cb) {
27 }
28 26
29 virtual void DidCreateDocumentElement(blink::WebLocalFrame* frame) OVERRIDE { 27 virtual void DidCreateDocumentElement(blink::WebLocalFrame* frame) OVERRIDE {
30 CallbackAndDie(true); 28 CallbackAndDie(true);
31 } 29 }
32 30
33 virtual void DidFailProvisionalLoad( 31 virtual void DidFailProvisionalLoad(
34 blink::WebLocalFrame* frame, 32 blink::WebLocalFrame* frame,
35 const blink::WebURLError& error) OVERRIDE { 33 const blink::WebURLError& error) OVERRIDE {
36 CallbackAndDie(false); 34 CallbackAndDie(false);
37 } 35 }
38 36
39 private: 37 private:
40 void CallbackAndDie(bool succeeded) { 38 void CallbackAndDie(bool succeeded) {
41 v8::Isolate* isolate = context_->isolate(); 39 v8::Isolate* isolate = context_->isolate();
42 v8::HandleScope handle_scope(isolate); 40 v8::HandleScope handle_scope(isolate);
43 v8::Handle<v8::Value> args[] = { v8::Boolean::New(isolate, succeeded) }; 41 v8::Handle<v8::Value> args[] = { v8::Boolean::New(isolate, succeeded) };
44 context_->CallFunction(callback_.NewHandle(isolate), 1, args); 42 context_->CallFunction(callback_.NewHandle(isolate), 1, args);
45 delete this; 43 delete this;
46 } 44 }
47 45
48 ChromeV8Context* context_; 46 ScriptContext* context_;
49 ScopedPersistent<v8::Function> callback_; 47 ScopedPersistent<v8::Function> callback_;
50 DISALLOW_COPY_AND_ASSIGN(LoadWatcher); 48 DISALLOW_COPY_AND_ASSIGN(LoadWatcher);
51 }; 49 };
52 } // namespace 50 } // namespace
53 51
54 52
55 RenderViewObserverNatives::RenderViewObserverNatives(Dispatcher* dispatcher, 53 RenderViewObserverNatives::RenderViewObserverNatives(Dispatcher* dispatcher,
56 ChromeV8Context* context) 54 ChromeV8Context* context)
57 : ChromeV8Extension(dispatcher, context) { 55 : ChromeV8Extension(dispatcher, context) {
58 RouteFunction("OnDocumentElementCreated", 56 RouteFunction("OnDocumentElementCreated",
(...skipping 14 matching lines...) Expand all
73 LOG(WARNING) << "No render view found to register LoadWatcher."; 71 LOG(WARNING) << "No render view found to register LoadWatcher.";
74 return; 72 return;
75 } 73 }
76 74
77 new LoadWatcher(context(), view, args[1].As<v8::Function>()); 75 new LoadWatcher(context(), view, args[1].As<v8::Function>());
78 76
79 args.GetReturnValue().Set(true); 77 args.GetReturnValue().Set(true);
80 } 78 }
81 79
82 } // namespace extensions 80 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/render_view_observer_natives.h ('k') | chrome/renderer/extensions/request_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698