diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-29 22:48:44 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-29 22:48:44 +0000 |
commit | 60ceb6b29c613a3fa31834e0a1f440fecaf7d005 (patch) | |
tree | e193f51bcdb3d3483e6c2d2f38c09fabe4d514b2 /webkit | |
parent | b75858a2c0bdb08b5324e2610d04498aadc9f600 (diff) | |
download | chromium_src-60ceb6b29c613a3fa31834e0a1f440fecaf7d005.zip chromium_src-60ceb6b29c613a3fa31834e0a1f440fecaf7d005.tar.gz chromium_src-60ceb6b29c613a3fa31834e0a1f440fecaf7d005.tar.bz2 |
Add UI to TestShell to enable/disable images, plugins, and scripts.
R=pkasting
Review URL: http://codereview.chromium.org/549213
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37557 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/tools/test_shell/resource.h | 5 | ||||
-rw-r--r-- | webkit/tools/test_shell/resources/test_shell.rc | 7 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.cc | 4 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.h | 13 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_win.cc | 21 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.cc | 15 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.h | 3 |
7 files changed, 66 insertions, 2 deletions
diff --git a/webkit/tools/test_shell/resource.h b/webkit/tools/test_shell/resource.h index 68aa6a2..3b51310 100644 --- a/webkit/tools/test_shell/resource.h +++ b/webkit/tools/test_shell/resource.h @@ -16,6 +16,9 @@ #define IDM_EXIT 105 #define IDM_DUMP_BODY_TEXT 110 #define IDM_DUMP_RENDER_TREE 111 +#define IDM_ENABLE_IMAGES 114 +#define IDM_ENABLE_PLUGINS 115 +#define IDM_ENABLE_SCRIPTS 116 #define IDM_SHOW_DEV_TOOLS 112 #define IDI_TESTSHELL 107 #define IDI_SMALL 108 @@ -38,6 +41,6 @@ #define _APS_NEXT_RESOURCE_VALUE 129 #define _APS_NEXT_COMMAND_VALUE 32771 #define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 114 +#define _APS_NEXT_SYMED_VALUE 117 #endif #endif diff --git a/webkit/tools/test_shell/resources/test_shell.rc b/webkit/tools/test_shell/resources/test_shell.rc index 68c2acc..73d0909 100644 --- a/webkit/tools/test_shell/resources/test_shell.rc +++ b/webkit/tools/test_shell/resources/test_shell.rc @@ -46,7 +46,12 @@ BEGIN BEGIN MENUITEM "Dump body text...", IDM_DUMP_BODY_TEXT MENUITEM "Dump render tree...", IDM_DUMP_RENDER_TREE - MENUITEM "Show Developer Tools", IDM_SHOW_DEV_TOOLS + MENUITEM SEPARATOR + MENUITEM "Enable images", IDM_ENABLE_IMAGES, CHECKED + MENUITEM "Enable plugins", IDM_ENABLE_PLUGINS, CHECKED + MENUITEM "Enable scripts", IDM_ENABLE_SCRIPTS, CHECKED + MENUITEM SEPARATOR + MENUITEM "Show developer tools...", IDM_SHOW_DEV_TOOLS END POPUP "&Help" BEGIN diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index d931384..63c5a52 100644 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -119,6 +119,10 @@ TestShell::TestShell() #endif test_params_(NULL), is_modal_(false), + is_loading_(false), + allow_images_(true), + allow_plugins_(true), + allow_scripts_(true), dump_stats_table_on_exit_(false) { accessibility_controller_.reset(new AccessibilityController(this)); delegate_.reset(new TestWebViewDelegate(this)); diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h index 00a01c2..73fe3a3 100644 --- a/webkit/tools/test_shell/test_shell.h +++ b/webkit/tools/test_shell/test_shell.h @@ -110,6 +110,15 @@ public: bool is_loading() const { return is_loading_; } void set_is_loading(bool is_loading) { is_loading_ = is_loading; } + bool allow_images() const { return allow_images_; } + void set_allow_images(bool allow) { allow_images_ = allow; } + + bool allow_plugins() const { return allow_plugins_; } + void set_allow_plugins(bool allow) { allow_plugins_ = allow; } + + bool allow_scripts() const { return allow_scripts_; } + void set_allow_scripts(bool allow) { allow_scripts_ = allow; } + void UpdateNavigationControls(); // A new TestShell window will be opened with devtools url. @@ -391,6 +400,10 @@ private: // True if the page is loading. bool is_loading_; + bool allow_images_; + bool allow_plugins_; + bool allow_scripts_; + // The preferences for the test shell. static WebPreferences* web_prefs_; diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc index bab45ab..5aaea38 100644 --- a/webkit/tools/test_shell/test_shell_win.cc +++ b/webkit/tools/test_shell/test_shell_win.cc @@ -584,6 +584,27 @@ LRESULT CALLBACK TestShell::WndProc(HWND hwnd, UINT message, WPARAM wParam, case IDM_DUMP_RENDER_TREE: shell->DumpRenderTree(); break; + case IDM_ENABLE_IMAGES: + case IDM_ENABLE_PLUGINS: + case IDM_ENABLE_SCRIPTS: { + HMENU menu = GetSubMenu(GetMenu(hwnd), 1); + bool was_checked = + (GetMenuState(menu, wmId, MF_BYCOMMAND) & MF_CHECKED) != 0; + CheckMenuItem(menu, wmId, + MF_BYCOMMAND | (was_checked ? MF_UNCHECKED : MF_CHECKED)); + switch (wmId) { + case IDM_ENABLE_IMAGES: + shell->set_allow_images(!was_checked); + break; + case IDM_ENABLE_PLUGINS: + shell->set_allow_plugins(!was_checked); + break; + case IDM_ENABLE_SCRIPTS: + shell->set_allow_scripts(!was_checked); + break; + } + break; + } case IDM_SHOW_DEV_TOOLS: shell->ShowDevTools(); break; diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index c789997..7768a53 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -663,6 +663,16 @@ WebMediaPlayer* TestWebViewDelegate::createMediaPlayer( return new webkit_glue::WebMediaPlayerImpl(client, factory); } +bool TestWebViewDelegate::allowPlugins(WebFrame* frame, + bool enabled_per_settings) { + return shell_->allow_plugins(); +} + +bool TestWebViewDelegate::allowImages(WebFrame* frame, + bool enabled_per_settings) { + return shell_->allow_images(); +} + void TestWebViewDelegate::loadURLExternally( WebFrame* frame, const WebURLRequest& request, WebNavigationPolicy policy) { @@ -998,6 +1008,11 @@ void TestWebViewDelegate::didRunInsecureContent( printf("didRunInsecureContent\n"); } +bool TestWebViewDelegate::allowScript(WebFrame* frame, + bool enabled_per_settings) { + return shell_->allow_scripts(); +} + void TestWebViewDelegate::focusAccessibilityObject( const WebAccessibilityObject& object) { shell_->accessibility_controller()->SetFocusedElement(object); diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index 6036648..305b2fa 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -152,6 +152,8 @@ class TestWebViewDelegate : public WebKit::WebViewClient, WebKit::WebFrame*, WebKit::WebWorkerClient*); virtual WebKit::WebMediaPlayer* createMediaPlayer( WebKit::WebFrame*, WebKit::WebMediaPlayerClient*); + virtual bool allowPlugins(WebKit::WebFrame* frame, bool enabled_per_settings); + virtual bool allowImages(WebKit::WebFrame* frame, bool enabled_per_settings); virtual void loadURLExternally( WebKit::WebFrame*, const WebKit::WebURLRequest&, WebKit::WebNavigationPolicy); @@ -203,6 +205,7 @@ class TestWebViewDelegate : public WebKit::WebViewClient, virtual void didDisplayInsecureContent(WebKit::WebFrame* frame); virtual void didRunInsecureContent( WebKit::WebFrame* frame, const WebKit::WebSecurityOrigin& origin); + virtual bool allowScript(WebKit::WebFrame* frame, bool enabled_per_settings); // webkit_glue::WebPluginPageDelegate virtual webkit_glue::WebPluginDelegate* CreatePluginDelegate( |