mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Set eol-style property on all files. Future commits will use the subversion auto-props configuration at http://src.chromium.org/viewvc/chrome/trunk/tools/buildbot/slave/config
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@109 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -1,105 +1,105 @@
|
||||
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "uiplugin_test.h"
|
||||
#include "uiplugin.h"
|
||||
#include "cefclient.h"
|
||||
|
||||
|
||||
// Implementation of the V8 handler class for the "window.uiapp" functions.
|
||||
class ClientV8UIHandler : public CefThreadSafeBase<CefV8Handler>
|
||||
{
|
||||
public:
|
||||
ClientV8UIHandler() {}
|
||||
|
||||
// Execute with the specified argument list and return value. Return true if
|
||||
// the method was handled.
|
||||
virtual bool Execute(const std::wstring& name,
|
||||
CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
std::wstring& exception)
|
||||
{
|
||||
if(name == L"modifyRotation") {
|
||||
// This function requires one argument.
|
||||
if(arguments.size() != 1)
|
||||
return false;
|
||||
|
||||
float increment = 0.;
|
||||
if(arguments[0]->IsInt()) {
|
||||
// The argument is an integer value.
|
||||
increment = static_cast<float>(arguments[0]->GetIntValue());
|
||||
} else if(arguments[0]->IsDouble()) {
|
||||
// The argument is an double value.
|
||||
increment = static_cast<float>(arguments[0]->GetDoubleValue());
|
||||
}
|
||||
|
||||
if(increment != 0.) {
|
||||
// Modify the rotation accordingly.
|
||||
ModifyRotation(increment);
|
||||
return true;
|
||||
}
|
||||
} else if(name == L"resetRotation") {
|
||||
// Reset the rotation value.
|
||||
ResetRotation();
|
||||
return true;
|
||||
} else if(name == L"viewSource") {
|
||||
// View the page source.
|
||||
AppGetBrowser()->GetMainFrame()->ViewSource();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
void InitUIPluginTest()
|
||||
{
|
||||
// Structure providing information about the client plugin.
|
||||
CefPluginInfo plugin_info;
|
||||
plugin_info.display_name = L"Client UI Plugin";
|
||||
plugin_info.unique_name = L"client_ui_plugin";
|
||||
plugin_info.version = L"1, 0, 0, 1";
|
||||
plugin_info.description = L"My Example Client UI Plugin";
|
||||
|
||||
CefPluginMimeType mime_type;
|
||||
mime_type.mime_type = L"application/x-client-ui-plugin";
|
||||
mime_type.file_extensions.push_back(L"*");
|
||||
plugin_info.mime_types.push_back(mime_type);
|
||||
|
||||
plugin_info.np_getentrypoints = NP_UIGetEntryPoints;
|
||||
plugin_info.np_initialize = NP_UIInitialize;
|
||||
plugin_info.np_shutdown = NP_UIShutdown;
|
||||
|
||||
// Register the internal client plugin
|
||||
CefRegisterPlugin(plugin_info);
|
||||
|
||||
// Register a V8 extension with the below JavaScript code that calls native
|
||||
// methods implemented in ClientV8UIHandler.
|
||||
std::wstring code = L"var cef;"
|
||||
L"if (!cef)"
|
||||
L" cef = {};"
|
||||
L"if (!cef.uiapp)"
|
||||
L" cef.uiapp = {};"
|
||||
L"(function() {"
|
||||
L" cef.uiapp.modifyRotation = function(val) {"
|
||||
L" native function modifyRotation();"
|
||||
L" return modifyRotation(val);"
|
||||
L" };"
|
||||
L" cef.uiapp.resetRotation = function() {"
|
||||
L" native function resetRotation();"
|
||||
L" return resetRotation();"
|
||||
L" };"
|
||||
L" cef.uiapp.viewSource = function() {"
|
||||
L" native function viewSource();"
|
||||
L" return viewSource();"
|
||||
L" };"
|
||||
L"})();";
|
||||
CefRegisterExtension(L"uiplugin/test", code, new ClientV8UIHandler());
|
||||
}
|
||||
|
||||
void RunUIPluginTest(CefRefPtr<CefBrowser> browser)
|
||||
{
|
||||
browser->GetMainFrame()->LoadURL(L"http://tests/uiapp");
|
||||
}
|
||||
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "uiplugin_test.h"
|
||||
#include "uiplugin.h"
|
||||
#include "cefclient.h"
|
||||
|
||||
|
||||
// Implementation of the V8 handler class for the "window.uiapp" functions.
|
||||
class ClientV8UIHandler : public CefThreadSafeBase<CefV8Handler>
|
||||
{
|
||||
public:
|
||||
ClientV8UIHandler() {}
|
||||
|
||||
// Execute with the specified argument list and return value. Return true if
|
||||
// the method was handled.
|
||||
virtual bool Execute(const std::wstring& name,
|
||||
CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
std::wstring& exception)
|
||||
{
|
||||
if(name == L"modifyRotation") {
|
||||
// This function requires one argument.
|
||||
if(arguments.size() != 1)
|
||||
return false;
|
||||
|
||||
float increment = 0.;
|
||||
if(arguments[0]->IsInt()) {
|
||||
// The argument is an integer value.
|
||||
increment = static_cast<float>(arguments[0]->GetIntValue());
|
||||
} else if(arguments[0]->IsDouble()) {
|
||||
// The argument is an double value.
|
||||
increment = static_cast<float>(arguments[0]->GetDoubleValue());
|
||||
}
|
||||
|
||||
if(increment != 0.) {
|
||||
// Modify the rotation accordingly.
|
||||
ModifyRotation(increment);
|
||||
return true;
|
||||
}
|
||||
} else if(name == L"resetRotation") {
|
||||
// Reset the rotation value.
|
||||
ResetRotation();
|
||||
return true;
|
||||
} else if(name == L"viewSource") {
|
||||
// View the page source.
|
||||
AppGetBrowser()->GetMainFrame()->ViewSource();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
void InitUIPluginTest()
|
||||
{
|
||||
// Structure providing information about the client plugin.
|
||||
CefPluginInfo plugin_info;
|
||||
plugin_info.display_name = L"Client UI Plugin";
|
||||
plugin_info.unique_name = L"client_ui_plugin";
|
||||
plugin_info.version = L"1, 0, 0, 1";
|
||||
plugin_info.description = L"My Example Client UI Plugin";
|
||||
|
||||
CefPluginMimeType mime_type;
|
||||
mime_type.mime_type = L"application/x-client-ui-plugin";
|
||||
mime_type.file_extensions.push_back(L"*");
|
||||
plugin_info.mime_types.push_back(mime_type);
|
||||
|
||||
plugin_info.np_getentrypoints = NP_UIGetEntryPoints;
|
||||
plugin_info.np_initialize = NP_UIInitialize;
|
||||
plugin_info.np_shutdown = NP_UIShutdown;
|
||||
|
||||
// Register the internal client plugin
|
||||
CefRegisterPlugin(plugin_info);
|
||||
|
||||
// Register a V8 extension with the below JavaScript code that calls native
|
||||
// methods implemented in ClientV8UIHandler.
|
||||
std::wstring code = L"var cef;"
|
||||
L"if (!cef)"
|
||||
L" cef = {};"
|
||||
L"if (!cef.uiapp)"
|
||||
L" cef.uiapp = {};"
|
||||
L"(function() {"
|
||||
L" cef.uiapp.modifyRotation = function(val) {"
|
||||
L" native function modifyRotation();"
|
||||
L" return modifyRotation(val);"
|
||||
L" };"
|
||||
L" cef.uiapp.resetRotation = function() {"
|
||||
L" native function resetRotation();"
|
||||
L" return resetRotation();"
|
||||
L" };"
|
||||
L" cef.uiapp.viewSource = function() {"
|
||||
L" native function viewSource();"
|
||||
L" return viewSource();"
|
||||
L" };"
|
||||
L"})();";
|
||||
CefRegisterExtension(L"uiplugin/test", code, new ClientV8UIHandler());
|
||||
}
|
||||
|
||||
void RunUIPluginTest(CefRefPtr<CefBrowser> browser)
|
||||
{
|
||||
browser->GetMainFrame()->LoadURL(L"http://tests/uiapp");
|
||||
}
|
||||
|
Reference in New Issue
Block a user