| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 std::string extension_id_; | 187 std::string extension_id_; |
| 188 int browser_window_id_; | 188 int browser_window_id_; |
| 189 ViewType::Type view_type_; | 189 ViewType::Type view_type_; |
| 190 v8::Local<v8::Array> views_; | 190 v8::Local<v8::Array> views_; |
| 191 int index_; | 191 int index_; |
| 192 }; | 192 }; |
| 193 | 193 |
| 194 class ExtensionImpl : public ExtensionBase { | 194 class ExtensionImpl : public ExtensionBase { |
| 195 public: | 195 public: |
| 196 ExtensionImpl() : ExtensionBase( | 196 ExtensionImpl() : ExtensionBase( |
| 197 kExtensionName, GetStringResource<IDR_EXTENSION_PROCESS_BINDINGS_JS>(), | 197 kExtensionName, GetStringResource(IDR_EXTENSION_PROCESS_BINDINGS_JS), |
| 198 arraysize(kExtensionDeps), kExtensionDeps) {} | 198 arraysize(kExtensionDeps), kExtensionDeps) {} |
| 199 | 199 |
| 200 static void SetFunctionNames(const std::vector<std::string>& names) { | 200 static void SetFunctionNames(const std::vector<std::string>& names) { |
| 201 std::set<std::string>* name_set = GetFunctionNameSet(); | 201 std::set<std::string>* name_set = GetFunctionNameSet(); |
| 202 for (size_t i = 0; i < names.size(); ++i) { | 202 for (size_t i = 0; i < names.size(); ++i) { |
| 203 name_set->insert(names[i]); | 203 name_set->insert(names[i]); |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 | 206 |
| 207 // Note: do not call this function before or during the chromeHidden.onLoad | 207 // Note: do not call this function before or during the chromeHidden.onLoad |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } else if (name->Equals(v8::String::New("IsIncognitoProcess"))) { | 246 } else if (name->Equals(v8::String::New("IsIncognitoProcess"))) { |
| 247 return v8::FunctionTemplate::New(IsIncognitoProcess); | 247 return v8::FunctionTemplate::New(IsIncognitoProcess); |
| 248 } | 248 } |
| 249 | 249 |
| 250 return ExtensionBase::GetNativeFunction(name); | 250 return ExtensionBase::GetNativeFunction(name); |
| 251 } | 251 } |
| 252 | 252 |
| 253 private: | 253 private: |
| 254 static v8::Handle<v8::Value> GetExtensionAPIDefinition( | 254 static v8::Handle<v8::Value> GetExtensionAPIDefinition( |
| 255 const v8::Arguments& args) { | 255 const v8::Arguments& args) { |
| 256 return v8::String::New(GetStringResource<IDR_EXTENSION_API_JSON>()); | 256 return v8::String::New(GetStringResource(IDR_EXTENSION_API_JSON)); |
| 257 } | 257 } |
| 258 | 258 |
| 259 static v8::Handle<v8::Value> PopupViewFinder( | 259 static v8::Handle<v8::Value> PopupViewFinder( |
| 260 const v8::Arguments& args, | 260 const v8::Arguments& args, |
| 261 ViewType::Type viewtype_to_find) { | 261 ViewType::Type viewtype_to_find) { |
| 262 // TODO(twiz) Correct the logic that ties the ownership of the pop-up view | 262 // TODO(twiz) Correct the logic that ties the ownership of the pop-up view |
| 263 // to the hosting view. At the moment we assume that there may only be | 263 // to the hosting view. At the moment we assume that there may only be |
| 264 // a single pop-up view for a given extension. By doing so, we can find | 264 // a single pop-up view for a given extension. By doing so, we can find |
| 265 // the pop-up view by simply searching for the only pop-up view present. | 265 // the pop-up view by simply searching for the only pop-up view present. |
| 266 // We also assume that if the current view is a pop-up, we can find the | 266 // We also assume that if the current view is a pop-up, we can find the |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 const std::string& function_name) { | 671 const std::string& function_name) { |
| 672 static const char kMessage[] = | 672 static const char kMessage[] = |
| 673 "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" |
| 674 " in your manifest what permissions you need."; | 674 " in your manifest what permissions you need."; |
| 675 std::string error_msg = StringPrintf(kMessage, function_name.c_str()); | 675 std::string error_msg = StringPrintf(kMessage, function_name.c_str()); |
| 676 | 676 |
| 677 return v8::ThrowException(v8::Exception::Error( | 677 return v8::ThrowException(v8::Exception::Error( |
| 678 v8::String::New(error_msg.c_str()))); | 678 v8::String::New(error_msg.c_str()))); |
| 679 } | 679 } |
| 680 | 680 |
| OLD | NEW |