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

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 10827210: Set the user gesture when executing script. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 1826 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 np_script.UTF8Length = script_string->value().length(); 1837 np_script.UTF8Length = script_string->value().length();
1838 1838
1839 // Get the current frame to pass to the evaluate function. 1839 // Get the current frame to pass to the evaluate function.
1840 WebFrame* frame = container_->element().document().frame(); 1840 WebFrame* frame = container_->element().document().frame();
1841 if (!frame) { 1841 if (!frame) {
1842 try_catch.SetException("No frame to execute script in."); 1842 try_catch.SetException("No frame to execute script in.");
1843 return PP_MakeUndefined(); 1843 return PP_MakeUndefined();
1844 } 1844 }
1845 1845
1846 NPVariant result; 1846 NPVariant result;
1847 bool ok = WebBindings::evaluate(NULL, frame->windowObject(), &np_script, 1847 bool ok = false;
1848 &result); 1848 if (IsProcessingUserGesture()) {
1849 WebKit::WebScopedUserGesture user_gesture;
1850 ok = WebBindings::evaluate(NULL, frame->windowObject(), &np_script,
1851 &result);
1852 } else {
1853 ok = WebBindings::evaluate(NULL, frame->windowObject(), &np_script,
1854 &result);
1855 }
1849 if (!ok) { 1856 if (!ok) {
1850 // TryCatch doesn't catch the exceptions properly. Since this is only for 1857 // TryCatch doesn't catch the exceptions properly. Since this is only for
1851 // a trusted API, just set to a general exception message. 1858 // a trusted API, just set to a general exception message.
1852 try_catch.SetException("Exception caught"); 1859 try_catch.SetException("Exception caught");
1853 WebBindings::releaseVariantValue(&result); 1860 WebBindings::releaseVariantValue(&result);
1854 return PP_MakeUndefined(); 1861 return PP_MakeUndefined();
1855 } 1862 }
1856 1863
1857 PP_Var ret = NPVariantToPPVar(this, &result); 1864 PP_Var ret = NPVariantToPPVar(this, &result);
1858 WebBindings::releaseVariantValue(&result); 1865 WebBindings::releaseVariantValue(&result);
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
2248 screen_size_for_fullscreen_ = gfx::Size(); 2255 screen_size_for_fullscreen_ = gfx::Size();
2249 WebElement element = container_->element(); 2256 WebElement element = container_->element();
2250 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2257 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2251 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2258 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2252 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2259 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2253 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2260 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2254 } 2261 }
2255 2262
2256 } // namespace ppapi 2263 } // namespace ppapi
2257 } // namespace webkit 2264 } // namespace webkit
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698