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

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

Issue 164225: Switch to WebFrame from the WebKit API.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/extensions/event_bindings.cc ('k') | chrome/renderer/external_extension.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_process_bindings.h" 5 #include "chrome/renderer/extensions/extension_process_bindings.h"
6 6
7 #include "base/singleton.h" 7 #include "base/singleton.h"
8 #include "chrome/common/extensions/extension.h" 8 #include "chrome/common/extensions/extension.h"
9 #include "chrome/common/render_messages.h" 9 #include "chrome/common/render_messages.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
11 #include "chrome/renderer/extensions/bindings_utils.h" 11 #include "chrome/renderer/extensions/bindings_utils.h"
12 #include "chrome/renderer/extensions/event_bindings.h" 12 #include "chrome/renderer/extensions/event_bindings.h"
13 #include "chrome/renderer/extensions/renderer_extension_bindings.h" 13 #include "chrome/renderer/extensions/renderer_extension_bindings.h"
14 #include "chrome/renderer/js_only_v8_extensions.h" 14 #include "chrome/renderer/js_only_v8_extensions.h"
15 #include "chrome/renderer/render_view.h" 15 #include "chrome/renderer/render_view.h"
16 #include "grit/common_resources.h" 16 #include "grit/common_resources.h"
17 #include "grit/renderer_resources.h" 17 #include "grit/renderer_resources.h"
18 #include "webkit/glue/webframe.h" 18 #include "webkit/api/public/WebFrame.h"
19 19
20 using bindings_utils::GetStringResource; 20 using bindings_utils::GetStringResource;
21 using bindings_utils::ContextInfo; 21 using bindings_utils::ContextInfo;
22 using bindings_utils::ContextList; 22 using bindings_utils::ContextList;
23 using bindings_utils::GetContexts; 23 using bindings_utils::GetContexts;
24 using bindings_utils::GetPendingRequestMap; 24 using bindings_utils::GetPendingRequestMap;
25 using bindings_utils::PendingRequest; 25 using bindings_utils::PendingRequest;
26 using bindings_utils::PendingRequestMap; 26 using bindings_utils::PendingRequestMap;
27 using bindings_utils::ExtensionBase; 27 using bindings_utils::ExtensionBase;
28 28
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 name_set->insert(names[i]); 75 name_set->insert(names[i]);
76 } 76 }
77 } 77 }
78 78
79 // Note: do not call this function before or during the chromeHidden.onLoad 79 // Note: do not call this function before or during the chromeHidden.onLoad
80 // event dispatch. The URL might not have been committed yet and might not 80 // event dispatch. The URL might not have been committed yet and might not
81 // be an extension URL. 81 // be an extension URL.
82 static std::string ExtensionIdForCurrentContext() { 82 static std::string ExtensionIdForCurrentContext() {
83 RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext(); 83 RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext();
84 DCHECK(renderview); 84 DCHECK(renderview);
85 GURL url = renderview->webview()->GetMainFrame()->GetURL(); 85 GURL url = renderview->webview()->GetMainFrame()->url();
86 if (url.SchemeIs(chrome::kExtensionScheme)) 86 if (url.SchemeIs(chrome::kExtensionScheme))
87 return url.host(); 87 return url.host();
88 return std::string(); 88 return std::string();
89 } 89 }
90 90
91 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( 91 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
92 v8::Handle<v8::String> name) { 92 v8::Handle<v8::String> name) {
93 if (name->Equals(v8::String::New("GetExtensionAPIDefinition"))) { 93 if (name->Equals(v8::String::New("GetExtensionAPIDefinition"))) {
94 return v8::FunctionTemplate::New(GetExtensionAPIDefinition); 94 return v8::FunctionTemplate::New(GetExtensionAPIDefinition);
95 } else if (name->Equals(v8::String::New("GetViews"))) { 95 } else if (name->Equals(v8::String::New("GetViews"))) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 // Starts an API request to the browser, with an optional callback. The 186 // Starts an API request to the browser, with an optional callback. The
187 // callback will be dispatched to EventBindings::HandleResponse. 187 // callback will be dispatched to EventBindings::HandleResponse.
188 static v8::Handle<v8::Value> StartRequest(const v8::Arguments& args) { 188 static v8::Handle<v8::Value> StartRequest(const v8::Arguments& args) {
189 // Get the current RenderView so that we can send a routed IPC message from 189 // Get the current RenderView so that we can send a routed IPC message from
190 // the correct source. 190 // the correct source.
191 RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext(); 191 RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext();
192 if (!renderview) 192 if (!renderview)
193 return v8::Undefined(); 193 return v8::Undefined();
194 194
195 if (args.Length() != 4 || !args[0]->IsString() || !args[1]->IsString() || 195 if (args.Length() != 4 || !args[0]->IsString() || !args[1]->IsString() ||
196 !args[2]->IsInt32() || !args[3]->IsBoolean()) 196 !args[2]->IsInt32() || !args[3]->IsBoolean())
197 return v8::Undefined(); 197 return v8::Undefined();
198 198
199 std::string name = *v8::String::AsciiValue(args[0]); 199 std::string name = *v8::String::AsciiValue(args[0]);
200 if (GetFunctionNameSet()->find(name) == GetFunctionNameSet()->end()) { 200 if (GetFunctionNameSet()->find(name) == GetFunctionNameSet()->end()) {
201 NOTREACHED() << "Unexpected function " << name; 201 NOTREACHED() << "Unexpected function " << name;
202 return v8::Undefined(); 202 return v8::Undefined();
203 } 203 }
204 204
205 if (!ExtensionProcessBindings::CurrentContextHasPermission(name)) 205 if (!ExtensionProcessBindings::CurrentContextHasPermission(name))
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 332
333 v8::Local<v8::Function> function = 333 v8::Local<v8::Function> function =
334 v8::Local<v8::Function>::Cast(console_error); 334 v8::Local<v8::Function>::Cast(console_error);
335 v8::Local<v8::Value> argv[] = { v8::String::New(error_msg.c_str()) }; 335 v8::Local<v8::Value> argv[] = { v8::String::New(error_msg.c_str()) };
336 if (!function.IsEmpty()) 336 if (!function.IsEmpty())
337 function->Call(console->ToObject(), arraysize(argv), argv); 337 function->Call(console->ToObject(), arraysize(argv), argv);
338 338
339 return v8::Undefined(); 339 return v8::Undefined();
340 #endif 340 #endif
341 } 341 }
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/event_bindings.cc ('k') | chrome/renderer/external_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698