| 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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| (...skipping 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1685 return NPObjectToPPVar(this, container_->scriptableObjectForElement()); | 1685 return NPObjectToPPVar(this, container_->scriptableObjectForElement()); |
| 1686 } | 1686 } |
| 1687 | 1687 |
| 1688 PP_Var PluginInstance::ExecuteScript(PP_Instance instance, | 1688 PP_Var PluginInstance::ExecuteScript(PP_Instance instance, |
| 1689 PP_Var script, | 1689 PP_Var script, |
| 1690 PP_Var* exception) { | 1690 PP_Var* exception) { |
| 1691 // Executing the script may remove the plugin from the DOM, so we need to keep | 1691 // Executing the script may remove the plugin from the DOM, so we need to keep |
| 1692 // a reference to ourselves so that we can still process the result after the | 1692 // a reference to ourselves so that we can still process the result after the |
| 1693 // WebBindings::evaluate() below. | 1693 // WebBindings::evaluate() below. |
| 1694 scoped_refptr<PluginInstance> ref(this); | 1694 scoped_refptr<PluginInstance> ref(this); |
| 1695 TryCatch try_catch(module()->pp_module(), exception); | 1695 TryCatch try_catch(exception); |
| 1696 if (try_catch.has_exception()) | 1696 if (try_catch.has_exception()) |
| 1697 return PP_MakeUndefined(); | 1697 return PP_MakeUndefined(); |
| 1698 | 1698 |
| 1699 // Convert the script into an inconvenient NPString object. | 1699 // Convert the script into an inconvenient NPString object. |
| 1700 StringVar* script_string = StringVar::FromPPVar(script); | 1700 StringVar* script_string = StringVar::FromPPVar(script); |
| 1701 if (!script_string) { | 1701 if (!script_string) { |
| 1702 try_catch.SetException("Script param to ExecuteScript must be a string."); | 1702 try_catch.SetException("Script param to ExecuteScript must be a string."); |
| 1703 return PP_MakeUndefined(); | 1703 return PP_MakeUndefined(); |
| 1704 } | 1704 } |
| 1705 NPString np_script; | 1705 NPString np_script; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1724 return PP_MakeUndefined(); | 1724 return PP_MakeUndefined(); |
| 1725 } | 1725 } |
| 1726 | 1726 |
| 1727 PP_Var ret = NPVariantToPPVar(this, &result); | 1727 PP_Var ret = NPVariantToPPVar(this, &result); |
| 1728 WebBindings::releaseVariantValue(&result); | 1728 WebBindings::releaseVariantValue(&result); |
| 1729 return ret; | 1729 return ret; |
| 1730 } | 1730 } |
| 1731 | 1731 |
| 1732 PP_Var PluginInstance::GetDefaultCharSet(PP_Instance instance) { | 1732 PP_Var PluginInstance::GetDefaultCharSet(PP_Instance instance) { |
| 1733 std::string encoding = delegate()->GetDefaultEncoding(); | 1733 std::string encoding = delegate()->GetDefaultEncoding(); |
| 1734 return StringVar::StringToPPVar(module()->pp_module(), encoding); | 1734 return StringVar::StringToPPVar(encoding); |
| 1735 } | 1735 } |
| 1736 | 1736 |
| 1737 void PluginInstance::Log(PP_Instance instance, | 1737 void PluginInstance::Log(PP_Instance instance, |
| 1738 int log_level, | 1738 int log_level, |
| 1739 PP_Var value) { | 1739 PP_Var value) { |
| 1740 // TODO(brettw) get the plugin name and use it as the source. | 1740 // TODO(brettw) get the plugin name and use it as the source. |
| 1741 LogWithSource(instance, log_level, PP_MakeUndefined(), value); | 1741 LogWithSource(instance, log_level, PP_MakeUndefined(), value); |
| 1742 } | 1742 } |
| 1743 | 1743 |
| 1744 void PluginInstance::LogWithSource(PP_Instance instance, | 1744 void PluginInstance::LogWithSource(PP_Instance instance, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1889 PP_Instance instance, | 1889 PP_Instance instance, |
| 1890 PP_Var relative, | 1890 PP_Var relative, |
| 1891 PP_URLComponents_Dev* components) { | 1891 PP_URLComponents_Dev* components) { |
| 1892 StringVar* relative_string = StringVar::FromPPVar(relative); | 1892 StringVar* relative_string = StringVar::FromPPVar(relative); |
| 1893 if (!relative_string) | 1893 if (!relative_string) |
| 1894 return PP_MakeNull(); | 1894 return PP_MakeNull(); |
| 1895 | 1895 |
| 1896 WebElement plugin_element = container()->element(); | 1896 WebElement plugin_element = container()->element(); |
| 1897 GURL document_url = plugin_element.document().baseURL(); | 1897 GURL document_url = plugin_element.document().baseURL(); |
| 1898 return ::ppapi::URLUtilImpl::GenerateURLReturn( | 1898 return ::ppapi::URLUtilImpl::GenerateURLReturn( |
| 1899 module()->pp_module(), | |
| 1900 document_url.Resolve(relative_string->value()), | 1899 document_url.Resolve(relative_string->value()), |
| 1901 components); | 1900 components); |
| 1902 } | 1901 } |
| 1903 | 1902 |
| 1904 PP_Bool PluginInstance::DocumentCanRequest(PP_Instance instance, PP_Var url) { | 1903 PP_Bool PluginInstance::DocumentCanRequest(PP_Instance instance, PP_Var url) { |
| 1905 StringVar* url_string = StringVar::FromPPVar(url); | 1904 StringVar* url_string = StringVar::FromPPVar(url); |
| 1906 if (!url_string) | 1905 if (!url_string) |
| 1907 return PP_FALSE; | 1906 return PP_FALSE; |
| 1908 | 1907 |
| 1909 WebKit::WebSecurityOrigin security_origin; | 1908 WebKit::WebSecurityOrigin security_origin; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1926 WebKit::WebSecurityOrigin target_origin; | 1925 WebKit::WebSecurityOrigin target_origin; |
| 1927 if (!SecurityOriginForInstance(instance, &target_origin)) | 1926 if (!SecurityOriginForInstance(instance, &target_origin)) |
| 1928 return PP_FALSE; | 1927 return PP_FALSE; |
| 1929 | 1928 |
| 1930 return BoolToPPBool(our_origin.canAccess(target_origin)); | 1929 return BoolToPPBool(our_origin.canAccess(target_origin)); |
| 1931 } | 1930 } |
| 1932 | 1931 |
| 1933 PP_Var PluginInstance::GetDocumentURL(PP_Instance instance, | 1932 PP_Var PluginInstance::GetDocumentURL(PP_Instance instance, |
| 1934 PP_URLComponents_Dev* components) { | 1933 PP_URLComponents_Dev* components) { |
| 1935 WebKit::WebDocument document = container()->element().document(); | 1934 WebKit::WebDocument document = container()->element().document(); |
| 1936 return ::ppapi::URLUtilImpl::GenerateURLReturn(module()->pp_module(), | 1935 return ::ppapi::URLUtilImpl::GenerateURLReturn(document.url(), components); |
| 1937 document.url(), components); | |
| 1938 } | 1936 } |
| 1939 | 1937 |
| 1940 PP_Var PluginInstance::GetPluginInstanceURL( | 1938 PP_Var PluginInstance::GetPluginInstanceURL( |
| 1941 PP_Instance instance, | 1939 PP_Instance instance, |
| 1942 PP_URLComponents_Dev* components) { | 1940 PP_URLComponents_Dev* components) { |
| 1943 return ::ppapi::URLUtilImpl::GenerateURLReturn(module()->pp_module(), | 1941 return ::ppapi::URLUtilImpl::GenerateURLReturn(plugin_url_, components); |
| 1944 plugin_url_, components); | |
| 1945 } | 1942 } |
| 1946 | 1943 |
| 1947 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { | 1944 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { |
| 1948 cursor_.reset(cursor); | 1945 cursor_.reset(cursor); |
| 1949 if (fullscreen_container_) { | 1946 if (fullscreen_container_) { |
| 1950 fullscreen_container_->DidChangeCursor(*cursor); | 1947 fullscreen_container_->DidChangeCursor(*cursor); |
| 1951 } else { | 1948 } else { |
| 1952 delegate()->DidChangeCursor(this, *cursor); | 1949 delegate()->DidChangeCursor(this, *cursor); |
| 1953 } | 1950 } |
| 1954 } | 1951 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2014 screen_size_for_fullscreen_ = gfx::Size(); | 2011 screen_size_for_fullscreen_ = gfx::Size(); |
| 2015 WebElement element = container_->element(); | 2012 WebElement element = container_->element(); |
| 2016 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2013 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
| 2017 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2014 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
| 2018 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2015 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
| 2019 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2016 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
| 2020 } | 2017 } |
| 2021 | 2018 |
| 2022 } // namespace ppapi | 2019 } // namespace ppapi |
| 2023 } // namespace webkit | 2020 } // namespace webkit |
| OLD | NEW |