Merge revision 600 changes:

- Add ability to directly retrieve plugin information (issue #575).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@601 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-04-20 21:15:58 +00:00
parent 77a340ec9c
commit b1f9c5428c
18 changed files with 739 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
#include "include/cef_command_line.h"
#include "include/cef_frame.h"
#include "include/cef_runnable.h"
#include "include/cef_web_plugin.h"
#include "include/cef_web_urlrequest.h"
#include "cefclient/cefclient_switches.h"
#include "cefclient/client_handler.h"
@@ -65,6 +66,46 @@ void UIT_InvokeScript(CefRefPtr<CefBrowser> browser) {
}
}
void UIT_RunPluginInfoTest(CefRefPtr<CefBrowser> browser) {
std::string html = "<html><head><title>Plugin Info Test</title></head><body>";
// Find the flash plugin first to test that get by name works.
std::string flash_name;
CefRefPtr<CefWebPluginInfo> info = CefGetWebPluginInfo("Shockwave Flash");
if (info.get()) {
flash_name = info->GetName();
html += "\n<b>Flash is installed!</b>"
"<br/>Name: " + flash_name +
"\n<br/>Description: " + info->GetDescription().ToString() +
"\n<br/>Version: " + info->GetVersion().ToString() +
"\n<br/>Path: " + info->GetPath().ToString();
}
if (!flash_name.empty()) {
html += "\n<br/><br/><b>Other installed plugins:</b>";
} else {
html += "\n<b>Installed plugins:</b>";
}
// Display all other plugins.
size_t count = CefGetWebPluginCount();
for (size_t i = 0; i < count; ++i) {
CefRefPtr<CefWebPluginInfo> info = CefGetWebPluginInfo(i);
ASSERT(info.get());
if (!flash_name.empty() && info->GetName() == flash_name)
continue;
html += "\n<br/><br/>Name: " + info->GetName().ToString() +
"\n<br/>Description: " + info->GetDescription().ToString() +
"\n<br/>Version: " + info->GetVersion().ToString() +
"\n<br/>Path: " + info->GetPath().ToString();
}
html += "</body></html>";
browser->GetMainFrame()->LoadString(html, "http://tests/plugin_info");
}
// Return the int representation of the specified string.
int GetIntValue(const CefString& str) {
if (str.empty())
@@ -601,3 +642,13 @@ void RunDragDropTest(CefRefPtr<CefBrowser> browser) {
void RunModalDialogTest(CefRefPtr<CefBrowser> browser) {
browser->GetMainFrame()->LoadURL("http://tests/modalmain");
}
void RunPluginInfoTest(CefRefPtr<CefBrowser> browser) {
if (CefCurrentlyOn(TID_UI)) {
UIT_RunPluginInfoTest(browser);
} else {
// Execute on the UI thread.
CefPostTask(TID_UI,
NewCefRunnableFunction(&UIT_RunPluginInfoTest, browser));
}
}

View File

@@ -51,6 +51,7 @@ void RunWebURLRequestTest(CefRefPtr<CefBrowser> browser);
void RunDOMAccessTest(CefRefPtr<CefBrowser> browser);
void RunDragDropTest(CefRefPtr<CefBrowser> browser);
void RunModalDialogTest(CefRefPtr<CefBrowser> browser);
void RunPluginInfoTest(CefRefPtr<CefBrowser> browser);
#if defined(OS_WIN)
void RunTransparentPopupTest(CefRefPtr<CefBrowser> browser);

View File

@@ -79,6 +79,7 @@ BEGIN
MENUITEM "JavaScript Execute", ID_TESTS_JAVASCRIPT_EXECUTE
MENUITEM "JavaScript Invoke", ID_TESTS_JAVASCRIPT_INVOKE
MENUITEM "Plugin", ID_TESTS_PLUGIN
MENUITEM "Plugin Info", ID_TESTS_PLUGIN_INFO
MENUITEM "Popup Window", ID_TESTS_POPUP
MENUITEM "Transparent Popup Window", ID_TESTS_TRANSPARENT_POPUP
MENUITEM "Request", ID_TESTS_REQUEST

View File

@@ -206,6 +206,14 @@ gboolean ShowDevtoolsActivated(GtkWidget* widget) {
return FALSE; // Don't stop this message.
}
// Callback for Debug > Plugin Info... menu item.
gboolean PluginInfoActivated(GtkWidget* widget) {
if (g_handler.get() && g_handler->GetBrowserHwnd())
RunPluginInfoTest(g_handler->GetBrowser());
return FALSE; // Don't stop this message.
}
// Callback for when you click the back button.
void BackButtonClicked(GtkButton* button) {
if (g_handler.get() && g_handler->GetBrowserHwnd())
@@ -301,6 +309,8 @@ GtkWidget* CreateMenuBar() {
G_CALLBACK(DragDropActivated));
AddMenuEntry(debug_menu, "Show DevTools",
G_CALLBACK(ShowDevtoolsActivated));
AddMenuEntry(debug_menu, "Plugin Info",
G_CALLBACK(PluginInfoActivated));
return menu_bar;
}

View File

@@ -211,6 +211,7 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
- (IBAction)testZoomReset:(id)sender;
- (IBAction)testDevToolsShow:(id)sender;
- (IBAction)testDevToolsClose:(id)sender;
- (IBAction)testPluginInfo:(id)sender;
@end
@implementation ClientAppDelegate
@@ -301,6 +302,9 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
[testMenu addItemWithTitle:@"Close DevTools"
action:@selector(testDevToolsClose:)
keyEquivalent:@""];
[testMenu addItemWithTitle:@"Plugin Info"
action:@selector(testPluginInfo:)
keyEquivalent:@""];
[testItem setSubmenu:testMenu];
[menubar addItem:testItem];
@@ -522,6 +526,11 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
}
}
- (IBAction)testPluginInfo:(id)sender {
if (g_handler.get() && g_handler->GetBrowserHwnd())
RunPluginInfoTest(g_handler->GetBrowser());
}
// Sent by the default notification center immediately before the application
// terminates.
- (void)applicationWillTerminate:(NSNotification *)aNotification {

View File

@@ -464,6 +464,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
if (browser.get())
RunPluginTest(browser);
return 0;
case ID_TESTS_PLUGIN_INFO: // Test plugin info
if (browser.get())
RunPluginInfoTest(browser);
return 0;
case ID_TESTS_POPUP: // Test a popup window
if (browser.get())
RunPopupTest(browser);

View File

@@ -57,6 +57,7 @@
#define ID_TESTS_TRANSPARENT_OSRAPP 32797
#define ID_TESTS_JAVASCRIPT_INVOKE 32798
#define ID_TESTS_GETIMAGE 32799
#define ID_TESTS_PLUGIN_INFO 32800
#define IDC_STATIC -1
#define IDS_LOGO 1000
#define IDS_UIPLUGIN 1001