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

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

Issue 10025007: Convert tabs, windows, and extension APIs to feature system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blah Created 8 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 (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/extension_custom_bindings.h" 5 #include "chrome/renderer/extensions/extension_custom_bindings.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "chrome/common/chrome_view_type.h" 10 #include "chrome/common/chrome_view_type.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 content::ViewType view_type_; 103 content::ViewType view_type_;
104 v8::Local<v8::Array> views_; 104 v8::Local<v8::Array> views_;
105 int index_; 105 int index_;
106 }; 106 };
107 107
108 } // namespace 108 } // namespace
109 109
110 ExtensionCustomBindings::ExtensionCustomBindings( 110 ExtensionCustomBindings::ExtensionCustomBindings(
111 ExtensionDispatcher* extension_dispatcher) 111 ExtensionDispatcher* extension_dispatcher)
112 : ChromeV8Extension(extension_dispatcher) { 112 : ChromeV8Extension(extension_dispatcher) {
113 RouteStaticFunction("GetExtensionViews", &GetExtensionViews); 113 RouteFunction("GetExtensionViews",
114 base::Bind(&ExtensionCustomBindings::GetExtensionViews,
115 base::Unretained(this)));
114 RouteStaticFunction("OpenChannelToExtension", &OpenChannelToExtension); 116 RouteStaticFunction("OpenChannelToExtension", &OpenChannelToExtension);
115 } 117 }
116 118
117 // static
118 v8::Handle<v8::Value> ExtensionCustomBindings::GetExtensionViews( 119 v8::Handle<v8::Value> ExtensionCustomBindings::GetExtensionViews(
119 const v8::Arguments& args) { 120 const v8::Arguments& args) {
120 if (args.Length() != 2) 121 if (args.Length() != 2)
121 return v8::Undefined(); 122 return v8::Undefined();
122 123
123 if (!args[0]->IsInt32() || !args[1]->IsString()) 124 if (!args[0]->IsInt32() || !args[1]->IsString())
124 return v8::Undefined(); 125 return v8::Undefined();
125 126
126 // |browser_window_id| == extension_misc::kUnknownWindowId means getting 127 // |browser_window_id| == extension_misc::kUnknownWindowId means getting
127 // views attached to any browser window. 128 // views attached to any browser window.
(...skipping 17 matching lines...) Expand all
145 } else if (view_type_string == chrome::kViewTypeExtensionDialog) { 146 } else if (view_type_string == chrome::kViewTypeExtensionDialog) {
146 view_type = chrome::VIEW_TYPE_EXTENSION_DIALOG; 147 view_type = chrome::VIEW_TYPE_EXTENSION_DIALOG;
147 } else if (view_type_string == chrome::kViewTypeAppShell) { 148 } else if (view_type_string == chrome::kViewTypeAppShell) {
148 view_type = chrome::VIEW_TYPE_APP_SHELL; 149 view_type = chrome::VIEW_TYPE_APP_SHELL;
149 } else if (view_type_string == chrome::kViewTypePanel) { 150 } else if (view_type_string == chrome::kViewTypePanel) {
150 view_type = chrome::VIEW_TYPE_PANEL; 151 view_type = chrome::VIEW_TYPE_PANEL;
151 } else if (view_type_string != chrome::kViewTypeAll) { 152 } else if (view_type_string != chrome::kViewTypeAll) {
152 return v8::Undefined(); 153 return v8::Undefined();
153 } 154 }
154 155
155 ExtensionCustomBindings* v8_extension = 156 ChromeV8Context* context =
156 GetFromArguments<ExtensionCustomBindings>(args); 157 extension_dispatcher()->v8_context_set().GetCurrent();
157 const ::Extension* extension = 158 const Extension* extension =
158 v8_extension->GetExtensionForCurrentRenderView(); 159 extension_dispatcher()->extensions()->GetByID(context->GetExtensionID());
159 if (!extension) 160 if (!extension)
160 return v8::Undefined(); 161 return v8::Undefined();
161 162
162 ExtensionViewAccumulator accumulator(extension->id(), browser_window_id, 163 ExtensionViewAccumulator accumulator(extension->id(), browser_window_id,
163 view_type); 164 view_type);
164 content::RenderView::ForEach(&accumulator); 165 content::RenderView::ForEach(&accumulator);
165 return accumulator.views(); 166 return accumulator.views();
166 } 167 }
167 168
168 // static 169 // static
(...skipping 18 matching lines...) Expand all
187 renderview->Send(new ExtensionHostMsg_OpenChannelToExtension( 188 renderview->Send(new ExtensionHostMsg_OpenChannelToExtension(
188 renderview->GetRoutingID(), 189 renderview->GetRoutingID(),
189 source_id, 190 source_id,
190 target_id, 191 target_id,
191 channel_name, 192 channel_name,
192 &port_id)); 193 &port_id));
193 return v8::Integer::New(port_id); 194 return v8::Integer::New(port_id);
194 } 195 }
195 196
196 } // namespace extensions 197 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/extension_custom_bindings.h ('k') | chrome/renderer/extensions/extension_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698