| OLD | NEW |
| 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 <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 return v8::FunctionTemplate::New(GetCurrentPageActions, | 168 return v8::FunctionTemplate::New(GetCurrentPageActions, |
| 169 v8::External::New(this)); | 169 v8::External::New(this)); |
| 170 } else if (name->Equals(v8::String::New("StartRequest"))) { | 170 } else if (name->Equals(v8::String::New("StartRequest"))) { |
| 171 return v8::FunctionTemplate::New(StartRequest, | 171 return v8::FunctionTemplate::New(StartRequest, |
| 172 v8::External::New(this)); | 172 v8::External::New(this)); |
| 173 } else if (name->Equals(v8::String::New("GetRenderViewId"))) { | 173 } else if (name->Equals(v8::String::New("GetRenderViewId"))) { |
| 174 return v8::FunctionTemplate::New(GetRenderViewId); | 174 return v8::FunctionTemplate::New(GetRenderViewId); |
| 175 } else if (name->Equals(v8::String::New("SetIconCommon"))) { | 175 } else if (name->Equals(v8::String::New("SetIconCommon"))) { |
| 176 return v8::FunctionTemplate::New(SetIconCommon, | 176 return v8::FunctionTemplate::New(SetIconCommon, |
| 177 v8::External::New(this)); | 177 v8::External::New(this)); |
| 178 } else if (name->Equals(v8::String::New("IsExtensionProcess"))) { | |
| 179 return v8::FunctionTemplate::New(IsExtensionProcess, | |
| 180 v8::External::New(this)); | |
| 181 } else if (name->Equals(v8::String::New("IsIncognitoProcess"))) { | |
| 182 return v8::FunctionTemplate::New(IsIncognitoProcess); | |
| 183 } else if (name->Equals(v8::String::New("GetUniqueSubEventName"))) { | 178 } else if (name->Equals(v8::String::New("GetUniqueSubEventName"))) { |
| 184 return v8::FunctionTemplate::New(GetUniqueSubEventName); | 179 return v8::FunctionTemplate::New(GetUniqueSubEventName); |
| 185 } else if (name->Equals(v8::String::New("GetLocalFileSystem"))) { | 180 } else if (name->Equals(v8::String::New("GetLocalFileSystem"))) { |
| 186 return v8::FunctionTemplate::New(GetLocalFileSystem); | 181 return v8::FunctionTemplate::New(GetLocalFileSystem); |
| 187 } else if (name->Equals(v8::String::New("DecodeJPEG"))) { | 182 } else if (name->Equals(v8::String::New("DecodeJPEG"))) { |
| 188 return v8::FunctionTemplate::New(DecodeJPEG, v8::External::New(this)); | 183 return v8::FunctionTemplate::New(DecodeJPEG, v8::External::New(this)); |
| 189 } | 184 } |
| 190 | 185 |
| 191 return ExtensionBase::GetNativeFunction(name); | 186 return ExtensionBase::GetNativeFunction(name); |
| 192 } | 187 } |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 | 538 |
| 544 return StartRequestCommon(args, &list_value); | 539 return StartRequestCommon(args, &list_value); |
| 545 } | 540 } |
| 546 | 541 |
| 547 static v8::Handle<v8::Value> GetRenderViewId(const v8::Arguments& args) { | 542 static v8::Handle<v8::Value> GetRenderViewId(const v8::Arguments& args) { |
| 548 RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext(); | 543 RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext(); |
| 549 if (!renderview) | 544 if (!renderview) |
| 550 return v8::Undefined(); | 545 return v8::Undefined(); |
| 551 return v8::Integer::New(renderview->routing_id()); | 546 return v8::Integer::New(renderview->routing_id()); |
| 552 } | 547 } |
| 553 | |
| 554 static v8::Handle<v8::Value> IsExtensionProcess(const v8::Arguments& args) { | |
| 555 ExtensionImpl* v8_extension = GetFromArguments<ExtensionImpl>(args); | |
| 556 return v8::Boolean::New( | |
| 557 v8_extension->extension_dispatcher_->is_extension_process()); | |
| 558 } | |
| 559 | |
| 560 static v8::Handle<v8::Value> IsIncognitoProcess(const v8::Arguments& args) { | |
| 561 return v8::Boolean::New( | |
| 562 ChromeRenderProcessObserver::is_incognito_process()); | |
| 563 } | |
| 564 }; | 548 }; |
| 565 | 549 |
| 566 } // namespace | 550 } // namespace |
| 567 | 551 |
| 568 v8::Extension* ExtensionProcessBindings::Get( | 552 v8::Extension* ExtensionProcessBindings::Get( |
| 569 ExtensionDispatcher* extension_dispatcher) { | 553 ExtensionDispatcher* extension_dispatcher) { |
| 570 static v8::Extension* extension = new ExtensionImpl(extension_dispatcher); | 554 static v8::Extension* extension = new ExtensionImpl(extension_dispatcher); |
| 571 CHECK_EQ(extension_dispatcher, | 555 CHECK_EQ(extension_dispatcher, |
| 572 static_cast<ExtensionImpl*>(extension)->extension_dispatcher()); | 556 static_cast<ExtensionImpl*>(extension)->extension_dispatcher()); |
| 573 return extension; | 557 return extension; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 597 if (!retval.IsEmpty() && !retval->IsUndefined()) { | 581 if (!retval.IsEmpty() && !retval->IsUndefined()) { |
| 598 std::string error = *v8::String::AsciiValue(retval); | 582 std::string error = *v8::String::AsciiValue(retval); |
| 599 DCHECK(false) << error; | 583 DCHECK(false) << error; |
| 600 } | 584 } |
| 601 #endif | 585 #endif |
| 602 | 586 |
| 603 request->second->context.Dispose(); | 587 request->second->context.Dispose(); |
| 604 request->second->context.Clear(); | 588 request->second->context.Clear(); |
| 605 pending_requests.erase(request); | 589 pending_requests.erase(request); |
| 606 } | 590 } |
| OLD | NEW |