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

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

Issue 6242010: Refactor away most of ExtensionRendererInfo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 9 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 205
206 // Note: do not call this function before or during the chromeHidden.onLoad 206 // Note: do not call this function before or during the chromeHidden.onLoad
207 // event dispatch. The URL might not have been committed yet and might not 207 // event dispatch. The URL might not have been committed yet and might not
208 // be an extension URL. 208 // be an extension URL.
209 static std::string ExtensionIdForCurrentContext() { 209 static std::string ExtensionIdForCurrentContext() {
210 RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext(); 210 RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext();
211 if (!renderview) 211 if (!renderview)
212 return std::string(); // this can happen as a tab is closing. 212 return std::string(); // this can happen as a tab is closing.
213 213
214 GURL url = renderview->webview()->mainFrame()->url(); 214 GURL url = renderview->webview()->mainFrame()->url();
215 if (!ExtensionRendererInfo::ExtensionBindingsAllowed(url)) 215 const ExtensionRendererInfo* extensions =
216 EventBindings::GetRenderThread()->GetExtensions();
217 if (!extensions->ExtensionBindingsAllowed(url))
216 return std::string(); 218 return std::string();
217 219
218 return ExtensionRendererInfo::GetIdByURL(url); 220 return extensions->GetIdByURL(url);
219 } 221 }
220 222
221 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( 223 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
222 v8::Handle<v8::String> name) { 224 v8::Handle<v8::String> name) {
223 if (name->Equals(v8::String::New("GetExtensionAPIDefinition"))) { 225 if (name->Equals(v8::String::New("GetExtensionAPIDefinition"))) {
224 return v8::FunctionTemplate::New(GetExtensionAPIDefinition); 226 return v8::FunctionTemplate::New(GetExtensionAPIDefinition);
225 } else if (name->Equals(v8::String::New("GetExtensionViews"))) { 227 } else if (name->Equals(v8::String::New("GetExtensionViews"))) {
226 return v8::FunctionTemplate::New(GetExtensionViews); 228 return v8::FunctionTemplate::New(GetExtensionViews);
227 } else if (name->Equals(v8::String::New("GetNextRequestId"))) { 229 } else if (name->Equals(v8::String::New("GetNextRequestId"))) {
228 return v8::FunctionTemplate::New(GetNextRequestId); 230 return v8::FunctionTemplate::New(GetNextRequestId);
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 ExtensionProcessBindings::ThrowPermissionDeniedException( 671 ExtensionProcessBindings::ThrowPermissionDeniedException(
670 const std::string& function_name) { 672 const std::string& function_name) {
671 static const char kMessage[] = 673 static const char kMessage[] =
672 "You do not have permission to use '%s'. Be sure to declare" 674 "You do not have permission to use '%s'. Be sure to declare"
673 " in your manifest what permissions you need."; 675 " in your manifest what permissions you need.";
674 std::string error_msg = StringPrintf(kMessage, function_name.c_str()); 676 std::string error_msg = StringPrintf(kMessage, function_name.c_str());
675 677
676 return v8::ThrowException(v8::Exception::Error( 678 return v8::ThrowException(v8::Exception::Error(
677 v8::String::New(error_msg.c_str()))); 679 v8::String::New(error_msg.c_str())));
678 } 680 }
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/event_bindings.cc ('k') | chrome/renderer/extensions/extension_renderer_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698