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

Side by Side Diff: chrome/renderer/extensions/chrome_v8_extension.h

Issue 11571014: Lazy load chrome.* APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: windows interactive_ui_tests fix Created 7 years, 9 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 (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 #ifndef CHROME_RENDERER_EXTENSIONS_CHROME_V8_EXTENSION_H_ 5 #ifndef CHROME_RENDERER_EXTENSIONS_CHROME_V8_EXTENSION_H_
6 #define CHROME_RENDERER_EXTENSIONS_CHROME_V8_EXTENSION_H_ 6 #define CHROME_RENDERER_EXTENSIONS_CHROME_V8_EXTENSION_H_
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/linked_ptr.h" 9 #include "base/memory/linked_ptr.h"
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
11 #include "chrome/renderer/extensions/chrome_v8_extension_handler.h" 11 #include "chrome/renderer/extensions/chrome_v8_extension_handler.h"
12 #include "chrome/renderer/extensions/native_handler.h" 12 #include "chrome/renderer/extensions/object_backed_native_handler.h"
13 #include "v8/include/v8.h" 13 #include "v8/include/v8.h"
14 14
15 #include <map> 15 #include <map>
16 #include <set> 16 #include <set>
17 #include <string> 17 #include <string>
18 18
19 19
20 namespace content { 20 namespace content {
21 class RenderView; 21 class RenderView;
22 } 22 }
23 23
24 namespace extensions { 24 namespace extensions {
25 class ChromeV8Context; 25 class ChromeV8Context;
26 class Dispatcher; 26 class Dispatcher;
27 class Extension; 27 class Extension;
28 28
29 // DEPRECATED.
30 //
29 // This is a base class for chrome extension bindings. Common features that 31 // This is a base class for chrome extension bindings. Common features that
30 // are shared by different modules go here. 32 // are shared by different modules go here.
31 // TODO(koz): Rename this to ExtensionNativeModule. 33 //
32 class ChromeV8Extension : public NativeHandler { 34 // TODO(kalman): Delete this class entirely, it has no value anymore.
35 // Custom bindings should extend ObjectBackedNativeHandler.
36 class ChromeV8Extension : public ObjectBackedNativeHandler {
33 public: 37 public:
34 typedef std::set<ChromeV8Extension*> InstanceSet; 38 // EXTRA DEPRECATED. DO NOT USE THIS CONSTRUCTOR. It doesn't work in subtle
35 static const InstanceSet& GetAll(); 39 // cases.
40 explicit ChromeV8Extension(Dispatcher* dispatcher);
36 41
37 explicit ChromeV8Extension(Dispatcher* dispatcher); 42 ChromeV8Extension(Dispatcher* dispatcher, v8::Handle<v8::Context> context);
38 virtual ~ChromeV8Extension(); 43 virtual ~ChromeV8Extension();
39 44
40 Dispatcher* dispatcher() { return dispatcher_; } 45 Dispatcher* dispatcher() { return dispatcher_; }
41 46
47 ChromeV8Context* GetContext();
48
49 // Shortcuts through to the context's render view and extension.
50 content::RenderView* GetRenderView();
51 const Extension* GetExtensionForRenderView();
52
42 protected: 53 protected:
43 template<class T> 54 template<class T>
44 static T* GetFromArguments(const v8::Arguments& args) { 55 static T* GetFromArguments(const v8::Arguments& args) {
45 CHECK(!args.Data().IsEmpty()); 56 CHECK(!args.Data().IsEmpty());
46 T* result = static_cast<T*>(args.Data().As<v8::External>()->Value()); 57 T* result = static_cast<T*>(args.Data().As<v8::External>()->Value());
47 return result; 58 return result;
48 } 59 }
49 60
50 // Gets the render view for the current v8 context.
51 static content::RenderView* GetCurrentRenderView();
52
53 // Note: do not call this function before or during the chromeHidden.onLoad
54 // event dispatch. The URL might not have been committed yet and might not
55 // be an extension URL.
56 const Extension* GetExtensionForCurrentRenderView() const;
57
58 // Returns the chromeHidden object for the current context.
59 static v8::Handle<v8::Value> GetChromeHidden(const v8::Arguments& args);
60
61 Dispatcher* dispatcher_; 61 Dispatcher* dispatcher_;
62 62
63 private: 63 private:
64 DISALLOW_COPY_AND_ASSIGN(ChromeV8Extension); 64 DISALLOW_COPY_AND_ASSIGN(ChromeV8Extension);
65 }; 65 };
66 66
67 } // namespace extensions 67 } // namespace extensions
68 68
69 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_EXTENSION_H_ 69 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_EXTENSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698