diff options
author | esprehn <esprehn@chromium.org> | 2016-03-01 20:57:24 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-02 04:58:19 +0000 |
commit | 7252f0b67814dbaa6390d76ddc48e95438bbb5a1 (patch) | |
tree | fa1a063c080775a2d4bf8e189c41b95b1ed8a2c6 | |
parent | 4e6623013973747a357b11dd1ff0bb646e1db249 (diff) | |
download | chromium_src-7252f0b67814dbaa6390d76ddc48e95438bbb5a1.zip chromium_src-7252f0b67814dbaa6390d76ddc48e95438bbb5a1.tar.gz chromium_src-7252f0b67814dbaa6390d76ddc48e95438bbb5a1.tar.bz2 |
Remove WebScriptBindings.
Extension code does so much work in general (and copies strings),
the string optimization here doesn't really save much and adds
extra public API surface to blink we'd rather not have. Having
WebScriptBindings also encourages writing JS bindings out in
content, when they should really be inside blink instead.
Lets remove them and just use the normal v8_helpers that the rest
of the extensions system uses. As we move more extensions code down
into blink we can add optimizations like this back again.
BUG=561879
Review URL: https://codereview.chromium.org/1754713003
Cr-Commit-Position: refs/heads/master@{#378692}
-rw-r--r-- | chrome/renderer/extensions/file_browser_handler_custom_bindings.cc | 6 | ||||
-rw-r--r-- | extensions/renderer/content_watcher.cc | 1 | ||||
-rw-r--r-- | extensions/renderer/css_native_handler.cc | 13 | ||||
-rw-r--r-- | third_party/WebKit/Source/web/WebScriptBindings.cpp | 48 | ||||
-rw-r--r-- | third_party/WebKit/Source/web/web.gypi | 1 | ||||
-rw-r--r-- | third_party/WebKit/public/blink_headers.gypi | 1 | ||||
-rw-r--r-- | third_party/WebKit/public/web/WebScriptBindings.h | 59 |
7 files changed, 10 insertions, 119 deletions
diff --git a/chrome/renderer/extensions/file_browser_handler_custom_bindings.cc b/chrome/renderer/extensions/file_browser_handler_custom_bindings.cc index f5d2818..c892e6a 100644 --- a/chrome/renderer/extensions/file_browser_handler_custom_bindings.cc +++ b/chrome/renderer/extensions/file_browser_handler_custom_bindings.cc @@ -9,10 +9,10 @@ #include "base/logging.h" #include "build/build_config.h" #include "extensions/renderer/script_context.h" +#include "extensions/renderer/v8_helpers.h" #include "third_party/WebKit/public/platform/WebString.h" #include "third_party/WebKit/public/web/WebDOMFileSystem.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" -#include "third_party/WebKit/public/web/WebScriptBindings.h" namespace extensions { @@ -71,8 +71,8 @@ void FileBrowserHandlerCustomBindings::GetEntryURL( CHECK(args[0]->IsObject()); const blink::WebURL& url = blink::WebDOMFileSystem::createFileSystemURL(args[0]); - args.GetReturnValue().Set( - blink::WebScriptBindings::toV8String(url.string(), args.GetIsolate())); + args.GetReturnValue().Set(v8_helpers::ToV8StringUnsafe( + args.GetIsolate(), url.string().utf8().c_str())); } } // namespace extensions diff --git a/extensions/renderer/content_watcher.cc b/extensions/renderer/content_watcher.cc index 3ab9e59..95c8a57 100644 --- a/extensions/renderer/content_watcher.cc +++ b/extensions/renderer/content_watcher.cc @@ -12,7 +12,6 @@ #include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebElement.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" -#include "third_party/WebKit/public/web/WebScriptBindings.h" #include "third_party/WebKit/public/web/WebView.h" namespace extensions { diff --git a/extensions/renderer/css_native_handler.cc b/extensions/renderer/css_native_handler.cc index ab3ec61..d7cdc39 100644 --- a/extensions/renderer/css_native_handler.cc +++ b/extensions/renderer/css_native_handler.cc @@ -5,8 +5,8 @@ #include "extensions/renderer/css_native_handler.h" #include "extensions/renderer/script_context.h" +#include "extensions/renderer/v8_helpers.h" #include "third_party/WebKit/public/platform/WebString.h" -#include "third_party/WebKit/public/web/WebScriptBindings.h" #include "third_party/WebKit/public/web/WebSelector.h" namespace extensions { @@ -24,12 +24,13 @@ void CssNativeHandler::CanonicalizeCompoundSelector( const v8::FunctionCallbackInfo<v8::Value>& args) { CHECK_EQ(args.Length(), 1); CHECK(args[0]->IsString()); - WebString input_selector = - blink::WebScriptBindings::toWebString(args[0].As<v8::String>()); + std::string input_selector = *v8::String::Utf8Value(args[0]); + // TODO(esprehn): This API shouldn't exist, the extension code should be + // moved into blink. WebString output_selector = blink::canonicalizeSelector( - input_selector, blink::WebSelectorTypeCompound); - args.GetReturnValue().Set(blink::WebScriptBindings::toV8String( - output_selector, context()->v8_context()->GetIsolate())); + WebString::fromUTF8(input_selector), blink::WebSelectorTypeCompound); + args.GetReturnValue().Set(v8_helpers::ToV8StringUnsafe( + args.GetIsolate(), output_selector.utf8().c_str())); } } // namespace extensions diff --git a/third_party/WebKit/Source/web/WebScriptBindings.cpp b/third_party/WebKit/Source/web/WebScriptBindings.cpp deleted file mode 100644 index de5df23..0000000 --- a/third_party/WebKit/Source/web/WebScriptBindings.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "public/web/WebScriptBindings.h" - -#include "bindings/core/v8/V8Binding.h" -#include "public/platform/WebString.h" - -namespace blink { - -v8::Local<v8::String> WebScriptBindings::toV8String(const WebString& string, v8::Isolate* isolate) -{ - return v8String(isolate, string); -} - -WebString WebScriptBindings::toWebString(v8::Local<v8::String> v8String) -{ - return v8StringToWebCoreString<String>(v8String, Externalize); -} - -} // namespace blink diff --git a/third_party/WebKit/Source/web/web.gypi b/third_party/WebKit/Source/web/web.gypi index 831a696..acc22fe 100644 --- a/third_party/WebKit/Source/web/web.gypi +++ b/third_party/WebKit/Source/web/web.gypi @@ -200,7 +200,6 @@ 'WebScopedMicrotaskSuppression.cpp', 'WebScopedUserGesture.cpp', 'WebScopedWindowFocusAllowedIndicator.cpp', - 'WebScriptBindings.cpp', 'WebScriptController.cpp', 'WebScriptSource.cpp', 'WebSearchableFormData.cpp', diff --git a/third_party/WebKit/public/blink_headers.gypi b/third_party/WebKit/public/blink_headers.gypi index 660570d..2310732 100644 --- a/third_party/WebKit/public/blink_headers.gypi +++ b/third_party/WebKit/public/blink_headers.gypi @@ -443,7 +443,6 @@ "web/WebScopedMicrotaskSuppression.h", "web/WebScopedUserGesture.h", "web/WebScopedWindowFocusAllowedIndicator.h", - "web/WebScriptBindings.h", "web/WebScriptController.h", "web/WebScriptExecutionCallback.h", "web/WebScriptSource.h", diff --git a/third_party/WebKit/public/web/WebScriptBindings.h b/third_party/WebKit/public/web/WebScriptBindings.h deleted file mode 100644 index 2e18ce3..0000000 --- a/third_party/WebKit/public/web/WebScriptBindings.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef WebScriptBindings_h -#define WebScriptBindings_h - -#include "../platform/WebCommon.h" - -namespace v8 { -class Isolate; -class String; -template <class T> class Local; -template <class T> class Local; -} - -namespace blink { - -class WebString; - -class WebScriptBindings { -public: - // Efficiently converts a WebString to a v8::String. The caller must have - // a HandleScope to guard the result's lifetime. - BLINK_EXPORT static v8::Local<v8::String> toV8String(const WebString&, v8::Isolate*); - - // You can use v8::Value::toString() to get a v8::String, but remember to wrap that in a v8::TryCatch. - BLINK_EXPORT static WebString toWebString(v8::Local<v8::String>); -}; - -} // namespace blink - -#endif |