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

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: Remove more deadness 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 ExtensionRendererInfo* extensions = RenderThread::current()->extensions();
216 if (!extensions->ExtensionBindingsAllowed(url))
216 return std::string(); 217 return std::string();
217 218
218 return ExtensionRendererInfo::GetIdByURL(url); 219 return extensions->GetIdByURL(url);
219 } 220 }
220 221
221 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( 222 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
222 v8::Handle<v8::String> name) { 223 v8::Handle<v8::String> name) {
223 if (name->Equals(v8::String::New("GetExtensionAPIDefinition"))) { 224 if (name->Equals(v8::String::New("GetExtensionAPIDefinition"))) {
224 return v8::FunctionTemplate::New(GetExtensionAPIDefinition); 225 return v8::FunctionTemplate::New(GetExtensionAPIDefinition);
225 } else if (name->Equals(v8::String::New("GetExtensionViews"))) { 226 } else if (name->Equals(v8::String::New("GetExtensionViews"))) {
226 return v8::FunctionTemplate::New(GetExtensionViews); 227 return v8::FunctionTemplate::New(GetExtensionViews);
227 } else if (name->Equals(v8::String::New("GetNextRequestId"))) { 228 } else if (name->Equals(v8::String::New("GetNextRequestId"))) {
228 return v8::FunctionTemplate::New(GetNextRequestId); 229 return v8::FunctionTemplate::New(GetNextRequestId);
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 ExtensionProcessBindings::ThrowPermissionDeniedException( 670 ExtensionProcessBindings::ThrowPermissionDeniedException(
670 const std::string& function_name) { 671 const std::string& function_name) {
671 static const char kMessage[] = 672 static const char kMessage[] =
672 "You do not have permission to use '%s'. Be sure to declare" 673 "You do not have permission to use '%s'. Be sure to declare"
673 " in your manifest what permissions you need."; 674 " in your manifest what permissions you need.";
674 std::string error_msg = StringPrintf(kMessage, function_name.c_str()); 675 std::string error_msg = StringPrintf(kMessage, function_name.c_str());
675 676
676 return v8::ThrowException(v8::Exception::Error( 677 return v8::ThrowException(v8::Exception::Error(
677 v8::String::New(error_msg.c_str()))); 678 v8::String::New(error_msg.c_str())));
678 } 679 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698