mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update all files to use Windows CRLF (\r\n) line endings (issue #45).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@33 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
# This file is an addendum to the Chromium AUTHORS file.
|
# This file is an addendum to the Chromium AUTHORS file.
|
||||||
# Names should be added to this file like so:
|
# Names should be added to this file like so:
|
||||||
# Name or Organization <email address>
|
# Name or Organization <email address>
|
||||||
|
|
||||||
Marshall Greenblatt <magreenblatt@gmail.com>
|
Marshall Greenblatt <magreenblatt@gmail.com>
|
@ -1,32 +1,32 @@
|
|||||||
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
// met:
|
// met:
|
||||||
//
|
//
|
||||||
// * Redistributions of source code must retain the above copyright
|
// * Redistributions of source code must retain the above copyright
|
||||||
// notice, this list of conditions and the following disclaimer.
|
// notice, this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above
|
// * Redistributions in binary form must reproduce the above
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
// in the documentation and/or other materials provided with the
|
// in the documentation and/or other materials provided with the
|
||||||
// distribution.
|
// distribution.
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
// or promote products derived from this software without specific prior
|
// or promote products derived from this software without specific prior
|
||||||
// written permission.
|
// written permission.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
#ifdef _MSC_VER // MSVC
|
#ifdef _MSC_VER // MSVC
|
||||||
|
@ -1,85 +1,85 @@
|
|||||||
// Copyright (c) 2008 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2008 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
// met:
|
// met:
|
||||||
//
|
//
|
||||||
// * Redistributions of source code must retain the above copyright
|
// * Redistributions of source code must retain the above copyright
|
||||||
// notice, this list of conditions and the following disclaimer.
|
// notice, this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above
|
// * Redistributions in binary form must reproduce the above
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
// in the documentation and/or other materials provided with the
|
// in the documentation and/or other materials provided with the
|
||||||
// distribution.
|
// distribution.
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
// or promote products derived from this software without specific prior
|
// or promote products derived from this software without specific prior
|
||||||
// written permission.
|
// written permission.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
#ifndef _CEF_PLUGIN_H
|
#ifndef _CEF_PLUGIN_H
|
||||||
#define _CEF_PLUGIN_H
|
#define _CEF_PLUGIN_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "webkit/glue/plugins/nphostapi.h"
|
#include "webkit/glue/plugins/nphostapi.h"
|
||||||
#include "third_party/npapi/bindings/npapi.h"
|
#include "third_party/npapi/bindings/npapi.h"
|
||||||
|
|
||||||
// Netscape plugins are normally built at separate DLLs that are loaded by the
|
// Netscape plugins are normally built at separate DLLs that are loaded by the
|
||||||
// browser when needed. This interface supports the creation of plugins that
|
// browser when needed. This interface supports the creation of plugins that
|
||||||
// are an embedded component of the application. Embedded plugins built using
|
// are an embedded component of the application. Embedded plugins built using
|
||||||
// this interface use the same Netscape Plugin API as DLL-based plugins.
|
// this interface use the same Netscape Plugin API as DLL-based plugins.
|
||||||
// See https://developer.mozilla.org/En/Gecko_Plugin_API_Reference for complete
|
// See https://developer.mozilla.org/En/Gecko_Plugin_API_Reference for complete
|
||||||
// documentation on how to use the Netscape Plugin API.
|
// documentation on how to use the Netscape Plugin API.
|
||||||
|
|
||||||
// This structure describes a mime type entry for a plugin.
|
// This structure describes a mime type entry for a plugin.
|
||||||
struct CefPluginMimeType {
|
struct CefPluginMimeType {
|
||||||
// The actual mime type.
|
// The actual mime type.
|
||||||
std::wstring mime_type;
|
std::wstring mime_type;
|
||||||
|
|
||||||
// A list of all the file extensions for this mime type.
|
// A list of all the file extensions for this mime type.
|
||||||
std::vector<std::wstring> file_extensions;
|
std::vector<std::wstring> file_extensions;
|
||||||
|
|
||||||
// Description of the mime type.
|
// Description of the mime type.
|
||||||
std::wstring description;
|
std::wstring description;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This structure provides attribute information and entry point functions for
|
// This structure provides attribute information and entry point functions for
|
||||||
// a plugin.
|
// a plugin.
|
||||||
struct CefPluginInfo {
|
struct CefPluginInfo {
|
||||||
// The unique name that identifies the plugin.
|
// The unique name that identifies the plugin.
|
||||||
std::wstring unique_name;
|
std::wstring unique_name;
|
||||||
|
|
||||||
// The friendly display name of the plugin.
|
// The friendly display name of the plugin.
|
||||||
std::wstring display_name;
|
std::wstring display_name;
|
||||||
|
|
||||||
// The version string of the plugin.
|
// The version string of the plugin.
|
||||||
std::wstring version;
|
std::wstring version;
|
||||||
|
|
||||||
// A description of the plugin.
|
// A description of the plugin.
|
||||||
std::wstring description;
|
std::wstring description;
|
||||||
|
|
||||||
// A list of all the mime types that this plugin supports.
|
// A list of all the mime types that this plugin supports.
|
||||||
std::vector<CefPluginMimeType> mime_types;
|
std::vector<CefPluginMimeType> mime_types;
|
||||||
|
|
||||||
// Entry point function pointers.
|
// Entry point function pointers.
|
||||||
NP_GetEntryPointsFunc np_getentrypoints;
|
NP_GetEntryPointsFunc np_getentrypoints;
|
||||||
NP_InitializeFunc np_initialize;
|
NP_InitializeFunc np_initialize;
|
||||||
NP_ShutdownFunc np_shutdown;
|
NP_ShutdownFunc np_shutdown;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Register a plugin with the system.
|
// Register a plugin with the system.
|
||||||
bool CefRegisterPlugin(const struct CefPluginInfo& plugin_info);
|
bool CefRegisterPlugin(const struct CefPluginInfo& plugin_info);
|
||||||
|
|
||||||
#endif // _CEF_PLUGIN_H
|
#endif // _CEF_PLUGIN_H
|
||||||
|
@ -1,64 +1,64 @@
|
|||||||
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
// met:
|
// met:
|
||||||
//
|
//
|
||||||
// * Redistributions of source code must retain the above copyright
|
// * Redistributions of source code must retain the above copyright
|
||||||
// notice, this list of conditions and the following disclaimer.
|
// notice, this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above
|
// * Redistributions in binary form must reproduce the above
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
// in the documentation and/or other materials provided with the
|
// in the documentation and/or other materials provided with the
|
||||||
// distribution.
|
// distribution.
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
// or promote products derived from this software without specific prior
|
// or promote products derived from this software without specific prior
|
||||||
// written permission.
|
// written permission.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
#ifndef _CEF_PLUGIN_CAPI_H
|
#ifndef _CEF_PLUGIN_CAPI_H
|
||||||
#define _CEF_PLUGIN_CAPI_H
|
#define _CEF_PLUGIN_CAPI_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "cef_export.h"
|
#include "cef_export.h"
|
||||||
#include "webkit/glue/plugins/nphostapi.h"
|
#include "webkit/glue/plugins/nphostapi.h"
|
||||||
#include "third_party/npapi/bindings/npapi.h"
|
#include "third_party/npapi/bindings/npapi.h"
|
||||||
|
|
||||||
// Netscape plugins are normally built at separate DLLs that are loaded by the
|
// Netscape plugins are normally built at separate DLLs that are loaded by the
|
||||||
// browser when needed. This interface supports the creation of plugins that
|
// browser when needed. This interface supports the creation of plugins that
|
||||||
// are an embedded component of the application. Embedded plugins built using
|
// are an embedded component of the application. Embedded plugins built using
|
||||||
// this interface use the same Netscape Plugin API as DLL-based plugins.
|
// this interface use the same Netscape Plugin API as DLL-based plugins.
|
||||||
// See https://developer.mozilla.org/En/Gecko_Plugin_API_Reference for complete
|
// See https://developer.mozilla.org/En/Gecko_Plugin_API_Reference for complete
|
||||||
// documentation on how to use the Netscape Plugin API.
|
// documentation on how to use the Netscape Plugin API.
|
||||||
|
|
||||||
// This structure provides attribute information and entry point functions for
|
// This structure provides attribute information and entry point functions for
|
||||||
// a plugin.
|
// a plugin.
|
||||||
typedef struct _cef_plugin_info_t {
|
typedef struct _cef_plugin_info_t {
|
||||||
// The unique name that identifies the plugin.
|
// The unique name that identifies the plugin.
|
||||||
const wchar_t* unique_name;
|
const wchar_t* unique_name;
|
||||||
|
|
||||||
// The friendly display name of the plugin.
|
// The friendly display name of the plugin.
|
||||||
const wchar_t* display_name;
|
const wchar_t* display_name;
|
||||||
|
|
||||||
// The version string of the plugin.
|
// The version string of the plugin.
|
||||||
const wchar_t* version;
|
const wchar_t* version;
|
||||||
|
|
||||||
// A description of the plugin.
|
// A description of the plugin.
|
||||||
const wchar_t* description;
|
const wchar_t* description;
|
||||||
|
|
||||||
// A pipe (|) delimited list of mime type values that the plugin supports.
|
// A pipe (|) delimited list of mime type values that the plugin supports.
|
||||||
@ -71,20 +71,20 @@ typedef struct _cef_plugin_info_t {
|
|||||||
|
|
||||||
// A pipe (|) delimited list of description values. Each value is associated
|
// A pipe (|) delimited list of description values. Each value is associated
|
||||||
// with the mime type value at the same position.
|
// with the mime type value at the same position.
|
||||||
const wchar_t* type_descriptions;
|
const wchar_t* type_descriptions;
|
||||||
|
|
||||||
// Entry point function pointers.
|
// Entry point function pointers.
|
||||||
NP_GetEntryPointsFunc np_getentrypoints;
|
NP_GetEntryPointsFunc np_getentrypoints;
|
||||||
NP_InitializeFunc np_initialize;
|
NP_InitializeFunc np_initialize;
|
||||||
NP_ShutdownFunc np_shutdown;
|
NP_ShutdownFunc np_shutdown;
|
||||||
} cef_plugin_info_t;
|
} cef_plugin_info_t;
|
||||||
|
|
||||||
// Register a plugin with the system. Returns true (1) on success.
|
// Register a plugin with the system. Returns true (1) on success.
|
||||||
CEF_EXPORT int cef_register_plugin(const cef_plugin_info_t* plugin_info);
|
CEF_EXPORT int cef_register_plugin(const cef_plugin_info_t* plugin_info);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // _CEF_PLUGIN_CAPI_H
|
#endif // _CEF_PLUGIN_CAPI_H
|
||||||
|
@ -1,126 +1,126 @@
|
|||||||
// Copyright (c) 2008 Marshall A. Greenblatt. Portions Copyright (c)
|
// Copyright (c) 2008 Marshall A. Greenblatt. Portions Copyright (c)
|
||||||
// 2006-2008 Google Inc. All rights reserved.
|
// 2006-2008 Google Inc. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
// met:
|
// met:
|
||||||
//
|
//
|
||||||
// * Redistributions of source code must retain the above copyright
|
// * Redistributions of source code must retain the above copyright
|
||||||
// notice, this list of conditions and the following disclaimer.
|
// notice, this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above
|
// * Redistributions in binary form must reproduce the above
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
// in the documentation and/or other materials provided with the
|
// in the documentation and/or other materials provided with the
|
||||||
// distribution.
|
// distribution.
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
// or promote products derived from this software without specific prior
|
// or promote products derived from this software without specific prior
|
||||||
// written permission.
|
// written permission.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
#ifndef _CEF_PTR_H
|
#ifndef _CEF_PTR_H
|
||||||
#define _CEF_PTR_H
|
#define _CEF_PTR_H
|
||||||
|
|
||||||
// Smart pointer implementation borrowed from base/ref_counted.h
|
// Smart pointer implementation borrowed from base/ref_counted.h
|
||||||
//
|
//
|
||||||
// A smart pointer class for reference counted objects. Use this class instead
|
// A smart pointer class for reference counted objects. Use this class instead
|
||||||
// of calling AddRef and Release manually on a reference counted object to
|
// of calling AddRef and Release manually on a reference counted object to
|
||||||
// avoid common memory leaks caused by forgetting to Release an object
|
// avoid common memory leaks caused by forgetting to Release an object
|
||||||
// reference. Sample usage:
|
// reference. Sample usage:
|
||||||
//
|
//
|
||||||
// class MyFoo : public CefBase {
|
// class MyFoo : public CefBase {
|
||||||
// ...
|
// ...
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// void some_function() {
|
// void some_function() {
|
||||||
// // The MyFoo object that |foo| represents starts with a single
|
// // The MyFoo object that |foo| represents starts with a single
|
||||||
// // reference.
|
// // reference.
|
||||||
// CefRefPtr<MyFoo> foo = new MyFoo();
|
// CefRefPtr<MyFoo> foo = new MyFoo();
|
||||||
// foo->Method(param);
|
// foo->Method(param);
|
||||||
// // |foo| is released when this function returns
|
// // |foo| is released when this function returns
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// void some_other_function() {
|
// void some_other_function() {
|
||||||
// CefRefPtr<MyFoo> foo = new MyFoo();
|
// CefRefPtr<MyFoo> foo = new MyFoo();
|
||||||
// ...
|
// ...
|
||||||
// foo = NULL; // explicitly releases |foo|
|
// foo = NULL; // explicitly releases |foo|
|
||||||
// ...
|
// ...
|
||||||
// if (foo)
|
// if (foo)
|
||||||
// foo->Method(param);
|
// foo->Method(param);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// The above examples show how CefRefPtr<T> acts like a pointer to T.
|
// The above examples show how CefRefPtr<T> acts like a pointer to T.
|
||||||
// Given two CefRefPtr<T> classes, it is also possible to exchange
|
// Given two CefRefPtr<T> classes, it is also possible to exchange
|
||||||
// references between the two objects, like so:
|
// references between the two objects, like so:
|
||||||
//
|
//
|
||||||
// {
|
// {
|
||||||
// CefRefPtr<MyFoo> a = new MyFoo();
|
// CefRefPtr<MyFoo> a = new MyFoo();
|
||||||
// CefRefPtr<MyFoo> b;
|
// CefRefPtr<MyFoo> b;
|
||||||
//
|
//
|
||||||
// b.swap(a);
|
// b.swap(a);
|
||||||
// // now, |b| references the MyFoo object, and |a| references NULL.
|
// // now, |b| references the MyFoo object, and |a| references NULL.
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// To make both |a| and |b| in the above example reference the same MyFoo
|
// To make both |a| and |b| in the above example reference the same MyFoo
|
||||||
// object, simply use the assignment operator:
|
// object, simply use the assignment operator:
|
||||||
//
|
//
|
||||||
// {
|
// {
|
||||||
// CefRefPtr<MyFoo> a = new MyFoo();
|
// CefRefPtr<MyFoo> a = new MyFoo();
|
||||||
// CefRefPtr<MyFoo> b;
|
// CefRefPtr<MyFoo> b;
|
||||||
//
|
//
|
||||||
// b = a;
|
// b = a;
|
||||||
// // now, |a| and |b| each own a reference to the same MyFoo object.
|
// // now, |a| and |b| each own a reference to the same MyFoo object.
|
||||||
// // the reference count of the underlying MyFoo object will be 2.
|
// // the reference count of the underlying MyFoo object will be 2.
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Reference counted objects can also be passed as function parameters and
|
// Reference counted objects can also be passed as function parameters and
|
||||||
// used as function return values:
|
// used as function return values:
|
||||||
//
|
//
|
||||||
// void some_func_with_param(CefRefPtr<MyFoo> param) {
|
// void some_func_with_param(CefRefPtr<MyFoo> param) {
|
||||||
// // A reference is added to the MyFoo object that |param| represents
|
// // A reference is added to the MyFoo object that |param| represents
|
||||||
// // during the scope of some_func_with_param() and released when
|
// // during the scope of some_func_with_param() and released when
|
||||||
// // some_func_with_param() goes out of scope.
|
// // some_func_with_param() goes out of scope.
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// CefRefPtr<MyFoo> some_func_with_retval() {
|
// CefRefPtr<MyFoo> some_func_with_retval() {
|
||||||
// // The MyFoo object that |foox| represents starts with a single
|
// // The MyFoo object that |foox| represents starts with a single
|
||||||
// // reference.
|
// // reference.
|
||||||
// CefRefPtr<MyFoo> foox = new MyFoo();
|
// CefRefPtr<MyFoo> foox = new MyFoo();
|
||||||
//
|
//
|
||||||
// // Creating the return value adds an additional reference.
|
// // Creating the return value adds an additional reference.
|
||||||
// return foox;
|
// return foox;
|
||||||
//
|
//
|
||||||
// // When some_func_with_retval() goes out of scope the original |foox|
|
// // When some_func_with_retval() goes out of scope the original |foox|
|
||||||
// // reference is released.
|
// // reference is released.
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// void and_another_function() {
|
// void and_another_function() {
|
||||||
// CefRefPtr<MyFoo> foo = new MyFoo();
|
// CefRefPtr<MyFoo> foo = new MyFoo();
|
||||||
//
|
//
|
||||||
// // pass |foo| as a parameter.
|
// // pass |foo| as a parameter.
|
||||||
// some_function(foo);
|
// some_function(foo);
|
||||||
//
|
//
|
||||||
// CefRefPtr<MyFoo> foo2 = some_func_with_retval();
|
// CefRefPtr<MyFoo> foo2 = some_func_with_retval();
|
||||||
// // Now, since we kept a reference to the some_func_with_retval() return
|
// // Now, since we kept a reference to the some_func_with_retval() return
|
||||||
// // value, |foo2| is the only class pointing to the MyFoo object created
|
// // value, |foo2| is the only class pointing to the MyFoo object created
|
||||||
// in some_func_with_retval(), and it has a reference count of 1.
|
// in some_func_with_retval(), and it has a reference count of 1.
|
||||||
//
|
//
|
||||||
// some_func_with_retval();
|
// some_func_with_retval();
|
||||||
// // Now, since we didn't keep a reference to the some_func_with_retval()
|
// // Now, since we didn't keep a reference to the some_func_with_retval()
|
||||||
// // return value, the MyFoo object created in some_func_with_retval()
|
// // return value, the MyFoo object created in some_func_with_retval()
|
||||||
// // will automatically be released.
|
// // will automatically be released.
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// And in standard containers:
|
// And in standard containers:
|
||||||
//
|
//
|
||||||
@ -128,66 +128,66 @@
|
|||||||
// // Create a vector that holds MyFoo objects.
|
// // Create a vector that holds MyFoo objects.
|
||||||
// std::vector<CefRefPtr<MyFoo> > MyFooVec;
|
// std::vector<CefRefPtr<MyFoo> > MyFooVec;
|
||||||
//
|
//
|
||||||
// // The MyFoo object that |foo| represents starts with a single
|
// // The MyFoo object that |foo| represents starts with a single
|
||||||
// // reference.
|
// // reference.
|
||||||
// CefRefPtr<MyFoo> foo = new MyFoo();
|
// CefRefPtr<MyFoo> foo = new MyFoo();
|
||||||
//
|
//
|
||||||
// // When the MyFoo object is added to |MyFooVec| the reference count
|
// // When the MyFoo object is added to |MyFooVec| the reference count
|
||||||
// // is increased to 2.
|
// // is increased to 2.
|
||||||
// MyFooVec.push_back(foo);
|
// MyFooVec.push_back(foo);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
template <class T>
|
template <class T>
|
||||||
class CefRefPtr {
|
class CefRefPtr {
|
||||||
public:
|
public:
|
||||||
CefRefPtr() : ptr_(NULL) {
|
CefRefPtr() : ptr_(NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr(T* p) : ptr_(p) {
|
CefRefPtr(T* p) : ptr_(p) {
|
||||||
if (ptr_)
|
if (ptr_)
|
||||||
ptr_->AddRef();
|
ptr_->AddRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr(const CefRefPtr<T>& r) : ptr_(r.ptr_) {
|
CefRefPtr(const CefRefPtr<T>& r) : ptr_(r.ptr_) {
|
||||||
if (ptr_)
|
if (ptr_)
|
||||||
ptr_->AddRef();
|
ptr_->AddRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
~CefRefPtr() {
|
~CefRefPtr() {
|
||||||
if (ptr_)
|
if (ptr_)
|
||||||
ptr_->Release();
|
ptr_->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
T* get() const { return ptr_; }
|
T* get() const { return ptr_; }
|
||||||
operator T*() const { return ptr_; }
|
operator T*() const { return ptr_; }
|
||||||
T* operator->() const { return ptr_; }
|
T* operator->() const { return ptr_; }
|
||||||
|
|
||||||
CefRefPtr<T>& operator=(T* p) {
|
CefRefPtr<T>& operator=(T* p) {
|
||||||
// AddRef first so that self assignment should work
|
// AddRef first so that self assignment should work
|
||||||
if (p)
|
if (p)
|
||||||
p->AddRef();
|
p->AddRef();
|
||||||
if (ptr_ )
|
if (ptr_ )
|
||||||
ptr_ ->Release();
|
ptr_ ->Release();
|
||||||
ptr_ = p;
|
ptr_ = p;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<T>& operator=(const CefRefPtr<T>& r) {
|
CefRefPtr<T>& operator=(const CefRefPtr<T>& r) {
|
||||||
return *this = r.ptr_;
|
return *this = r.ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void swap(T** pp) {
|
void swap(T** pp) {
|
||||||
T* p = ptr_;
|
T* p = ptr_;
|
||||||
ptr_ = *pp;
|
ptr_ = *pp;
|
||||||
*pp = p;
|
*pp = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void swap(CefRefPtr<T>& r) {
|
void swap(CefRefPtr<T>& r) {
|
||||||
swap(&r.ptr_);
|
swap(&r.ptr_);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T* ptr_;
|
T* ptr_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _CEF_PTR_H
|
#endif // _CEF_PTR_H
|
||||||
|
@ -1,30 +1,30 @@
|
|||||||
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
// met:
|
// met:
|
||||||
//
|
//
|
||||||
// * Redistributions of source code must retain the above copyright
|
// * Redistributions of source code must retain the above copyright
|
||||||
// notice, this list of conditions and the following disclaimer.
|
// notice, this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above
|
// * Redistributions in binary form must reproduce the above
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
// in the documentation and/or other materials provided with the
|
// in the documentation and/or other materials provided with the
|
||||||
// distribution.
|
// distribution.
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
// or promote products derived from this software without specific prior
|
// or promote products derived from this software without specific prior
|
||||||
// written permission.
|
// written permission.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#ifndef _CEF_STRING_H
|
#ifndef _CEF_STRING_H
|
||||||
|
@ -1,30 +1,30 @@
|
|||||||
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
// met:
|
// met:
|
||||||
//
|
//
|
||||||
// * Redistributions of source code must retain the above copyright
|
// * Redistributions of source code must retain the above copyright
|
||||||
// notice, this list of conditions and the following disclaimer.
|
// notice, this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above
|
// * Redistributions in binary form must reproduce the above
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
// in the documentation and/or other materials provided with the
|
// in the documentation and/or other materials provided with the
|
||||||
// distribution.
|
// distribution.
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
// or promote products derived from this software without specific prior
|
// or promote products derived from this software without specific prior
|
||||||
// written permission.
|
// written permission.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#ifndef _CEF_STRING_LIST_H
|
#ifndef _CEF_STRING_LIST_H
|
||||||
|
@ -1,30 +1,30 @@
|
|||||||
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
// met:
|
// met:
|
||||||
//
|
//
|
||||||
// * Redistributions of source code must retain the above copyright
|
// * Redistributions of source code must retain the above copyright
|
||||||
// notice, this list of conditions and the following disclaimer.
|
// notice, this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above
|
// * Redistributions in binary form must reproduce the above
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
// in the documentation and/or other materials provided with the
|
// in the documentation and/or other materials provided with the
|
||||||
// distribution.
|
// distribution.
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
// or promote products derived from this software without specific prior
|
// or promote products derived from this software without specific prior
|
||||||
// written permission.
|
// written permission.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#ifndef _CEF_STRING_MAP_H
|
#ifndef _CEF_STRING_MAP_H
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
// met:
|
// met:
|
||||||
//
|
//
|
||||||
// * Redistributions of source code must retain the above copyright
|
// * Redistributions of source code must retain the above copyright
|
||||||
// notice, this list of conditions and the following disclaimer.
|
// notice, this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above
|
// * Redistributions in binary form must reproduce the above
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
// in the documentation and/or other materials provided with the
|
// in the documentation and/or other materials provided with the
|
||||||
// distribution.
|
// distribution.
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
// or promote products derived from this software without specific prior
|
// or promote products derived from this software without specific prior
|
||||||
// written permission.
|
// written permission.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
#ifndef _CEF_TYPES_H
|
#ifndef _CEF_TYPES_H
|
||||||
@ -35,12 +35,12 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Bring in platform-specific definitions.
|
// Bring in platform-specific definitions.
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "cef_types_win.h"
|
#include "cef_types_win.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Define handler return value types. Returning RV_HANDLED indicates
|
// Define handler return value types. Returning RV_HANDLED indicates
|
||||||
// that the implementation completely handled the method and that no further
|
// that the implementation completely handled the method and that no further
|
||||||
@ -56,11 +56,11 @@ enum cef_retval_t
|
|||||||
// Various browser navigation types supported by chrome.
|
// Various browser navigation types supported by chrome.
|
||||||
enum cef_handler_navtype_t
|
enum cef_handler_navtype_t
|
||||||
{
|
{
|
||||||
NAVTYPE_LINKCLICKED = 0,
|
NAVTYPE_LINKCLICKED = 0,
|
||||||
NAVTYPE_FORMSUBMITTED,
|
NAVTYPE_FORMSUBMITTED,
|
||||||
NAVTYPE_BACKFORWARD,
|
NAVTYPE_BACKFORWARD,
|
||||||
NAVTYPE_RELOAD,
|
NAVTYPE_RELOAD,
|
||||||
NAVTYPE_FORMRESUBMITTED,
|
NAVTYPE_FORMRESUBMITTED,
|
||||||
NAVTYPE_OTHER,
|
NAVTYPE_OTHER,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -68,62 +68,62 @@ enum cef_handler_navtype_t
|
|||||||
// descriptions of the error codes.
|
// descriptions of the error codes.
|
||||||
enum cef_handler_errorcode_t
|
enum cef_handler_errorcode_t
|
||||||
{
|
{
|
||||||
ERR_FAILED = -2,
|
ERR_FAILED = -2,
|
||||||
ERR_ABORTED = -3,
|
ERR_ABORTED = -3,
|
||||||
ERR_INVALID_ARGUMENT = -4,
|
ERR_INVALID_ARGUMENT = -4,
|
||||||
ERR_INVALID_HANDLE = -5,
|
ERR_INVALID_HANDLE = -5,
|
||||||
ERR_FILE_NOT_FOUND = -6,
|
ERR_FILE_NOT_FOUND = -6,
|
||||||
ERR_TIMED_OUT = -7,
|
ERR_TIMED_OUT = -7,
|
||||||
ERR_FILE_TOO_BIG = -8,
|
ERR_FILE_TOO_BIG = -8,
|
||||||
ERR_UNEXPECTED = -9,
|
ERR_UNEXPECTED = -9,
|
||||||
ERR_ACCESS_DENIED = -10,
|
ERR_ACCESS_DENIED = -10,
|
||||||
ERR_NOT_IMPLEMENTED = -11,
|
ERR_NOT_IMPLEMENTED = -11,
|
||||||
ERR_CONNECTION_CLOSED = -100,
|
ERR_CONNECTION_CLOSED = -100,
|
||||||
ERR_CONNECTION_RESET = -101,
|
ERR_CONNECTION_RESET = -101,
|
||||||
ERR_CONNECTION_REFUSED = -102,
|
ERR_CONNECTION_REFUSED = -102,
|
||||||
ERR_CONNECTION_ABORTED = -103,
|
ERR_CONNECTION_ABORTED = -103,
|
||||||
ERR_CONNECTION_FAILED = -104,
|
ERR_CONNECTION_FAILED = -104,
|
||||||
ERR_NAME_NOT_RESOLVED = -105,
|
ERR_NAME_NOT_RESOLVED = -105,
|
||||||
ERR_INTERNET_DISCONNECTED = -106,
|
ERR_INTERNET_DISCONNECTED = -106,
|
||||||
ERR_SSL_PROTOCOL_ERROR = -107,
|
ERR_SSL_PROTOCOL_ERROR = -107,
|
||||||
ERR_ADDRESS_INVALID = -108,
|
ERR_ADDRESS_INVALID = -108,
|
||||||
ERR_ADDRESS_UNREACHABLE = -109,
|
ERR_ADDRESS_UNREACHABLE = -109,
|
||||||
ERR_SSL_CLIENT_AUTH_CERT_NEEDED = -110,
|
ERR_SSL_CLIENT_AUTH_CERT_NEEDED = -110,
|
||||||
ERR_TUNNEL_CONNECTION_FAILED = -111,
|
ERR_TUNNEL_CONNECTION_FAILED = -111,
|
||||||
ERR_NO_SSL_VERSIONS_ENABLED = -112,
|
ERR_NO_SSL_VERSIONS_ENABLED = -112,
|
||||||
ERR_SSL_VERSION_OR_CIPHER_MISMATCH = -113,
|
ERR_SSL_VERSION_OR_CIPHER_MISMATCH = -113,
|
||||||
ERR_SSL_RENEGOTIATION_REQUESTED = -114,
|
ERR_SSL_RENEGOTIATION_REQUESTED = -114,
|
||||||
ERR_CERT_COMMON_NAME_INVALID = -200,
|
ERR_CERT_COMMON_NAME_INVALID = -200,
|
||||||
ERR_CERT_DATE_INVALID = -201,
|
ERR_CERT_DATE_INVALID = -201,
|
||||||
ERR_CERT_AUTHORITY_INVALID = -202,
|
ERR_CERT_AUTHORITY_INVALID = -202,
|
||||||
ERR_CERT_CONTAINS_ERRORS = -203,
|
ERR_CERT_CONTAINS_ERRORS = -203,
|
||||||
ERR_CERT_NO_REVOCATION_MECHANISM = -204,
|
ERR_CERT_NO_REVOCATION_MECHANISM = -204,
|
||||||
ERR_CERT_UNABLE_TO_CHECK_REVOCATION = -205,
|
ERR_CERT_UNABLE_TO_CHECK_REVOCATION = -205,
|
||||||
ERR_CERT_REVOKED = -206,
|
ERR_CERT_REVOKED = -206,
|
||||||
ERR_CERT_INVALID = -207,
|
ERR_CERT_INVALID = -207,
|
||||||
ERR_CERT_END = -208,
|
ERR_CERT_END = -208,
|
||||||
ERR_INVALID_URL = -300,
|
ERR_INVALID_URL = -300,
|
||||||
ERR_DISALLOWED_URL_SCHEME = -301,
|
ERR_DISALLOWED_URL_SCHEME = -301,
|
||||||
ERR_UNKNOWN_URL_SCHEME = -302,
|
ERR_UNKNOWN_URL_SCHEME = -302,
|
||||||
ERR_TOO_MANY_REDIRECTS = -310,
|
ERR_TOO_MANY_REDIRECTS = -310,
|
||||||
ERR_UNSAFE_REDIRECT = -311,
|
ERR_UNSAFE_REDIRECT = -311,
|
||||||
ERR_UNSAFE_PORT = -312,
|
ERR_UNSAFE_PORT = -312,
|
||||||
ERR_INVALID_RESPONSE = -320,
|
ERR_INVALID_RESPONSE = -320,
|
||||||
ERR_INVALID_CHUNKED_ENCODING = -321,
|
ERR_INVALID_CHUNKED_ENCODING = -321,
|
||||||
ERR_METHOD_NOT_SUPPORTED = -322,
|
ERR_METHOD_NOT_SUPPORTED = -322,
|
||||||
ERR_UNEXPECTED_PROXY_AUTH = -323,
|
ERR_UNEXPECTED_PROXY_AUTH = -323,
|
||||||
ERR_EMPTY_RESPONSE = -324,
|
ERR_EMPTY_RESPONSE = -324,
|
||||||
ERR_RESPONSE_HEADERS_TOO_BIG = -325,
|
ERR_RESPONSE_HEADERS_TOO_BIG = -325,
|
||||||
ERR_CACHE_MISS = -400,
|
ERR_CACHE_MISS = -400,
|
||||||
ERR_INSECURE_RESPONSE = -501,
|
ERR_INSECURE_RESPONSE = -501,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Structure representing menu information.
|
// Structure representing menu information.
|
||||||
typedef struct _cef_handler_menuinfo_t
|
typedef struct _cef_handler_menuinfo_t
|
||||||
{
|
{
|
||||||
int typeFlags;
|
int typeFlags;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
const wchar_t* linkUrl;
|
const wchar_t* linkUrl;
|
||||||
const wchar_t* imageUrl;
|
const wchar_t* imageUrl;
|
||||||
const wchar_t* pageUrl;
|
const wchar_t* pageUrl;
|
||||||
@ -137,60 +137,60 @@ typedef struct _cef_handler_menuinfo_t
|
|||||||
// The cef_handler_menuinfo_t typeFlags value will be a combination of the
|
// The cef_handler_menuinfo_t typeFlags value will be a combination of the
|
||||||
// following values.
|
// following values.
|
||||||
enum cef_handler_menutypebits_t
|
enum cef_handler_menutypebits_t
|
||||||
{
|
{
|
||||||
// No node is selected
|
// No node is selected
|
||||||
MENUTYPE_NONE = 0x0,
|
MENUTYPE_NONE = 0x0,
|
||||||
// The top page is selected
|
// The top page is selected
|
||||||
MENUTYPE_PAGE = 0x1,
|
MENUTYPE_PAGE = 0x1,
|
||||||
// A subframe page is selected
|
// A subframe page is selected
|
||||||
MENUTYPE_FRAME = 0x2,
|
MENUTYPE_FRAME = 0x2,
|
||||||
// A link is selected
|
// A link is selected
|
||||||
MENUTYPE_LINK = 0x4,
|
MENUTYPE_LINK = 0x4,
|
||||||
// An image is selected
|
// An image is selected
|
||||||
MENUTYPE_IMAGE = 0x8,
|
MENUTYPE_IMAGE = 0x8,
|
||||||
// There is a textual or mixed selection that is selected
|
// There is a textual or mixed selection that is selected
|
||||||
MENUTYPE_SELECTION = 0x10,
|
MENUTYPE_SELECTION = 0x10,
|
||||||
// An editable element is selected
|
// An editable element is selected
|
||||||
MENUTYPE_EDITABLE = 0x20,
|
MENUTYPE_EDITABLE = 0x20,
|
||||||
// A misspelled word is selected
|
// A misspelled word is selected
|
||||||
MENUTYPE_MISSPELLED_WORD = 0x40,
|
MENUTYPE_MISSPELLED_WORD = 0x40,
|
||||||
// A video node is selected
|
// A video node is selected
|
||||||
MENUTYPE_VIDEO = 0x80,
|
MENUTYPE_VIDEO = 0x80,
|
||||||
// A video node is selected
|
// A video node is selected
|
||||||
MENUTYPE_AUDIO = 0x100,
|
MENUTYPE_AUDIO = 0x100,
|
||||||
};
|
};
|
||||||
|
|
||||||
// The cef_handler_menuinfo_t editFlags value will be a combination of the
|
// The cef_handler_menuinfo_t editFlags value will be a combination of the
|
||||||
// following values.
|
// following values.
|
||||||
enum cef_handler_menucapabilitybits_t
|
enum cef_handler_menucapabilitybits_t
|
||||||
{
|
{
|
||||||
MENU_CAN_DO_NONE = 0x0,
|
MENU_CAN_DO_NONE = 0x0,
|
||||||
MENU_CAN_UNDO = 0x1,
|
MENU_CAN_UNDO = 0x1,
|
||||||
MENU_CAN_REDO = 0x2,
|
MENU_CAN_REDO = 0x2,
|
||||||
MENU_CAN_CUT = 0x4,
|
MENU_CAN_CUT = 0x4,
|
||||||
MENU_CAN_COPY = 0x8,
|
MENU_CAN_COPY = 0x8,
|
||||||
MENU_CAN_PASTE = 0x10,
|
MENU_CAN_PASTE = 0x10,
|
||||||
MENU_CAN_DELETE = 0x20,
|
MENU_CAN_DELETE = 0x20,
|
||||||
MENU_CAN_SELECT_ALL = 0x40,
|
MENU_CAN_SELECT_ALL = 0x40,
|
||||||
MENU_CAN_GO_FORWARD = 0x80,
|
MENU_CAN_GO_FORWARD = 0x80,
|
||||||
MENU_CAN_GO_BACK = 0x100,
|
MENU_CAN_GO_BACK = 0x100,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Supported menu ID values.
|
// Supported menu ID values.
|
||||||
enum cef_handler_menuid_t
|
enum cef_handler_menuid_t
|
||||||
{
|
{
|
||||||
MENU_ID_NAV_BACK = 10,
|
MENU_ID_NAV_BACK = 10,
|
||||||
MENU_ID_NAV_FORWARD = 11,
|
MENU_ID_NAV_FORWARD = 11,
|
||||||
MENU_ID_NAV_RELOAD = 12,
|
MENU_ID_NAV_RELOAD = 12,
|
||||||
MENU_ID_NAV_STOP = 13,
|
MENU_ID_NAV_STOP = 13,
|
||||||
MENU_ID_UNDO = 20,
|
MENU_ID_UNDO = 20,
|
||||||
MENU_ID_REDO = 21,
|
MENU_ID_REDO = 21,
|
||||||
MENU_ID_CUT = 22,
|
MENU_ID_CUT = 22,
|
||||||
MENU_ID_COPY = 23,
|
MENU_ID_COPY = 23,
|
||||||
MENU_ID_PASTE = 24,
|
MENU_ID_PASTE = 24,
|
||||||
MENU_ID_DELETE = 25,
|
MENU_ID_DELETE = 25,
|
||||||
MENU_ID_SELECTALL = 26,
|
MENU_ID_SELECTALL = 26,
|
||||||
MENU_ID_PRINT = 30,
|
MENU_ID_PRINT = 30,
|
||||||
MENU_ID_VIEWSOURCE = 31,
|
MENU_ID_VIEWSOURCE = 31,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
// met:
|
// met:
|
||||||
//
|
//
|
||||||
// * Redistributions of source code must retain the above copyright
|
// * Redistributions of source code must retain the above copyright
|
||||||
// notice, this list of conditions and the following disclaimer.
|
// notice, this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above
|
// * Redistributions in binary form must reproduce the above
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
// in the documentation and/or other materials provided with the
|
// in the documentation and/or other materials provided with the
|
||||||
// distribution.
|
// distribution.
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
// or promote products derived from this software without specific prior
|
// or promote products derived from this software without specific prior
|
||||||
// written permission.
|
// written permission.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
#ifndef _CEF_TYPES_WIN_H
|
#ifndef _CEF_TYPES_WIN_H
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
// Copyright (c) 2008 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2008 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
// met:
|
// met:
|
||||||
//
|
//
|
||||||
// * Redistributions of source code must retain the above copyright
|
// * Redistributions of source code must retain the above copyright
|
||||||
// notice, this list of conditions and the following disclaimer.
|
// notice, this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above
|
// * Redistributions in binary form must reproduce the above
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
// in the documentation and/or other materials provided with the
|
// in the documentation and/or other materials provided with the
|
||||||
// distribution.
|
// distribution.
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
// or promote products derived from this software without specific prior
|
// or promote products derived from this software without specific prior
|
||||||
// written permission.
|
// written permission.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
#ifndef _CEF_WIN_H
|
#ifndef _CEF_WIN_H
|
||||||
@ -78,15 +78,15 @@ public:
|
|||||||
cef_string_free(m_windowName);
|
cef_string_free(m_windowName);
|
||||||
}
|
}
|
||||||
|
|
||||||
CefWindowInfo(const CefWindowInfo& r)
|
CefWindowInfo(const CefWindowInfo& r)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
*this = r;
|
*this = r;
|
||||||
}
|
}
|
||||||
CefWindowInfo(const cef_window_info_t& r)
|
CefWindowInfo(const cef_window_info_t& r)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
*this = r;
|
*this = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init()
|
void Init()
|
||||||
@ -103,28 +103,28 @@ public:
|
|||||||
m_hWnd = NULL;
|
m_hWnd = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefWindowInfo& operator=(const CefWindowInfo& r)
|
CefWindowInfo& operator=(const CefWindowInfo& r)
|
||||||
{
|
{
|
||||||
return operator=(static_cast<const cef_window_info_t&>(r));
|
return operator=(static_cast<const cef_window_info_t&>(r));
|
||||||
}
|
}
|
||||||
CefWindowInfo& operator=(const cef_window_info_t& r)
|
CefWindowInfo& operator=(const cef_window_info_t& r)
|
||||||
{
|
{
|
||||||
m_dwExStyle = r.m_dwExStyle;
|
m_dwExStyle = r.m_dwExStyle;
|
||||||
if(m_windowName)
|
if(m_windowName)
|
||||||
cef_string_free(m_windowName);
|
cef_string_free(m_windowName);
|
||||||
if(r.m_windowName)
|
if(r.m_windowName)
|
||||||
m_windowName = cef_string_alloc(r.m_windowName);
|
m_windowName = cef_string_alloc(r.m_windowName);
|
||||||
else
|
else
|
||||||
m_windowName = NULL;
|
m_windowName = NULL;
|
||||||
m_dwStyle = r.m_dwStyle;
|
m_dwStyle = r.m_dwStyle;
|
||||||
m_x = r.m_x;
|
m_x = r.m_x;
|
||||||
m_y = r.m_y;
|
m_y = r.m_y;
|
||||||
m_nWidth = r.m_nWidth;
|
m_nWidth = r.m_nWidth;
|
||||||
m_nHeight = r.m_nHeight;
|
m_nHeight = r.m_nHeight;
|
||||||
m_hWndParent = r.m_hWndParent;
|
m_hWndParent = r.m_hWndParent;
|
||||||
m_hMenu = r.m_hMenu;
|
m_hMenu = r.m_hMenu;
|
||||||
m_hWnd = r.m_hWnd;
|
m_hWnd = r.m_hWnd;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetAsChild(HWND hWndParent, RECT windowRect)
|
void SetAsChild(HWND hWndParent, RECT windowRect)
|
||||||
@ -140,16 +140,16 @@ public:
|
|||||||
|
|
||||||
void SetAsPopup(HWND hWndParent, LPCTSTR windowName)
|
void SetAsPopup(HWND hWndParent, LPCTSTR windowName)
|
||||||
{
|
{
|
||||||
m_dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
|
m_dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
|
||||||
m_hWndParent = hWndParent;
|
m_hWndParent = hWndParent;
|
||||||
m_x = CW_USEDEFAULT;
|
m_x = CW_USEDEFAULT;
|
||||||
m_y = CW_USEDEFAULT;
|
m_y = CW_USEDEFAULT;
|
||||||
m_nWidth = CW_USEDEFAULT;
|
m_nWidth = CW_USEDEFAULT;
|
||||||
m_nHeight = CW_USEDEFAULT;
|
m_nHeight = CW_USEDEFAULT;
|
||||||
|
|
||||||
if(m_windowName)
|
if(m_windowName)
|
||||||
cef_string_free(m_windowName);
|
cef_string_free(m_windowName);
|
||||||
if(windowName)
|
if(windowName)
|
||||||
m_windowName = cef_string_alloc(windowName);
|
m_windowName = cef_string_alloc(windowName);
|
||||||
else
|
else
|
||||||
m_windowName = NULL;
|
m_windowName = NULL;
|
||||||
@ -168,15 +168,15 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CefPrintInfo(const CefPrintInfo& r)
|
CefPrintInfo(const CefPrintInfo& r)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
*this = r;
|
*this = r;
|
||||||
}
|
}
|
||||||
CefPrintInfo(const cef_print_info_t& r)
|
CefPrintInfo(const cef_print_info_t& r)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
*this = r;
|
*this = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init()
|
void Init()
|
||||||
@ -186,19 +186,19 @@ public:
|
|||||||
m_Scale = 0;
|
m_Scale = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefPrintInfo& operator=(const CefPrintInfo& r)
|
CefPrintInfo& operator=(const CefPrintInfo& r)
|
||||||
{
|
{
|
||||||
return operator=(static_cast<const cef_print_info_t&>(r));
|
return operator=(static_cast<const cef_print_info_t&>(r));
|
||||||
}
|
}
|
||||||
CefPrintInfo& operator=(const cef_print_info_t& r)
|
CefPrintInfo& operator=(const cef_print_info_t& r)
|
||||||
{
|
{
|
||||||
m_hDC = r.m_hDC;
|
m_hDC = r.m_hDC;
|
||||||
m_Rect.left = r.m_Rect.left;
|
m_Rect.left = r.m_Rect.left;
|
||||||
m_Rect.right = r.m_Rect.right;
|
m_Rect.right = r.m_Rect.right;
|
||||||
m_Rect.top = r.m_Rect.top;
|
m_Rect.top = r.m_Rect.top;
|
||||||
m_Rect.bottom = r.m_Rect.bottom;
|
m_Rect.bottom = r.m_Rect.bottom;
|
||||||
m_Scale = r.m_Scale;
|
m_Scale = r.m_Scale;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,49 +1,49 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
#include "browser_drag_delegate.h"
|
#include "browser_drag_delegate.h"
|
||||||
|
|
||||||
#include <atltypes.h>
|
#include <atltypes.h>
|
||||||
|
|
||||||
#include "webkit/api/public/WebPoint.h"
|
#include "webkit/api/public/WebPoint.h"
|
||||||
#include "webkit/glue/webview.h"
|
#include "webkit/glue/webview.h"
|
||||||
|
|
||||||
using WebKit::WebPoint;
|
using WebKit::WebPoint;
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void GetCursorPositions(HWND hwnd, CPoint* client, CPoint* screen) {
|
void GetCursorPositions(HWND hwnd, CPoint* client, CPoint* screen) {
|
||||||
// GetCursorPos will fail if the input desktop isn't the current desktop.
|
// GetCursorPos will fail if the input desktop isn't the current desktop.
|
||||||
// See http://b/1173534. (0,0) is wrong, but better than uninitialized.
|
// See http://b/1173534. (0,0) is wrong, but better than uninitialized.
|
||||||
if (!GetCursorPos(screen))
|
if (!GetCursorPos(screen))
|
||||||
screen->SetPoint(0, 0);
|
screen->SetPoint(0, 0);
|
||||||
|
|
||||||
*client = *screen;
|
*client = *screen;
|
||||||
ScreenToClient(hwnd, client);
|
ScreenToClient(hwnd, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
void BrowserDragDelegate::OnDragSourceCancel() {
|
void BrowserDragDelegate::OnDragSourceCancel() {
|
||||||
OnDragSourceDrop();
|
OnDragSourceDrop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserDragDelegate::OnDragSourceDrop() {
|
void BrowserDragDelegate::OnDragSourceDrop() {
|
||||||
CPoint client;
|
CPoint client;
|
||||||
CPoint screen;
|
CPoint screen;
|
||||||
GetCursorPositions(source_hwnd_, &client, &screen);
|
GetCursorPositions(source_hwnd_, &client, &screen);
|
||||||
webview_->DragSourceEndedAt(WebPoint(client.x, client.y),
|
webview_->DragSourceEndedAt(WebPoint(client.x, client.y),
|
||||||
WebPoint(screen.x, screen.y));
|
WebPoint(screen.x, screen.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserDragDelegate::OnDragSourceMove() {
|
void BrowserDragDelegate::OnDragSourceMove() {
|
||||||
CPoint client;
|
CPoint client;
|
||||||
CPoint screen;
|
CPoint screen;
|
||||||
GetCursorPositions(source_hwnd_, &client, &screen);
|
GetCursorPositions(source_hwnd_, &client, &screen);
|
||||||
webview_->DragSourceMovedTo(WebPoint(client.x, client.y),
|
webview_->DragSourceMovedTo(WebPoint(client.x, client.y),
|
||||||
WebPoint(screen.x, screen.y));
|
WebPoint(screen.x, screen.y));
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,37 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
//
|
//
|
||||||
// A class that implements BaseDragSource for the test shell webview delegate.
|
// A class that implements BaseDragSource for the test shell webview delegate.
|
||||||
|
|
||||||
#ifndef _BROWSER_DRAG_DELEGATE_H
|
#ifndef _BROWSER_DRAG_DELEGATE_H
|
||||||
#define _BROWSER_DRAG_DELEGATE_H
|
#define _BROWSER_DRAG_DELEGATE_H
|
||||||
|
|
||||||
#include "base/base_drag_source.h"
|
#include "base/base_drag_source.h"
|
||||||
|
|
||||||
class WebView;
|
class WebView;
|
||||||
|
|
||||||
class BrowserDragDelegate : public BaseDragSource {
|
class BrowserDragDelegate : public BaseDragSource {
|
||||||
public:
|
public:
|
||||||
BrowserDragDelegate(HWND source_hwnd, WebView* webview)
|
BrowserDragDelegate(HWND source_hwnd, WebView* webview)
|
||||||
: BaseDragSource(),
|
: BaseDragSource(),
|
||||||
source_hwnd_(source_hwnd),
|
source_hwnd_(source_hwnd),
|
||||||
webview_(webview) { }
|
webview_(webview) { }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// BaseDragSource
|
// BaseDragSource
|
||||||
virtual void OnDragSourceCancel();
|
virtual void OnDragSourceCancel();
|
||||||
virtual void OnDragSourceDrop();
|
virtual void OnDragSourceDrop();
|
||||||
virtual void OnDragSourceMove();
|
virtual void OnDragSourceMove();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WebView* webview_;
|
WebView* webview_;
|
||||||
|
|
||||||
// A HWND for the source we are associated with, used for translating
|
// A HWND for the source we are associated with, used for translating
|
||||||
// mouse coordinates from screen to client coordinates.
|
// mouse coordinates from screen to client coordinates.
|
||||||
HWND source_hwnd_;
|
HWND source_hwnd_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _BROWSER_DRAG_DELEGATE_H
|
#endif // _BROWSER_DRAG_DELEGATE_H
|
||||||
|
|
||||||
|
@ -1,63 +1,63 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
#include "browser_drop_delegate.h"
|
#include "browser_drop_delegate.h"
|
||||||
|
|
||||||
#include "webkit/api/public/WebDragData.h"
|
#include "webkit/api/public/WebDragData.h"
|
||||||
#include "webkit/api/public/WebPoint.h"
|
#include "webkit/api/public/WebPoint.h"
|
||||||
#include "webkit/glue/webdropdata.h"
|
#include "webkit/glue/webdropdata.h"
|
||||||
#include "webkit/glue/webview.h"
|
#include "webkit/glue/webview.h"
|
||||||
|
|
||||||
using WebKit::WebPoint;
|
using WebKit::WebPoint;
|
||||||
|
|
||||||
// BaseDropTarget methods ----------------------------------------------------
|
// BaseDropTarget methods ----------------------------------------------------
|
||||||
|
|
||||||
DWORD BrowserDropDelegate::OnDragEnter(IDataObject* data_object,
|
DWORD BrowserDropDelegate::OnDragEnter(IDataObject* data_object,
|
||||||
DWORD key_state,
|
DWORD key_state,
|
||||||
POINT cursor_position,
|
POINT cursor_position,
|
||||||
DWORD effect) {
|
DWORD effect) {
|
||||||
WebDropData drop_data;
|
WebDropData drop_data;
|
||||||
WebDropData::PopulateWebDropData(data_object, &drop_data);
|
WebDropData::PopulateWebDropData(data_object, &drop_data);
|
||||||
|
|
||||||
POINT client_pt = cursor_position;
|
POINT client_pt = cursor_position;
|
||||||
ScreenToClient(GetHWND(), &client_pt);
|
ScreenToClient(GetHWND(), &client_pt);
|
||||||
bool valid = webview_->DragTargetDragEnter(
|
bool valid = webview_->DragTargetDragEnter(
|
||||||
drop_data.ToDragData(), drop_data.identity,
|
drop_data.ToDragData(), drop_data.identity,
|
||||||
WebPoint(client_pt.x, client_pt.y),
|
WebPoint(client_pt.x, client_pt.y),
|
||||||
WebPoint(cursor_position.x, cursor_position.y));
|
WebPoint(cursor_position.x, cursor_position.y));
|
||||||
return valid ? DROPEFFECT_COPY : DROPEFFECT_NONE;
|
return valid ? DROPEFFECT_COPY : DROPEFFECT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD BrowserDropDelegate::OnDragOver(IDataObject* data_object,
|
DWORD BrowserDropDelegate::OnDragOver(IDataObject* data_object,
|
||||||
DWORD key_state,
|
DWORD key_state,
|
||||||
POINT cursor_position,
|
POINT cursor_position,
|
||||||
DWORD effect) {
|
DWORD effect) {
|
||||||
POINT client_pt = cursor_position;
|
POINT client_pt = cursor_position;
|
||||||
ScreenToClient(GetHWND(), &client_pt);
|
ScreenToClient(GetHWND(), &client_pt);
|
||||||
bool valid = webview_->DragTargetDragOver(
|
bool valid = webview_->DragTargetDragOver(
|
||||||
WebPoint(client_pt.x, client_pt.y),
|
WebPoint(client_pt.x, client_pt.y),
|
||||||
WebPoint(cursor_position.x, cursor_position.y));
|
WebPoint(cursor_position.x, cursor_position.y));
|
||||||
return valid ? DROPEFFECT_COPY : DROPEFFECT_NONE;
|
return valid ? DROPEFFECT_COPY : DROPEFFECT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserDropDelegate::OnDragLeave(IDataObject* data_object) {
|
void BrowserDropDelegate::OnDragLeave(IDataObject* data_object) {
|
||||||
webview_->DragTargetDragLeave();
|
webview_->DragTargetDragLeave();
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD BrowserDropDelegate::OnDrop(IDataObject* data_object,
|
DWORD BrowserDropDelegate::OnDrop(IDataObject* data_object,
|
||||||
DWORD key_state,
|
DWORD key_state,
|
||||||
POINT cursor_position,
|
POINT cursor_position,
|
||||||
DWORD effect) {
|
DWORD effect) {
|
||||||
POINT client_pt = cursor_position;
|
POINT client_pt = cursor_position;
|
||||||
ScreenToClient(GetHWND(), &client_pt);
|
ScreenToClient(GetHWND(), &client_pt);
|
||||||
webview_->DragTargetDrop(
|
webview_->DragTargetDrop(
|
||||||
WebPoint(client_pt.x, client_pt.y),
|
WebPoint(client_pt.x, client_pt.y),
|
||||||
WebPoint(cursor_position.x, cursor_position.y));
|
WebPoint(cursor_position.x, cursor_position.y));
|
||||||
|
|
||||||
// webkit win port always returns DROPEFFECT_NONE
|
// webkit win port always returns DROPEFFECT_NONE
|
||||||
return DROPEFFECT_NONE;
|
return DROPEFFECT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,43 +1,43 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
//
|
//
|
||||||
// A class that implements BaseDropTarget for the test shell webview delegate.
|
// A class that implements BaseDropTarget for the test shell webview delegate.
|
||||||
|
|
||||||
#ifndef _BROWSER_DROP_DELEGATE_H
|
#ifndef _BROWSER_DROP_DELEGATE_H
|
||||||
#define _BROWSER_DROP_DELEGATE_H
|
#define _BROWSER_DROP_DELEGATE_H
|
||||||
|
|
||||||
#include "base/base_drop_target.h"
|
#include "base/base_drop_target.h"
|
||||||
|
|
||||||
class WebView;
|
class WebView;
|
||||||
|
|
||||||
class BrowserDropDelegate : public BaseDropTarget {
|
class BrowserDropDelegate : public BaseDropTarget {
|
||||||
public:
|
public:
|
||||||
BrowserDropDelegate(HWND source_hwnd, WebView* webview)
|
BrowserDropDelegate(HWND source_hwnd, WebView* webview)
|
||||||
: BaseDropTarget(source_hwnd),
|
: BaseDropTarget(source_hwnd),
|
||||||
webview_(webview) { }
|
webview_(webview) { }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// BaseDropTarget methods
|
// BaseDropTarget methods
|
||||||
virtual DWORD OnDragEnter(IDataObject* data_object,
|
virtual DWORD OnDragEnter(IDataObject* data_object,
|
||||||
DWORD key_state,
|
DWORD key_state,
|
||||||
POINT cursor_position,
|
POINT cursor_position,
|
||||||
DWORD effect);
|
DWORD effect);
|
||||||
virtual DWORD OnDragOver(IDataObject* data_object,
|
virtual DWORD OnDragOver(IDataObject* data_object,
|
||||||
DWORD key_state,
|
DWORD key_state,
|
||||||
POINT cursor_position,
|
POINT cursor_position,
|
||||||
DWORD effect);
|
DWORD effect);
|
||||||
virtual void OnDragLeave(IDataObject* data_object);
|
virtual void OnDragLeave(IDataObject* data_object);
|
||||||
virtual DWORD OnDrop(IDataObject* data_object,
|
virtual DWORD OnDrop(IDataObject* data_object,
|
||||||
DWORD key_state,
|
DWORD key_state,
|
||||||
POINT cursor_position,
|
POINT cursor_position,
|
||||||
DWORD effect);
|
DWORD effect);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WebView* webview_;
|
WebView* webview_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _BROWSER_DROP_DELEGATE_H
|
#endif // _BROWSER_DROP_DELEGATE_H
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
#include "browser_impl.h"
|
#include "browser_impl.h"
|
||||||
@ -41,25 +41,25 @@ CefBrowserImpl::CefBrowserImpl(CefWindowInfo& windowInfo, bool popup,
|
|||||||
void CefBrowserImpl::GoBack()
|
void CefBrowserImpl::GoBack()
|
||||||
{
|
{
|
||||||
PostTask(FROM_HERE, NewRunnableMethod(this,
|
PostTask(FROM_HERE, NewRunnableMethod(this,
|
||||||
&CefBrowserImpl::UIT_HandleActionView, MENU_ID_NAV_BACK));
|
&CefBrowserImpl::UIT_HandleActionView, MENU_ID_NAV_BACK));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::GoForward()
|
void CefBrowserImpl::GoForward()
|
||||||
{
|
{
|
||||||
PostTask(FROM_HERE, NewRunnableMethod(this,
|
PostTask(FROM_HERE, NewRunnableMethod(this,
|
||||||
&CefBrowserImpl::UIT_HandleActionView, MENU_ID_NAV_FORWARD));
|
&CefBrowserImpl::UIT_HandleActionView, MENU_ID_NAV_FORWARD));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::Reload()
|
void CefBrowserImpl::Reload()
|
||||||
{
|
{
|
||||||
PostTask(FROM_HERE, NewRunnableMethod(this,
|
PostTask(FROM_HERE, NewRunnableMethod(this,
|
||||||
&CefBrowserImpl::UIT_HandleActionView, MENU_ID_NAV_RELOAD));
|
&CefBrowserImpl::UIT_HandleActionView, MENU_ID_NAV_RELOAD));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::StopLoad()
|
void CefBrowserImpl::StopLoad()
|
||||||
{
|
{
|
||||||
PostTask(FROM_HERE, NewRunnableMethod(this,
|
PostTask(FROM_HERE, NewRunnableMethod(this,
|
||||||
&CefBrowserImpl::UIT_HandleActionView, MENU_ID_NAV_STOP));
|
&CefBrowserImpl::UIT_HandleActionView, MENU_ID_NAV_STOP));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::SetFocus(bool enable)
|
void CefBrowserImpl::SetFocus(bool enable)
|
||||||
@ -167,8 +167,8 @@ void CefBrowserImpl::RemoveCefFrame(const std::wstring& name)
|
|||||||
WebFrame* CefBrowserImpl::GetWebFrame(CefRefPtr<CefFrame> frame)
|
WebFrame* CefBrowserImpl::GetWebFrame(CefRefPtr<CefFrame> frame)
|
||||||
{
|
{
|
||||||
std::wstring name = frame->GetName();
|
std::wstring name = frame->GetName();
|
||||||
if(name.empty())
|
if(name.empty())
|
||||||
return GetWebView()->GetMainFrame();
|
return GetWebView()->GetMainFrame();
|
||||||
return GetWebView()->GetFrameWithName(name);
|
return GetWebView()->GetFrameWithName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,49 +176,49 @@ void CefBrowserImpl::Undo(CefRefPtr<CefFrame> frame)
|
|||||||
{
|
{
|
||||||
frame->AddRef();
|
frame->AddRef();
|
||||||
PostTask(FROM_HERE, NewRunnableMethod(this,
|
PostTask(FROM_HERE, NewRunnableMethod(this,
|
||||||
&CefBrowserImpl::UIT_HandleAction, MENU_ID_UNDO, frame.get()));
|
&CefBrowserImpl::UIT_HandleAction, MENU_ID_UNDO, frame.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::Redo(CefRefPtr<CefFrame> frame)
|
void CefBrowserImpl::Redo(CefRefPtr<CefFrame> frame)
|
||||||
{
|
{
|
||||||
frame->AddRef();
|
frame->AddRef();
|
||||||
PostTask(FROM_HERE, NewRunnableMethod(this,
|
PostTask(FROM_HERE, NewRunnableMethod(this,
|
||||||
&CefBrowserImpl::UIT_HandleAction, MENU_ID_REDO, frame.get()));
|
&CefBrowserImpl::UIT_HandleAction, MENU_ID_REDO, frame.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::Cut(CefRefPtr<CefFrame> frame)
|
void CefBrowserImpl::Cut(CefRefPtr<CefFrame> frame)
|
||||||
{
|
{
|
||||||
frame->AddRef();
|
frame->AddRef();
|
||||||
PostTask(FROM_HERE, NewRunnableMethod(this,
|
PostTask(FROM_HERE, NewRunnableMethod(this,
|
||||||
&CefBrowserImpl::UIT_HandleAction, MENU_ID_CUT, frame.get()));
|
&CefBrowserImpl::UIT_HandleAction, MENU_ID_CUT, frame.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::Copy(CefRefPtr<CefFrame> frame)
|
void CefBrowserImpl::Copy(CefRefPtr<CefFrame> frame)
|
||||||
{
|
{
|
||||||
frame->AddRef();
|
frame->AddRef();
|
||||||
PostTask(FROM_HERE, NewRunnableMethod(this,
|
PostTask(FROM_HERE, NewRunnableMethod(this,
|
||||||
&CefBrowserImpl::UIT_HandleAction, MENU_ID_COPY, frame.get()));
|
&CefBrowserImpl::UIT_HandleAction, MENU_ID_COPY, frame.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::Paste(CefRefPtr<CefFrame> frame)
|
void CefBrowserImpl::Paste(CefRefPtr<CefFrame> frame)
|
||||||
{
|
{
|
||||||
frame->AddRef();
|
frame->AddRef();
|
||||||
PostTask(FROM_HERE, NewRunnableMethod(this,
|
PostTask(FROM_HERE, NewRunnableMethod(this,
|
||||||
&CefBrowserImpl::UIT_HandleAction, MENU_ID_PASTE, frame.get()));
|
&CefBrowserImpl::UIT_HandleAction, MENU_ID_PASTE, frame.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::Delete(CefRefPtr<CefFrame> frame)
|
void CefBrowserImpl::Delete(CefRefPtr<CefFrame> frame)
|
||||||
{
|
{
|
||||||
frame->AddRef();
|
frame->AddRef();
|
||||||
PostTask(FROM_HERE, NewRunnableMethod(this,
|
PostTask(FROM_HERE, NewRunnableMethod(this,
|
||||||
&CefBrowserImpl::UIT_HandleAction, MENU_ID_DELETE, frame.get()));
|
&CefBrowserImpl::UIT_HandleAction, MENU_ID_DELETE, frame.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::SelectAll(CefRefPtr<CefFrame> frame)
|
void CefBrowserImpl::SelectAll(CefRefPtr<CefFrame> frame)
|
||||||
{
|
{
|
||||||
frame->AddRef();
|
frame->AddRef();
|
||||||
PostTask(FROM_HERE, NewRunnableMethod(this,
|
PostTask(FROM_HERE, NewRunnableMethod(this,
|
||||||
&CefBrowserImpl::UIT_HandleAction, MENU_ID_SELECTALL, frame.get()));
|
&CefBrowserImpl::UIT_HandleAction, MENU_ID_SELECTALL, frame.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -226,14 +226,14 @@ void CefBrowserImpl::Print(CefRefPtr<CefFrame> frame)
|
|||||||
{
|
{
|
||||||
frame->AddRef();
|
frame->AddRef();
|
||||||
PostTask(FROM_HERE, NewRunnableMethod(this,
|
PostTask(FROM_HERE, NewRunnableMethod(this,
|
||||||
&CefBrowserImpl::UIT_HandleAction, MENU_ID_PRINT, frame.get()));
|
&CefBrowserImpl::UIT_HandleAction, MENU_ID_PRINT, frame.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::ViewSource(CefRefPtr<CefFrame> frame)
|
void CefBrowserImpl::ViewSource(CefRefPtr<CefFrame> frame)
|
||||||
{
|
{
|
||||||
frame->AddRef();
|
frame->AddRef();
|
||||||
PostTask(FROM_HERE, NewRunnableMethod(this,
|
PostTask(FROM_HERE, NewRunnableMethod(this,
|
||||||
&CefBrowserImpl::UIT_HandleAction, MENU_ID_VIEWSOURCE, frame.get()));
|
&CefBrowserImpl::UIT_HandleAction, MENU_ID_VIEWSOURCE, frame.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::LoadRequest(CefRefPtr<CefFrame> frame,
|
void CefBrowserImpl::LoadRequest(CefRefPtr<CefFrame> frame,
|
||||||
@ -278,12 +278,12 @@ void CefBrowserImpl::LoadStream(CefRefPtr<CefFrame> frame,
|
|||||||
void CefBrowserImpl::ExecuteJavaScript(CefRefPtr<CefFrame> frame,
|
void CefBrowserImpl::ExecuteJavaScript(CefRefPtr<CefFrame> frame,
|
||||||
const std::wstring& jsCode,
|
const std::wstring& jsCode,
|
||||||
const std::wstring& scriptUrl,
|
const std::wstring& scriptUrl,
|
||||||
int startLine)
|
int startLine)
|
||||||
{
|
{
|
||||||
frame->AddRef();
|
frame->AddRef();
|
||||||
PostTask(FROM_HERE, NewRunnableMethod(this,
|
PostTask(FROM_HERE, NewRunnableMethod(this,
|
||||||
&CefBrowserImpl::UIT_ExecuteJavaScript, frame.get(), jsCode, scriptUrl,
|
&CefBrowserImpl::UIT_ExecuteJavaScript, frame.get(), jsCode, scriptUrl,
|
||||||
startLine));
|
startLine));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring CefBrowserImpl::GetURL(CefRefPtr<CefFrame> frame)
|
std::wstring CefBrowserImpl::GetURL(CefRefPtr<CefFrame> frame)
|
||||||
@ -309,10 +309,10 @@ bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, bool popup,
|
|||||||
// or cancel the window creation.
|
// or cancel the window creation.
|
||||||
CefHandler::RetVal rv =
|
CefHandler::RetVal rv =
|
||||||
handler->HandleBeforeCreated(NULL, windowInfo, popup, handler, newUrl);
|
handler->HandleBeforeCreated(NULL, windowInfo, popup, handler, newUrl);
|
||||||
if(rv == RV_HANDLED)
|
if(rv == RV_HANDLED)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<CefBrowserImpl> browser(
|
CefRefPtr<CefBrowserImpl> browser(
|
||||||
new CefBrowserImpl(windowInfo, popup, handler));
|
new CefBrowserImpl(windowInfo, popup, handler));
|
||||||
PostTask(FROM_HERE, NewRunnableMethod(browser.get(),
|
PostTask(FROM_HERE, NewRunnableMethod(browser.get(),
|
||||||
@ -337,7 +337,7 @@ CefRefPtr<CefBrowser> CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo,
|
|||||||
// or cancel the window creation.
|
// or cancel the window creation.
|
||||||
CefHandler::RetVal rv = handler->HandleBeforeCreated(NULL, windowInfo,
|
CefHandler::RetVal rv = handler->HandleBeforeCreated(NULL, windowInfo,
|
||||||
popup, handler, newUrl);
|
popup, handler, newUrl);
|
||||||
if(rv == RV_HANDLED)
|
if(rv == RV_HANDLED)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,327 +347,327 @@ CefRefPtr<CefBrowser> CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo,
|
|||||||
return browser;
|
return browser;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::UIT_LoadURL(CefFrame* frame,
|
void CefBrowserImpl::UIT_LoadURL(CefFrame* frame,
|
||||||
const std::wstring& url)
|
const std::wstring& url)
|
||||||
{
|
{
|
||||||
UIT_LoadURLForRequest(frame, url, std::wstring(), WebHTTPBody(),
|
UIT_LoadURLForRequest(frame, url, std::wstring(), WebHTTPBody(),
|
||||||
CefRequest::HeaderMap());
|
CefRequest::HeaderMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::UIT_LoadURLForRequestRef(CefFrame* frame,
|
void CefBrowserImpl::UIT_LoadURLForRequestRef(CefFrame* frame,
|
||||||
CefRequest* request)
|
CefRequest* request)
|
||||||
{
|
{
|
||||||
std::wstring url = request->GetURL();
|
std::wstring url = request->GetURL();
|
||||||
std::wstring method = request->GetMethod();
|
std::wstring method = request->GetMethod();
|
||||||
|
|
||||||
CefRequestImpl *impl = static_cast<CefRequestImpl*>(request);
|
CefRequestImpl *impl = static_cast<CefRequestImpl*>(request);
|
||||||
|
|
||||||
WebHTTPBody upload_data;
|
WebHTTPBody upload_data;
|
||||||
CefRefPtr<CefPostData> postdata = impl->GetPostData();
|
CefRefPtr<CefPostData> postdata = impl->GetPostData();
|
||||||
if(postdata.get()) {
|
if(postdata.get()) {
|
||||||
upload_data.initialize();
|
upload_data.initialize();
|
||||||
static_cast<CefPostDataImpl*>(postdata.get())->Get(upload_data);
|
static_cast<CefPostDataImpl*>(postdata.get())->Get(upload_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRequest::HeaderMap headers;
|
CefRequest::HeaderMap headers;
|
||||||
impl->GetHeaderMap(headers);
|
impl->GetHeaderMap(headers);
|
||||||
|
|
||||||
UIT_LoadURLForRequest(frame, url, method, upload_data, headers);
|
UIT_LoadURLForRequest(frame, url, method, upload_data, headers);
|
||||||
|
|
||||||
request->Release();
|
request->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::UIT_LoadURLForRequest(CefFrame* frame,
|
void CefBrowserImpl::UIT_LoadURLForRequest(CefFrame* frame,
|
||||||
const std::wstring& url,
|
const std::wstring& url,
|
||||||
const std::wstring& method,
|
const std::wstring& method,
|
||||||
const WebKit::WebHTTPBody& upload_data,
|
const WebKit::WebHTTPBody& upload_data,
|
||||||
const CefRequest::HeaderMap& headers)
|
const CefRequest::HeaderMap& headers)
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
if (url.empty())
|
if (url.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GURL gurl(url);
|
GURL gurl(url);
|
||||||
|
|
||||||
if (!gurl.is_valid() && !gurl.has_scheme()) {
|
if (!gurl.is_valid() && !gurl.has_scheme()) {
|
||||||
// Try to add "http://" at the beginning
|
// Try to add "http://" at the beginning
|
||||||
gurl = GURL(std::wstring(L"http://") + url);
|
gurl = GURL(std::wstring(L"http://") + url);
|
||||||
if (!gurl.is_valid())
|
if (!gurl.is_valid())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nav_controller_->LoadEntry(
|
nav_controller_->LoadEntry(
|
||||||
new BrowserNavigationEntry(-1, gurl, std::wstring(), frame->GetName(),
|
new BrowserNavigationEntry(-1, gurl, std::wstring(), frame->GetName(),
|
||||||
method, upload_data, headers));
|
method, upload_data, headers));
|
||||||
|
|
||||||
frame->Release();
|
frame->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::UIT_LoadHTML(CefFrame* frame,
|
void CefBrowserImpl::UIT_LoadHTML(CefFrame* frame,
|
||||||
const std::wstring& html,
|
const std::wstring& html,
|
||||||
const std::wstring& url)
|
const std::wstring& url)
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
GURL gurl(url);
|
GURL gurl(url);
|
||||||
|
|
||||||
if (!gurl.is_valid() && !gurl.has_scheme()) {
|
if (!gurl.is_valid() && !gurl.has_scheme()) {
|
||||||
// Try to add "http://" at the beginning
|
// Try to add "http://" at the beginning
|
||||||
gurl = GURL(std::wstring(L"http://") + url);
|
gurl = GURL(std::wstring(L"http://") + url);
|
||||||
if (!gurl.is_valid())
|
if (!gurl.is_valid())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebFrame* web_frame = GetWebFrame(frame);
|
WebFrame* web_frame = GetWebFrame(frame);
|
||||||
if(web_frame)
|
if(web_frame)
|
||||||
web_frame->LoadHTMLString(WideToUTF8(html), gurl);
|
web_frame->LoadHTMLString(WideToUTF8(html), gurl);
|
||||||
|
|
||||||
frame->Release();
|
frame->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::UIT_LoadHTMLForStreamRef(CefFrame* frame,
|
void CefBrowserImpl::UIT_LoadHTMLForStreamRef(CefFrame* frame,
|
||||||
CefStreamReader* stream,
|
CefStreamReader* stream,
|
||||||
const std::wstring& url)
|
const std::wstring& url)
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
GURL gurl(url);
|
GURL gurl(url);
|
||||||
|
|
||||||
if (!gurl.is_valid() && !gurl.has_scheme()) {
|
if (!gurl.is_valid() && !gurl.has_scheme()) {
|
||||||
// Try to add "http://" at the beginning
|
// Try to add "http://" at the beginning
|
||||||
gurl = GURL(std::wstring(L"http://") + url);
|
gurl = GURL(std::wstring(L"http://") + url);
|
||||||
if (!gurl.is_valid())
|
if (!gurl.is_valid())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read all of the stream data into a std::string.
|
// read all of the stream data into a std::string.
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
char buff[BUFFER_SIZE];
|
char buff[BUFFER_SIZE];
|
||||||
size_t read;
|
size_t read;
|
||||||
do {
|
do {
|
||||||
read = stream->Read(buff, sizeof(char), BUFFER_SIZE-1);
|
read = stream->Read(buff, sizeof(char), BUFFER_SIZE-1);
|
||||||
if(read > 0) {
|
if(read > 0) {
|
||||||
buff[read] = 0;
|
buff[read] = 0;
|
||||||
ss << buff;
|
ss << buff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(read > 0);
|
while(read > 0);
|
||||||
|
|
||||||
WebFrame* web_frame = GetWebFrame(frame);
|
WebFrame* web_frame = GetWebFrame(frame);
|
||||||
if(web_frame)
|
if(web_frame)
|
||||||
web_frame->LoadHTMLString(ss.str(), gurl);
|
web_frame->LoadHTMLString(ss.str(), gurl);
|
||||||
|
|
||||||
stream->Release();
|
stream->Release();
|
||||||
frame->Release();
|
frame->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::UIT_ExecuteJavaScript(CefFrame* frame,
|
void CefBrowserImpl::UIT_ExecuteJavaScript(CefFrame* frame,
|
||||||
const std::wstring& js_code,
|
const std::wstring& js_code,
|
||||||
const std::wstring& script_url,
|
const std::wstring& script_url,
|
||||||
int start_line)
|
int start_line)
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
|
||||||
|
|
||||||
WebFrame* web_frame = GetWebFrame(frame);
|
|
||||||
if(web_frame) {
|
|
||||||
web_frame->ExecuteScript(
|
|
||||||
WebScriptSource(WebString(js_code), WebURL(GURL(script_url)),
|
|
||||||
start_line));
|
|
||||||
}
|
|
||||||
|
|
||||||
frame->Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefBrowserImpl::UIT_GoBackOrForward(int offset)
|
|
||||||
{
|
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
nav_controller_->GoToOffset(offset);
|
|
||||||
}
|
WebFrame* web_frame = GetWebFrame(frame);
|
||||||
|
if(web_frame) {
|
||||||
void CefBrowserImpl::UIT_Reload()
|
web_frame->ExecuteScript(
|
||||||
{
|
WebScriptSource(WebString(js_code), WebURL(GURL(script_url)),
|
||||||
|
start_line));
|
||||||
|
}
|
||||||
|
|
||||||
|
frame->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserImpl::UIT_GoBackOrForward(int offset)
|
||||||
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
nav_controller_->Reload();
|
nav_controller_->GoToOffset(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefBrowserImpl::UIT_Reload()
|
||||||
|
{
|
||||||
|
REQUIRE_UIT();
|
||||||
|
nav_controller_->Reload();
|
||||||
|
}
|
||||||
|
|
||||||
bool CefBrowserImpl::UIT_Navigate(const BrowserNavigationEntry& entry,
|
bool CefBrowserImpl::UIT_Navigate(const BrowserNavigationEntry& entry,
|
||||||
bool reload)
|
bool reload)
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
// Get the right target frame for the entry.
|
// Get the right target frame for the entry.
|
||||||
WebFrame* frame;
|
WebFrame* frame;
|
||||||
if (!entry.GetTargetFrame().empty())
|
if (!entry.GetTargetFrame().empty())
|
||||||
frame = GetWebView()->GetFrameWithName(entry.GetTargetFrame());
|
frame = GetWebView()->GetFrameWithName(entry.GetTargetFrame());
|
||||||
else
|
else
|
||||||
frame = GetWebView()->GetMainFrame();
|
frame = GetWebView()->GetMainFrame();
|
||||||
// TODO(mpcomplete): should we clear the target frame, or should
|
// TODO(mpcomplete): should we clear the target frame, or should
|
||||||
// back/forward navigations maintain the target frame?
|
// back/forward navigations maintain the target frame?
|
||||||
|
|
||||||
// A navigation resulting from loading a javascript URL should not be
|
// A navigation resulting from loading a javascript URL should not be
|
||||||
// treated as a browser initiated event. Instead, we want it to look as if
|
// treated as a browser initiated event. Instead, we want it to look as if
|
||||||
// the page initiated any load resulting from JS execution.
|
// the page initiated any load resulting from JS execution.
|
||||||
if (!entry.GetURL().SchemeIs("javascript")) {
|
if (!entry.GetURL().SchemeIs("javascript")) {
|
||||||
delegate_->set_pending_extra_data(
|
delegate_->set_pending_extra_data(
|
||||||
new BrowserExtraData(entry.GetPageID()));
|
new BrowserExtraData(entry.GetPageID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are reloading, then WebKit will use the state of the current page.
|
// If we are reloading, then WebKit will use the state of the current page.
|
||||||
// Otherwise, we give it the state to navigate to.
|
// Otherwise, we give it the state to navigate to.
|
||||||
if (reload) {
|
if (reload) {
|
||||||
frame->Reload();
|
frame->Reload();
|
||||||
} else if (!entry.GetContentState().empty()) {
|
} else if (!entry.GetContentState().empty()) {
|
||||||
DCHECK(entry.GetPageID() != -1);
|
DCHECK(entry.GetPageID() != -1);
|
||||||
frame->LoadHistoryItem(
|
frame->LoadHistoryItem(
|
||||||
webkit_glue::HistoryItemFromString(entry.GetContentState()));
|
webkit_glue::HistoryItemFromString(entry.GetContentState()));
|
||||||
} else {
|
} else {
|
||||||
DCHECK(entry.GetPageID() == -1);
|
DCHECK(entry.GetPageID() == -1);
|
||||||
WebURLRequest request(entry.GetURL());
|
WebURLRequest request(entry.GetURL());
|
||||||
|
|
||||||
if(entry.GetMethod().size() > 0) {
|
if(entry.GetMethod().size() > 0) {
|
||||||
request.setHTTPMethod(
|
request.setHTTPMethod(
|
||||||
StdStringToWebString(WideToUTF8(entry.GetMethod())));
|
StdStringToWebString(WideToUTF8(entry.GetMethod())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entry.GetHeaders().size() > 0)
|
if(entry.GetHeaders().size() > 0)
|
||||||
CefRequestImpl::SetHeaderMap(entry.GetHeaders(), request);
|
CefRequestImpl::SetHeaderMap(entry.GetHeaders(), request);
|
||||||
|
|
||||||
if(!entry.GetUploadData().isNull())
|
if(!entry.GetUploadData().isNull())
|
||||||
{
|
{
|
||||||
std::string method = WebStringToStdString(request.httpMethod());
|
std::string method = WebStringToStdString(request.httpMethod());
|
||||||
if(method == "GET" || method == "HEAD") {
|
if(method == "GET" || method == "HEAD") {
|
||||||
request.setHTTPMethod(StdStringToWebString("POST"));
|
request.setHTTPMethod(StdStringToWebString("POST"));
|
||||||
}
|
}
|
||||||
if(request.httpHeaderField(StdStringToWebString("Content-Type")).length()
|
if(request.httpHeaderField(StdStringToWebString("Content-Type")).length()
|
||||||
== 0) {
|
== 0) {
|
||||||
request.setHTTPHeaderField(
|
request.setHTTPHeaderField(
|
||||||
StdStringToWebString("Content-Type"),
|
StdStringToWebString("Content-Type"),
|
||||||
StdStringToWebString("application/x-www-form-urlencoded"));
|
StdStringToWebString("application/x-www-form-urlencoded"));
|
||||||
}
|
}
|
||||||
request.setHTTPBody(entry.GetUploadData());
|
request.setHTTPBody(entry.GetUploadData());
|
||||||
}
|
}
|
||||||
|
|
||||||
frame->LoadRequest(request);
|
frame->LoadRequest(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case LoadRequest failed before DidCreateDataSource was called.
|
// In case LoadRequest failed before DidCreateDataSource was called.
|
||||||
delegate_->set_pending_extra_data(NULL);
|
delegate_->set_pending_extra_data(NULL);
|
||||||
|
|
||||||
if (handler_.get() && handler_->HandleSetFocus(this, false) == RV_CONTINUE) {
|
if (handler_.get() && handler_->HandleSetFocus(this, false) == RV_CONTINUE) {
|
||||||
// Restore focus to the main frame prior to loading new request.
|
// Restore focus to the main frame prior to loading new request.
|
||||||
// This makes sure that we don't have a focused iframe. Otherwise, that
|
// This makes sure that we don't have a focused iframe. Otherwise, that
|
||||||
// iframe would keep focus when the SetFocus called immediately after
|
// iframe would keep focus when the SetFocus called immediately after
|
||||||
// LoadRequest, thus making some tests fail (see http://b/issue?id=845337
|
// LoadRequest, thus making some tests fail (see http://b/issue?id=845337
|
||||||
// for more details).
|
// for more details).
|
||||||
// TODO(cef): The above comment may be wrong, or the below call to
|
// TODO(cef): The above comment may be wrong, or the below call to
|
||||||
// SetFocusedFrame() may be unnecessary or in the wrong place. See this
|
// SetFocusedFrame() may be unnecessary or in the wrong place. See this
|
||||||
// thread for additional details:
|
// thread for additional details:
|
||||||
// http://groups.google.com/group/chromium-dev/browse_thread/thread/42bcd31b59e3a168
|
// http://groups.google.com/group/chromium-dev/browse_thread/thread/42bcd31b59e3a168
|
||||||
GetWebView()->SetFocusedFrame(frame);
|
GetWebView()->SetFocusedFrame(frame);
|
||||||
UIT_SetFocus(GetWebViewHost(), true);
|
UIT_SetFocus(GetWebViewHost(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<CefBrowserImpl> CefBrowserImpl::UIT_CreatePopupWindow(const std::wstring& url)
|
CefRefPtr<CefBrowserImpl> CefBrowserImpl::UIT_CreatePopupWindow(const std::wstring& url)
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
CefWindowInfo info;
|
CefWindowInfo info;
|
||||||
info.SetAsPopup(NULL, url.c_str());
|
info.SetAsPopup(NULL, url.c_str());
|
||||||
CefRefPtr<CefHandler> handler = handler_;
|
CefRefPtr<CefHandler> handler = handler_;
|
||||||
std::wstring newUrl = url;
|
std::wstring newUrl = url;
|
||||||
|
|
||||||
if(handler_.get())
|
if(handler_.get())
|
||||||
{
|
{
|
||||||
// Give the handler an opportunity to modify window attributes, handler,
|
// Give the handler an opportunity to modify window attributes, handler,
|
||||||
// or cancel the window creation.
|
// or cancel the window creation.
|
||||||
CefHandler::RetVal rv =
|
CefHandler::RetVal rv =
|
||||||
handler_->HandleBeforeCreated(this, info, true, handler, newUrl);
|
handler_->HandleBeforeCreated(this, info, true, handler, newUrl);
|
||||||
if(rv == RV_HANDLED)
|
if(rv == RV_HANDLED)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<CefBrowserImpl> browser(new CefBrowserImpl(info, true, handler));
|
CefRefPtr<CefBrowserImpl> browser(new CefBrowserImpl(info, true, handler));
|
||||||
browser->UIT_CreateBrowser(newUrl);
|
browser->UIT_CreateBrowser(newUrl);
|
||||||
|
|
||||||
return browser;
|
return browser;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::UIT_Show(WebKit::WebNavigationPolicy policy)
|
void CefBrowserImpl::UIT_Show(WebKit::WebNavigationPolicy policy)
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
delegate_->show(policy);
|
delegate_->show(policy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::UIT_HandleActionView(CefHandler::MenuId menuId)
|
void CefBrowserImpl::UIT_HandleActionView(CefHandler::MenuId menuId)
|
||||||
{
|
{
|
||||||
return UIT_HandleAction(menuId, NULL);
|
return UIT_HandleAction(menuId, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::UIT_HandleAction(CefHandler::MenuId menuId,
|
void CefBrowserImpl::UIT_HandleAction(CefHandler::MenuId menuId,
|
||||||
CefFrame* frame)
|
CefFrame* frame)
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
WebFrame* web_frame = NULL;
|
WebFrame* web_frame = NULL;
|
||||||
if(frame)
|
if(frame)
|
||||||
web_frame = GetWebFrame(frame);
|
web_frame = GetWebFrame(frame);
|
||||||
|
|
||||||
switch(menuId)
|
switch(menuId)
|
||||||
{
|
{
|
||||||
case MENU_ID_NAV_BACK:
|
case MENU_ID_NAV_BACK:
|
||||||
UIT_GoBackOrForward(-1);
|
UIT_GoBackOrForward(-1);
|
||||||
break;
|
break;
|
||||||
case MENU_ID_NAV_FORWARD:
|
case MENU_ID_NAV_FORWARD:
|
||||||
UIT_GoBackOrForward(1);
|
UIT_GoBackOrForward(1);
|
||||||
break;
|
break;
|
||||||
case MENU_ID_NAV_RELOAD:
|
case MENU_ID_NAV_RELOAD:
|
||||||
UIT_Reload();
|
UIT_Reload();
|
||||||
break;
|
break;
|
||||||
case MENU_ID_NAV_STOP:
|
case MENU_ID_NAV_STOP:
|
||||||
GetWebView()->StopLoading();
|
GetWebView()->StopLoading();
|
||||||
break;
|
break;
|
||||||
case MENU_ID_UNDO:
|
case MENU_ID_UNDO:
|
||||||
if(web_frame)
|
if(web_frame)
|
||||||
web_frame->Undo();
|
web_frame->Undo();
|
||||||
break;
|
break;
|
||||||
case MENU_ID_REDO:
|
case MENU_ID_REDO:
|
||||||
if(web_frame)
|
if(web_frame)
|
||||||
web_frame->Redo();
|
web_frame->Redo();
|
||||||
break;
|
break;
|
||||||
case MENU_ID_CUT:
|
case MENU_ID_CUT:
|
||||||
if(web_frame)
|
if(web_frame)
|
||||||
web_frame->Cut();
|
web_frame->Cut();
|
||||||
break;
|
break;
|
||||||
case MENU_ID_COPY:
|
case MENU_ID_COPY:
|
||||||
if(web_frame)
|
if(web_frame)
|
||||||
web_frame->Copy();
|
web_frame->Copy();
|
||||||
break;
|
break;
|
||||||
case MENU_ID_PASTE:
|
case MENU_ID_PASTE:
|
||||||
if(web_frame)
|
if(web_frame)
|
||||||
web_frame->Paste();
|
web_frame->Paste();
|
||||||
break;
|
break;
|
||||||
case MENU_ID_DELETE:
|
case MENU_ID_DELETE:
|
||||||
if(web_frame)
|
if(web_frame)
|
||||||
web_frame->Delete();
|
web_frame->Delete();
|
||||||
break;
|
break;
|
||||||
case MENU_ID_SELECTALL:
|
case MENU_ID_SELECTALL:
|
||||||
if(web_frame)
|
if(web_frame)
|
||||||
web_frame->SelectAll();
|
web_frame->SelectAll();
|
||||||
break;
|
break;
|
||||||
case MENU_ID_PRINT:
|
case MENU_ID_PRINT:
|
||||||
if(web_frame)
|
if(web_frame)
|
||||||
UIT_PrintPages(web_frame);
|
UIT_PrintPages(web_frame);
|
||||||
break;
|
break;
|
||||||
case MENU_ID_VIEWSOURCE:
|
case MENU_ID_VIEWSOURCE:
|
||||||
if(web_frame)
|
if(web_frame)
|
||||||
UIT_ViewDocumentString(web_frame);
|
UIT_ViewDocumentString(web_frame);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(frame)
|
if(frame)
|
||||||
frame->Release();
|
frame->Release();
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef _BROWSER_IMPL_H
|
#ifndef _BROWSER_IMPL_H
|
||||||
#define _BROWSER_IMPL_H
|
#define _BROWSER_IMPL_H
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ public:
|
|||||||
void ExecuteJavaScript(CefRefPtr<CefFrame> frame,
|
void ExecuteJavaScript(CefRefPtr<CefFrame> frame,
|
||||||
const std::wstring& jsCode,
|
const std::wstring& jsCode,
|
||||||
const std::wstring& scriptUrl,
|
const std::wstring& scriptUrl,
|
||||||
int startLine);
|
int startLine);
|
||||||
virtual std::wstring GetURL(CefRefPtr<CefFrame> frame);
|
virtual std::wstring GetURL(CefRefPtr<CefFrame> frame);
|
||||||
|
|
||||||
WebView* GetWebView() const {
|
WebView* GetWebView() const {
|
||||||
@ -97,15 +97,15 @@ public:
|
|||||||
WebViewHost* GetWebViewHost() const {
|
WebViewHost* GetWebViewHost() const {
|
||||||
return webviewhost_.get();
|
return webviewhost_.get();
|
||||||
}
|
}
|
||||||
BrowserWebViewDelegate* GetWebViewDelegate() const {
|
BrowserWebViewDelegate* GetWebViewDelegate() const {
|
||||||
return delegate_.get();
|
return delegate_.get();
|
||||||
}
|
}
|
||||||
HWND GetWebViewWndHandle() const {
|
HWND GetWebViewWndHandle() const {
|
||||||
return webviewhost_->view_handle();
|
return webviewhost_->view_handle();
|
||||||
}
|
}
|
||||||
WebKit::WebWidget* GetPopup() const {
|
WebKit::WebWidget* GetPopup() const {
|
||||||
return popuphost_ ? popuphost_->webwidget() : NULL;
|
return popuphost_ ? popuphost_->webwidget() : NULL;
|
||||||
}
|
}
|
||||||
WebWidgetHost* GetPopupHost() const {
|
WebWidgetHost* GetPopupHost() const {
|
||||||
return popuphost_;
|
return popuphost_;
|
||||||
}
|
}
|
||||||
@ -152,34 +152,34 @@ public:
|
|||||||
|
|
||||||
void UIT_CreateBrowser(const std::wstring& url);
|
void UIT_CreateBrowser(const std::wstring& url);
|
||||||
|
|
||||||
void UIT_LoadURL(CefFrame* frame,
|
void UIT_LoadURL(CefFrame* frame,
|
||||||
const std::wstring& url);
|
const std::wstring& url);
|
||||||
void UIT_LoadURLForRequest(CefFrame* frame,
|
void UIT_LoadURLForRequest(CefFrame* frame,
|
||||||
const std::wstring& url,
|
const std::wstring& url,
|
||||||
const std::wstring& method,
|
const std::wstring& method,
|
||||||
const WebKit::WebHTTPBody& upload_data,
|
const WebKit::WebHTTPBody& upload_data,
|
||||||
const CefRequest::HeaderMap& headers);
|
const CefRequest::HeaderMap& headers);
|
||||||
void UIT_LoadURLForRequestRef(CefFrame* frame,
|
void UIT_LoadURLForRequestRef(CefFrame* frame,
|
||||||
CefRequest* request);
|
CefRequest* request);
|
||||||
void UIT_LoadHTML(CefFrame* frame,
|
void UIT_LoadHTML(CefFrame* frame,
|
||||||
const std::wstring& html,
|
const std::wstring& html,
|
||||||
const std::wstring& url);
|
const std::wstring& url);
|
||||||
void UIT_LoadHTMLForStreamRef(CefFrame* frame,
|
void UIT_LoadHTMLForStreamRef(CefFrame* frame,
|
||||||
CefStreamReader* stream,
|
CefStreamReader* stream,
|
||||||
const std::wstring& url);
|
const std::wstring& url);
|
||||||
void UIT_ExecuteJavaScript(CefFrame* frame,
|
void UIT_ExecuteJavaScript(CefFrame* frame,
|
||||||
const std::wstring& js_code,
|
const std::wstring& js_code,
|
||||||
const std::wstring& script_url,
|
const std::wstring& script_url,
|
||||||
int start_line);
|
int start_line);
|
||||||
void UIT_GoBackOrForward(int offset);
|
void UIT_GoBackOrForward(int offset);
|
||||||
void UIT_Reload();
|
void UIT_Reload();
|
||||||
bool UIT_Navigate(const BrowserNavigationEntry& entry, bool reload);
|
bool UIT_Navigate(const BrowserNavigationEntry& entry, bool reload);
|
||||||
void UIT_SetFocus(WebWidgetHost* host, bool enable);
|
void UIT_SetFocus(WebWidgetHost* host, bool enable);
|
||||||
|
|
||||||
CefRefPtr<CefBrowserImpl> UIT_CreatePopupWindow(const std::wstring& url);
|
CefRefPtr<CefBrowserImpl> UIT_CreatePopupWindow(const std::wstring& url);
|
||||||
WebKit::WebWidget* UIT_CreatePopupWidget(WebView* webview);
|
WebKit::WebWidget* UIT_CreatePopupWidget(WebView* webview);
|
||||||
void UIT_ClosePopupWidget();
|
void UIT_ClosePopupWidget();
|
||||||
|
|
||||||
void UIT_Show(WebKit::WebNavigationPolicy policy);
|
void UIT_Show(WebKit::WebNavigationPolicy policy);
|
||||||
|
|
||||||
// Handles most simple browser actions
|
// Handles most simple browser actions
|
||||||
@ -223,7 +223,7 @@ protected:
|
|||||||
|
|
||||||
std::wstring title_;
|
std::wstring title_;
|
||||||
|
|
||||||
// Context object used to manage printing.
|
// Context object used to manage printing.
|
||||||
printing::PrintingContext print_context_;
|
printing::PrintingContext print_context_;
|
||||||
|
|
||||||
typedef std::map<std::wstring, CefFrame*> FrameMap;
|
typedef std::map<std::wstring, CefFrame*> FrameMap;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
#include "browser_impl.h"
|
#include "browser_impl.h"
|
||||||
@ -13,9 +13,9 @@
|
|||||||
|
|
||||||
#include "base/string_util.h"
|
#include "base/string_util.h"
|
||||||
#include "base/win_util.h"
|
#include "base/win_util.h"
|
||||||
#include "skia/ext/vector_canvas.h"
|
#include "skia/ext/vector_canvas.h"
|
||||||
#include "webkit/api/public/WebRect.h"
|
#include "webkit/api/public/WebRect.h"
|
||||||
#include "webkit/api/public/WebSize.h"
|
#include "webkit/api/public/WebSize.h"
|
||||||
#include "webkit/glue/webframe.h"
|
#include "webkit/glue/webframe.h"
|
||||||
#include "webkit/glue/webkit_glue.h"
|
#include "webkit/glue/webkit_glue.h"
|
||||||
|
|
||||||
@ -39,59 +39,59 @@ LRESULT CALLBACK CefBrowserImpl::WndProc(HWND hwnd, UINT message,
|
|||||||
CefBrowserImpl* browser =
|
CefBrowserImpl* browser =
|
||||||
static_cast<CefBrowserImpl*>(win_util::GetWindowUserData(hwnd));
|
static_cast<CefBrowserImpl*>(win_util::GetWindowUserData(hwnd));
|
||||||
|
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
{
|
{
|
||||||
int wmId = LOWORD(wParam);
|
int wmId = LOWORD(wParam);
|
||||||
int wmEvent = HIWORD(wParam);
|
int wmEvent = HIWORD(wParam);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
{
|
{
|
||||||
CefRefPtr<CefHandler> handler = browser->GetHandler();
|
CefRefPtr<CefHandler> handler = browser->GetHandler();
|
||||||
if(handler.get()) {
|
if(handler.get()) {
|
||||||
// Notify the handler that the window is about to be closed
|
// Notify the handler that the window is about to be closed
|
||||||
handler->HandleBeforeWindowClose(browser);
|
handler->HandleBeforeWindowClose(browser);
|
||||||
}
|
}
|
||||||
RevokeDragDrop(browser->GetWebViewWndHandle());
|
RevokeDragDrop(browser->GetWebViewWndHandle());
|
||||||
|
|
||||||
// Call GC twice to clean up garbage.
|
// Call GC twice to clean up garbage.
|
||||||
browser->GetWebView()->GetMainFrame()->CallJSGC();
|
browser->GetWebView()->GetMainFrame()->CallJSGC();
|
||||||
browser->GetWebView()->GetMainFrame()->CallJSGC();
|
browser->GetWebView()->GetMainFrame()->CallJSGC();
|
||||||
|
|
||||||
// Clean up anything associated with the WebViewHost widget.
|
// Clean up anything associated with the WebViewHost widget.
|
||||||
browser->GetWebViewHost()->webwidget()->close();
|
browser->GetWebViewHost()->webwidget()->close();
|
||||||
|
|
||||||
// Remove the browser from the list maintained by the context
|
// Remove the browser from the list maintained by the context
|
||||||
_Context->RemoveBrowser(browser);
|
_Context->RemoveBrowser(browser);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
if (browser && browser->GetWebView()) {
|
if (browser && browser->GetWebView()) {
|
||||||
// resize the web view window to the full size of the browser window
|
// resize the web view window to the full size of the browser window
|
||||||
RECT rc;
|
RECT rc;
|
||||||
GetClientRect(browser->GetMainWndHandle(), &rc);
|
GetClientRect(browser->GetMainWndHandle(), &rc);
|
||||||
MoveWindow(browser->GetWebViewWndHandle(), 0, 0, rc.right, rc.bottom,
|
MoveWindow(browser->GetWebViewWndHandle(), 0, 0, rc.right, rc.bottom,
|
||||||
TRUE);
|
TRUE);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_SETFOCUS:
|
case WM_SETFOCUS:
|
||||||
if (browser && browser->GetWebView())
|
if (browser && browser->GetWebView())
|
||||||
browser->GetWebView()->setFocus(true);
|
browser->GetWebView()->setFocus(true);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_KILLFOCUS:
|
case WM_KILLFOCUS:
|
||||||
if (browser && browser->GetWebView())
|
if (browser && browser->GetWebView())
|
||||||
browser->GetWebView()->setFocus(false);
|
browser->GetWebView()->setFocus(false);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_ERASEBKGND:
|
case WM_ERASEBKGND:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||||
@ -111,9 +111,9 @@ std::wstring CefBrowserImpl::GetSource(CefRefPtr<CefFrame> frame)
|
|||||||
{
|
{
|
||||||
// We need to send the request to the UI thread and wait for the result
|
// We need to send the request to the UI thread and wait for the result
|
||||||
|
|
||||||
// Event that will be used to signal that data is available. Start
|
// Event that will be used to signal that data is available. Start
|
||||||
// in non-signaled mode so that the event will block.
|
// in non-signaled mode so that the event will block.
|
||||||
HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
DCHECK(hEvent != NULL);
|
DCHECK(hEvent != NULL);
|
||||||
|
|
||||||
CefRefPtr<CefStreamWriter> stream(new CefBytesWriter(BUFFER_SIZE));
|
CefRefPtr<CefStreamWriter> stream(new CefBytesWriter(BUFFER_SIZE));
|
||||||
@ -148,9 +148,9 @@ std::wstring CefBrowserImpl::GetText(CefRefPtr<CefFrame> frame)
|
|||||||
{
|
{
|
||||||
// We need to send the request to the UI thread and wait for the result
|
// We need to send the request to the UI thread and wait for the result
|
||||||
|
|
||||||
// Event that will be used to signal that data is available. Start
|
// Event that will be used to signal that data is available. Start
|
||||||
// in non-signaled mode so that the event will block.
|
// in non-signaled mode so that the event will block.
|
||||||
HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
DCHECK(hEvent != NULL);
|
DCHECK(hEvent != NULL);
|
||||||
|
|
||||||
CefRefPtr<CefStreamWriter> stream(new CefBytesWriter(BUFFER_SIZE));
|
CefRefPtr<CefStreamWriter> stream(new CefBytesWriter(BUFFER_SIZE));
|
||||||
@ -185,9 +185,9 @@ bool CefBrowserImpl::CanGoBack()
|
|||||||
{
|
{
|
||||||
// We need to send the request to the UI thread and wait for the result
|
// We need to send the request to the UI thread and wait for the result
|
||||||
|
|
||||||
// Event that will be used to signal that data is available. Start
|
// Event that will be used to signal that data is available. Start
|
||||||
// in non-signaled mode so that the event will block.
|
// in non-signaled mode so that the event will block.
|
||||||
HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
DCHECK(hEvent != NULL);
|
DCHECK(hEvent != NULL);
|
||||||
|
|
||||||
bool retVal = true;
|
bool retVal = true;
|
||||||
@ -215,9 +215,9 @@ bool CefBrowserImpl::CanGoForward()
|
|||||||
{
|
{
|
||||||
// We need to send the request to the UI thread and wait for the result
|
// We need to send the request to the UI thread and wait for the result
|
||||||
|
|
||||||
// Event that will be used to signal that data is available. Start
|
// Event that will be used to signal that data is available. Start
|
||||||
// in non-signaled mode so that the event will block.
|
// in non-signaled mode so that the event will block.
|
||||||
HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
DCHECK(hEvent != NULL);
|
DCHECK(hEvent != NULL);
|
||||||
|
|
||||||
bool retVal = true;
|
bool retVal = true;
|
||||||
@ -244,31 +244,31 @@ void CefBrowserImpl::UIT_CreateBrowser(const std::wstring& url)
|
|||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
// Create the new browser window
|
// Create the new browser window
|
||||||
window_info_.m_hWnd = CreateWindowEx(window_info_.m_dwExStyle, GetWndClass(),
|
window_info_.m_hWnd = CreateWindowEx(window_info_.m_dwExStyle, GetWndClass(),
|
||||||
window_info_.m_windowName, window_info_.m_dwStyle,
|
window_info_.m_windowName, window_info_.m_dwStyle,
|
||||||
window_info_.m_x, window_info_.m_y, window_info_.m_nWidth,
|
window_info_.m_x, window_info_.m_y, window_info_.m_nWidth,
|
||||||
window_info_.m_nHeight, window_info_.m_hWndParent, window_info_.m_hMenu,
|
window_info_.m_nHeight, window_info_.m_hWndParent, window_info_.m_hMenu,
|
||||||
_Context->GetInstanceHandle(), NULL);
|
_Context->GetInstanceHandle(), NULL);
|
||||||
DCHECK(window_info_.m_hWnd != NULL);
|
DCHECK(window_info_.m_hWnd != NULL);
|
||||||
|
|
||||||
// Set window user data to this object for future reference from the window
|
// Set window user data to this object for future reference from the window
|
||||||
// procedure
|
// procedure
|
||||||
win_util::SetWindowUserData(window_info_.m_hWnd, this);
|
win_util::SetWindowUserData(window_info_.m_hWnd, this);
|
||||||
|
|
||||||
// Add the new browser to the list maintained by the context
|
// Add the new browser to the list maintained by the context
|
||||||
_Context->AddBrowser(this);
|
_Context->AddBrowser(this);
|
||||||
|
|
||||||
// Create the webview host object
|
// Create the webview host object
|
||||||
webviewhost_.reset(
|
webviewhost_.reset(
|
||||||
WebViewHost::Create(window_info_.m_hWnd, delegate_.get(),
|
WebViewHost::Create(window_info_.m_hWnd, delegate_.get(),
|
||||||
*_Context->GetWebPreferences()));
|
*_Context->GetWebPreferences()));
|
||||||
GetWebView()->SetUseEditorDelegate(true);
|
GetWebView()->SetUseEditorDelegate(true);
|
||||||
delegate_->RegisterDragDrop();
|
delegate_->RegisterDragDrop();
|
||||||
|
|
||||||
// Size the web view window to the browser window
|
// Size the web view window to the browser window
|
||||||
RECT cr;
|
RECT cr;
|
||||||
GetClientRect(window_info_.m_hWnd, &cr);
|
GetClientRect(window_info_.m_hWnd, &cr);
|
||||||
SetWindowPos(GetWebViewWndHandle(), NULL, cr.left, cr.top, cr.right,
|
SetWindowPos(GetWebViewWndHandle(), NULL, cr.left, cr.top, cr.right,
|
||||||
cr.bottom, SWP_NOZORDER | SWP_SHOWWINDOW);
|
cr.bottom, SWP_NOZORDER | SWP_SHOWWINDOW);
|
||||||
|
|
||||||
if(handler_.get()) {
|
if(handler_.get()) {
|
||||||
@ -286,46 +286,46 @@ void CefBrowserImpl::UIT_CreateBrowser(const std::wstring& url)
|
|||||||
void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable)
|
void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable)
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
if (enable)
|
if (enable)
|
||||||
::SetFocus(host->view_handle());
|
::SetFocus(host->view_handle());
|
||||||
else if (::GetFocus() == host->view_handle())
|
else if (::GetFocus() == host->view_handle())
|
||||||
::SetFocus(NULL);
|
::SetFocus(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebKit::WebWidget* CefBrowserImpl::UIT_CreatePopupWidget(WebView* webview)
|
WebKit::WebWidget* CefBrowserImpl::UIT_CreatePopupWidget(WebView* webview)
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
DCHECK(!popuphost_);
|
DCHECK(!popuphost_);
|
||||||
popuphost_ = WebWidgetHost::Create(NULL, popup_delegate_.get());
|
popuphost_ = WebWidgetHost::Create(NULL, popup_delegate_.get());
|
||||||
ShowWindow(GetPopupWndHandle(), SW_SHOW);
|
ShowWindow(GetPopupWndHandle(), SW_SHOW);
|
||||||
|
|
||||||
return popuphost_->webwidget();
|
return popuphost_->webwidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::UIT_ClosePopupWidget()
|
void CefBrowserImpl::UIT_ClosePopupWidget()
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
PostMessage(GetPopupWndHandle(), WM_CLOSE, 0, 0);
|
PostMessage(GetPopupWndHandle(), WM_CLOSE, 0, 0);
|
||||||
popuphost_ = NULL;
|
popuphost_ = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void WriteTextToFile(const std::string& data,
|
static void WriteTextToFile(const std::string& data,
|
||||||
const std::wstring& file_path)
|
const std::wstring& file_path)
|
||||||
{
|
{
|
||||||
FILE* fp;
|
FILE* fp;
|
||||||
errno_t err = _wfopen_s(&fp, file_path.c_str(), L"wt");
|
errno_t err = _wfopen_s(&fp, file_path.c_str(), L"wt");
|
||||||
if (err)
|
if (err)
|
||||||
return;
|
return;
|
||||||
fwrite(data.c_str(), 1, data.size(), fp);
|
fwrite(data.c_str(), 1, data.size(), fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefBrowserImpl::UIT_ViewDocumentString(WebFrame *frame)
|
bool CefBrowserImpl::UIT_ViewDocumentString(WebFrame *frame)
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
DWORD dwRetVal;
|
DWORD dwRetVal;
|
||||||
@ -333,7 +333,7 @@ bool CefBrowserImpl::UIT_ViewDocumentString(WebFrame *frame)
|
|||||||
TCHAR lpPathBuffer[512];
|
TCHAR lpPathBuffer[512];
|
||||||
UINT uRetVal;
|
UINT uRetVal;
|
||||||
TCHAR szTempName[512];
|
TCHAR szTempName[512];
|
||||||
|
|
||||||
dwRetVal = GetTempPath(dwBufSize, // length of the buffer
|
dwRetVal = GetTempPath(dwBufSize, // length of the buffer
|
||||||
lpPathBuffer); // buffer for path
|
lpPathBuffer); // buffer for path
|
||||||
if (dwRetVal > dwBufSize || (dwRetVal == 0))
|
if (dwRetVal > dwBufSize || (dwRetVal == 0))
|
||||||
@ -349,22 +349,22 @@ bool CefBrowserImpl::UIT_ViewDocumentString(WebFrame *frame)
|
|||||||
|
|
||||||
size_t len = wcslen(szTempName);
|
size_t len = wcslen(szTempName);
|
||||||
wcscpy(szTempName + len - 3, L"txt");
|
wcscpy(szTempName + len - 3, L"txt");
|
||||||
WriteTextToFile(frame->GetFullPageHtml(), szTempName);
|
WriteTextToFile(frame->GetFullPageHtml(), szTempName);
|
||||||
|
|
||||||
int errorCode = (int)ShellExecute(GetMainWndHandle(), L"open", szTempName,
|
int errorCode = (int)ShellExecute(GetMainWndHandle(), L"open", szTempName,
|
||||||
NULL, NULL, SW_SHOWNORMAL);
|
NULL, NULL, SW_SHOWNORMAL);
|
||||||
if(errorCode <= 32)
|
if(errorCode <= 32)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::UIT_GetDocumentStringNotify(CefFrame* frame,
|
void CefBrowserImpl::UIT_GetDocumentStringNotify(CefFrame* frame,
|
||||||
CefStreamWriter* writer,
|
CefStreamWriter* writer,
|
||||||
HANDLE hEvent)
|
HANDLE hEvent)
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
WebFrame* web_frame = GetWebFrame(frame);
|
WebFrame* web_frame = GetWebFrame(frame);
|
||||||
if(web_frame) {
|
if(web_frame) {
|
||||||
// Retrieve the document string
|
// Retrieve the document string
|
||||||
@ -378,14 +378,14 @@ void CefBrowserImpl::UIT_GetDocumentStringNotify(CefFrame* frame,
|
|||||||
|
|
||||||
writer->Release();
|
writer->Release();
|
||||||
frame->Release();
|
frame->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::UIT_GetDocumentTextNotify(CefFrame* frame,
|
void CefBrowserImpl::UIT_GetDocumentTextNotify(CefFrame* frame,
|
||||||
CefStreamWriter* writer,
|
CefStreamWriter* writer,
|
||||||
HANDLE hEvent)
|
HANDLE hEvent)
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
WebFrame* web_frame = GetWebFrame(frame);
|
WebFrame* web_frame = GetWebFrame(frame);
|
||||||
if(web_frame) {
|
if(web_frame) {
|
||||||
// Retrieve the document string
|
// Retrieve the document string
|
||||||
@ -400,12 +400,12 @@ void CefBrowserImpl::UIT_GetDocumentTextNotify(CefFrame* frame,
|
|||||||
|
|
||||||
writer->Release();
|
writer->Release();
|
||||||
frame->Release();
|
frame->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::UIT_CanGoBackNotify(bool *retVal, HANDLE hEvent)
|
void CefBrowserImpl::UIT_CanGoBackNotify(bool *retVal, HANDLE hEvent)
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
*retVal = UIT_CanGoBack();
|
*retVal = UIT_CanGoBack();
|
||||||
|
|
||||||
// Notify the calling thread that the data is now available
|
// Notify the calling thread that the data is now available
|
||||||
@ -415,190 +415,190 @@ void CefBrowserImpl::UIT_CanGoBackNotify(bool *retVal, HANDLE hEvent)
|
|||||||
void CefBrowserImpl::UIT_CanGoForwardNotify(bool *retVal, HANDLE hEvent)
|
void CefBrowserImpl::UIT_CanGoForwardNotify(bool *retVal, HANDLE hEvent)
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
*retVal = UIT_CanGoForward();
|
*retVal = UIT_CanGoForward();
|
||||||
|
|
||||||
// Notify the calling thread that the data is now available
|
// Notify the calling thread that the data is now available
|
||||||
SetEvent(hEvent);
|
SetEvent(hEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::UIT_PrintPage(int page_number, int total_pages,
|
void CefBrowserImpl::UIT_PrintPage(int page_number, int total_pages,
|
||||||
const gfx::Size& canvas_size,
|
const gfx::Size& canvas_size,
|
||||||
WebFrame* frame) {
|
WebFrame* frame) {
|
||||||
#if !CEF_PATCHES_APPLIED
|
#if !CEF_PATCHES_APPLIED
|
||||||
NOTREACHED() << "CEF patches must be applied to support printing.";
|
NOTREACHED() << "CEF patches must be applied to support printing.";
|
||||||
return;
|
return;
|
||||||
#endif // !CEF_PATCHES_APPLIED
|
#endif // !CEF_PATCHES_APPLIED
|
||||||
|
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
printing::PrintParams params;
|
printing::PrintParams params;
|
||||||
const printing::PrintSettings &settings = print_context_.settings();
|
const printing::PrintSettings &settings = print_context_.settings();
|
||||||
settings.RenderParams(¶ms);
|
settings.RenderParams(¶ms);
|
||||||
|
|
||||||
int src_size_x = canvas_size.width();
|
int src_size_x = canvas_size.width();
|
||||||
int src_size_y = canvas_size.height();
|
int src_size_y = canvas_size.height();
|
||||||
float src_margin = .1f * src_size_x;
|
float src_margin = .1f * src_size_x;
|
||||||
|
|
||||||
int dest_size_x = settings.page_setup_pixels().physical_size().width();
|
int dest_size_x = settings.page_setup_pixels().physical_size().width();
|
||||||
int dest_size_y = settings.page_setup_pixels().physical_size().height();
|
int dest_size_y = settings.page_setup_pixels().physical_size().height();
|
||||||
float dest_margin = .1f * dest_size_x;
|
float dest_margin = .1f * dest_size_x;
|
||||||
|
|
||||||
print_context_.NewPage();
|
print_context_.NewPage();
|
||||||
|
|
||||||
HDC hDC = print_context_.context();
|
HDC hDC = print_context_.context();
|
||||||
BOOL res;
|
BOOL res;
|
||||||
|
|
||||||
// Save the state to make sure the context this function call does not modify
|
// Save the state to make sure the context this function call does not modify
|
||||||
// the device context.
|
// the device context.
|
||||||
int saved_state = SaveDC(hDC);
|
int saved_state = SaveDC(hDC);
|
||||||
DCHECK_NE(saved_state, 0);
|
DCHECK_NE(saved_state, 0);
|
||||||
|
|
||||||
skia::VectorCanvas canvas(hDC, dest_size_x, dest_size_y);
|
skia::VectorCanvas canvas(hDC, dest_size_x, dest_size_y);
|
||||||
|
|
||||||
// Adjust for the margin offset.
|
// Adjust for the margin offset.
|
||||||
canvas.translate(dest_margin, dest_margin);
|
canvas.translate(dest_margin, dest_margin);
|
||||||
|
|
||||||
// Apply the print scaling factor.
|
// Apply the print scaling factor.
|
||||||
float print_scale = (dest_size_x - dest_margin * 2) / src_size_x;
|
float print_scale = (dest_size_x - dest_margin * 2) / src_size_x;
|
||||||
canvas.scale(print_scale, print_scale);
|
canvas.scale(print_scale, print_scale);
|
||||||
|
|
||||||
// Set the clipping region to be sure to not overflow.
|
// Set the clipping region to be sure to not overflow.
|
||||||
SkRect clip_rect;
|
SkRect clip_rect;
|
||||||
clip_rect.set(0, 0, static_cast<float>(src_size_x),
|
clip_rect.set(0, 0, static_cast<float>(src_size_x),
|
||||||
static_cast<float>(src_size_y));
|
static_cast<float>(src_size_y));
|
||||||
canvas.clipRect(clip_rect);
|
canvas.clipRect(clip_rect);
|
||||||
|
|
||||||
// Apply the WebKit scaling factor.
|
// Apply the WebKit scaling factor.
|
||||||
float webkit_scale = 0;
|
float webkit_scale = 0;
|
||||||
#if CEF_PATCHES_APPLIED
|
#if CEF_PATCHES_APPLIED
|
||||||
webkit_scale = frame->GetPrintPageShrink(page_number);
|
webkit_scale = frame->GetPrintPageShrink(page_number);
|
||||||
#endif // CEF_PATCHES_APPLIED
|
#endif // CEF_PATCHES_APPLIED
|
||||||
if (webkit_scale <= 0) {
|
if (webkit_scale <= 0) {
|
||||||
NOTREACHED() << "Printing page " << page_number << " failed.";
|
NOTREACHED() << "Printing page " << page_number << " failed.";
|
||||||
}
|
}
|
||||||
canvas.scale(webkit_scale, webkit_scale);
|
canvas.scale(webkit_scale, webkit_scale);
|
||||||
|
|
||||||
frame->PrintPage(page_number, &canvas);
|
frame->PrintPage(page_number, &canvas);
|
||||||
|
|
||||||
res = RestoreDC(hDC, saved_state);
|
res = RestoreDC(hDC, saved_state);
|
||||||
DCHECK_NE(res, 0);
|
DCHECK_NE(res, 0);
|
||||||
|
|
||||||
if(handler_.get()) {
|
if(handler_.get()) {
|
||||||
saved_state = SaveDC(hDC);
|
saved_state = SaveDC(hDC);
|
||||||
DCHECK_NE(saved_state, 0);
|
DCHECK_NE(saved_state, 0);
|
||||||
|
|
||||||
// Gather print header state information
|
// Gather print header state information
|
||||||
RECT rect;
|
RECT rect;
|
||||||
rect.left = (int)floor(dest_margin / 2);
|
rect.left = (int)floor(dest_margin / 2);
|
||||||
rect.top = rect.left;
|
rect.top = rect.left;
|
||||||
rect.right = (int)ceil(dest_size_x - dest_margin / 2);
|
rect.right = (int)ceil(dest_size_x - dest_margin / 2);
|
||||||
rect.bottom = (int)ceil(dest_size_y - dest_margin / 2);
|
rect.bottom = (int)ceil(dest_size_y - dest_margin / 2);
|
||||||
|
|
||||||
double scale = (double)settings.dpi() / (double)settings.desired_dpi;
|
double scale = (double)settings.dpi() / (double)settings.desired_dpi;
|
||||||
|
|
||||||
CefPrintInfo printInfo;
|
CefPrintInfo printInfo;
|
||||||
|
|
||||||
printInfo.m_hDC = hDC;
|
printInfo.m_hDC = hDC;
|
||||||
printInfo.m_Rect = rect;
|
printInfo.m_Rect = rect;
|
||||||
printInfo.m_Scale = scale;
|
printInfo.m_Scale = scale;
|
||||||
|
|
||||||
std::wstring url = UTF8ToWide(frame->GetURL().spec());
|
std::wstring url = UTF8ToWide(frame->GetURL().spec());
|
||||||
std::wstring title = title_;
|
std::wstring title = title_;
|
||||||
|
|
||||||
std::wstring topLeft, topCenter, topRight;
|
std::wstring topLeft, topCenter, topRight;
|
||||||
std::wstring bottomLeft, bottomCenter, bottomRight;
|
std::wstring bottomLeft, bottomCenter, bottomRight;
|
||||||
|
|
||||||
// allow the handler to format print header and/or footer
|
// allow the handler to format print header and/or footer
|
||||||
CefHandler::RetVal rv = handler_->HandlePrintHeaderFooter(this,
|
CefHandler::RetVal rv = handler_->HandlePrintHeaderFooter(this,
|
||||||
GetCefFrame(frame), printInfo, url, title, page_number+1, total_pages,
|
GetCefFrame(frame), printInfo, url, title, page_number+1, total_pages,
|
||||||
topLeft, topCenter, topRight, bottomLeft, bottomCenter, bottomRight);
|
topLeft, topCenter, topRight, bottomLeft, bottomCenter, bottomRight);
|
||||||
|
|
||||||
if(rv != RV_HANDLED) {
|
if(rv != RV_HANDLED) {
|
||||||
// Draw handler-defined headers and/or footers.
|
// Draw handler-defined headers and/or footers.
|
||||||
LOGFONT lf;
|
LOGFONT lf;
|
||||||
memset(&lf, 0, sizeof(lf));
|
memset(&lf, 0, sizeof(lf));
|
||||||
lf.lfHeight = (int)ceil(10. * scale);
|
lf.lfHeight = (int)ceil(10. * scale);
|
||||||
lf.lfPitchAndFamily = FF_SWISS;
|
lf.lfPitchAndFamily = FF_SWISS;
|
||||||
HFONT hFont = CreateFontIndirect(&lf);
|
HFONT hFont = CreateFontIndirect(&lf);
|
||||||
|
|
||||||
HFONT hOldFont = (HFONT)SelectObject(hDC, hFont);
|
HFONT hOldFont = (HFONT)SelectObject(hDC, hFont);
|
||||||
COLORREF hOldColor = SetTextColor(hDC, RGB(0,0,0));
|
COLORREF hOldColor = SetTextColor(hDC, RGB(0,0,0));
|
||||||
int hOldBkMode = SetBkMode(hDC, TRANSPARENT);
|
int hOldBkMode = SetBkMode(hDC, TRANSPARENT);
|
||||||
|
|
||||||
// TODO(cef): Keep the header strings inside a reasonable bounding box
|
// TODO(cef): Keep the header strings inside a reasonable bounding box
|
||||||
// so that they don't overlap each other.
|
// so that they don't overlap each other.
|
||||||
if(topLeft.size() > 0) {
|
if(topLeft.size() > 0) {
|
||||||
DrawText(hDC, topLeft.c_str(), topLeft.size(), &rect,
|
DrawText(hDC, topLeft.c_str(), topLeft.size(), &rect,
|
||||||
DT_LEFT | DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS
|
DT_LEFT | DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS
|
||||||
| DT_EXPANDTABS | DT_NOPREFIX);
|
| DT_EXPANDTABS | DT_NOPREFIX);
|
||||||
}
|
}
|
||||||
if(topCenter.size() > 0) {
|
if(topCenter.size() > 0) {
|
||||||
DrawText(hDC, topCenter.c_str(), topCenter.size(), &rect,
|
DrawText(hDC, topCenter.c_str(), topCenter.size(), &rect,
|
||||||
DT_CENTER | DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS
|
DT_CENTER | DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS
|
||||||
| DT_EXPANDTABS | DT_NOPREFIX);
|
| DT_EXPANDTABS | DT_NOPREFIX);
|
||||||
}
|
}
|
||||||
if(topRight.size() > 0) {
|
if(topRight.size() > 0) {
|
||||||
DrawText(hDC, topRight.c_str(), topRight.size(), &rect,
|
DrawText(hDC, topRight.c_str(), topRight.size(), &rect,
|
||||||
DT_RIGHT | DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS
|
DT_RIGHT | DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS
|
||||||
| DT_EXPANDTABS | DT_NOPREFIX);
|
| DT_EXPANDTABS | DT_NOPREFIX);
|
||||||
}
|
}
|
||||||
if(bottomLeft.size() > 0) {
|
if(bottomLeft.size() > 0) {
|
||||||
DrawText(hDC, bottomLeft.c_str(), bottomLeft.size(), &rect,
|
DrawText(hDC, bottomLeft.c_str(), bottomLeft.size(), &rect,
|
||||||
DT_LEFT | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS
|
DT_LEFT | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS
|
||||||
| DT_EXPANDTABS | DT_NOPREFIX);
|
| DT_EXPANDTABS | DT_NOPREFIX);
|
||||||
}
|
}
|
||||||
if(bottomCenter.size() > 0) {
|
if(bottomCenter.size() > 0) {
|
||||||
DrawText(hDC, bottomCenter.c_str(), bottomCenter.size(), &rect,
|
DrawText(hDC, bottomCenter.c_str(), bottomCenter.size(), &rect,
|
||||||
DT_CENTER | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS
|
DT_CENTER | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS
|
||||||
| DT_EXPANDTABS | DT_NOPREFIX);
|
| DT_EXPANDTABS | DT_NOPREFIX);
|
||||||
}
|
}
|
||||||
if(bottomRight.size() > 0) {
|
if(bottomRight.size() > 0) {
|
||||||
DrawText(hDC, bottomRight.c_str(), bottomRight.size(), &rect,
|
DrawText(hDC, bottomRight.c_str(), bottomRight.size(), &rect,
|
||||||
DT_RIGHT | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS
|
DT_RIGHT | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS
|
||||||
| DT_EXPANDTABS | DT_NOPREFIX);
|
| DT_EXPANDTABS | DT_NOPREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetTextColor(hDC, hOldColor);
|
SetTextColor(hDC, hOldColor);
|
||||||
SelectObject(hDC, hOldFont);
|
SelectObject(hDC, hOldFont);
|
||||||
DeleteObject(hFont);
|
DeleteObject(hFont);
|
||||||
SetBkMode(hDC, hOldBkMode);
|
SetBkMode(hDC, hOldBkMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = RestoreDC(hDC, saved_state);
|
res = RestoreDC(hDC, saved_state);
|
||||||
DCHECK_NE(res, 0);
|
DCHECK_NE(res, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
print_context_.PageDone();
|
print_context_.PageDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::UIT_PrintPages(WebFrame* frame) {
|
void CefBrowserImpl::UIT_PrintPages(WebFrame* frame) {
|
||||||
#if !CEF_PATCHES_APPLIED
|
#if !CEF_PATCHES_APPLIED
|
||||||
NOTREACHED() << "CEF patches must be applied to support printing.";
|
NOTREACHED() << "CEF patches must be applied to support printing.";
|
||||||
return;
|
return;
|
||||||
#endif // !CEF_PATCHES_APPLIED
|
#endif // !CEF_PATCHES_APPLIED
|
||||||
|
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
TCHAR printername[512];
|
TCHAR printername[512];
|
||||||
DWORD size = sizeof(printername)-1;
|
DWORD size = sizeof(printername)-1;
|
||||||
if(GetDefaultPrinter(printername, &size)) {
|
if(GetDefaultPrinter(printername, &size)) {
|
||||||
printing::PrintSettings settings;
|
printing::PrintSettings settings;
|
||||||
settings.set_device_name(printername);
|
settings.set_device_name(printername);
|
||||||
// Initialize it.
|
// Initialize it.
|
||||||
print_context_.InitWithSettings(settings);
|
print_context_.InitWithSettings(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(print_context_.AskUserForSettings(
|
if(print_context_.AskUserForSettings(
|
||||||
GetMainWndHandle(), UIT_GetPagesCount(frame), false)
|
GetMainWndHandle(), UIT_GetPagesCount(frame), false)
|
||||||
!= printing::PrintingContext::OK)
|
!= printing::PrintingContext::OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
printing::PrintParams params;
|
printing::PrintParams params;
|
||||||
const printing::PrintSettings &settings = print_context_.settings();
|
const printing::PrintSettings &settings = print_context_.settings();
|
||||||
|
|
||||||
settings.RenderParams(¶ms);
|
settings.RenderParams(¶ms);
|
||||||
|
|
||||||
int page_count = 0;
|
int page_count = 0;
|
||||||
gfx::Size canvas_size;
|
gfx::Size canvas_size;
|
||||||
|
|
||||||
@ -611,46 +611,46 @@ void CefBrowserImpl::UIT_PrintPages(WebFrame* frame) {
|
|||||||
printing::ConvertUnit(
|
printing::ConvertUnit(
|
||||||
settings.page_setup_pixels().physical_size().height(),
|
settings.page_setup_pixels().physical_size().height(),
|
||||||
static_cast<int>(params.dpi),
|
static_cast<int>(params.dpi),
|
||||||
params.desired_dpi));
|
params.desired_dpi));
|
||||||
page_count = frame->PrintBegin(WebSize(canvas_size));
|
page_count = frame->PrintBegin(WebSize(canvas_size));
|
||||||
|
|
||||||
if (page_count) {
|
if (page_count) {
|
||||||
bool old_state = MessageLoop::current()->NestableTasksAllowed();
|
bool old_state = MessageLoop::current()->NestableTasksAllowed();
|
||||||
MessageLoop::current()->SetNestableTasksAllowed(false);
|
MessageLoop::current()->SetNestableTasksAllowed(false);
|
||||||
|
|
||||||
// TODO(cef): Use the page title as the document name
|
// TODO(cef): Use the page title as the document name
|
||||||
print_context_.NewDocument(L"New Document");
|
print_context_.NewDocument(L"New Document");
|
||||||
if(settings.ranges.size() > 0) {
|
if(settings.ranges.size() > 0) {
|
||||||
for (unsigned x = 0; x < settings.ranges.size(); ++x) {
|
for (unsigned x = 0; x < settings.ranges.size(); ++x) {
|
||||||
const printing::PageRange& range = settings.ranges[x];
|
const printing::PageRange& range = settings.ranges[x];
|
||||||
for(int i = range.from; i <= range.to; ++i)
|
for(int i = range.from; i <= range.to; ++i)
|
||||||
UIT_PrintPage(i, page_count, canvas_size, frame);
|
UIT_PrintPage(i, page_count, canvas_size, frame);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < page_count; ++i)
|
for(int i = 0; i < page_count; ++i)
|
||||||
UIT_PrintPage(i, page_count, canvas_size, frame);
|
UIT_PrintPage(i, page_count, canvas_size, frame);
|
||||||
}
|
}
|
||||||
print_context_.DocumentDone();
|
print_context_.DocumentDone();
|
||||||
|
|
||||||
MessageLoop::current()->SetNestableTasksAllowed(old_state);
|
MessageLoop::current()->SetNestableTasksAllowed(old_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
frame->PrintEnd();
|
frame->PrintEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CefBrowserImpl::UIT_GetPagesCount(WebFrame* frame)
|
int CefBrowserImpl::UIT_GetPagesCount(WebFrame* frame)
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
printing::PrintParams params;
|
printing::PrintParams params;
|
||||||
const printing::PrintSettings &settings = print_context_.settings();
|
const printing::PrintSettings &settings = print_context_.settings();
|
||||||
|
|
||||||
settings.RenderParams(¶ms);
|
settings.RenderParams(¶ms);
|
||||||
|
|
||||||
// The dbi will be 0 if no default printer is configured.
|
// The dbi will be 0 if no default printer is configured.
|
||||||
if(params.dpi == 0)
|
if(params.dpi == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int page_count = 0;
|
int page_count = 0;
|
||||||
gfx::Size canvas_size;
|
gfx::Size canvas_size;
|
||||||
|
|
||||||
@ -663,9 +663,9 @@ int CefBrowserImpl::UIT_GetPagesCount(WebFrame* frame)
|
|||||||
printing::ConvertUnit(
|
printing::ConvertUnit(
|
||||||
settings.page_setup_pixels().physical_size().height(),
|
settings.page_setup_pixels().physical_size().height(),
|
||||||
static_cast<int>(params.dpi),
|
static_cast<int>(params.dpi),
|
||||||
params.desired_dpi));
|
params.desired_dpi));
|
||||||
page_count = frame->PrintBegin(WebSize(canvas_size));
|
page_count = frame->PrintBegin(WebSize(canvas_size));
|
||||||
frame->PrintEnd();
|
frame->PrintEnd();
|
||||||
|
|
||||||
return page_count;
|
return page_count;
|
||||||
}
|
}
|
||||||
|
@ -1,242 +1,242 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
#include "browser_navigation_controller.h"
|
#include "browser_navigation_controller.h"
|
||||||
#include "browser_impl.h"
|
#include "browser_impl.h"
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "net/base/upload_data.h"
|
#include "net/base/upload_data.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// BrowserNavigationEntry
|
// BrowserNavigationEntry
|
||||||
|
|
||||||
BrowserNavigationEntry::BrowserNavigationEntry()
|
BrowserNavigationEntry::BrowserNavigationEntry()
|
||||||
: page_id_(-1) {
|
: page_id_(-1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserNavigationEntry::BrowserNavigationEntry(int page_id,
|
BrowserNavigationEntry::BrowserNavigationEntry(int page_id,
|
||||||
const GURL& url,
|
const GURL& url,
|
||||||
const std::wstring& title,
|
const std::wstring& title,
|
||||||
const std::wstring& target_frame,
|
const std::wstring& target_frame,
|
||||||
const std::wstring& method,
|
const std::wstring& method,
|
||||||
const WebKit::WebHTTPBody& upload,
|
const WebKit::WebHTTPBody& upload,
|
||||||
const CefRequest::HeaderMap& headers)
|
const CefRequest::HeaderMap& headers)
|
||||||
: page_id_(page_id),
|
: page_id_(page_id),
|
||||||
url_(url),
|
url_(url),
|
||||||
title_(title),
|
title_(title),
|
||||||
target_frame_(target_frame),
|
target_frame_(target_frame),
|
||||||
method_(method),
|
method_(method),
|
||||||
headers_(headers) {
|
headers_(headers) {
|
||||||
if(!upload.isNull())
|
if(!upload.isNull())
|
||||||
upload_ = upload;
|
upload_ = upload;
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserNavigationEntry::~BrowserNavigationEntry() {
|
BrowserNavigationEntry::~BrowserNavigationEntry() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserNavigationEntry::SetContentState(const std::string& state) {
|
void BrowserNavigationEntry::SetContentState(const std::string& state) {
|
||||||
state_ = state;
|
state_ = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// BrowserNavigationController
|
// BrowserNavigationController
|
||||||
|
|
||||||
BrowserNavigationController::BrowserNavigationController(CefBrowserImpl* shell)
|
BrowserNavigationController::BrowserNavigationController(CefBrowserImpl* shell)
|
||||||
: pending_entry_(NULL),
|
: pending_entry_(NULL),
|
||||||
last_committed_entry_index_(-1),
|
last_committed_entry_index_(-1),
|
||||||
pending_entry_index_(-1),
|
pending_entry_index_(-1),
|
||||||
browser_(shell),
|
browser_(shell),
|
||||||
max_page_id_(-1) {
|
max_page_id_(-1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserNavigationController::~BrowserNavigationController() {
|
BrowserNavigationController::~BrowserNavigationController() {
|
||||||
DiscardPendingEntry();
|
DiscardPendingEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserNavigationController::Reset() {
|
void BrowserNavigationController::Reset() {
|
||||||
entries_.clear();
|
entries_.clear();
|
||||||
DiscardPendingEntry();
|
DiscardPendingEntry();
|
||||||
|
|
||||||
last_committed_entry_index_ = -1;
|
last_committed_entry_index_ = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserNavigationController::Reload() {
|
void BrowserNavigationController::Reload() {
|
||||||
// Base the navigation on where we are now...
|
// Base the navigation on where we are now...
|
||||||
int current_index = GetCurrentEntryIndex();
|
int current_index = GetCurrentEntryIndex();
|
||||||
|
|
||||||
// If we are no where, then we can't reload. TODO(darin): We should add a
|
// If we are no where, then we can't reload. TODO(darin): We should add a
|
||||||
// CanReload method.
|
// CanReload method.
|
||||||
if (current_index == -1)
|
if (current_index == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DiscardPendingEntry();
|
DiscardPendingEntry();
|
||||||
|
|
||||||
pending_entry_index_ = current_index;
|
pending_entry_index_ = current_index;
|
||||||
NavigateToPendingEntry(true);
|
NavigateToPendingEntry(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserNavigationController::GoToOffset(int offset) {
|
void BrowserNavigationController::GoToOffset(int offset) {
|
||||||
int index = last_committed_entry_index_ + offset;
|
int index = last_committed_entry_index_ + offset;
|
||||||
if (index < 0 || index >= GetEntryCount())
|
if (index < 0 || index >= GetEntryCount())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GoToIndex(index);
|
GoToIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserNavigationController::GoToIndex(int index) {
|
void BrowserNavigationController::GoToIndex(int index) {
|
||||||
DCHECK(index >= 0);
|
DCHECK(index >= 0);
|
||||||
DCHECK(index < static_cast<int>(entries_.size()));
|
DCHECK(index < static_cast<int>(entries_.size()));
|
||||||
|
|
||||||
DiscardPendingEntry();
|
DiscardPendingEntry();
|
||||||
|
|
||||||
pending_entry_index_ = index;
|
pending_entry_index_ = index;
|
||||||
NavigateToPendingEntry(false);
|
NavigateToPendingEntry(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserNavigationController::LoadEntry(BrowserNavigationEntry* entry) {
|
void BrowserNavigationController::LoadEntry(BrowserNavigationEntry* entry) {
|
||||||
// When navigating to a new page, we don't know for sure if we will actually
|
// When navigating to a new page, we don't know for sure if we will actually
|
||||||
// end up leaving the current page. The new page load could for example
|
// end up leaving the current page. The new page load could for example
|
||||||
// result in a download or a 'no content' response (e.g., a mailto: URL).
|
// result in a download or a 'no content' response (e.g., a mailto: URL).
|
||||||
DiscardPendingEntry();
|
DiscardPendingEntry();
|
||||||
pending_entry_ = entry;
|
pending_entry_ = entry;
|
||||||
NavigateToPendingEntry(false);
|
NavigateToPendingEntry(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BrowserNavigationEntry* BrowserNavigationController::GetLastCommittedEntry() const {
|
BrowserNavigationEntry* BrowserNavigationController::GetLastCommittedEntry() const {
|
||||||
if (last_committed_entry_index_ == -1)
|
if (last_committed_entry_index_ == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
return entries_[last_committed_entry_index_].get();
|
return entries_[last_committed_entry_index_].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserNavigationEntry* BrowserNavigationController::GetActiveEntry() const {
|
BrowserNavigationEntry* BrowserNavigationController::GetActiveEntry() const {
|
||||||
BrowserNavigationEntry* entry = pending_entry_;
|
BrowserNavigationEntry* entry = pending_entry_;
|
||||||
if (!entry)
|
if (!entry)
|
||||||
entry = GetLastCommittedEntry();
|
entry = GetLastCommittedEntry();
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BrowserNavigationController::GetCurrentEntryIndex() const {
|
int BrowserNavigationController::GetCurrentEntryIndex() const {
|
||||||
if (pending_entry_index_ != -1)
|
if (pending_entry_index_ != -1)
|
||||||
return pending_entry_index_;
|
return pending_entry_index_;
|
||||||
return last_committed_entry_index_;
|
return last_committed_entry_index_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BrowserNavigationEntry* BrowserNavigationController::GetEntryAtIndex(
|
BrowserNavigationEntry* BrowserNavigationController::GetEntryAtIndex(
|
||||||
int index) const {
|
int index) const {
|
||||||
if (index < 0 || index >= GetEntryCount())
|
if (index < 0 || index >= GetEntryCount())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return entries_[index].get();
|
return entries_[index].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserNavigationEntry* BrowserNavigationController::GetEntryWithPageID(
|
BrowserNavigationEntry* BrowserNavigationController::GetEntryWithPageID(
|
||||||
int32 page_id) const {
|
int32 page_id) const {
|
||||||
int index = GetEntryIndexWithPageID(page_id);
|
int index = GetEntryIndexWithPageID(page_id);
|
||||||
return (index != -1) ? entries_[index].get() : NULL;
|
return (index != -1) ? entries_[index].get() : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserNavigationController::DidNavigateToEntry(BrowserNavigationEntry* entry) {
|
void BrowserNavigationController::DidNavigateToEntry(BrowserNavigationEntry* entry) {
|
||||||
// If the entry is that of a page with PageID larger than any this Tab has
|
// If the entry is that of a page with PageID larger than any this Tab has
|
||||||
// seen before, then consider it a new navigation.
|
// seen before, then consider it a new navigation.
|
||||||
if (entry->GetPageID() > GetMaxPageID()) {
|
if (entry->GetPageID() > GetMaxPageID()) {
|
||||||
InsertEntry(entry);
|
InsertEntry(entry);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, we just need to update an existing entry with matching PageID.
|
// Otherwise, we just need to update an existing entry with matching PageID.
|
||||||
// If the existing entry corresponds to the entry which is pending, then we
|
// If the existing entry corresponds to the entry which is pending, then we
|
||||||
// must update the current entry index accordingly. When navigating to the
|
// must update the current entry index accordingly. When navigating to the
|
||||||
// same URL, a new PageID is not created.
|
// same URL, a new PageID is not created.
|
||||||
|
|
||||||
int existing_entry_index = GetEntryIndexWithPageID(entry->GetPageID());
|
int existing_entry_index = GetEntryIndexWithPageID(entry->GetPageID());
|
||||||
BrowserNavigationEntry* existing_entry = (existing_entry_index != -1) ?
|
BrowserNavigationEntry* existing_entry = (existing_entry_index != -1) ?
|
||||||
entries_[existing_entry_index].get() : NULL;
|
entries_[existing_entry_index].get() : NULL;
|
||||||
if (!existing_entry) {
|
if (!existing_entry) {
|
||||||
// No existing entry, then simply ignore this navigation!
|
// No existing entry, then simply ignore this navigation!
|
||||||
DLOG(WARNING) << "ignoring navigation for page: " << entry->GetPageID();
|
DLOG(WARNING) << "ignoring navigation for page: " << entry->GetPageID();
|
||||||
} else if (existing_entry == pending_entry_) {
|
} else if (existing_entry == pending_entry_) {
|
||||||
// The given entry might provide a new URL... e.g., navigating back to a
|
// The given entry might provide a new URL... e.g., navigating back to a
|
||||||
// page in session history could have resulted in a new client redirect.
|
// page in session history could have resulted in a new client redirect.
|
||||||
existing_entry->SetURL(entry->GetURL());
|
existing_entry->SetURL(entry->GetURL());
|
||||||
existing_entry->SetContentState(entry->GetContentState());
|
existing_entry->SetContentState(entry->GetContentState());
|
||||||
last_committed_entry_index_ = pending_entry_index_;
|
last_committed_entry_index_ = pending_entry_index_;
|
||||||
pending_entry_index_ = -1;
|
pending_entry_index_ = -1;
|
||||||
pending_entry_ = NULL;
|
pending_entry_ = NULL;
|
||||||
} else if (pending_entry_ && pending_entry_->GetPageID() == -1 &&
|
} else if (pending_entry_ && pending_entry_->GetPageID() == -1 &&
|
||||||
pending_entry_->GetURL() == existing_entry->GetURL()) {
|
pending_entry_->GetURL() == existing_entry->GetURL()) {
|
||||||
// Not a new navigation
|
// Not a new navigation
|
||||||
DiscardPendingEntry();
|
DiscardPendingEntry();
|
||||||
} else {
|
} else {
|
||||||
// The given entry might provide a new URL... e.g., navigating to a page
|
// The given entry might provide a new URL... e.g., navigating to a page
|
||||||
// might result in a client redirect, which should override the URL of the
|
// might result in a client redirect, which should override the URL of the
|
||||||
// existing entry.
|
// existing entry.
|
||||||
existing_entry->SetURL(entry->GetURL());
|
existing_entry->SetURL(entry->GetURL());
|
||||||
existing_entry->SetContentState(entry->GetContentState());
|
existing_entry->SetContentState(entry->GetContentState());
|
||||||
|
|
||||||
// The navigation could have been issued by the renderer, so be sure that
|
// The navigation could have been issued by the renderer, so be sure that
|
||||||
// we update our current index.
|
// we update our current index.
|
||||||
last_committed_entry_index_ = existing_entry_index;
|
last_committed_entry_index_ = existing_entry_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete entry;
|
delete entry;
|
||||||
UpdateMaxPageID();
|
UpdateMaxPageID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserNavigationController::DiscardPendingEntry() {
|
void BrowserNavigationController::DiscardPendingEntry() {
|
||||||
if (pending_entry_index_ == -1)
|
if (pending_entry_index_ == -1)
|
||||||
delete pending_entry_;
|
delete pending_entry_;
|
||||||
pending_entry_ = NULL;
|
pending_entry_ = NULL;
|
||||||
pending_entry_index_ = -1;
|
pending_entry_index_ = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserNavigationController::InsertEntry(BrowserNavigationEntry* entry) {
|
void BrowserNavigationController::InsertEntry(BrowserNavigationEntry* entry) {
|
||||||
DiscardPendingEntry();
|
DiscardPendingEntry();
|
||||||
|
|
||||||
// Prune any entry which are in front of the current entry
|
// Prune any entry which are in front of the current entry
|
||||||
int current_size = static_cast<int>(entries_.size());
|
int current_size = static_cast<int>(entries_.size());
|
||||||
if (current_size > 0) {
|
if (current_size > 0) {
|
||||||
while (last_committed_entry_index_ < (current_size - 1)) {
|
while (last_committed_entry_index_ < (current_size - 1)) {
|
||||||
entries_.pop_back();
|
entries_.pop_back();
|
||||||
current_size--;
|
current_size--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entries_.push_back(linked_ptr<BrowserNavigationEntry>(entry));
|
entries_.push_back(linked_ptr<BrowserNavigationEntry>(entry));
|
||||||
last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1;
|
last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1;
|
||||||
UpdateMaxPageID();
|
UpdateMaxPageID();
|
||||||
}
|
}
|
||||||
|
|
||||||
int BrowserNavigationController::GetEntryIndexWithPageID(int32 page_id) const {
|
int BrowserNavigationController::GetEntryIndexWithPageID(int32 page_id) const {
|
||||||
for (int i = static_cast<int>(entries_.size())-1; i >= 0; --i) {
|
for (int i = static_cast<int>(entries_.size())-1; i >= 0; --i) {
|
||||||
if (entries_[i]->GetPageID() == page_id)
|
if (entries_[i]->GetPageID() == page_id)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserNavigationController::NavigateToPendingEntry(bool reload) {
|
void BrowserNavigationController::NavigateToPendingEntry(bool reload) {
|
||||||
// For session history navigations only the pending_entry_index_ is set.
|
// For session history navigations only the pending_entry_index_ is set.
|
||||||
if (!pending_entry_) {
|
if (!pending_entry_) {
|
||||||
DCHECK(pending_entry_index_ != -1);
|
DCHECK(pending_entry_index_ != -1);
|
||||||
pending_entry_ = entries_[pending_entry_index_].get();
|
pending_entry_ = entries_[pending_entry_index_].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (browser_->UIT_Navigate(*pending_entry_, reload)) {
|
if (browser_->UIT_Navigate(*pending_entry_, reload)) {
|
||||||
// Note: this is redundant if navigation completed synchronously because
|
// Note: this is redundant if navigation completed synchronously because
|
||||||
// DidNavigateToEntry call this as well.
|
// DidNavigateToEntry call this as well.
|
||||||
UpdateMaxPageID();
|
UpdateMaxPageID();
|
||||||
} else {
|
} else {
|
||||||
DiscardPendingEntry();
|
DiscardPendingEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserNavigationController::UpdateMaxPageID() {
|
void BrowserNavigationController::UpdateMaxPageID() {
|
||||||
BrowserNavigationEntry* entry = GetActiveEntry();
|
BrowserNavigationEntry* entry = GetActiveEntry();
|
||||||
if (entry)
|
if (entry)
|
||||||
max_page_id_ = std::max(max_page_id_, entry->GetPageID());
|
max_page_id_ = std::max(max_page_id_, entry->GetPageID());
|
||||||
}
|
}
|
||||||
|
@ -1,212 +1,212 @@
|
|||||||
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef _BROWSER_NAVIGATION_CONTROLLER_H
|
#ifndef _BROWSER_NAVIGATION_CONTROLLER_H
|
||||||
#define _BROWSER_NAVIGATION_CONTROLLER_H
|
#define _BROWSER_NAVIGATION_CONTROLLER_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
#include "base/linked_ptr.h"
|
#include "base/linked_ptr.h"
|
||||||
#include "base/ref_counted.h"
|
#include "base/ref_counted.h"
|
||||||
#include "googleurl/src/gurl.h"
|
#include "googleurl/src/gurl.h"
|
||||||
#include "webkit/api/public/WebDataSource.h"
|
#include "webkit/api/public/WebDataSource.h"
|
||||||
#include "webkit/api/public/WebHTTPBody.h"
|
#include "webkit/api/public/WebHTTPBody.h"
|
||||||
|
|
||||||
#include "include/cef.h"
|
#include "include/cef.h"
|
||||||
|
|
||||||
class GURL;
|
class GURL;
|
||||||
class CefBrowserImpl;
|
class CefBrowserImpl;
|
||||||
|
|
||||||
// Associated with browser-initated navigations to hold tracking data.
|
// Associated with browser-initated navigations to hold tracking data.
|
||||||
class BrowserExtraData : public WebKit::WebDataSource::ExtraData {
|
class BrowserExtraData : public WebKit::WebDataSource::ExtraData {
|
||||||
public:
|
public:
|
||||||
BrowserExtraData(int32 pending_page_id)
|
BrowserExtraData(int32 pending_page_id)
|
||||||
: pending_page_id(pending_page_id),
|
: pending_page_id(pending_page_id),
|
||||||
request_committed(false) {
|
request_committed(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contains the page_id for this navigation or -1 if there is none yet.
|
// Contains the page_id for this navigation or -1 if there is none yet.
|
||||||
int32 pending_page_id;
|
int32 pending_page_id;
|
||||||
|
|
||||||
// True if we have already processed the "DidCommitLoad" event for this
|
// True if we have already processed the "DidCommitLoad" event for this
|
||||||
// request. Used by session history.
|
// request. Used by session history.
|
||||||
bool request_committed;
|
bool request_committed;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Stores one back/forward navigation state for the test shell.
|
// Stores one back/forward navigation state for the test shell.
|
||||||
class BrowserNavigationEntry {
|
class BrowserNavigationEntry {
|
||||||
public:
|
public:
|
||||||
BrowserNavigationEntry();
|
BrowserNavigationEntry();
|
||||||
BrowserNavigationEntry(int page_id,
|
BrowserNavigationEntry(int page_id,
|
||||||
const GURL& url,
|
const GURL& url,
|
||||||
const std::wstring& title,
|
const std::wstring& title,
|
||||||
const std::wstring& target_frame,
|
const std::wstring& target_frame,
|
||||||
const std::wstring& method,
|
const std::wstring& method,
|
||||||
const WebKit::WebHTTPBody& upload,
|
const WebKit::WebHTTPBody& upload,
|
||||||
const CefRequest::HeaderMap& headers);
|
const CefRequest::HeaderMap& headers);
|
||||||
~BrowserNavigationEntry();
|
~BrowserNavigationEntry();
|
||||||
|
|
||||||
// Set / Get the URI
|
// Set / Get the URI
|
||||||
void SetURL(const GURL& url) { url_ = url; }
|
void SetURL(const GURL& url) { url_ = url; }
|
||||||
const GURL& GetURL() const { return url_; }
|
const GURL& GetURL() const { return url_; }
|
||||||
|
|
||||||
// Set / Get the title
|
// Set / Get the title
|
||||||
void SetTitle(const std::wstring& a_title) { title_ = a_title; }
|
void SetTitle(const std::wstring& a_title) { title_ = a_title; }
|
||||||
const std::wstring& GetTitle() const { return title_; }
|
const std::wstring& GetTitle() const { return title_; }
|
||||||
|
|
||||||
// Set / Get opaque state.
|
// Set / Get opaque state.
|
||||||
// WARNING: This state is saved to the database and used to restore previous
|
// WARNING: This state is saved to the database and used to restore previous
|
||||||
// states. If you use write a custom TabContents and provide your own
|
// states. If you use write a custom TabContents and provide your own
|
||||||
// state make sure you have the ability to modify the format in the future
|
// state make sure you have the ability to modify the format in the future
|
||||||
// while being able to deal with older versions.
|
// while being able to deal with older versions.
|
||||||
void SetContentState(const std::string& state);
|
void SetContentState(const std::string& state);
|
||||||
const std::string& GetContentState() const { return state_; }
|
const std::string& GetContentState() const { return state_; }
|
||||||
|
|
||||||
// Get the page id corresponding to the tab's state.
|
// Get the page id corresponding to the tab's state.
|
||||||
void SetPageID(int page_id) { page_id_ = page_id; }
|
void SetPageID(int page_id) { page_id_ = page_id; }
|
||||||
int32 GetPageID() const { return page_id_; }
|
int32 GetPageID() const { return page_id_; }
|
||||||
|
|
||||||
const std::wstring& GetTargetFrame() const { return target_frame_; }
|
const std::wstring& GetTargetFrame() const { return target_frame_; }
|
||||||
|
|
||||||
const std::wstring& GetMethod() const { return method_; }
|
const std::wstring& GetMethod() const { return method_; }
|
||||||
const WebKit::WebHTTPBody& GetUploadData() const { return upload_; }
|
const WebKit::WebHTTPBody& GetUploadData() const { return upload_; }
|
||||||
const CefRequest::HeaderMap& GetHeaders() const { return headers_; }
|
const CefRequest::HeaderMap& GetHeaders() const { return headers_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Describes the current page that the tab represents. This is not relevant
|
// Describes the current page that the tab represents. This is not relevant
|
||||||
// for all tab contents types.
|
// for all tab contents types.
|
||||||
int32 page_id_;
|
int32 page_id_;
|
||||||
|
|
||||||
GURL url_;
|
GURL url_;
|
||||||
std::wstring title_;
|
std::wstring title_;
|
||||||
std::string state_;
|
std::string state_;
|
||||||
std::wstring method_;
|
std::wstring method_;
|
||||||
WebKit::WebHTTPBody upload_;
|
WebKit::WebHTTPBody upload_;
|
||||||
CefRequest::HeaderMap headers_;
|
CefRequest::HeaderMap headers_;
|
||||||
|
|
||||||
std::wstring target_frame_;
|
std::wstring target_frame_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(BrowserNavigationEntry);
|
DISALLOW_COPY_AND_ASSIGN(BrowserNavigationEntry);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Browser's NavigationController. The goal is to be as close to the Chrome
|
// Browser's NavigationController. The goal is to be as close to the Chrome
|
||||||
// version as possible.
|
// version as possible.
|
||||||
class BrowserNavigationController {
|
class BrowserNavigationController {
|
||||||
public:
|
public:
|
||||||
BrowserNavigationController(CefBrowserImpl* shell);
|
BrowserNavigationController(CefBrowserImpl* shell);
|
||||||
~BrowserNavigationController();
|
~BrowserNavigationController();
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
// Causes the controller to reload the current (or pending) entry.
|
// Causes the controller to reload the current (or pending) entry.
|
||||||
void Reload();
|
void Reload();
|
||||||
|
|
||||||
// Causes the controller to go to the specified offset from current. Does
|
// Causes the controller to go to the specified offset from current. Does
|
||||||
// nothing if out of bounds.
|
// nothing if out of bounds.
|
||||||
void GoToOffset(int offset);
|
void GoToOffset(int offset);
|
||||||
|
|
||||||
// Causes the controller to go to the specified index.
|
// Causes the controller to go to the specified index.
|
||||||
void GoToIndex(int index);
|
void GoToIndex(int index);
|
||||||
|
|
||||||
// Causes the controller to load the specified entry. The controller
|
// Causes the controller to load the specified entry. The controller
|
||||||
// assumes ownership of the entry.
|
// assumes ownership of the entry.
|
||||||
// NOTE: Do not pass an entry that the controller already owns!
|
// NOTE: Do not pass an entry that the controller already owns!
|
||||||
void LoadEntry(BrowserNavigationEntry* entry);
|
void LoadEntry(BrowserNavigationEntry* entry);
|
||||||
|
|
||||||
// Returns the last committed entry, which may be null if there are no
|
// Returns the last committed entry, which may be null if there are no
|
||||||
// committed entries.
|
// committed entries.
|
||||||
BrowserNavigationEntry* GetLastCommittedEntry() const;
|
BrowserNavigationEntry* GetLastCommittedEntry() const;
|
||||||
|
|
||||||
// Returns the number of entries in the NavigationControllerBase, excluding
|
// Returns the number of entries in the NavigationControllerBase, excluding
|
||||||
// the pending entry if there is one.
|
// the pending entry if there is one.
|
||||||
int GetEntryCount() const {
|
int GetEntryCount() const {
|
||||||
return static_cast<int>(entries_.size());
|
return static_cast<int>(entries_.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the active entry, which is the pending entry if a navigation is in
|
// Returns the active entry, which is the pending entry if a navigation is in
|
||||||
// progress or the last committed entry otherwise. NOTE: This can be NULL!!
|
// progress or the last committed entry otherwise. NOTE: This can be NULL!!
|
||||||
//
|
//
|
||||||
// If you are trying to get the current state of the NavigationControllerBase,
|
// If you are trying to get the current state of the NavigationControllerBase,
|
||||||
// this is the method you will typically want to call.
|
// this is the method you will typically want to call.
|
||||||
BrowserNavigationEntry* GetActiveEntry() const;
|
BrowserNavigationEntry* GetActiveEntry() const;
|
||||||
|
|
||||||
// Returns the index from which we would go back/forward or reload. This is
|
// Returns the index from which we would go back/forward or reload. This is
|
||||||
// the last_committed_entry_index_ if pending_entry_index_ is -1. Otherwise,
|
// the last_committed_entry_index_ if pending_entry_index_ is -1. Otherwise,
|
||||||
// it is the pending_entry_index_.
|
// it is the pending_entry_index_.
|
||||||
int GetCurrentEntryIndex() const;
|
int GetCurrentEntryIndex() const;
|
||||||
|
|
||||||
// Returns the entry at the specified index. Returns NULL if out of
|
// Returns the entry at the specified index. Returns NULL if out of
|
||||||
// bounds.
|
// bounds.
|
||||||
BrowserNavigationEntry* GetEntryAtIndex(int index) const;
|
BrowserNavigationEntry* GetEntryAtIndex(int index) const;
|
||||||
|
|
||||||
// Return the entry with the corresponding type and page_id, or NULL if
|
// Return the entry with the corresponding type and page_id, or NULL if
|
||||||
// not found.
|
// not found.
|
||||||
BrowserNavigationEntry* GetEntryWithPageID(int32 page_id) const;
|
BrowserNavigationEntry* GetEntryWithPageID(int32 page_id) const;
|
||||||
|
|
||||||
// Returns the index of the last committed entry.
|
// Returns the index of the last committed entry.
|
||||||
int GetLastCommittedEntryIndex() const {
|
int GetLastCommittedEntryIndex() const {
|
||||||
return last_committed_entry_index_;
|
return last_committed_entry_index_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if there are no entries before the last committed entry.
|
// Returns true if there are no entries before the last committed entry.
|
||||||
bool IsAtStart() const {
|
bool IsAtStart() const {
|
||||||
return (GetLastCommittedEntryIndex() == 0);
|
return (GetLastCommittedEntryIndex() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if there are no entries after the last committed entry.
|
// Returns true if there are no entries after the last committed entry.
|
||||||
bool IsAtEnd() const {
|
bool IsAtEnd() const {
|
||||||
return (GetLastCommittedEntryIndex() == GetEntryCount()-1);
|
return (GetLastCommittedEntryIndex() == GetEntryCount()-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to inform us of a navigation being committed for a tab. We will take
|
// Used to inform us of a navigation being committed for a tab. We will take
|
||||||
// ownership of the entry. Any entry located forward to the current entry will
|
// ownership of the entry. Any entry located forward to the current entry will
|
||||||
// be deleted. The new entry becomes the current entry.
|
// be deleted. The new entry becomes the current entry.
|
||||||
void DidNavigateToEntry(BrowserNavigationEntry* entry);
|
void DidNavigateToEntry(BrowserNavigationEntry* entry);
|
||||||
|
|
||||||
// Used to inform us to discard its pending entry.
|
// Used to inform us to discard its pending entry.
|
||||||
void DiscardPendingEntry();
|
void DiscardPendingEntry();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Inserts an entry after the current position, removing all entries after it.
|
// Inserts an entry after the current position, removing all entries after it.
|
||||||
// The new entry will become the active one.
|
// The new entry will become the active one.
|
||||||
void InsertEntry(BrowserNavigationEntry* entry);
|
void InsertEntry(BrowserNavigationEntry* entry);
|
||||||
|
|
||||||
int GetMaxPageID() const { return max_page_id_; }
|
int GetMaxPageID() const { return max_page_id_; }
|
||||||
void NavigateToPendingEntry(bool reload);
|
void NavigateToPendingEntry(bool reload);
|
||||||
|
|
||||||
// Return the index of the entry with the corresponding type and page_id,
|
// Return the index of the entry with the corresponding type and page_id,
|
||||||
// or -1 if not found.
|
// or -1 if not found.
|
||||||
int GetEntryIndexWithPageID(int32 page_id) const;
|
int GetEntryIndexWithPageID(int32 page_id) const;
|
||||||
|
|
||||||
// Updates the max page ID with that of the given entry, if is larger.
|
// Updates the max page ID with that of the given entry, if is larger.
|
||||||
void UpdateMaxPageID();
|
void UpdateMaxPageID();
|
||||||
|
|
||||||
// List of NavigationEntry for this tab
|
// List of NavigationEntry for this tab
|
||||||
typedef std::vector< linked_ptr<BrowserNavigationEntry> > NavigationEntryList;
|
typedef std::vector< linked_ptr<BrowserNavigationEntry> > NavigationEntryList;
|
||||||
typedef NavigationEntryList::iterator NavigationEntryListIterator;
|
typedef NavigationEntryList::iterator NavigationEntryListIterator;
|
||||||
NavigationEntryList entries_;
|
NavigationEntryList entries_;
|
||||||
|
|
||||||
// An entry we haven't gotten a response for yet. This will be discarded
|
// An entry we haven't gotten a response for yet. This will be discarded
|
||||||
// when we navigate again. It's used only so we know what the currently
|
// when we navigate again. It's used only so we know what the currently
|
||||||
// displayed tab is.
|
// displayed tab is.
|
||||||
BrowserNavigationEntry* pending_entry_;
|
BrowserNavigationEntry* pending_entry_;
|
||||||
|
|
||||||
// currently visible entry
|
// currently visible entry
|
||||||
int last_committed_entry_index_;
|
int last_committed_entry_index_;
|
||||||
|
|
||||||
// index of pending entry if it is in entries_, or -1 if pending_entry_ is a
|
// index of pending entry if it is in entries_, or -1 if pending_entry_ is a
|
||||||
// new entry (created by LoadURL).
|
// new entry (created by LoadURL).
|
||||||
int pending_entry_index_;
|
int pending_entry_index_;
|
||||||
|
|
||||||
CefBrowserImpl* browser_;
|
CefBrowserImpl* browser_;
|
||||||
int max_page_id_;
|
int max_page_id_;
|
||||||
|
|
||||||
DISALLOW_EVIL_CONSTRUCTORS(BrowserNavigationController);
|
DISALLOW_EVIL_CONSTRUCTORS(BrowserNavigationController);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _BROWSER_NAVIGATION_CONTROLLER_H
|
#endif // _BROWSER_NAVIGATION_CONTROLLER_H
|
||||||
|
|
||||||
|
@ -1,63 +1,63 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
#include "browser_request_context.h"
|
#include "browser_request_context.h"
|
||||||
|
|
||||||
#include "net/base/cookie_monster.h"
|
#include "net/base/cookie_monster.h"
|
||||||
#include "net/base/host_resolver.h"
|
#include "net/base/host_resolver.h"
|
||||||
#include "net/ftp/ftp_network_layer.h"
|
#include "net/ftp/ftp_network_layer.h"
|
||||||
#include "net/proxy/proxy_service.h"
|
#include "net/proxy/proxy_service.h"
|
||||||
#include "webkit/glue/webkit_glue.h"
|
#include "webkit/glue/webkit_glue.h"
|
||||||
|
|
||||||
BrowserRequestContext::BrowserRequestContext() {
|
BrowserRequestContext::BrowserRequestContext() {
|
||||||
Init(std::wstring(), net::HttpCache::NORMAL, false);
|
Init(std::wstring(), net::HttpCache::NORMAL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserRequestContext::BrowserRequestContext(
|
BrowserRequestContext::BrowserRequestContext(
|
||||||
const std::wstring& cache_path,
|
const std::wstring& cache_path,
|
||||||
net::HttpCache::Mode cache_mode,
|
net::HttpCache::Mode cache_mode,
|
||||||
bool no_proxy) {
|
bool no_proxy) {
|
||||||
Init(cache_path, cache_mode, no_proxy);
|
Init(cache_path, cache_mode, no_proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserRequestContext::Init(
|
void BrowserRequestContext::Init(
|
||||||
const std::wstring& cache_path,
|
const std::wstring& cache_path,
|
||||||
net::HttpCache::Mode cache_mode,
|
net::HttpCache::Mode cache_mode,
|
||||||
bool no_proxy) {
|
bool no_proxy) {
|
||||||
cookie_store_ = new net::CookieMonster();
|
cookie_store_ = new net::CookieMonster();
|
||||||
|
|
||||||
// hard-code A-L and A-C for test shells
|
// hard-code A-L and A-C for test shells
|
||||||
accept_language_ = "en-us,en";
|
accept_language_ = "en-us,en";
|
||||||
accept_charset_ = "iso-8859-1,*,utf-8";
|
accept_charset_ = "iso-8859-1,*,utf-8";
|
||||||
|
|
||||||
net::ProxyConfig proxy_config;
|
net::ProxyConfig proxy_config;
|
||||||
host_resolver_ = net::CreateSystemHostResolver();
|
host_resolver_ = net::CreateSystemHostResolver();
|
||||||
proxy_service_ = net::ProxyService::Create(no_proxy ? &proxy_config : NULL,
|
proxy_service_ = net::ProxyService::Create(no_proxy ? &proxy_config : NULL,
|
||||||
false, NULL, NULL);
|
false, NULL, NULL);
|
||||||
|
|
||||||
net::HttpCache *cache;
|
net::HttpCache *cache;
|
||||||
if (cache_path.empty()) {
|
if (cache_path.empty()) {
|
||||||
cache = new net::HttpCache(host_resolver_, proxy_service_, 0);
|
cache = new net::HttpCache(host_resolver_, proxy_service_, 0);
|
||||||
} else {
|
} else {
|
||||||
cache = new net::HttpCache(host_resolver_, proxy_service_, cache_path, 0);
|
cache = new net::HttpCache(host_resolver_, proxy_service_, cache_path, 0);
|
||||||
}
|
}
|
||||||
cache->set_mode(cache_mode);
|
cache->set_mode(cache_mode);
|
||||||
http_transaction_factory_ = cache;
|
http_transaction_factory_ = cache;
|
||||||
|
|
||||||
ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_);
|
ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_);
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserRequestContext::~BrowserRequestContext() {
|
BrowserRequestContext::~BrowserRequestContext() {
|
||||||
delete cookie_store_;
|
delete cookie_store_;
|
||||||
delete ftp_transaction_factory_;
|
delete ftp_transaction_factory_;
|
||||||
delete http_transaction_factory_;
|
delete http_transaction_factory_;
|
||||||
delete proxy_service_;
|
delete proxy_service_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& BrowserRequestContext::GetUserAgent(
|
const std::string& BrowserRequestContext::GetUserAgent(
|
||||||
const GURL& url) const {
|
const GURL& url) const {
|
||||||
return webkit_glue::GetUserAgent(url);
|
return webkit_glue::GetUserAgent(url);
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef _BROWSER_REQUEST_CONTEXT_H
|
#ifndef _BROWSER_REQUEST_CONTEXT_H
|
||||||
#define _BROWSER_REQUEST_CONTEXT_H
|
#define _BROWSER_REQUEST_CONTEXT_H
|
||||||
|
|
||||||
#include "net/http/http_cache.h"
|
#include "net/http/http_cache.h"
|
||||||
#include "net/url_request/url_request_context.h"
|
#include "net/url_request/url_request_context.h"
|
||||||
|
|
||||||
// A basic URLRequestContext that only provides an in-memory cookie store.
|
// A basic URLRequestContext that only provides an in-memory cookie store.
|
||||||
class BrowserRequestContext : public URLRequestContext {
|
class BrowserRequestContext : public URLRequestContext {
|
||||||
public:
|
public:
|
||||||
// Use an in-memory cache
|
// Use an in-memory cache
|
||||||
BrowserRequestContext();
|
BrowserRequestContext();
|
||||||
|
|
||||||
// Use an on-disk cache at the specified location. Optionally, use the cache
|
// Use an on-disk cache at the specified location. Optionally, use the cache
|
||||||
// in playback or record mode.
|
// in playback or record mode.
|
||||||
BrowserRequestContext(const std::wstring& cache_path,
|
BrowserRequestContext(const std::wstring& cache_path,
|
||||||
net::HttpCache::Mode cache_mode,
|
net::HttpCache::Mode cache_mode,
|
||||||
bool no_proxy);
|
bool no_proxy);
|
||||||
|
|
||||||
~BrowserRequestContext();
|
~BrowserRequestContext();
|
||||||
|
|
||||||
virtual const std::string& GetUserAgent(const GURL& url) const;
|
virtual const std::string& GetUserAgent(const GURL& url) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Init(const std::wstring& cache_path, net::HttpCache::Mode cache_mode,
|
void Init(const std::wstring& cache_path, net::HttpCache::Mode cache_mode,
|
||||||
bool no_proxy);
|
bool no_proxy);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _BROWSER_REQUEST_CONTEXT_H
|
#endif // _BROWSER_REQUEST_CONTEXT_H
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,40 +1,40 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef _BROWSER_RESOURCE_LOADER_BRIDGE_H
|
#ifndef _BROWSER_RESOURCE_LOADER_BRIDGE_H
|
||||||
#define _BROWSER_RESOURCE_LOADER_BRIDGE_H
|
#define _BROWSER_RESOURCE_LOADER_BRIDGE_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class GURL;
|
class GURL;
|
||||||
class URLRequestContext;
|
class URLRequestContext;
|
||||||
|
|
||||||
class BrowserResourceLoaderBridge {
|
class BrowserResourceLoaderBridge {
|
||||||
public:
|
public:
|
||||||
// Call this function to initialize the simple resource loader bridge. If
|
// Call this function to initialize the simple resource loader bridge. If
|
||||||
// the given context is null, then a default BrowserRequestContext will be
|
// the given context is null, then a default BrowserRequestContext will be
|
||||||
// instantiated. Otherwise, a reference is taken to the given request
|
// instantiated. Otherwise, a reference is taken to the given request
|
||||||
// context, which will be released when Shutdown is called. The caller
|
// context, which will be released when Shutdown is called. The caller
|
||||||
// should not hold another reference to the request context! It is safe to
|
// should not hold another reference to the request context! It is safe to
|
||||||
// call this function multiple times.
|
// call this function multiple times.
|
||||||
//
|
//
|
||||||
// NOTE: If this function is not called, then a default request context will
|
// NOTE: If this function is not called, then a default request context will
|
||||||
// be initialized lazily.
|
// be initialized lazily.
|
||||||
//
|
//
|
||||||
static void Init(URLRequestContext* context);
|
static void Init(URLRequestContext* context);
|
||||||
|
|
||||||
// Call this function to shutdown the simple resource loader bridge.
|
// Call this function to shutdown the simple resource loader bridge.
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
|
|
||||||
// May only be called after Init.
|
// May only be called after Init.
|
||||||
static void SetCookie(const GURL& url,
|
static void SetCookie(const GURL& url,
|
||||||
const GURL& first_party_for_cookies,
|
const GURL& first_party_for_cookies,
|
||||||
const std::string& cookie);
|
const std::string& cookie);
|
||||||
static std::string GetCookies(const GURL& url,
|
static std::string GetCookies(const GURL& url,
|
||||||
const GURL& first_party_for_cookies);
|
const GURL& first_party_for_cookies);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _BROWSER_RESOURCE_LOADER_BRIDGE_H
|
#endif // _BROWSER_RESOURCE_LOADER_BRIDGE_H
|
||||||
|
|
||||||
|
@ -1,64 +1,64 @@
|
|||||||
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
|
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
MSVC_PUSH_WARNING_LEVEL(0);
|
MSVC_PUSH_WARNING_LEVEL(0);
|
||||||
#include "TextEncoding.h"
|
#include "TextEncoding.h"
|
||||||
#include "webkit/glue/webframe_impl.h"
|
#include "webkit/glue/webframe_impl.h"
|
||||||
MSVC_POP_WARNING();
|
MSVC_POP_WARNING();
|
||||||
|
|
||||||
#include "browser_webkit_glue.h"
|
#include "browser_webkit_glue.h"
|
||||||
|
|
||||||
#undef LOG
|
#undef LOG
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
#include "base/resource_util.h"
|
#include "base/resource_util.h"
|
||||||
#include "base/scoped_ptr.h"
|
#include "base/scoped_ptr.h"
|
||||||
#include "base/string16.h"
|
#include "base/string16.h"
|
||||||
#include "base/win_util.h"
|
#include "base/win_util.h"
|
||||||
#include "net/base/mime_util.h"
|
#include "net/base/mime_util.h"
|
||||||
#include "webkit/glue/glue_util.h"
|
#include "webkit/glue/glue_util.h"
|
||||||
#include "webkit/glue/webframe.h"
|
#include "webkit/glue/webframe.h"
|
||||||
#include "webkit/glue/webkit_glue.h"
|
#include "webkit/glue/webkit_glue.h"
|
||||||
|
|
||||||
// Generated by GRIT
|
// Generated by GRIT
|
||||||
#include "grit/webkit_resources.h"
|
#include "grit/webkit_resources.h"
|
||||||
|
|
||||||
namespace webkit_glue {
|
namespace webkit_glue {
|
||||||
|
|
||||||
bool IsMediaPlayerAvailable() {
|
bool IsMediaPlayerAvailable() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrecacheUrl(const char16* url, int url_length) {}
|
void PrecacheUrl(const char16* url, int url_length) {}
|
||||||
|
|
||||||
void AppendToLog(const char* file, int line, const char* msg) {
|
void AppendToLog(const char* file, int line, const char* msg) {
|
||||||
logging::LogMessage(file, line).stream() << msg;
|
logging::LogMessage(file, line).stream() << msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringPiece GetRawDataResource(HMODULE module, int resource_id) {
|
StringPiece GetRawDataResource(HMODULE module, int resource_id) {
|
||||||
void* data_ptr;
|
void* data_ptr;
|
||||||
size_t data_size;
|
size_t data_size;
|
||||||
return base::GetDataResourceFromModule(module, resource_id, &data_ptr,
|
return base::GetDataResourceFromModule(module, resource_id, &data_ptr,
|
||||||
&data_size) ?
|
&data_size) ?
|
||||||
StringPiece(static_cast<char*>(data_ptr), data_size) : StringPiece();
|
StringPiece(static_cast<char*>(data_ptr), data_size) : StringPiece();
|
||||||
}
|
}
|
||||||
|
|
||||||
StringPiece NetResourceProvider(int key) {
|
StringPiece NetResourceProvider(int key) {
|
||||||
return GetRawDataResource(::GetModuleHandle(NULL), key);
|
return GetRawDataResource(::GetModuleHandle(NULL), key);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringPiece GetDataResource(int resource_id) {
|
StringPiece GetDataResource(int resource_id) {
|
||||||
switch (resource_id) {
|
switch (resource_id) {
|
||||||
case IDR_BROKENIMAGE: {
|
case IDR_BROKENIMAGE: {
|
||||||
// Use webkit's broken image icon (16x16)
|
// Use webkit's broken image icon (16x16)
|
||||||
static unsigned char broken_image_data[] = {
|
static unsigned char broken_image_data[] = {
|
||||||
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x10, 0x00, 0x10, 0x00, 0xD5, 0x00,
|
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x10, 0x00, 0x10, 0x00, 0xD5, 0x00,
|
||||||
0x00, 0x20, 0x68, 0xB0, 0x70, 0x98, 0xC0, 0x28, 0x78, 0xB8, 0x20, 0x70,
|
0x00, 0x20, 0x68, 0xB0, 0x70, 0x98, 0xC0, 0x28, 0x78, 0xB8, 0x20, 0x70,
|
||||||
0xB8, 0x88, 0xB8, 0xD8, 0x78, 0x98, 0xC8, 0x28, 0x80, 0xC0, 0xF8, 0xF8,
|
0xB8, 0x88, 0xB8, 0xD8, 0x78, 0x98, 0xC8, 0x28, 0x80, 0xC0, 0xF8, 0xF8,
|
||||||
@ -88,22 +88,22 @@ StringPiece GetDataResource(int resource_id) {
|
|||||||
0x03, 0xA8, 0x03, 0x15, 0x0A, 0x0A, 0x15, 0xA9, 0x03, 0x07, 0x18, 0x01,
|
0x03, 0xA8, 0x03, 0x15, 0x0A, 0x0A, 0x15, 0xA9, 0x03, 0x07, 0x18, 0x01,
|
||||||
0xA7, 0xA9, 0xAB, 0xAD, 0xAF, 0x07, 0x01, 0x0F, 0x07, 0x15, 0xBD, 0x15,
|
0xA7, 0xA9, 0xAB, 0xAD, 0xAF, 0x07, 0x01, 0x0F, 0x07, 0x15, 0xBD, 0x15,
|
||||||
0x00, 0xC0, 0x00, 0xBE, 0x15, 0x07, 0x0F, 0x0E, 0xBC, 0xC3, 0xC9, 0xBD,
|
0x00, 0xC0, 0x00, 0xBE, 0x15, 0x07, 0x0F, 0x0E, 0xBC, 0xC3, 0xC9, 0xBD,
|
||||||
0x07, 0x0E, 0xC7, 0x4C, 0xCF, 0x49, 0xCD, 0xD2, 0xD3, 0xD4, 0xD2, 0x41,
|
0x07, 0x0E, 0xC7, 0x4C, 0xCF, 0x49, 0xCD, 0xD2, 0xD3, 0xD4, 0xD2, 0x41,
|
||||||
0x00, 0x3B
|
0x00, 0x3B
|
||||||
};
|
};
|
||||||
return StringPiece(reinterpret_cast<char*>(broken_image_data),
|
return StringPiece(reinterpret_cast<char*>(broken_image_data),
|
||||||
static_cast<StringPiece::size_type>(
|
static_cast<StringPiece::size_type>(
|
||||||
sizeof(broken_image_data) / sizeof(unsigned char)));
|
sizeof(broken_image_data) / sizeof(unsigned char)));
|
||||||
}
|
}
|
||||||
case IDR_FEED_PREVIEW:
|
case IDR_FEED_PREVIEW:
|
||||||
// It is necessary to return a feed preview template that contains
|
// It is necessary to return a feed preview template that contains
|
||||||
// a {{URL}} substring where the feed URL should go; see the code
|
// a {{URL}} substring where the feed URL should go; see the code
|
||||||
// that computes feed previews in feed_preview.cc:MakeFeedPreview.
|
// that computes feed previews in feed_preview.cc:MakeFeedPreview.
|
||||||
// This fixes issue #932714.
|
// This fixes issue #932714.
|
||||||
return "Feed preview for {{URL}}";
|
return "Feed preview for {{URL}}";
|
||||||
case IDR_TEXTAREA_RESIZER: {
|
case IDR_TEXTAREA_RESIZER: {
|
||||||
// Use webkit's text area resizer image.
|
// Use webkit's text area resizer image.
|
||||||
static unsigned char area_resizer_data[] = {
|
static unsigned char area_resizer_data[] = {
|
||||||
0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D,
|
0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D,
|
||||||
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08,
|
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08,
|
||||||
0x08, 0x06, 0x00, 0x00, 0x00, 0xC4, 0x0F, 0xBE, 0x8B, 0x00, 0x00, 0x00,
|
0x08, 0x06, 0x00, 0x00, 0x00, 0xC4, 0x0F, 0xBE, 0x8B, 0x00, 0x00, 0x00,
|
||||||
@ -120,85 +120,85 @@ StringPiece GetDataResource(int resource_id) {
|
|||||||
0x98, 0x0E, 0x17, 0x7C, 0x1B, 0xCA, 0x36, 0x92, 0x76, 0x6A, 0x48, 0x66,
|
0x98, 0x0E, 0x17, 0x7C, 0x1B, 0xCA, 0x36, 0x92, 0x76, 0x6A, 0x48, 0x66,
|
||||||
0x37, 0x68, 0xAA, 0x05, 0x38, 0x03, 0x00, 0x40, 0x17, 0x33, 0x3D, 0x58,
|
0x37, 0x68, 0xAA, 0x05, 0x38, 0x03, 0x00, 0x40, 0x17, 0x33, 0x3D, 0x58,
|
||||||
0x57, 0x6B, 0xB3, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE,
|
0x57, 0x6B, 0xB3, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE,
|
||||||
0x42, 0x60, 0x82
|
0x42, 0x60, 0x82
|
||||||
};
|
};
|
||||||
return StringPiece(reinterpret_cast<char*>(area_resizer_data),
|
return StringPiece(reinterpret_cast<char*>(area_resizer_data),
|
||||||
static_cast<StringPiece::size_type>(
|
static_cast<StringPiece::size_type>(
|
||||||
sizeof(area_resizer_data) / sizeof(unsigned char)));
|
sizeof(area_resizer_data) / sizeof(unsigned char)));
|
||||||
}
|
}
|
||||||
case IDR_SEARCH_CANCEL:
|
case IDR_SEARCH_CANCEL:
|
||||||
case IDR_SEARCH_CANCEL_PRESSED:
|
case IDR_SEARCH_CANCEL_PRESSED:
|
||||||
case IDR_SEARCH_MAGNIFIER:
|
case IDR_SEARCH_MAGNIFIER:
|
||||||
case IDR_SEARCH_MAGNIFIER_RESULTS:
|
case IDR_SEARCH_MAGNIFIER_RESULTS:
|
||||||
case IDR_MEDIA_PAUSE_BUTTON:
|
case IDR_MEDIA_PAUSE_BUTTON:
|
||||||
case IDR_MEDIA_PLAY_BUTTON:
|
case IDR_MEDIA_PLAY_BUTTON:
|
||||||
case IDR_MEDIA_SOUND_FULL_BUTTON:
|
case IDR_MEDIA_SOUND_FULL_BUTTON:
|
||||||
case IDR_MEDIA_SOUND_NONE_BUTTON:
|
case IDR_MEDIA_SOUND_NONE_BUTTON:
|
||||||
return NetResourceProvider(resource_id);
|
return NetResourceProvider(resource_id);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return StringPiece();
|
return StringPiece();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetApplicationDirectory(std::wstring *path) {
|
bool GetApplicationDirectory(std::wstring *path) {
|
||||||
return PathService::Get(base::DIR_EXE, path);
|
return PathService::Get(base::DIR_EXE, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
GURL GetInspectorURL() {
|
GURL GetInspectorURL() {
|
||||||
return GURL("cef-resource://inspector/inspector.html");
|
return GURL("cef-resource://inspector/inspector.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetUIResourceProtocol() {
|
std::string GetUIResourceProtocol() {
|
||||||
return "cef-resource";
|
return "cef-resource";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetExeDirectory(std::wstring *path) {
|
bool GetExeDirectory(std::wstring *path) {
|
||||||
return PathService::Get(base::DIR_EXE, path);
|
return PathService::Get(base::DIR_EXE, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpellCheckWord(const wchar_t* word, int word_len,
|
bool SpellCheckWord(const wchar_t* word, int word_len,
|
||||||
int* misspelling_start, int* misspelling_len) {
|
int* misspelling_start, int* misspelling_len) {
|
||||||
// Report all words being correctly spelled.
|
// Report all words being correctly spelled.
|
||||||
*misspelling_start = 0;
|
*misspelling_start = 0;
|
||||||
*misspelling_len = 0;
|
*misspelling_len = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsPluginRunningInRendererProcess() {
|
bool IsPluginRunningInRendererProcess() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetPluginFinderURL(std::string* plugin_finder_url) {
|
bool GetPluginFinderURL(std::string* plugin_finder_url) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsDefaultPluginEnabled() {
|
bool IsDefaultPluginEnabled() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring GetWebKitLocale() {
|
std::wstring GetWebKitLocale() {
|
||||||
return L"en-US";
|
return L"en-US";
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitializeTextEncoding() {
|
void InitializeTextEncoding() {
|
||||||
WebCore::UTF8Encoding();
|
WebCore::UTF8Encoding();
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::Handle<v8::Context> GetV8Context(WebFrame* frame)
|
v8::Handle<v8::Context> GetV8Context(WebFrame* frame)
|
||||||
{
|
{
|
||||||
WebFrameImpl* webFrameImpl = static_cast<WebFrameImpl*>(frame);
|
WebFrameImpl* webFrameImpl = static_cast<WebFrameImpl*>(frame);
|
||||||
WebCore::Frame* core_frame = webFrameImpl->frame();
|
WebCore::Frame* core_frame = webFrameImpl->frame();
|
||||||
return WebCore::V8Proxy::context(core_frame);
|
return WebCore::V8Proxy::context(core_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloseIdleConnections() {
|
void CloseIdleConnections() {
|
||||||
// Used in benchmarking, Ignored for CEF.
|
// Used in benchmarking, Ignored for CEF.
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetCacheMode(bool enabled) {
|
void SetCacheMode(bool enabled) {
|
||||||
// Used in benchmarking, Ignored for CEF.
|
// Used in benchmarking, Ignored for CEF.
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webkit_glue
|
} // namespace webkit_glue
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. All rights
|
// 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
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@ -27,7 +27,7 @@ BOOL SaveBitmapToFile(HBITMAP hBmp, HDC hDC, LPCTSTR file, LPBYTE lpBits);
|
|||||||
// Text encoding objects must be initialized on the main thread.
|
// Text encoding objects must be initialized on the main thread.
|
||||||
void InitializeTextEncoding();
|
void InitializeTextEncoding();
|
||||||
|
|
||||||
// This is called indirectly by the network layer to access resources.
|
// This is called indirectly by the network layer to access resources.
|
||||||
StringPiece NetResourceProvider(int key);
|
StringPiece NetResourceProvider(int key);
|
||||||
|
|
||||||
// Retrieve the V8 context associated with the frame.
|
// Retrieve the V8 context associated with the frame.
|
||||||
|
@ -1,140 +1,140 @@
|
|||||||
// Copyright (c) 2009 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2009 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2009 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2009 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef _BROWSER_WEBKIT_INIT_H
|
#ifndef _BROWSER_WEBKIT_INIT_H
|
||||||
#define _BROWSER_WEBKIT_INIT_H
|
#define _BROWSER_WEBKIT_INIT_H
|
||||||
|
|
||||||
#include "base/file_util.h"
|
#include "base/file_util.h"
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
#include "base/stats_counters.h"
|
#include "base/stats_counters.h"
|
||||||
#include "base/string_util.h"
|
#include "base/string_util.h"
|
||||||
#include "media/base/media.h"
|
#include "media/base/media.h"
|
||||||
#include "webkit/api/public/WebCString.h"
|
#include "webkit/api/public/WebCString.h"
|
||||||
#include "webkit/api/public/WebData.h"
|
#include "webkit/api/public/WebData.h"
|
||||||
#include "webkit/api/public/WebKit.h"
|
#include "webkit/api/public/WebKit.h"
|
||||||
#include "webkit/api/public/WebStorageArea.h"
|
#include "webkit/api/public/WebStorageArea.h"
|
||||||
#include "webkit/api/public/WebStorageNamespace.h"
|
#include "webkit/api/public/WebStorageNamespace.h"
|
||||||
#include "webkit/api/public/WebString.h"
|
#include "webkit/api/public/WebString.h"
|
||||||
#include "webkit/api/public/WebURL.h"
|
#include "webkit/api/public/WebURL.h"
|
||||||
#include "webkit/glue/simple_webmimeregistry_impl.h"
|
#include "webkit/glue/simple_webmimeregistry_impl.h"
|
||||||
#include "webkit/glue/webclipboard_impl.h"
|
#include "webkit/glue/webclipboard_impl.h"
|
||||||
#include "webkit/glue/webkit_glue.h"
|
#include "webkit/glue/webkit_glue.h"
|
||||||
#include "webkit/glue/webkitclient_impl.h"
|
#include "webkit/glue/webkitclient_impl.h"
|
||||||
#include "webkit/extensions/v8/gears_extension.h"
|
#include "webkit/extensions/v8/gears_extension.h"
|
||||||
#include "webkit/extensions/v8/interval_extension.h"
|
#include "webkit/extensions/v8/interval_extension.h"
|
||||||
#include "browser_resource_loader_bridge.h"
|
#include "browser_resource_loader_bridge.h"
|
||||||
|
|
||||||
|
|
||||||
class BrowserWebKitInit : public webkit_glue::WebKitClientImpl {
|
class BrowserWebKitInit : public webkit_glue::WebKitClientImpl {
|
||||||
public:
|
public:
|
||||||
BrowserWebKitInit() {
|
BrowserWebKitInit() {
|
||||||
v8::V8::SetCounterFunction(StatsTable::FindLocation);
|
v8::V8::SetCounterFunction(StatsTable::FindLocation);
|
||||||
|
|
||||||
WebKit::initialize(this);
|
WebKit::initialize(this);
|
||||||
WebKit::setLayoutTestMode(false);
|
WebKit::setLayoutTestMode(false);
|
||||||
WebKit::registerURLSchemeAsLocal(
|
WebKit::registerURLSchemeAsLocal(
|
||||||
ASCIIToUTF16(webkit_glue::GetUIResourceProtocol()));
|
ASCIIToUTF16(webkit_glue::GetUIResourceProtocol()));
|
||||||
WebKit::registerURLSchemeAsNoAccess(
|
WebKit::registerURLSchemeAsNoAccess(
|
||||||
ASCIIToUTF16(webkit_glue::GetUIResourceProtocol()));
|
ASCIIToUTF16(webkit_glue::GetUIResourceProtocol()));
|
||||||
WebKit::registerExtension(extensions_v8::GearsExtension::Get());
|
WebKit::registerExtension(extensions_v8::GearsExtension::Get());
|
||||||
WebKit::registerExtension(extensions_v8::IntervalExtension::Get());
|
WebKit::registerExtension(extensions_v8::IntervalExtension::Get());
|
||||||
|
|
||||||
// Load libraries for media and enable the media player.
|
// Load libraries for media and enable the media player.
|
||||||
FilePath module_path;
|
FilePath module_path;
|
||||||
if (PathService::Get(base::DIR_MODULE, &module_path) &&
|
if (PathService::Get(base::DIR_MODULE, &module_path) &&
|
||||||
media::InitializeMediaLibrary(module_path)) {
|
media::InitializeMediaLibrary(module_path)) {
|
||||||
WebKit::enableMediaPlayer();
|
WebKit::enableMediaPlayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~BrowserWebKitInit() {
|
~BrowserWebKitInit() {
|
||||||
WebKit::shutdown();
|
WebKit::shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual WebKit::WebMimeRegistry* mimeRegistry() {
|
virtual WebKit::WebMimeRegistry* mimeRegistry() {
|
||||||
return &mime_registry_;
|
return &mime_registry_;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebKit::WebClipboard* clipboard() {
|
WebKit::WebClipboard* clipboard() {
|
||||||
if (!clipboard_.get()) {
|
if (!clipboard_.get()) {
|
||||||
clipboard_.reset(new webkit_glue::WebClipboardImpl());
|
clipboard_.reset(new webkit_glue::WebClipboardImpl());
|
||||||
}
|
}
|
||||||
return clipboard_.get();
|
return clipboard_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual WebKit::WebSandboxSupport* sandboxSupport() {
|
virtual WebKit::WebSandboxSupport* sandboxSupport() {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool getFileSize(const WebKit::WebString& path, long long& result) {
|
virtual bool getFileSize(const WebKit::WebString& path, long long& result) {
|
||||||
return file_util::GetFileSize(
|
return file_util::GetFileSize(
|
||||||
FilePath(webkit_glue::WebStringToFilePathString(path)), &result);
|
FilePath(webkit_glue::WebStringToFilePathString(path)), &result);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual unsigned long long visitedLinkHash(const char* canonicalURL, size_t length) {
|
virtual unsigned long long visitedLinkHash(const char* canonicalURL, size_t length) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isLinkVisited(unsigned long long linkHash) {
|
virtual bool isLinkVisited(unsigned long long linkHash) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setCookies(const WebKit::WebURL& url,
|
virtual void setCookies(const WebKit::WebURL& url,
|
||||||
const WebKit::WebURL& first_party_for_cookies,
|
const WebKit::WebURL& first_party_for_cookies,
|
||||||
const WebKit::WebString& value) {
|
const WebKit::WebString& value) {
|
||||||
BrowserResourceLoaderBridge::SetCookie(
|
BrowserResourceLoaderBridge::SetCookie(
|
||||||
url, first_party_for_cookies, UTF16ToUTF8(value));
|
url, first_party_for_cookies, UTF16ToUTF8(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual WebKit::WebString cookies(
|
virtual WebKit::WebString cookies(
|
||||||
const WebKit::WebURL& url,
|
const WebKit::WebURL& url,
|
||||||
const WebKit::WebURL& first_party_for_cookies) {
|
const WebKit::WebURL& first_party_for_cookies) {
|
||||||
return UTF8ToUTF16(BrowserResourceLoaderBridge::GetCookies(
|
return UTF8ToUTF16(BrowserResourceLoaderBridge::GetCookies(
|
||||||
url, first_party_for_cookies));
|
url, first_party_for_cookies));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void prefetchHostName(const WebKit::WebString&) {
|
virtual void prefetchHostName(const WebKit::WebString&) {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual WebKit::WebData loadResource(const char* name) {
|
virtual WebKit::WebData loadResource(const char* name) {
|
||||||
if (!strcmp(name, "deleteButton")) {
|
if (!strcmp(name, "deleteButton")) {
|
||||||
// Create a red 30x30 square.
|
// Create a red 30x30 square.
|
||||||
const char red_square[] =
|
const char red_square[] =
|
||||||
"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52"
|
"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52"
|
||||||
"\x00\x00\x00\x1e\x00\x00\x00\x1e\x04\x03\x00\x00\x00\xc9\x1e\xb3"
|
"\x00\x00\x00\x1e\x00\x00\x00\x1e\x04\x03\x00\x00\x00\xc9\x1e\xb3"
|
||||||
"\x91\x00\x00\x00\x30\x50\x4c\x54\x45\x00\x00\x00\x80\x00\x00\x00"
|
"\x91\x00\x00\x00\x30\x50\x4c\x54\x45\x00\x00\x00\x80\x00\x00\x00"
|
||||||
"\x80\x00\x80\x80\x00\x00\x00\x80\x80\x00\x80\x00\x80\x80\x80\x80"
|
"\x80\x00\x80\x80\x00\x00\x00\x80\x80\x00\x80\x00\x80\x80\x80\x80"
|
||||||
"\x80\xc0\xc0\xc0\xff\x00\x00\x00\xff\x00\xff\xff\x00\x00\x00\xff"
|
"\x80\xc0\xc0\xc0\xff\x00\x00\x00\xff\x00\xff\xff\x00\x00\x00\xff"
|
||||||
"\xff\x00\xff\x00\xff\xff\xff\xff\xff\x7b\x1f\xb1\xc4\x00\x00\x00"
|
"\xff\x00\xff\x00\xff\xff\xff\xff\xff\x7b\x1f\xb1\xc4\x00\x00\x00"
|
||||||
"\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a"
|
"\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a"
|
||||||
"\x9c\x18\x00\x00\x00\x17\x49\x44\x41\x54\x78\x01\x63\x98\x89\x0a"
|
"\x9c\x18\x00\x00\x00\x17\x49\x44\x41\x54\x78\x01\x63\x98\x89\x0a"
|
||||||
"\x18\x50\xb9\x33\x47\xf9\xa8\x01\x32\xd4\xc2\x03\x00\x33\x84\x0d"
|
"\x18\x50\xb9\x33\x47\xf9\xa8\x01\x32\xd4\xc2\x03\x00\x33\x84\x0d"
|
||||||
"\x02\x3a\x91\xeb\xa5\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60"
|
"\x02\x3a\x91\xeb\xa5\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60"
|
||||||
"\x82";
|
"\x82";
|
||||||
return WebKit::WebData(red_square, arraysize(red_square));
|
return WebKit::WebData(red_square, arraysize(red_square));
|
||||||
}
|
}
|
||||||
return webkit_glue::WebKitClientImpl::loadResource(name);
|
return webkit_glue::WebKitClientImpl::loadResource(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual WebKit::WebString defaultLocale() {
|
virtual WebKit::WebString defaultLocale() {
|
||||||
return ASCIIToUTF16("en-US");
|
return ASCIIToUTF16("en-US");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual WebKit::WebStorageNamespace* createLocalStorageNamespace(
|
virtual WebKit::WebStorageNamespace* createLocalStorageNamespace(
|
||||||
const WebKit::WebString& path) {
|
const WebKit::WebString& path) {
|
||||||
return WebKit::WebStorageNamespace::createLocalStorageNamespace(path);
|
return WebKit::WebStorageNamespace::createLocalStorageNamespace(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual WebKit::WebStorageNamespace* createSessionStorageNamespace() {
|
virtual WebKit::WebStorageNamespace* createSessionStorageNamespace() {
|
||||||
return WebKit::WebStorageNamespace::createSessionStorageNamespace();
|
return WebKit::WebStorageNamespace::createSessionStorageNamespace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
webkit_glue::SimpleWebMimeRegistryImpl mime_registry_;
|
webkit_glue::SimpleWebMimeRegistryImpl mime_registry_;
|
||||||
scoped_ptr<WebKit::WebClipboard> clipboard_;
|
scoped_ptr<WebKit::WebClipboard> clipboard_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _BROWSER_WEBKIT_INIT_H
|
#endif // _BROWSER_WEBKIT_INIT_H
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,314 +1,314 @@
|
|||||||
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// BrowserWebViewDelegate class:
|
// BrowserWebViewDelegate class:
|
||||||
// This class implements the WebViewDelegate methods for the test shell. One
|
// This class implements the WebViewDelegate methods for the test shell. One
|
||||||
// instance is owned by each CefBrowser.
|
// instance is owned by each CefBrowser.
|
||||||
|
|
||||||
#ifndef _BROWSER_WEBVIEW_DELEGATE_H
|
#ifndef _BROWSER_WEBVIEW_DELEGATE_H
|
||||||
#define _BROWSER_WEBVIEW_DELEGATE_H
|
#define _BROWSER_WEBVIEW_DELEGATE_H
|
||||||
|
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#if defined(OS_LINUX)
|
#if defined(OS_LINUX)
|
||||||
#include <gdk/gdkcursor.h>
|
#include <gdk/gdkcursor.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
#include "base/ref_counted.h"
|
#include "base/ref_counted.h"
|
||||||
#include "base/scoped_ptr.h"
|
#include "base/scoped_ptr.h"
|
||||||
#include "webkit/glue/webcursor.h"
|
#include "webkit/glue/webcursor.h"
|
||||||
#include "webkit/glue/webview_delegate.h"
|
#include "webkit/glue/webview_delegate.h"
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#include "browser_drag_delegate.h"
|
#include "browser_drag_delegate.h"
|
||||||
#include "browser_drop_delegate.h"
|
#include "browser_drop_delegate.h"
|
||||||
#endif
|
#endif
|
||||||
#include "browser_navigation_controller.h"
|
#include "browser_navigation_controller.h"
|
||||||
|
|
||||||
class CefBrowserImpl;
|
class CefBrowserImpl;
|
||||||
struct ContextMenuMediaParams;
|
struct ContextMenuMediaParams;
|
||||||
struct WebPreferences;
|
struct WebPreferences;
|
||||||
class GURL;
|
class GURL;
|
||||||
class WebWidgetHost;
|
class WebWidgetHost;
|
||||||
|
|
||||||
class BrowserWebViewDelegate : public base::RefCounted<BrowserWebViewDelegate>,
|
class BrowserWebViewDelegate : public base::RefCounted<BrowserWebViewDelegate>,
|
||||||
public WebViewDelegate {
|
public WebViewDelegate {
|
||||||
public:
|
public:
|
||||||
BrowserWebViewDelegate(CefBrowserImpl* browser)
|
BrowserWebViewDelegate(CefBrowserImpl* browser)
|
||||||
: policy_delegate_enabled_(false),
|
: policy_delegate_enabled_(false),
|
||||||
policy_delegate_is_permissive_(false),
|
policy_delegate_is_permissive_(false),
|
||||||
browser_(browser),
|
browser_(browser),
|
||||||
top_loading_frame_(NULL),
|
top_loading_frame_(NULL),
|
||||||
page_id_(-1),
|
page_id_(-1),
|
||||||
last_page_id_updated_(-1),
|
last_page_id_updated_(-1),
|
||||||
smart_insert_delete_enabled_(true)
|
smart_insert_delete_enabled_(true)
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
, select_trailing_whitespace_enabled_(true)
|
, select_trailing_whitespace_enabled_(true)
|
||||||
#else
|
#else
|
||||||
, select_trailing_whitespace_enabled_(false)
|
, select_trailing_whitespace_enabled_(false)
|
||||||
#endif
|
#endif
|
||||||
#if defined(OS_LINUX)
|
#if defined(OS_LINUX)
|
||||||
, cursor_type_(GDK_X_CURSOR)
|
, cursor_type_(GDK_X_CURSOR)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual ~BrowserWebViewDelegate() {}
|
virtual ~BrowserWebViewDelegate() {}
|
||||||
|
|
||||||
// WebViewDelegate
|
// WebViewDelegate
|
||||||
virtual WebView* CreateWebView(WebView* webview,
|
virtual WebView* CreateWebView(WebView* webview,
|
||||||
bool user_gesture,
|
bool user_gesture,
|
||||||
const GURL& creator_url);
|
const GURL& creator_url);
|
||||||
virtual WebKit::WebWidget* CreatePopupWidget(
|
virtual WebKit::WebWidget* CreatePopupWidget(
|
||||||
WebView* webview,
|
WebView* webview,
|
||||||
bool activatable);
|
bool activatable);
|
||||||
virtual WebPluginDelegate* CreatePluginDelegate(
|
virtual WebPluginDelegate* CreatePluginDelegate(
|
||||||
WebView* webview,
|
WebView* webview,
|
||||||
const GURL& url,
|
const GURL& url,
|
||||||
const std::string& mime_type,
|
const std::string& mime_type,
|
||||||
const std::string& clsid,
|
const std::string& clsid,
|
||||||
std::string* actual_mime_type);
|
std::string* actual_mime_type);
|
||||||
virtual WebKit::WebMediaPlayer* CreateWebMediaPlayer(
|
virtual WebKit::WebMediaPlayer* CreateWebMediaPlayer(
|
||||||
WebKit::WebMediaPlayerClient* client);
|
WebKit::WebMediaPlayerClient* client);
|
||||||
virtual WebKit::WebWorker* CreateWebWorker(WebKit::WebWorkerClient* client);
|
virtual WebKit::WebWorker* CreateWebWorker(WebKit::WebWorkerClient* client);
|
||||||
virtual void OpenURL(WebView* webview,
|
virtual void OpenURL(WebView* webview,
|
||||||
const GURL& url,
|
const GURL& url,
|
||||||
const GURL& referrer,
|
const GURL& referrer,
|
||||||
WebKit::WebNavigationPolicy policy);
|
WebKit::WebNavigationPolicy policy);
|
||||||
virtual void DidMovePlugin(const WebPluginGeometry& move);
|
virtual void DidMovePlugin(const WebPluginGeometry& move);
|
||||||
virtual void RunJavaScriptAlert(WebFrame* webframe,
|
virtual void RunJavaScriptAlert(WebFrame* webframe,
|
||||||
const std::wstring& message);
|
const std::wstring& message);
|
||||||
virtual bool RunJavaScriptConfirm(WebFrame* webframe,
|
virtual bool RunJavaScriptConfirm(WebFrame* webframe,
|
||||||
const std::wstring& message);
|
const std::wstring& message);
|
||||||
virtual bool RunJavaScriptPrompt(WebFrame* webframe,
|
virtual bool RunJavaScriptPrompt(WebFrame* webframe,
|
||||||
const std::wstring& message,
|
const std::wstring& message,
|
||||||
const std::wstring& default_value,
|
const std::wstring& default_value,
|
||||||
std::wstring* result);
|
std::wstring* result);
|
||||||
virtual void SetStatusbarText(WebView* webview,
|
virtual void SetStatusbarText(WebView* webview,
|
||||||
const std::wstring& message);
|
const std::wstring& message);
|
||||||
virtual void AddMessageToConsole(WebView* webview,
|
virtual void AddMessageToConsole(WebView* webview,
|
||||||
const std::wstring& message,
|
const std::wstring& message,
|
||||||
unsigned int line_no,
|
unsigned int line_no,
|
||||||
const std::wstring& source_id);
|
const std::wstring& source_id);
|
||||||
virtual void StartDragging(WebView* webview,
|
virtual void StartDragging(WebView* webview,
|
||||||
const WebKit::WebDragData& drop_data);
|
const WebKit::WebDragData& drop_data);
|
||||||
virtual void ShowContextMenu(WebView* webview,
|
virtual void ShowContextMenu(WebView* webview,
|
||||||
ContextNodeType node_type,
|
ContextNodeType node_type,
|
||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
const GURL& link_url,
|
const GURL& link_url,
|
||||||
const GURL& image_url,
|
const GURL& image_url,
|
||||||
const GURL& page_url,
|
const GURL& page_url,
|
||||||
const GURL& frame_url,
|
const GURL& frame_url,
|
||||||
const ContextMenuMediaParams& media_params,
|
const ContextMenuMediaParams& media_params,
|
||||||
const std::wstring& selection_text,
|
const std::wstring& selection_text,
|
||||||
const std::wstring& misspelled_word,
|
const std::wstring& misspelled_word,
|
||||||
int edit_flags,
|
int edit_flags,
|
||||||
const std::string& security_info,
|
const std::string& security_info,
|
||||||
const std::string& frame_charset);
|
const std::string& frame_charset);
|
||||||
virtual void DidCreateDataSource(WebFrame* frame,
|
virtual void DidCreateDataSource(WebFrame* frame,
|
||||||
WebKit::WebDataSource* ds);
|
WebKit::WebDataSource* ds);
|
||||||
virtual void DidStartProvisionalLoadForFrame(
|
virtual void DidStartProvisionalLoadForFrame(
|
||||||
WebView* webview,
|
WebView* webview,
|
||||||
WebFrame* frame,
|
WebFrame* frame,
|
||||||
NavigationGesture gesture);
|
NavigationGesture gesture);
|
||||||
virtual void DidReceiveServerRedirectForProvisionalLoadForFrame(
|
virtual void DidReceiveServerRedirectForProvisionalLoadForFrame(
|
||||||
WebView* webview, WebFrame* frame);
|
WebView* webview, WebFrame* frame);
|
||||||
virtual void DidFailProvisionalLoadWithError(
|
virtual void DidFailProvisionalLoadWithError(
|
||||||
WebView* webview,
|
WebView* webview,
|
||||||
const WebKit::WebURLError& error,
|
const WebKit::WebURLError& error,
|
||||||
WebFrame* frame);
|
WebFrame* frame);
|
||||||
virtual void DidCommitLoadForFrame(WebView* webview, WebFrame* frame,
|
virtual void DidCommitLoadForFrame(WebView* webview, WebFrame* frame,
|
||||||
bool is_new_navigation);
|
bool is_new_navigation);
|
||||||
virtual void DidReceiveTitle(WebView* webview,
|
virtual void DidReceiveTitle(WebView* webview,
|
||||||
const std::wstring& title,
|
const std::wstring& title,
|
||||||
WebFrame* frame);
|
WebFrame* frame);
|
||||||
virtual void DidFinishDocumentLoadForFrame(WebView* webview,
|
virtual void DidFinishDocumentLoadForFrame(WebView* webview,
|
||||||
WebFrame* frame);
|
WebFrame* frame);
|
||||||
virtual void DidHandleOnloadEventsForFrame(WebView* webview,
|
virtual void DidHandleOnloadEventsForFrame(WebView* webview,
|
||||||
WebFrame* frame);
|
WebFrame* frame);
|
||||||
virtual void DidChangeLocationWithinPageForFrame(WebView* webview,
|
virtual void DidChangeLocationWithinPageForFrame(WebView* webview,
|
||||||
WebFrame* frame,
|
WebFrame* frame,
|
||||||
bool is_new_navigation);
|
bool is_new_navigation);
|
||||||
virtual void DidReceiveIconForFrame(WebView* webview, WebFrame* frame);
|
virtual void DidReceiveIconForFrame(WebView* webview, WebFrame* frame);
|
||||||
|
|
||||||
virtual void WillPerformClientRedirect(WebView* webview,
|
virtual void WillPerformClientRedirect(WebView* webview,
|
||||||
WebFrame* frame,
|
WebFrame* frame,
|
||||||
const std::wstring& dest_url,
|
const std::wstring& dest_url,
|
||||||
unsigned int delay_seconds,
|
unsigned int delay_seconds,
|
||||||
unsigned int fire_date);
|
unsigned int fire_date);
|
||||||
virtual void DidCancelClientRedirect(WebView* webview,
|
virtual void DidCancelClientRedirect(WebView* webview,
|
||||||
WebFrame* frame);
|
WebFrame* frame);
|
||||||
|
|
||||||
virtual void DidFinishLoadForFrame(WebView* webview, WebFrame* frame);
|
virtual void DidFinishLoadForFrame(WebView* webview, WebFrame* frame);
|
||||||
virtual void DidFailLoadWithError(WebView* webview,
|
virtual void DidFailLoadWithError(WebView* webview,
|
||||||
const WebKit::WebURLError& error,
|
const WebKit::WebURLError& error,
|
||||||
WebFrame* for_frame);
|
WebFrame* for_frame);
|
||||||
|
|
||||||
virtual void AssignIdentifierToRequest(WebView* webview,
|
virtual void AssignIdentifierToRequest(WebView* webview,
|
||||||
uint32 identifier,
|
uint32 identifier,
|
||||||
const WebKit::WebURLRequest& request);
|
const WebKit::WebURLRequest& request);
|
||||||
virtual void WillSendRequest(WebView* webview,
|
virtual void WillSendRequest(WebView* webview,
|
||||||
uint32 identifier,
|
uint32 identifier,
|
||||||
WebKit::WebURLRequest* request);
|
WebKit::WebURLRequest* request);
|
||||||
virtual void DidFinishLoading(WebView* webview, uint32 identifier);
|
virtual void DidFinishLoading(WebView* webview, uint32 identifier);
|
||||||
virtual void DidFailLoadingWithError(WebView* webview,
|
virtual void DidFailLoadingWithError(WebView* webview,
|
||||||
uint32 identifier,
|
uint32 identifier,
|
||||||
const WebKit::WebURLError& error);
|
const WebKit::WebURLError& error);
|
||||||
|
|
||||||
virtual bool ShouldBeginEditing(WebView* webview, std::wstring range);
|
virtual bool ShouldBeginEditing(WebView* webview, std::wstring range);
|
||||||
virtual bool ShouldEndEditing(WebView* webview, std::wstring range);
|
virtual bool ShouldEndEditing(WebView* webview, std::wstring range);
|
||||||
virtual bool ShouldInsertNode(WebView* webview,
|
virtual bool ShouldInsertNode(WebView* webview,
|
||||||
std::wstring node,
|
std::wstring node,
|
||||||
std::wstring range,
|
std::wstring range,
|
||||||
std::wstring action);
|
std::wstring action);
|
||||||
virtual bool ShouldInsertText(WebView* webview,
|
virtual bool ShouldInsertText(WebView* webview,
|
||||||
std::wstring text,
|
std::wstring text,
|
||||||
std::wstring range,
|
std::wstring range,
|
||||||
std::wstring action);
|
std::wstring action);
|
||||||
virtual bool ShouldChangeSelectedRange(WebView* webview,
|
virtual bool ShouldChangeSelectedRange(WebView* webview,
|
||||||
std::wstring fromRange,
|
std::wstring fromRange,
|
||||||
std::wstring toRange,
|
std::wstring toRange,
|
||||||
std::wstring affinity,
|
std::wstring affinity,
|
||||||
bool stillSelecting);
|
bool stillSelecting);
|
||||||
virtual bool ShouldDeleteRange(WebView* webview, std::wstring range);
|
virtual bool ShouldDeleteRange(WebView* webview, std::wstring range);
|
||||||
virtual bool ShouldApplyStyle(WebView* webview,
|
virtual bool ShouldApplyStyle(WebView* webview,
|
||||||
std::wstring style,
|
std::wstring style,
|
||||||
std::wstring range);
|
std::wstring range);
|
||||||
virtual bool SmartInsertDeleteEnabled();
|
virtual bool SmartInsertDeleteEnabled();
|
||||||
virtual void DidBeginEditing();
|
virtual void DidBeginEditing();
|
||||||
virtual void DidChangeSelection();
|
virtual void DidChangeSelection();
|
||||||
virtual void DidChangeContents();
|
virtual void DidChangeContents();
|
||||||
virtual void DidEndEditing();
|
virtual void DidEndEditing();
|
||||||
|
|
||||||
virtual void DidStartLoading(WebView* webview);
|
virtual void DidStartLoading(WebView* webview);
|
||||||
virtual void DidStopLoading(WebView* webview);
|
virtual void DidStopLoading(WebView* webview);
|
||||||
|
|
||||||
virtual void WindowObjectCleared(WebFrame* webframe);
|
virtual void WindowObjectCleared(WebFrame* webframe);
|
||||||
virtual WebKit::WebNavigationPolicy PolicyForNavigationAction(
|
virtual WebKit::WebNavigationPolicy PolicyForNavigationAction(
|
||||||
WebView* webview,
|
WebView* webview,
|
||||||
WebFrame* frame,
|
WebFrame* frame,
|
||||||
const WebKit::WebURLRequest& request,
|
const WebKit::WebURLRequest& request,
|
||||||
WebKit::WebNavigationType type,
|
WebKit::WebNavigationType type,
|
||||||
WebKit::WebNavigationPolicy default_policy,
|
WebKit::WebNavigationPolicy default_policy,
|
||||||
bool is_redirect);
|
bool is_redirect);
|
||||||
virtual void NavigateBackForwardSoon(int offset);
|
virtual void NavigateBackForwardSoon(int offset);
|
||||||
virtual int GetHistoryBackListCount();
|
virtual int GetHistoryBackListCount();
|
||||||
virtual int GetHistoryForwardListCount();
|
virtual int GetHistoryForwardListCount();
|
||||||
virtual void TakeFocus(WebView* webview, bool reverse);
|
virtual void TakeFocus(WebView* webview, bool reverse);
|
||||||
|
|
||||||
// WebWidgetClient
|
// WebWidgetClient
|
||||||
virtual void didInvalidateRect(const WebKit::WebRect& rect);
|
virtual void didInvalidateRect(const WebKit::WebRect& rect);
|
||||||
virtual void didScrollRect(int dx, int dy,
|
virtual void didScrollRect(int dx, int dy,
|
||||||
const WebKit::WebRect& clip_rect);
|
const WebKit::WebRect& clip_rect);
|
||||||
virtual void didFocus();
|
virtual void didFocus();
|
||||||
virtual void didBlur();
|
virtual void didBlur();
|
||||||
virtual void didChangeCursor(const WebKit::WebCursorInfo& cursor);
|
virtual void didChangeCursor(const WebKit::WebCursorInfo& cursor);
|
||||||
virtual void closeWidgetSoon();
|
virtual void closeWidgetSoon();
|
||||||
virtual void show(WebKit::WebNavigationPolicy policy);
|
virtual void show(WebKit::WebNavigationPolicy policy);
|
||||||
virtual void runModal();
|
virtual void runModal();
|
||||||
virtual WebKit::WebRect windowRect();
|
virtual WebKit::WebRect windowRect();
|
||||||
virtual void setWindowRect(const WebKit::WebRect& rect);
|
virtual void setWindowRect(const WebKit::WebRect& rect);
|
||||||
virtual WebKit::WebRect rootWindowRect();
|
virtual WebKit::WebRect rootWindowRect();
|
||||||
virtual WebKit::WebRect windowResizerRect();
|
virtual WebKit::WebRect windowResizerRect();
|
||||||
virtual WebKit::WebScreenInfo screenInfo();
|
virtual WebKit::WebScreenInfo screenInfo();
|
||||||
|
|
||||||
void SetSmartInsertDeleteEnabled(bool enabled);
|
void SetSmartInsertDeleteEnabled(bool enabled);
|
||||||
void SetSelectTrailingWhitespaceEnabled(bool enabled);
|
void SetSelectTrailingWhitespaceEnabled(bool enabled);
|
||||||
|
|
||||||
// Additional accessors
|
// Additional accessors
|
||||||
WebFrame* top_loading_frame() { return top_loading_frame_; }
|
WebFrame* top_loading_frame() { return top_loading_frame_; }
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
IDropTarget* drop_delegate() { return drop_delegate_.get(); }
|
IDropTarget* drop_delegate() { return drop_delegate_.get(); }
|
||||||
IDropSource* drag_delegate() { return drag_delegate_.get(); }
|
IDropSource* drag_delegate() { return drag_delegate_.get(); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void set_pending_extra_data(BrowserExtraData* extra_data) {
|
void set_pending_extra_data(BrowserExtraData* extra_data) {
|
||||||
pending_extra_data_.reset(extra_data);
|
pending_extra_data_.reset(extra_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods for modifying WebPreferences
|
// Methods for modifying WebPreferences
|
||||||
void SetUserStyleSheetEnabled(bool is_enabled);
|
void SetUserStyleSheetEnabled(bool is_enabled);
|
||||||
void SetUserStyleSheetLocation(const GURL& location);
|
void SetUserStyleSheetLocation(const GURL& location);
|
||||||
|
|
||||||
// Sets the webview as a drop target.
|
// Sets the webview as a drop target.
|
||||||
void RegisterDragDrop();
|
void RegisterDragDrop();
|
||||||
|
|
||||||
void SetCustomPolicyDelegate(bool is_custom, bool is_permissive);
|
void SetCustomPolicyDelegate(bool is_custom, bool is_permissive);
|
||||||
void WaitForPolicyDelegate();
|
void WaitForPolicyDelegate();
|
||||||
|
|
||||||
CefBrowserImpl* GetBrowser() { return browser_; }
|
CefBrowserImpl* GetBrowser() { return browser_; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Called when the URL of the page changes.
|
// Called when the URL of the page changes.
|
||||||
void UpdateAddressBar(WebView* webView);
|
void UpdateAddressBar(WebView* webView);
|
||||||
|
|
||||||
// Default handling of JavaScript messages.
|
// Default handling of JavaScript messages.
|
||||||
void ShowJavaScriptAlert(WebFrame* webframe, const std::wstring& message);
|
void ShowJavaScriptAlert(WebFrame* webframe, const std::wstring& message);
|
||||||
bool ShowJavaScriptConfirm(WebFrame* webframe, const std::wstring& message);
|
bool ShowJavaScriptConfirm(WebFrame* webframe, const std::wstring& message);
|
||||||
bool ShowJavaScriptPrompt(WebFrame* webframe, const std::wstring& message,
|
bool ShowJavaScriptPrompt(WebFrame* webframe, const std::wstring& message,
|
||||||
const std::wstring& default_value, std::wstring* result);
|
const std::wstring& default_value, std::wstring* result);
|
||||||
|
|
||||||
// In the Mac code, this is called to trigger the end of a test after the
|
// In the Mac code, this is called to trigger the end of a test after the
|
||||||
// page has finished loading. From here, we can generate the dump for the
|
// page has finished loading. From here, we can generate the dump for the
|
||||||
// test.
|
// test.
|
||||||
void LocationChangeDone(WebFrame*);
|
void LocationChangeDone(WebFrame*);
|
||||||
|
|
||||||
WebWidgetHost* GetWidgetHost();
|
WebWidgetHost* GetWidgetHost();
|
||||||
|
|
||||||
void UpdateForCommittedLoad(WebFrame* webframe, bool is_new_navigation);
|
void UpdateForCommittedLoad(WebFrame* webframe, bool is_new_navigation);
|
||||||
void UpdateURL(WebFrame* frame);
|
void UpdateURL(WebFrame* frame);
|
||||||
void UpdateSessionHistory(WebFrame* frame);
|
void UpdateSessionHistory(WebFrame* frame);
|
||||||
|
|
||||||
// Get a string suitable for dumping a frame to the console.
|
// Get a string suitable for dumping a frame to the console.
|
||||||
std::wstring GetFrameDescription(WebFrame* webframe);
|
std::wstring GetFrameDescription(WebFrame* webframe);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Causes navigation actions just printout the intended navigation instead
|
// Causes navigation actions just printout the intended navigation instead
|
||||||
// of taking you to the page. This is used for cases like mailto, where you
|
// of taking you to the page. This is used for cases like mailto, where you
|
||||||
// don't actually want to open the mail program.
|
// don't actually want to open the mail program.
|
||||||
bool policy_delegate_enabled_;
|
bool policy_delegate_enabled_;
|
||||||
|
|
||||||
// Toggles the behavior of the policy delegate. If true, then navigations
|
// Toggles the behavior of the policy delegate. If true, then navigations
|
||||||
// will be allowed. Otherwise, they will be ignored (dropped).
|
// will be allowed. Otherwise, they will be ignored (dropped).
|
||||||
bool policy_delegate_is_permissive_;
|
bool policy_delegate_is_permissive_;
|
||||||
|
|
||||||
// Non-owning pointer. The delegate is owned by the host.
|
// Non-owning pointer. The delegate is owned by the host.
|
||||||
CefBrowserImpl* browser_;
|
CefBrowserImpl* browser_;
|
||||||
|
|
||||||
// This is non-NULL IFF a load is in progress.
|
// This is non-NULL IFF a load is in progress.
|
||||||
WebFrame* top_loading_frame_;
|
WebFrame* top_loading_frame_;
|
||||||
|
|
||||||
// For tracking session history. See RenderView.
|
// For tracking session history. See RenderView.
|
||||||
int page_id_;
|
int page_id_;
|
||||||
int last_page_id_updated_;
|
int last_page_id_updated_;
|
||||||
|
|
||||||
scoped_ptr<BrowserExtraData> pending_extra_data_;
|
scoped_ptr<BrowserExtraData> pending_extra_data_;
|
||||||
|
|
||||||
// true if we want to enable smart insert/delete.
|
// true if we want to enable smart insert/delete.
|
||||||
bool smart_insert_delete_enabled_;
|
bool smart_insert_delete_enabled_;
|
||||||
|
|
||||||
// true if we want to enable selection of trailing whitespaces
|
// true if we want to enable selection of trailing whitespaces
|
||||||
bool select_trailing_whitespace_enabled_;
|
bool select_trailing_whitespace_enabled_;
|
||||||
|
|
||||||
WebCursor current_cursor_;
|
WebCursor current_cursor_;
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
// Classes needed by drag and drop.
|
// Classes needed by drag and drop.
|
||||||
scoped_refptr<BrowserDragDelegate> drag_delegate_;
|
scoped_refptr<BrowserDragDelegate> drag_delegate_;
|
||||||
scoped_refptr<BrowserDropDelegate> drop_delegate_;
|
scoped_refptr<BrowserDropDelegate> drop_delegate_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(OS_LINUX)
|
#if defined(OS_LINUX)
|
||||||
// The type of cursor the window is currently using.
|
// The type of cursor the window is currently using.
|
||||||
// Used for judging whether a new SetCursor call is actually changing the
|
// Used for judging whether a new SetCursor call is actually changing the
|
||||||
// cursor.
|
// cursor.
|
||||||
GdkCursorType cursor_type_;
|
GdkCursorType cursor_type_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(BrowserWebViewDelegate);
|
DISALLOW_COPY_AND_ASSIGN(BrowserWebViewDelegate);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _BROWSER_WEBVIEW_DELEGATE_H
|
#endif // _BROWSER_WEBVIEW_DELEGATE_H
|
||||||
|
@ -1,384 +1,384 @@
|
|||||||
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// This file contains the implementation of BrowserWebViewDelegate, which serves
|
// This file contains the implementation of BrowserWebViewDelegate, which serves
|
||||||
// as the WebViewDelegate for the BrowserWebHost. The host is expected to
|
// as the WebViewDelegate for the BrowserWebHost. The host is expected to
|
||||||
// have initialized a MessageLoop before these methods are called.
|
// have initialized a MessageLoop before these methods are called.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
#include "browser_webview_delegate.h"
|
#include "browser_webview_delegate.h"
|
||||||
#include "browser_drag_delegate.h"
|
#include "browser_drag_delegate.h"
|
||||||
#include "browser_drop_delegate.h"
|
#include "browser_drop_delegate.h"
|
||||||
#include "browser_navigation_controller.h"
|
#include "browser_navigation_controller.h"
|
||||||
#include "browser_impl.h"
|
#include "browser_impl.h"
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
|
|
||||||
#include <objidl.h>
|
#include <objidl.h>
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#include <shlwapi.h>
|
#include <shlwapi.h>
|
||||||
|
|
||||||
#include "base/gfx/gdi_util.h"
|
#include "base/gfx/gdi_util.h"
|
||||||
#include "base/gfx/native_widget_types.h"
|
#include "base/gfx/native_widget_types.h"
|
||||||
#include "base/gfx/point.h"
|
#include "base/gfx/point.h"
|
||||||
#include "base/message_loop.h"
|
#include "base/message_loop.h"
|
||||||
#include "base/string_util.h"
|
#include "base/string_util.h"
|
||||||
#include "base/trace_event.h"
|
#include "base/trace_event.h"
|
||||||
#include "net/base/net_errors.h"
|
#include "net/base/net_errors.h"
|
||||||
#include "webkit/api/public/WebCursorInfo.h"
|
#include "webkit/api/public/WebCursorInfo.h"
|
||||||
#include "webkit/api/public/WebRect.h"
|
#include "webkit/api/public/WebRect.h"
|
||||||
#include "webkit/glue/webdropdata.h"
|
#include "webkit/glue/webdropdata.h"
|
||||||
#include "webkit/glue/webframe.h"
|
#include "webkit/glue/webframe.h"
|
||||||
#include "webkit/glue/webpreferences.h"
|
#include "webkit/glue/webpreferences.h"
|
||||||
#include "webkit/glue/webplugin.h"
|
#include "webkit/glue/webplugin.h"
|
||||||
#include "webkit/glue/webkit_glue.h"
|
#include "webkit/glue/webkit_glue.h"
|
||||||
#include "webkit/glue/webview.h"
|
#include "webkit/glue/webview.h"
|
||||||
#include "webkit/glue/plugins/plugin_list.h"
|
#include "webkit/glue/plugins/plugin_list.h"
|
||||||
#include "webkit/glue/plugins/webplugin_delegate_impl.h"
|
#include "webkit/glue/plugins/webplugin_delegate_impl.h"
|
||||||
#include "webkit/glue/window_open_disposition.h"
|
#include "webkit/glue/window_open_disposition.h"
|
||||||
|
|
||||||
using WebKit::WebCursorInfo;
|
using WebKit::WebCursorInfo;
|
||||||
using WebKit::WebNavigationPolicy;
|
using WebKit::WebNavigationPolicy;
|
||||||
using WebKit::WebRect;
|
using WebKit::WebRect;
|
||||||
|
|
||||||
// WebViewDelegate -----------------------------------------------------------
|
// WebViewDelegate -----------------------------------------------------------
|
||||||
|
|
||||||
WebPluginDelegate* BrowserWebViewDelegate::CreatePluginDelegate(
|
WebPluginDelegate* BrowserWebViewDelegate::CreatePluginDelegate(
|
||||||
WebView* webview,
|
WebView* webview,
|
||||||
const GURL& url,
|
const GURL& url,
|
||||||
const std::string& mime_type,
|
const std::string& mime_type,
|
||||||
const std::string& clsid,
|
const std::string& clsid,
|
||||||
std::string* actual_mime_type) {
|
std::string* actual_mime_type) {
|
||||||
HWND hwnd = browser_->GetWebViewHost()->view_handle();
|
HWND hwnd = browser_->GetWebViewHost()->view_handle();
|
||||||
if (!hwnd)
|
if (!hwnd)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
bool allow_wildcard = true;
|
bool allow_wildcard = true;
|
||||||
|
|
||||||
// first, look for plugins using the normal plugin list
|
// first, look for plugins using the normal plugin list
|
||||||
WebPluginInfo info;
|
WebPluginInfo info;
|
||||||
if (NPAPI::PluginList::Singleton()->GetPluginInfo(url, mime_type, clsid,
|
if (NPAPI::PluginList::Singleton()->GetPluginInfo(url, mime_type, clsid,
|
||||||
allow_wildcard, &info,
|
allow_wildcard, &info,
|
||||||
actual_mime_type)) {
|
actual_mime_type)) {
|
||||||
if (actual_mime_type && !actual_mime_type->empty())
|
if (actual_mime_type && !actual_mime_type->empty())
|
||||||
return WebPluginDelegateImpl::Create(info.path, *actual_mime_type, hwnd);
|
return WebPluginDelegateImpl::Create(info.path, *actual_mime_type, hwnd);
|
||||||
else
|
else
|
||||||
return WebPluginDelegateImpl::Create(info.path, mime_type, hwnd);
|
return WebPluginDelegateImpl::Create(info.path, mime_type, hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWebViewDelegate::DidMovePlugin(const WebPluginGeometry& move) {
|
void BrowserWebViewDelegate::DidMovePlugin(const WebPluginGeometry& move) {
|
||||||
HRGN hrgn = ::CreateRectRgn(move.clip_rect.x(),
|
HRGN hrgn = ::CreateRectRgn(move.clip_rect.x(),
|
||||||
move.clip_rect.y(),
|
move.clip_rect.y(),
|
||||||
move.clip_rect.right(),
|
move.clip_rect.right(),
|
||||||
move.clip_rect.bottom());
|
move.clip_rect.bottom());
|
||||||
gfx::SubtractRectanglesFromRegion(hrgn, move.cutout_rects);
|
gfx::SubtractRectanglesFromRegion(hrgn, move.cutout_rects);
|
||||||
|
|
||||||
// Note: System will own the hrgn after we call SetWindowRgn,
|
// Note: System will own the hrgn after we call SetWindowRgn,
|
||||||
// so we don't need to call DeleteObject(hrgn)
|
// so we don't need to call DeleteObject(hrgn)
|
||||||
::SetWindowRgn(move.window, hrgn, FALSE);
|
::SetWindowRgn(move.window, hrgn, FALSE);
|
||||||
unsigned long flags = 0;
|
unsigned long flags = 0;
|
||||||
if (move.visible)
|
if (move.visible)
|
||||||
flags |= SWP_SHOWWINDOW;
|
flags |= SWP_SHOWWINDOW;
|
||||||
else
|
else
|
||||||
flags |= SWP_HIDEWINDOW;
|
flags |= SWP_HIDEWINDOW;
|
||||||
|
|
||||||
::SetWindowPos(move.window,
|
::SetWindowPos(move.window,
|
||||||
NULL,
|
NULL,
|
||||||
move.window_rect.x(),
|
move.window_rect.x(),
|
||||||
move.window_rect.y(),
|
move.window_rect.y(),
|
||||||
move.window_rect.width(),
|
move.window_rect.width(),
|
||||||
move.window_rect.height(),
|
move.window_rect.height(),
|
||||||
flags);
|
flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AddMenuItem(CefRefPtr<CefBrowser> browser, HMENU menu, int index,
|
static void AddMenuItem(CefRefPtr<CefBrowser> browser, HMENU menu, int index,
|
||||||
CefHandler::MenuId id, const wchar_t* label,
|
CefHandler::MenuId id, const wchar_t* label,
|
||||||
bool enabled, std::list<std::wstring>& label_list)
|
bool enabled, std::list<std::wstring>& label_list)
|
||||||
{
|
{
|
||||||
std::wstring actual_label = label;
|
std::wstring actual_label = label;
|
||||||
CefRefPtr<CefHandler> handler = browser->GetHandler();
|
CefRefPtr<CefHandler> handler = browser->GetHandler();
|
||||||
if(handler.get()) {
|
if(handler.get()) {
|
||||||
// Let the handler change the label if desired
|
// Let the handler change the label if desired
|
||||||
handler->HandleGetMenuLabel(browser, id, actual_label);
|
handler->HandleGetMenuLabel(browser, id, actual_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
// store the label in a list to simplify memory management
|
// store the label in a list to simplify memory management
|
||||||
label_list.push_back(actual_label);
|
label_list.push_back(actual_label);
|
||||||
|
|
||||||
MENUITEMINFO mii;
|
MENUITEMINFO mii;
|
||||||
mii.cbSize = sizeof(mii);
|
mii.cbSize = sizeof(mii);
|
||||||
mii.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING;
|
mii.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING;
|
||||||
mii.fType = MFT_STRING;
|
mii.fType = MFT_STRING;
|
||||||
if(!enabled) {
|
if(!enabled) {
|
||||||
mii.fMask |= MIIM_STATE;
|
mii.fMask |= MIIM_STATE;
|
||||||
mii.fState = MFS_GRAYED;
|
mii.fState = MFS_GRAYED;
|
||||||
}
|
}
|
||||||
mii.wID = id;
|
mii.wID = id;
|
||||||
mii.dwTypeData = const_cast<wchar_t*>(label_list.back().c_str());
|
mii.dwTypeData = const_cast<wchar_t*>(label_list.back().c_str());
|
||||||
|
|
||||||
InsertMenuItem(menu, index, TRUE, &mii);
|
InsertMenuItem(menu, index, TRUE, &mii);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AddMenuSeparator(HMENU menu, int index)
|
static void AddMenuSeparator(HMENU menu, int index)
|
||||||
{
|
{
|
||||||
MENUITEMINFO mii;
|
MENUITEMINFO mii;
|
||||||
mii.cbSize = sizeof(mii);
|
mii.cbSize = sizeof(mii);
|
||||||
mii.fMask = MIIM_FTYPE;
|
mii.fMask = MIIM_FTYPE;
|
||||||
mii.fType = MFT_SEPARATOR;
|
mii.fType = MFT_SEPARATOR;
|
||||||
|
|
||||||
InsertMenuItem(menu, index, TRUE, &mii);
|
InsertMenuItem(menu, index, TRUE, &mii);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWebViewDelegate::ShowContextMenu(
|
void BrowserWebViewDelegate::ShowContextMenu(
|
||||||
WebView* webview,
|
WebView* webview,
|
||||||
ContextNodeType node_type,
|
ContextNodeType node_type,
|
||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
const GURL& link_url,
|
const GURL& link_url,
|
||||||
const GURL& image_url,
|
const GURL& image_url,
|
||||||
const GURL& page_url,
|
const GURL& page_url,
|
||||||
const GURL& frame_url,
|
const GURL& frame_url,
|
||||||
const ContextMenuMediaParams& media_params,
|
const ContextMenuMediaParams& media_params,
|
||||||
const std::wstring& selection_text,
|
const std::wstring& selection_text,
|
||||||
const std::wstring& misspelled_word,
|
const std::wstring& misspelled_word,
|
||||||
int edit_flags,
|
int edit_flags,
|
||||||
const std::string& security_info,
|
const std::string& security_info,
|
||||||
const std::string& frame_charset) {
|
const std::string& frame_charset) {
|
||||||
|
|
||||||
POINT screen_pt = { x, y };
|
POINT screen_pt = { x, y };
|
||||||
MapWindowPoints(browser_->GetMainWndHandle(), HWND_DESKTOP,
|
MapWindowPoints(browser_->GetMainWndHandle(), HWND_DESKTOP,
|
||||||
&screen_pt, 1);
|
&screen_pt, 1);
|
||||||
|
|
||||||
HMENU menu = NULL;
|
HMENU menu = NULL;
|
||||||
std::list<std::wstring> label_list;
|
std::list<std::wstring> label_list;
|
||||||
|
|
||||||
// Enable recursive tasks on the message loop so we can get updates while
|
// Enable recursive tasks on the message loop so we can get updates while
|
||||||
// the context menu is being displayed.
|
// the context menu is being displayed.
|
||||||
bool old_state = MessageLoop::current()->NestableTasksAllowed();
|
bool old_state = MessageLoop::current()->NestableTasksAllowed();
|
||||||
MessageLoop::current()->SetNestableTasksAllowed(true);
|
MessageLoop::current()->SetNestableTasksAllowed(true);
|
||||||
|
|
||||||
if(browser_->UIT_CanGoBack())
|
if(browser_->UIT_CanGoBack())
|
||||||
edit_flags |= MENU_CAN_GO_BACK;
|
edit_flags |= MENU_CAN_GO_BACK;
|
||||||
if(browser_->UIT_CanGoForward())
|
if(browser_->UIT_CanGoForward())
|
||||||
edit_flags |= MENU_CAN_GO_FORWARD;
|
edit_flags |= MENU_CAN_GO_FORWARD;
|
||||||
|
|
||||||
CefRefPtr<CefHandler> handler = browser_->GetHandler();
|
CefRefPtr<CefHandler> handler = browser_->GetHandler();
|
||||||
if(handler.get()) {
|
if(handler.get()) {
|
||||||
// Gather menu information
|
// Gather menu information
|
||||||
CefHandler::MenuInfo menuInfo;
|
CefHandler::MenuInfo menuInfo;
|
||||||
std::wstring linkstr, imagestr, pagestr, framestr, securitystr;
|
std::wstring linkstr, imagestr, pagestr, framestr, securitystr;
|
||||||
|
|
||||||
linkstr = UTF8ToWide(link_url.spec().c_str());
|
linkstr = UTF8ToWide(link_url.spec().c_str());
|
||||||
imagestr = UTF8ToWide(image_url.spec().c_str());
|
imagestr = UTF8ToWide(image_url.spec().c_str());
|
||||||
pagestr = UTF8ToWide(page_url.spec().c_str());
|
pagestr = UTF8ToWide(page_url.spec().c_str());
|
||||||
framestr = UTF8ToWide(frame_url.spec().c_str());
|
framestr = UTF8ToWide(frame_url.spec().c_str());
|
||||||
securitystr = UTF8ToWide(security_info);
|
securitystr = UTF8ToWide(security_info);
|
||||||
|
|
||||||
menuInfo.typeFlags = node_type.type;
|
menuInfo.typeFlags = node_type.type;
|
||||||
menuInfo.x = screen_pt.x;
|
menuInfo.x = screen_pt.x;
|
||||||
menuInfo.y = screen_pt.y;
|
menuInfo.y = screen_pt.y;
|
||||||
menuInfo.linkUrl = linkstr.c_str();
|
menuInfo.linkUrl = linkstr.c_str();
|
||||||
menuInfo.imageUrl = imagestr.c_str();
|
menuInfo.imageUrl = imagestr.c_str();
|
||||||
menuInfo.pageUrl = pagestr.c_str();
|
menuInfo.pageUrl = pagestr.c_str();
|
||||||
menuInfo.frameUrl = framestr.c_str();
|
menuInfo.frameUrl = framestr.c_str();
|
||||||
menuInfo.selectionText = selection_text.c_str();
|
menuInfo.selectionText = selection_text.c_str();
|
||||||
menuInfo.misspelledWord = misspelled_word.c_str();
|
menuInfo.misspelledWord = misspelled_word.c_str();
|
||||||
menuInfo.editFlags = edit_flags;
|
menuInfo.editFlags = edit_flags;
|
||||||
menuInfo.securityInfo = securitystr.c_str();
|
menuInfo.securityInfo = securitystr.c_str();
|
||||||
|
|
||||||
// Notify the handler that a context menu is requested
|
// Notify the handler that a context menu is requested
|
||||||
CefHandler::RetVal rv = handler->HandleBeforeMenu(browser_, menuInfo);
|
CefHandler::RetVal rv = handler->HandleBeforeMenu(browser_, menuInfo);
|
||||||
if(rv == RV_HANDLED)
|
if(rv == RV_HANDLED)
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the correct default context menu
|
// Build the correct default context menu
|
||||||
if (node_type.type & ContextNodeType::EDITABLE) {
|
if (node_type.type & ContextNodeType::EDITABLE) {
|
||||||
menu = CreatePopupMenu();
|
menu = CreatePopupMenu();
|
||||||
AddMenuItem(browser_, menu, -1, MENU_ID_UNDO, L"Undo",
|
AddMenuItem(browser_, menu, -1, MENU_ID_UNDO, L"Undo",
|
||||||
!!(edit_flags & ContextNodeType::CAN_UNDO), label_list);
|
!!(edit_flags & ContextNodeType::CAN_UNDO), label_list);
|
||||||
AddMenuItem(browser_, menu, -1, MENU_ID_REDO, L"Redo",
|
AddMenuItem(browser_, menu, -1, MENU_ID_REDO, L"Redo",
|
||||||
!!(edit_flags & ContextNodeType::CAN_REDO), label_list);
|
!!(edit_flags & ContextNodeType::CAN_REDO), label_list);
|
||||||
AddMenuSeparator(menu, -1);
|
AddMenuSeparator(menu, -1);
|
||||||
AddMenuItem(browser_, menu, -1, MENU_ID_CUT, L"Cut",
|
AddMenuItem(browser_, menu, -1, MENU_ID_CUT, L"Cut",
|
||||||
!!(edit_flags & ContextNodeType::CAN_CUT), label_list);
|
!!(edit_flags & ContextNodeType::CAN_CUT), label_list);
|
||||||
AddMenuItem(browser_, menu, -1, MENU_ID_COPY, L"Copy",
|
AddMenuItem(browser_, menu, -1, MENU_ID_COPY, L"Copy",
|
||||||
!!(edit_flags & ContextNodeType::CAN_COPY), label_list);
|
!!(edit_flags & ContextNodeType::CAN_COPY), label_list);
|
||||||
AddMenuItem(browser_, menu, -1, MENU_ID_PASTE, L"Paste",
|
AddMenuItem(browser_, menu, -1, MENU_ID_PASTE, L"Paste",
|
||||||
!!(edit_flags & ContextNodeType::CAN_PASTE), label_list);
|
!!(edit_flags & ContextNodeType::CAN_PASTE), label_list);
|
||||||
AddMenuItem(browser_, menu, -1, MENU_ID_DELETE, L"Delete",
|
AddMenuItem(browser_, menu, -1, MENU_ID_DELETE, L"Delete",
|
||||||
!!(edit_flags & ContextNodeType::CAN_DELETE), label_list);
|
!!(edit_flags & ContextNodeType::CAN_DELETE), label_list);
|
||||||
AddMenuSeparator(menu, -1);
|
AddMenuSeparator(menu, -1);
|
||||||
AddMenuItem(browser_, menu, -1, MENU_ID_SELECTALL, L"Select All",
|
AddMenuItem(browser_, menu, -1, MENU_ID_SELECTALL, L"Select All",
|
||||||
!!(edit_flags & MENU_CAN_SELECT_ALL), label_list);
|
!!(edit_flags & MENU_CAN_SELECT_ALL), label_list);
|
||||||
} else if(node_type.type & ContextNodeType::SELECTION) {
|
} else if(node_type.type & ContextNodeType::SELECTION) {
|
||||||
menu = CreatePopupMenu();
|
menu = CreatePopupMenu();
|
||||||
AddMenuItem(browser_, menu, -1, MENU_ID_COPY, L"Copy",
|
AddMenuItem(browser_, menu, -1, MENU_ID_COPY, L"Copy",
|
||||||
!!(edit_flags & ContextNodeType::CAN_COPY), label_list);
|
!!(edit_flags & ContextNodeType::CAN_COPY), label_list);
|
||||||
} else if(node_type.type &
|
} else if(node_type.type &
|
||||||
(ContextNodeType::PAGE | ContextNodeType::FRAME)) {
|
(ContextNodeType::PAGE | ContextNodeType::FRAME)) {
|
||||||
menu = CreatePopupMenu();
|
menu = CreatePopupMenu();
|
||||||
AddMenuItem(browser_, menu, -1, MENU_ID_NAV_BACK, L"Back",
|
AddMenuItem(browser_, menu, -1, MENU_ID_NAV_BACK, L"Back",
|
||||||
browser_->UIT_CanGoBack(), label_list);
|
browser_->UIT_CanGoBack(), label_list);
|
||||||
AddMenuItem(browser_, menu, -1, MENU_ID_NAV_FORWARD, L"Forward",
|
AddMenuItem(browser_, menu, -1, MENU_ID_NAV_FORWARD, L"Forward",
|
||||||
browser_->UIT_CanGoForward(), label_list);
|
browser_->UIT_CanGoForward(), label_list);
|
||||||
AddMenuSeparator(menu, -1);
|
AddMenuSeparator(menu, -1);
|
||||||
AddMenuItem(browser_, menu, -1, MENU_ID_PRINT, L"Print",
|
AddMenuItem(browser_, menu, -1, MENU_ID_PRINT, L"Print",
|
||||||
true, label_list);
|
true, label_list);
|
||||||
AddMenuItem(browser_, menu, -1, MENU_ID_VIEWSOURCE, L"View Source",
|
AddMenuItem(browser_, menu, -1, MENU_ID_VIEWSOURCE, L"View Source",
|
||||||
true, label_list);
|
true, label_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(menu) {
|
if(menu) {
|
||||||
// show the context menu
|
// show the context menu
|
||||||
int selected_id = TrackPopupMenu(menu,
|
int selected_id = TrackPopupMenu(menu,
|
||||||
TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_RECURSE,
|
TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_RECURSE,
|
||||||
screen_pt.x, screen_pt.y, 0, browser_->GetMainWndHandle(), NULL);
|
screen_pt.x, screen_pt.y, 0, browser_->GetMainWndHandle(), NULL);
|
||||||
|
|
||||||
if(selected_id != 0) {
|
if(selected_id != 0) {
|
||||||
// An action was chosen
|
// An action was chosen
|
||||||
CefHandler::MenuId menuId = static_cast<CefHandler::MenuId>(selected_id);
|
CefHandler::MenuId menuId = static_cast<CefHandler::MenuId>(selected_id);
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
if(handler.get()) {
|
if(handler.get()) {
|
||||||
// Ask the handler if it wants to handle the action
|
// Ask the handler if it wants to handle the action
|
||||||
CefHandler::RetVal rv = handler->HandleMenuAction(browser_, menuId);
|
CefHandler::RetVal rv = handler->HandleMenuAction(browser_, menuId);
|
||||||
handled = (rv == RV_HANDLED);
|
handled = (rv == RV_HANDLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!handled) {
|
if(!handled) {
|
||||||
// Execute the action
|
// Execute the action
|
||||||
CefRefPtr<CefFrame> frame = browser_->GetFocusedFrame();
|
CefRefPtr<CefFrame> frame = browser_->GetFocusedFrame();
|
||||||
frame->AddRef();
|
frame->AddRef();
|
||||||
browser_->UIT_HandleAction(menuId, frame.get());
|
browser_->UIT_HandleAction(menuId, frame.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DestroyMenu(menu);
|
DestroyMenu(menu);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
MessageLoop::current()->SetNestableTasksAllowed(old_state);
|
MessageLoop::current()->SetNestableTasksAllowed(old_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// WebWidgetClient ---------------------------------------------------------
|
// WebWidgetClient ---------------------------------------------------------
|
||||||
|
|
||||||
void BrowserWebViewDelegate::show(WebNavigationPolicy) {
|
void BrowserWebViewDelegate::show(WebNavigationPolicy) {
|
||||||
if (WebWidgetHost* host = GetWidgetHost()) {
|
if (WebWidgetHost* host = GetWidgetHost()) {
|
||||||
HWND root = GetAncestor(host->view_handle(), GA_ROOT);
|
HWND root = GetAncestor(host->view_handle(), GA_ROOT);
|
||||||
ShowWindow(root, SW_SHOW);
|
ShowWindow(root, SW_SHOW);
|
||||||
UpdateWindow(root);
|
UpdateWindow(root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWebViewDelegate::closeWidgetSoon() {
|
void BrowserWebViewDelegate::closeWidgetSoon() {
|
||||||
if (this == browser_->GetWebViewDelegate()) {
|
if (this == browser_->GetWebViewDelegate()) {
|
||||||
PostMessage(browser_->GetMainWndHandle(), WM_CLOSE, 0, 0);
|
PostMessage(browser_->GetMainWndHandle(), WM_CLOSE, 0, 0);
|
||||||
} else if (this == browser_->GetPopupDelegate()) {
|
} else if (this == browser_->GetPopupDelegate()) {
|
||||||
browser_->UIT_ClosePopupWidget();
|
browser_->UIT_ClosePopupWidget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWebViewDelegate::didChangeCursor(
|
void BrowserWebViewDelegate::didChangeCursor(
|
||||||
const WebCursorInfo& cursor_info) {
|
const WebCursorInfo& cursor_info) {
|
||||||
if (WebWidgetHost* host = GetWidgetHost()) {
|
if (WebWidgetHost* host = GetWidgetHost()) {
|
||||||
current_cursor_.InitFromCursorInfo(cursor_info);
|
current_cursor_.InitFromCursorInfo(cursor_info);
|
||||||
HINSTANCE mod_handle = GetModuleHandle(NULL);
|
HINSTANCE mod_handle = GetModuleHandle(NULL);
|
||||||
host->SetCursor(current_cursor_.GetCursor(mod_handle));
|
host->SetCursor(current_cursor_.GetCursor(mod_handle));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRect BrowserWebViewDelegate::windowRect() {
|
WebRect BrowserWebViewDelegate::windowRect() {
|
||||||
if (WebWidgetHost* host = GetWidgetHost()) {
|
if (WebWidgetHost* host = GetWidgetHost()) {
|
||||||
RECT rect;
|
RECT rect;
|
||||||
::GetWindowRect(host->view_handle(), &rect);
|
::GetWindowRect(host->view_handle(), &rect);
|
||||||
return gfx::Rect(rect);
|
return gfx::Rect(rect);
|
||||||
}
|
}
|
||||||
return WebRect();
|
return WebRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWebViewDelegate::setWindowRect(const WebRect& rect) {
|
void BrowserWebViewDelegate::setWindowRect(const WebRect& rect) {
|
||||||
if (this == browser_->GetWebViewDelegate()) {
|
if (this == browser_->GetWebViewDelegate()) {
|
||||||
// ignored
|
// ignored
|
||||||
} else if (this == browser_->GetPopupDelegate()) {
|
} else if (this == browser_->GetPopupDelegate()) {
|
||||||
MoveWindow(browser_->GetPopupWndHandle(),
|
MoveWindow(browser_->GetPopupWndHandle(),
|
||||||
rect.x, rect.y, rect.width, rect.height, FALSE);
|
rect.x, rect.y, rect.width, rect.height, FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRect BrowserWebViewDelegate::rootWindowRect() {
|
WebRect BrowserWebViewDelegate::rootWindowRect() {
|
||||||
if (WebWidgetHost* host = GetWidgetHost()) {
|
if (WebWidgetHost* host = GetWidgetHost()) {
|
||||||
RECT rect;
|
RECT rect;
|
||||||
HWND root_window = ::GetAncestor(host->view_handle(), GA_ROOT);
|
HWND root_window = ::GetAncestor(host->view_handle(), GA_ROOT);
|
||||||
::GetWindowRect(root_window, &rect);
|
::GetWindowRect(root_window, &rect);
|
||||||
return gfx::Rect(rect);
|
return gfx::Rect(rect);
|
||||||
}
|
}
|
||||||
return WebRect();
|
return WebRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRect BrowserWebViewDelegate::windowResizerRect() {
|
WebRect BrowserWebViewDelegate::windowResizerRect() {
|
||||||
// Not necessary on Windows.
|
// Not necessary on Windows.
|
||||||
return WebRect();
|
return WebRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWebViewDelegate::runModal() {
|
void BrowserWebViewDelegate::runModal() {
|
||||||
WebWidgetHost* host = GetWidgetHost();
|
WebWidgetHost* host = GetWidgetHost();
|
||||||
if (!host)
|
if (!host)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
show(WebNavigationPolicy() /*XXX NEW_WINDOW*/);
|
show(WebNavigationPolicy() /*XXX NEW_WINDOW*/);
|
||||||
|
|
||||||
CefContext::BrowserList *list;
|
CefContext::BrowserList *list;
|
||||||
CefContext::BrowserList::const_iterator i;
|
CefContext::BrowserList::const_iterator i;
|
||||||
|
|
||||||
_Context->Lock();
|
_Context->Lock();
|
||||||
list = _Context->GetBrowserList();
|
list = _Context->GetBrowserList();
|
||||||
i = list->begin();
|
i = list->begin();
|
||||||
for (; i != list->end(); ++i) {
|
for (; i != list->end(); ++i) {
|
||||||
if (i->get()->IsPopup())
|
if (i->get()->IsPopup())
|
||||||
EnableWindow(i->get()->GetMainWndHandle(), FALSE);
|
EnableWindow(i->get()->GetMainWndHandle(), FALSE);
|
||||||
}
|
}
|
||||||
_Context->Unlock();
|
_Context->Unlock();
|
||||||
|
|
||||||
browser_->UIT_SetIsModal(true);
|
browser_->UIT_SetIsModal(true);
|
||||||
MessageLoop::current()->Run();
|
MessageLoop::current()->Run();
|
||||||
|
|
||||||
_Context->Lock();
|
_Context->Lock();
|
||||||
list = _Context->GetBrowserList();
|
list = _Context->GetBrowserList();
|
||||||
i = list->begin();
|
i = list->begin();
|
||||||
for (; i != list->end(); ++i)
|
for (; i != list->end(); ++i)
|
||||||
EnableWindow(i->get()->GetMainWndHandle(), TRUE);
|
EnableWindow(i->get()->GetMainWndHandle(), TRUE);
|
||||||
_Context->Unlock();
|
_Context->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private methods -----------------------------------------------------------
|
// Private methods -----------------------------------------------------------
|
||||||
|
|
||||||
void BrowserWebViewDelegate::ShowJavaScriptAlert(WebFrame* webframe,
|
void BrowserWebViewDelegate::ShowJavaScriptAlert(WebFrame* webframe,
|
||||||
const std::wstring& message)
|
const std::wstring& message)
|
||||||
{
|
{
|
||||||
// TODO(cef): Think about what we should be showing as the prompt caption
|
// TODO(cef): Think about what we should be showing as the prompt caption
|
||||||
MessageBox(browser_->GetMainWndHandle(), message.c_str(),
|
MessageBox(browser_->GetMainWndHandle(), message.c_str(),
|
||||||
browser_->UIT_GetTitle().c_str(), MB_OK | MB_ICONWARNING);
|
browser_->UIT_GetTitle().c_str(), MB_OK | MB_ICONWARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BrowserWebViewDelegate::ShowJavaScriptConfirm(WebFrame* webframe,
|
bool BrowserWebViewDelegate::ShowJavaScriptConfirm(WebFrame* webframe,
|
||||||
const std::wstring& message)
|
const std::wstring& message)
|
||||||
{
|
{
|
||||||
// TODO(cef): Think about what we should be showing as the prompt caption
|
// TODO(cef): Think about what we should be showing as the prompt caption
|
||||||
int rv = MessageBox(browser_->GetMainWndHandle(), message.c_str(),
|
int rv = MessageBox(browser_->GetMainWndHandle(), message.c_str(),
|
||||||
browser_->UIT_GetTitle().c_str(),
|
browser_->UIT_GetTitle().c_str(),
|
||||||
MB_YESNO | MB_ICONQUESTION);
|
MB_YESNO | MB_ICONQUESTION);
|
||||||
return (rv == IDYES);
|
return (rv == IDYES);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BrowserWebViewDelegate::ShowJavaScriptPrompt(WebFrame* webframe,
|
bool BrowserWebViewDelegate::ShowJavaScriptPrompt(WebFrame* webframe,
|
||||||
const std::wstring& message,
|
const std::wstring& message,
|
||||||
const std::wstring& default_value,
|
const std::wstring& default_value,
|
||||||
std::wstring* result)
|
std::wstring* result)
|
||||||
{
|
{
|
||||||
// TODO(cef): Implement a default prompt dialog
|
// TODO(cef): Implement a default prompt dialog
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "include/cef_string.h"
|
#include "include/cef_string.h"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
|
1030
libcef/context.cc
1030
libcef/context.cc
File diff suppressed because it is too large
Load Diff
@ -1,20 +1,20 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef _CONTEXT_H
|
#ifndef _CONTEXT_H
|
||||||
#define _CONTEXT_H
|
#define _CONTEXT_H
|
||||||
|
|
||||||
#include "../include/cef.h"
|
#include "../include/cef.h"
|
||||||
#include "base/at_exit.h"
|
#include "base/at_exit.h"
|
||||||
#include "base/message_loop.h"
|
#include "base/message_loop.h"
|
||||||
#include "base/stats_table.h"
|
#include "base/stats_table.h"
|
||||||
#include "base/gfx/native_widget_types.h"
|
#include "base/gfx/native_widget_types.h"
|
||||||
#include "webkit/glue/webpreferences.h"
|
#include "webkit/glue/webpreferences.h"
|
||||||
|
|
||||||
class BrowserWebKitInit;
|
class BrowserWebKitInit;
|
||||||
class CefBrowserImpl;
|
class CefBrowserImpl;
|
||||||
|
|
||||||
class CefContext : public CefThreadSafeBase<CefBase>
|
class CefContext : public CefThreadSafeBase<CefBase>
|
||||||
{
|
{
|
||||||
@ -54,10 +54,10 @@ public:
|
|||||||
void UIT_RegisterPlugin(struct CefPluginInfo* plugin_info);
|
void UIT_RegisterPlugin(struct CefPluginInfo* plugin_info);
|
||||||
void UIT_UnregisterPlugin(struct CefPluginInfo* plugin_info);
|
void UIT_UnregisterPlugin(struct CefPluginInfo* plugin_info);
|
||||||
|
|
||||||
bool DoWork();
|
bool DoWork();
|
||||||
bool DoDelayedWork();
|
bool DoDelayedWork();
|
||||||
bool DoIdleWork();
|
bool DoIdleWork();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetMessageLoopForUI(MessageLoopForUI* loop);
|
void SetMessageLoopForUI(MessageLoopForUI* loop);
|
||||||
void NotifyEvent();
|
void NotifyEvent();
|
||||||
@ -97,4 +97,4 @@ extern CefRefPtr<CefContext> _Context;
|
|||||||
// Macro for requiring that a function be called on the UI thread
|
// Macro for requiring that a function be called on the UI thread
|
||||||
#define REQUIRE_UIT() DCHECK(_Context->RunningOnUIThread())
|
#define REQUIRE_UIT() DCHECK(_Context->RunningOnUIThread())
|
||||||
|
|
||||||
#endif // _CONTEXT_H
|
#endif // _CONTEXT_H
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioPropertySheet
|
<VisualStudioPropertySheet
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="8.00"
|
Version="8.00"
|
||||||
Name="libcef"
|
Name="libcef"
|
||||||
InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\third_party\libpng\using_libpng.vsprops;$(SolutionDir)..\breakpad\using_breakpad.vsprops;$(SolutionDir)..\third_party\libxml\build\using_libxml.vsprops;$(SolutionDir)..\third_party\npapi\using_npapi.vsprops;$(SolutionDir)..\skia\using_skia.vsprops;$(SolutionDir)..\third_party\ffmpeg\using_ffmpeg.vsprops;.\libcef_webkit.vsprops"
|
InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\third_party\libpng\using_libpng.vsprops;$(SolutionDir)..\breakpad\using_breakpad.vsprops;$(SolutionDir)..\third_party\libxml\build\using_libxml.vsprops;$(SolutionDir)..\third_party\npapi\using_npapi.vsprops;$(SolutionDir)..\skia\using_skia.vsprops;$(SolutionDir)..\third_party\ffmpeg\using_ffmpeg.vsprops;.\libcef_webkit.vsprops"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalIncludeDirectories=""$(OutDir)\obj\WebKit";"$(OutDir)\obj\global_intermediate\webkit";"$(IntDir)\grit_derived_sources";"$(SolutionDir)";"$(IntDir)\..\localized_strings";"$(SolutionDir)..\webkit\port\bridge";"$(SolutionDir)..\webkit\port\platform";"$(SolutionDir)..\webkit\port\platform\network";"$(SolutionDir)..\webkit\glue";"$(SolutionDir)..\third_party\webkit\src\";"$(OutDir)\obj\WebCore\JavaScriptHeaders";"$(OutDir)""
|
AdditionalIncludeDirectories=""$(OutDir)\obj\WebKit";"$(OutDir)\obj\global_intermediate\webkit";"$(IntDir)\grit_derived_sources";"$(SolutionDir)";"$(IntDir)\..\localized_strings";"$(SolutionDir)..\webkit\port\bridge";"$(SolutionDir)..\webkit\port\platform";"$(SolutionDir)..\webkit\port\platform\network";"$(SolutionDir)..\webkit\glue";"$(SolutionDir)..\third_party\webkit\src\";"$(OutDir)\obj\WebCore\JavaScriptHeaders";"$(OutDir)""
|
||||||
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"
|
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="comctl32.lib shlwapi.lib rpcrt4.lib winmm.lib urlmon.lib"
|
AdditionalDependencies="comctl32.lib shlwapi.lib rpcrt4.lib winmm.lib urlmon.lib"
|
||||||
AdditionalLibraryDirectories=""$(OutDir)""
|
AdditionalLibraryDirectories=""$(OutDir)""
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
AdditionalIncludeDirectories=""$(SolutionDir)";"$(IntDir)\..\""
|
AdditionalIncludeDirectories=""$(SolutionDir)";"$(IntDir)\..\""
|
||||||
/>
|
/>
|
||||||
</VisualStudioPropertySheet>
|
</VisualStudioPropertySheet>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioPropertySheet
|
<VisualStudioPropertySheet
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="8.00"
|
Version="8.00"
|
||||||
Name="webkit_common"
|
Name="webkit_common"
|
||||||
InheritedPropertySheets=".\libcef_webkit_includes.vsprops;$(SolutionDir)..\webkit\build\webkit_common_defines.vsprops;$(SolutionDir)..\webkit\build\js_engine$(JS_ENGINE_TYPE).vsprops;$(SolutionDir)..\third_party\npapi\using_npapi.vsprops;$(SolutionDir)..\skia\using_skia.vsprops;$(SolutionDir)..\build\external_code.vsprops;$(SolutionDir)..\third_party\icu38\build\using_icu.vsprops"
|
InheritedPropertySheets=".\libcef_webkit_includes.vsprops;$(SolutionDir)..\webkit\build\webkit_common_defines.vsprops;$(SolutionDir)..\webkit\build\js_engine$(JS_ENGINE_TYPE).vsprops;$(SolutionDir)..\third_party\npapi\using_npapi.vsprops;$(SolutionDir)..\skia\using_skia.vsprops;$(SolutionDir)..\build\external_code.vsprops;$(SolutionDir)..\third_party\icu38\build\using_icu.vsprops"
|
||||||
>
|
>
|
||||||
</VisualStudioPropertySheet>
|
</VisualStudioPropertySheet>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -1,138 +1,138 @@
|
|||||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
#include "print_settings.h"
|
#include "print_settings.h"
|
||||||
|
|
||||||
#include "base/atomic_sequence_num.h"
|
#include "base/atomic_sequence_num.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "printing/units.h"
|
#include "printing/units.h"
|
||||||
|
|
||||||
namespace printing {
|
namespace printing {
|
||||||
|
|
||||||
// Global SequenceNumber used for generating unique cookie values.
|
// Global SequenceNumber used for generating unique cookie values.
|
||||||
static base::AtomicSequenceNumber cookie_seq(base::LINKER_INITIALIZED);
|
static base::AtomicSequenceNumber cookie_seq(base::LINKER_INITIALIZED);
|
||||||
|
|
||||||
PrintSettings::PrintSettings()
|
PrintSettings::PrintSettings()
|
||||||
: min_shrink(1.25),
|
: min_shrink(1.25),
|
||||||
max_shrink(2.0),
|
max_shrink(2.0),
|
||||||
desired_dpi(72),
|
desired_dpi(72),
|
||||||
selection_only(false),
|
selection_only(false),
|
||||||
to_file(false),
|
to_file(false),
|
||||||
dpi_(0),
|
dpi_(0),
|
||||||
landscape_(false) {
|
landscape_(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintSettings::Clear() {
|
void PrintSettings::Clear() {
|
||||||
ranges.clear();
|
ranges.clear();
|
||||||
min_shrink = 1.25;
|
min_shrink = 1.25;
|
||||||
max_shrink = 2.;
|
max_shrink = 2.;
|
||||||
desired_dpi = 72;
|
desired_dpi = 72;
|
||||||
selection_only = false;
|
selection_only = false;
|
||||||
to_file = false;
|
to_file = false;
|
||||||
printer_name_.clear();
|
printer_name_.clear();
|
||||||
device_name_.clear();
|
device_name_.clear();
|
||||||
page_setup_pixels_.Clear();
|
page_setup_pixels_.Clear();
|
||||||
dpi_ = 0;
|
dpi_ = 0;
|
||||||
landscape_ = false;
|
landscape_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
void PrintSettings::Init(HDC hdc,
|
void PrintSettings::Init(HDC hdc,
|
||||||
const DEVMODE& dev_mode,
|
const DEVMODE& dev_mode,
|
||||||
const PageRanges& new_ranges,
|
const PageRanges& new_ranges,
|
||||||
const std::wstring& new_device_name,
|
const std::wstring& new_device_name,
|
||||||
bool print_selection_only,
|
bool print_selection_only,
|
||||||
bool print_to_file) {
|
bool print_to_file) {
|
||||||
DCHECK(hdc);
|
DCHECK(hdc);
|
||||||
printer_name_ = dev_mode.dmDeviceName;
|
printer_name_ = dev_mode.dmDeviceName;
|
||||||
device_name_ = new_device_name;
|
device_name_ = new_device_name;
|
||||||
ranges = new_ranges;
|
ranges = new_ranges;
|
||||||
landscape_ = dev_mode.dmOrientation == DMORIENT_LANDSCAPE;
|
landscape_ = dev_mode.dmOrientation == DMORIENT_LANDSCAPE;
|
||||||
selection_only = print_selection_only;
|
selection_only = print_selection_only;
|
||||||
to_file = print_to_file;
|
to_file = print_to_file;
|
||||||
|
|
||||||
dpi_ = GetDeviceCaps(hdc, LOGPIXELSX);
|
dpi_ = GetDeviceCaps(hdc, LOGPIXELSX);
|
||||||
// No printer device is known to advertise different dpi in X and Y axis; even
|
// No printer device is known to advertise different dpi in X and Y axis; even
|
||||||
// the fax device using the 200x100 dpi setting. It's ought to break so many
|
// the fax device using the 200x100 dpi setting. It's ought to break so many
|
||||||
// applications that it's not even needed to care about. WebKit doesn't
|
// applications that it's not even needed to care about. WebKit doesn't
|
||||||
// support different dpi settings in X and Y axis.
|
// support different dpi settings in X and Y axis.
|
||||||
DCHECK_EQ(dpi_, GetDeviceCaps(hdc, LOGPIXELSY));
|
DCHECK_EQ(dpi_, GetDeviceCaps(hdc, LOGPIXELSY));
|
||||||
|
|
||||||
DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORX), 0);
|
DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORX), 0);
|
||||||
DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORY), 0);
|
DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORY), 0);
|
||||||
|
|
||||||
// Initialize page_setup_pixels_.
|
// Initialize page_setup_pixels_.
|
||||||
gfx::Size physical_size_pixels(GetDeviceCaps(hdc, PHYSICALWIDTH),
|
gfx::Size physical_size_pixels(GetDeviceCaps(hdc, PHYSICALWIDTH),
|
||||||
GetDeviceCaps(hdc, PHYSICALHEIGHT));
|
GetDeviceCaps(hdc, PHYSICALHEIGHT));
|
||||||
gfx::Rect printable_area_pixels(GetDeviceCaps(hdc, PHYSICALOFFSETX),
|
gfx::Rect printable_area_pixels(GetDeviceCaps(hdc, PHYSICALOFFSETX),
|
||||||
GetDeviceCaps(hdc, PHYSICALOFFSETY),
|
GetDeviceCaps(hdc, PHYSICALOFFSETY),
|
||||||
GetDeviceCaps(hdc, HORZRES),
|
GetDeviceCaps(hdc, HORZRES),
|
||||||
GetDeviceCaps(hdc, VERTRES));
|
GetDeviceCaps(hdc, VERTRES));
|
||||||
|
|
||||||
SetPrinterPrintableArea(physical_size_pixels, printable_area_pixels);
|
SetPrinterPrintableArea(physical_size_pixels, printable_area_pixels);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void PrintSettings::SetPrinterPrintableArea(
|
void PrintSettings::SetPrinterPrintableArea(
|
||||||
gfx::Size const& physical_size_pixels,
|
gfx::Size const& physical_size_pixels,
|
||||||
gfx::Rect const& printable_area_pixels) {
|
gfx::Rect const& printable_area_pixels) {
|
||||||
|
|
||||||
int margin_printer_units = ConvertUnit(500, kHundrethsMMPerInch, dpi_);
|
int margin_printer_units = ConvertUnit(500, kHundrethsMMPerInch, dpi_);
|
||||||
|
|
||||||
// Start by setting the user configuration
|
// Start by setting the user configuration
|
||||||
// Hard-code text_height = 0.5cm = ~1/5 of inch
|
// Hard-code text_height = 0.5cm = ~1/5 of inch
|
||||||
page_setup_pixels_.Init(physical_size_pixels,
|
page_setup_pixels_.Init(physical_size_pixels,
|
||||||
printable_area_pixels,
|
printable_area_pixels,
|
||||||
margin_printer_units);
|
margin_printer_units);
|
||||||
|
|
||||||
// Now apply user configured settings.
|
// Now apply user configured settings.
|
||||||
PageMargins margins;
|
PageMargins margins;
|
||||||
margins.header = margin_printer_units;
|
margins.header = margin_printer_units;
|
||||||
margins.footer = margin_printer_units;
|
margins.footer = margin_printer_units;
|
||||||
margins.left = margin_printer_units;
|
margins.left = margin_printer_units;
|
||||||
margins.top = margin_printer_units;
|
margins.top = margin_printer_units;
|
||||||
margins.right = margin_printer_units;
|
margins.right = margin_printer_units;
|
||||||
margins.bottom = margin_printer_units;
|
margins.bottom = margin_printer_units;
|
||||||
page_setup_pixels_.SetRequestedMargins(margins);
|
page_setup_pixels_.SetRequestedMargins(margins);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintSettings::RenderParams(PrintParams* params) const {
|
void PrintSettings::RenderParams(PrintParams* params) const {
|
||||||
DCHECK(params);
|
DCHECK(params);
|
||||||
params->printable_size.SetSize(page_setup_pixels_.content_area().width(),
|
params->printable_size.SetSize(page_setup_pixels_.content_area().width(),
|
||||||
page_setup_pixels_.content_area().height());
|
page_setup_pixels_.content_area().height());
|
||||||
params->dpi = dpi_;
|
params->dpi = dpi_;
|
||||||
// Currently hardcoded at 1.25. See PrintSettings' constructor.
|
// Currently hardcoded at 1.25. See PrintSettings' constructor.
|
||||||
params->min_shrink = min_shrink;
|
params->min_shrink = min_shrink;
|
||||||
// Currently hardcoded at 2.0. See PrintSettings' constructor.
|
// Currently hardcoded at 2.0. See PrintSettings' constructor.
|
||||||
params->max_shrink = max_shrink;
|
params->max_shrink = max_shrink;
|
||||||
// Currently hardcoded at 72dpi. See PrintSettings' constructor.
|
// Currently hardcoded at 72dpi. See PrintSettings' constructor.
|
||||||
params->desired_dpi = desired_dpi;
|
params->desired_dpi = desired_dpi;
|
||||||
// Always use an invalid cookie.
|
// Always use an invalid cookie.
|
||||||
params->document_cookie = 0;
|
params->document_cookie = 0;
|
||||||
params->selection_only = selection_only;
|
params->selection_only = selection_only;
|
||||||
params->to_file = to_file;
|
params->to_file = to_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrintSettings::Equals(const PrintSettings& rhs) const {
|
bool PrintSettings::Equals(const PrintSettings& rhs) const {
|
||||||
// Do not test the display device name (printer_name_) for equality since it
|
// Do not test the display device name (printer_name_) for equality since it
|
||||||
// may sometimes be chopped off at 30 chars. As long as device_name is the
|
// may sometimes be chopped off at 30 chars. As long as device_name is the
|
||||||
// same, that's fine.
|
// same, that's fine.
|
||||||
return ranges == rhs.ranges &&
|
return ranges == rhs.ranges &&
|
||||||
min_shrink == rhs.min_shrink &&
|
min_shrink == rhs.min_shrink &&
|
||||||
max_shrink == rhs.max_shrink &&
|
max_shrink == rhs.max_shrink &&
|
||||||
desired_dpi == rhs.desired_dpi &&
|
desired_dpi == rhs.desired_dpi &&
|
||||||
device_name_ == rhs.device_name_ &&
|
device_name_ == rhs.device_name_ &&
|
||||||
page_setup_pixels_.Equals(rhs.page_setup_pixels_) &&
|
page_setup_pixels_.Equals(rhs.page_setup_pixels_) &&
|
||||||
dpi_ == rhs.dpi_ &&
|
dpi_ == rhs.dpi_ &&
|
||||||
landscape_ == rhs.landscape_;
|
landscape_ == rhs.landscape_;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PrintSettings::NewCookie() {
|
int PrintSettings::NewCookie() {
|
||||||
// A cookie of 0 is used to mark a document as unassigned, count from 1.
|
// A cookie of 0 is used to mark a document as unassigned, count from 1.
|
||||||
return cookie_seq.GetNext() + 1;
|
return cookie_seq.GetNext() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace printing
|
} // namespace printing
|
||||||
|
|
||||||
|
@ -1,150 +1,150 @@
|
|||||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef _PRINTING_PRINT_SETTINGS_H
|
#ifndef _PRINTING_PRINT_SETTINGS_H
|
||||||
#define _PRINTING_PRINT_SETTINGS_H
|
#define _PRINTING_PRINT_SETTINGS_H
|
||||||
|
|
||||||
#include "base/gfx/rect.h"
|
#include "base/gfx/rect.h"
|
||||||
#include "printing/page_range.h"
|
#include "printing/page_range.h"
|
||||||
#include "printing/page_setup.h"
|
#include "printing/page_setup.h"
|
||||||
|
|
||||||
typedef struct HDC__* HDC;
|
typedef struct HDC__* HDC;
|
||||||
typedef struct _devicemodeW DEVMODE;
|
typedef struct _devicemodeW DEVMODE;
|
||||||
|
|
||||||
namespace printing {
|
namespace printing {
|
||||||
|
|
||||||
// Parameters for a render request.
|
// Parameters for a render request.
|
||||||
struct PrintParams {
|
struct PrintParams {
|
||||||
// In pixels according to dpi_x and dpi_y.
|
// In pixels according to dpi_x and dpi_y.
|
||||||
gfx::Size printable_size;
|
gfx::Size printable_size;
|
||||||
|
|
||||||
// Specifies dots per inch.
|
// Specifies dots per inch.
|
||||||
double dpi;
|
double dpi;
|
||||||
|
|
||||||
// Minimum shrink factor. See PrintSettings::min_shrink for more information.
|
// Minimum shrink factor. See PrintSettings::min_shrink for more information.
|
||||||
double min_shrink;
|
double min_shrink;
|
||||||
|
|
||||||
// Maximum shrink factor. See PrintSettings::max_shrink for more information.
|
// Maximum shrink factor. See PrintSettings::max_shrink for more information.
|
||||||
double max_shrink;
|
double max_shrink;
|
||||||
|
|
||||||
// Desired apparent dpi on paper.
|
// Desired apparent dpi on paper.
|
||||||
int desired_dpi;
|
int desired_dpi;
|
||||||
|
|
||||||
// Cookie for the document to ensure correctness.
|
// Cookie for the document to ensure correctness.
|
||||||
int document_cookie;
|
int document_cookie;
|
||||||
|
|
||||||
// Indicates if the user only wants to print the current selection.
|
// Indicates if the user only wants to print the current selection.
|
||||||
bool selection_only;
|
bool selection_only;
|
||||||
|
|
||||||
// Indicates if the user wants to print to file.
|
// Indicates if the user wants to print to file.
|
||||||
bool to_file;
|
bool to_file;
|
||||||
|
|
||||||
// Warning: do not compare document_cookie.
|
// Warning: do not compare document_cookie.
|
||||||
bool Equals(const PrintParams& rhs) const {
|
bool Equals(const PrintParams& rhs) const {
|
||||||
return printable_size == rhs.printable_size &&
|
return printable_size == rhs.printable_size &&
|
||||||
dpi == rhs.dpi &&
|
dpi == rhs.dpi &&
|
||||||
min_shrink == rhs.min_shrink &&
|
min_shrink == rhs.min_shrink &&
|
||||||
max_shrink == rhs.max_shrink &&
|
max_shrink == rhs.max_shrink &&
|
||||||
desired_dpi == rhs.desired_dpi &&
|
desired_dpi == rhs.desired_dpi &&
|
||||||
selection_only == rhs.selection_only &&
|
selection_only == rhs.selection_only &&
|
||||||
to_file == rhs.to_file;
|
to_file == rhs.to_file;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// OS-independent print settings.
|
// OS-independent print settings.
|
||||||
class PrintSettings {
|
class PrintSettings {
|
||||||
public:
|
public:
|
||||||
PrintSettings();
|
PrintSettings();
|
||||||
|
|
||||||
// Reinitialize the settings to the default values.
|
// Reinitialize the settings to the default values.
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
// Reads the settings from the selected device context. Calculates derived
|
// Reads the settings from the selected device context. Calculates derived
|
||||||
// values like printable_area_.
|
// values like printable_area_.
|
||||||
void Init(HDC hdc,
|
void Init(HDC hdc,
|
||||||
const DEVMODE& dev_mode,
|
const DEVMODE& dev_mode,
|
||||||
const PageRanges& new_ranges,
|
const PageRanges& new_ranges,
|
||||||
const std::wstring& new_device_name,
|
const std::wstring& new_device_name,
|
||||||
bool selection_only,
|
bool selection_only,
|
||||||
bool to_file);
|
bool to_file);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set printer printable area in pixels.
|
// Set printer printable area in pixels.
|
||||||
void SetPrinterPrintableArea(gfx::Size const& physical_size_pixels,
|
void SetPrinterPrintableArea(gfx::Size const& physical_size_pixels,
|
||||||
gfx::Rect const& printable_area_pixels);
|
gfx::Rect const& printable_area_pixels);
|
||||||
|
|
||||||
// Initializes the print parameters that needs to be sent to the renderer
|
// Initializes the print parameters that needs to be sent to the renderer
|
||||||
// process.
|
// process.
|
||||||
void RenderParams(PrintParams* params) const;
|
void RenderParams(PrintParams* params) const;
|
||||||
|
|
||||||
// Equality operator.
|
// Equality operator.
|
||||||
// NOTE: printer_name is NOT tested for equality since it doesn't affect the
|
// NOTE: printer_name is NOT tested for equality since it doesn't affect the
|
||||||
// output.
|
// output.
|
||||||
bool Equals(const PrintSettings& rhs) const;
|
bool Equals(const PrintSettings& rhs) const;
|
||||||
|
|
||||||
const std::wstring& printer_name() const { return printer_name_; }
|
const std::wstring& printer_name() const { return printer_name_; }
|
||||||
void set_device_name(const std::wstring& device_name) {
|
void set_device_name(const std::wstring& device_name) {
|
||||||
device_name_ = device_name;
|
device_name_ = device_name;
|
||||||
}
|
}
|
||||||
const std::wstring& device_name() const { return device_name_; }
|
const std::wstring& device_name() const { return device_name_; }
|
||||||
int dpi() const { return dpi_; }
|
int dpi() const { return dpi_; }
|
||||||
const PageSetup& page_setup_pixels() const { return page_setup_pixels_; }
|
const PageSetup& page_setup_pixels() const { return page_setup_pixels_; }
|
||||||
|
|
||||||
// Multi-page printing. Each PageRange describes a from-to page combination.
|
// Multi-page printing. Each PageRange describes a from-to page combination.
|
||||||
// This permits printing selected pages only.
|
// This permits printing selected pages only.
|
||||||
PageRanges ranges;
|
PageRanges ranges;
|
||||||
|
|
||||||
// By imaging to a width a little wider than the available pixels, thin pages
|
// By imaging to a width a little wider than the available pixels, thin pages
|
||||||
// will be scaled down a little, matching the way they print in IE and Camino.
|
// will be scaled down a little, matching the way they print in IE and Camino.
|
||||||
// This lets them use fewer sheets than they would otherwise, which is
|
// This lets them use fewer sheets than they would otherwise, which is
|
||||||
// presumably why other browsers do this. Wide pages will be scaled down more
|
// presumably why other browsers do this. Wide pages will be scaled down more
|
||||||
// than this.
|
// than this.
|
||||||
double min_shrink;
|
double min_shrink;
|
||||||
|
|
||||||
// This number determines how small we are willing to reduce the page content
|
// This number determines how small we are willing to reduce the page content
|
||||||
// in order to accommodate the widest line. If the page would have to be
|
// in order to accommodate the widest line. If the page would have to be
|
||||||
// reduced smaller to make the widest line fit, we just clip instead (this
|
// reduced smaller to make the widest line fit, we just clip instead (this
|
||||||
// behavior matches MacIE and Mozilla, at least)
|
// behavior matches MacIE and Mozilla, at least)
|
||||||
double max_shrink;
|
double max_shrink;
|
||||||
|
|
||||||
// Desired visible dots per inch rendering for output. Printing should be
|
// Desired visible dots per inch rendering for output. Printing should be
|
||||||
// scaled to ScreenDpi/dpix*desired_dpi.
|
// scaled to ScreenDpi/dpix*desired_dpi.
|
||||||
int desired_dpi;
|
int desired_dpi;
|
||||||
|
|
||||||
// Indicates if the user only wants to print the current selection.
|
// Indicates if the user only wants to print the current selection.
|
||||||
bool selection_only;
|
bool selection_only;
|
||||||
|
|
||||||
// Indicates if the user wants to print to file.
|
// Indicates if the user wants to print to file.
|
||||||
bool to_file;
|
bool to_file;
|
||||||
|
|
||||||
// Cookie generator. It is used to initialize PrintedDocument with its
|
// Cookie generator. It is used to initialize PrintedDocument with its
|
||||||
// associated PrintSettings, to be sure that each generated PrintedPage is
|
// associated PrintSettings, to be sure that each generated PrintedPage is
|
||||||
// correctly associated with its corresponding PrintedDocument.
|
// correctly associated with its corresponding PrintedDocument.
|
||||||
static int NewCookie();
|
static int NewCookie();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
// Settings that can't be changed without side-effects.
|
// Settings that can't be changed without side-effects.
|
||||||
|
|
||||||
// Printer name as shown to the user.
|
// Printer name as shown to the user.
|
||||||
std::wstring printer_name_;
|
std::wstring printer_name_;
|
||||||
|
|
||||||
// Printer device name as opened by the OS.
|
// Printer device name as opened by the OS.
|
||||||
std::wstring device_name_;
|
std::wstring device_name_;
|
||||||
|
|
||||||
// Page setup in pixel units, dpi adjusted.
|
// Page setup in pixel units, dpi adjusted.
|
||||||
PageSetup page_setup_pixels_;
|
PageSetup page_setup_pixels_;
|
||||||
|
|
||||||
// Printer's device effective dots per inch in both axis.
|
// Printer's device effective dots per inch in both axis.
|
||||||
int dpi_;
|
int dpi_;
|
||||||
|
|
||||||
// Is the orientation landscape or portrait.
|
// Is the orientation landscape or portrait.
|
||||||
bool landscape_;
|
bool landscape_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace printing
|
} // namespace printing
|
||||||
|
|
||||||
#endif // _PRINTING_PRINT_SETTINGS_H
|
#endif // _PRINTING_PRINT_SETTINGS_H
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,141 +1,141 @@
|
|||||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef _PRINTING_WIN_PRINTING_CONTEXT_H
|
#ifndef _PRINTING_WIN_PRINTING_CONTEXT_H
|
||||||
#define _PRINTING_WIN_PRINTING_CONTEXT_H
|
#define _PRINTING_WIN_PRINTING_CONTEXT_H
|
||||||
|
|
||||||
#include "print_settings.h"
|
#include "print_settings.h"
|
||||||
|
|
||||||
#include <ocidl.h>
|
#include <ocidl.h>
|
||||||
#include <commdlg.h>
|
#include <commdlg.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
|
|
||||||
namespace printing {
|
namespace printing {
|
||||||
|
|
||||||
// Describe the user selected printing context for Windows. This includes the
|
// Describe the user selected printing context for Windows. This includes the
|
||||||
// OS-dependent UI to ask the user about the print settings. This class directly
|
// OS-dependent UI to ask the user about the print settings. This class directly
|
||||||
// talk to the printer and manages the document and pages breaks.
|
// talk to the printer and manages the document and pages breaks.
|
||||||
class PrintingContext {
|
class PrintingContext {
|
||||||
public:
|
public:
|
||||||
// Tri-state result for user behavior-dependent functions.
|
// Tri-state result for user behavior-dependent functions.
|
||||||
enum Result {
|
enum Result {
|
||||||
OK,
|
OK,
|
||||||
CANCEL,
|
CANCEL,
|
||||||
FAILED,
|
FAILED,
|
||||||
};
|
};
|
||||||
|
|
||||||
PrintingContext();
|
PrintingContext();
|
||||||
~PrintingContext();
|
~PrintingContext();
|
||||||
|
|
||||||
// Asks the user what printer and format should be used to print. Updates the
|
// Asks the user what printer and format should be used to print. Updates the
|
||||||
// context with the select device settings.
|
// context with the select device settings.
|
||||||
Result AskUserForSettings(HWND window, int max_pages, bool has_selection);
|
Result AskUserForSettings(HWND window, int max_pages, bool has_selection);
|
||||||
|
|
||||||
// Selects the user's default printer and format. Updates the context with the
|
// Selects the user's default printer and format. Updates the context with the
|
||||||
// default device settings.
|
// default device settings.
|
||||||
Result UseDefaultSettings();
|
Result UseDefaultSettings();
|
||||||
|
|
||||||
// Initializes with predefined settings.
|
// Initializes with predefined settings.
|
||||||
Result InitWithSettings(const PrintSettings& settings);
|
Result InitWithSettings(const PrintSettings& settings);
|
||||||
|
|
||||||
// Reinitializes the settings to uninitialized for object reuse.
|
// Reinitializes the settings to uninitialized for object reuse.
|
||||||
void ResetSettings();
|
void ResetSettings();
|
||||||
|
|
||||||
// Does platform specific setup of the printer before the printing. Signal the
|
// Does platform specific setup of the printer before the printing. Signal the
|
||||||
// printer that a document is about to be spooled.
|
// printer that a document is about to be spooled.
|
||||||
// Warning: This function enters a message loop. That may cause side effects
|
// Warning: This function enters a message loop. That may cause side effects
|
||||||
// like IPC message processing! Some printers have side-effects on this call
|
// like IPC message processing! Some printers have side-effects on this call
|
||||||
// like virtual printers that ask the user for the path of the saved document;
|
// like virtual printers that ask the user for the path of the saved document;
|
||||||
// for example a PDF printer.
|
// for example a PDF printer.
|
||||||
Result NewDocument(const std::wstring& document_name);
|
Result NewDocument(const std::wstring& document_name);
|
||||||
|
|
||||||
// Starts a new page.
|
// Starts a new page.
|
||||||
Result NewPage();
|
Result NewPage();
|
||||||
|
|
||||||
// Closes the printed page.
|
// Closes the printed page.
|
||||||
Result PageDone();
|
Result PageDone();
|
||||||
|
|
||||||
// Closes the printing job. After this call the object is ready to start a new
|
// Closes the printing job. After this call the object is ready to start a new
|
||||||
// document.
|
// document.
|
||||||
Result DocumentDone();
|
Result DocumentDone();
|
||||||
|
|
||||||
// Cancels printing. Can be used in a multithreaded context. Takes effect
|
// Cancels printing. Can be used in a multithreaded context. Takes effect
|
||||||
// immediately.
|
// immediately.
|
||||||
void Cancel();
|
void Cancel();
|
||||||
|
|
||||||
// Dismiss the Print... dialog box if shown.
|
// Dismiss the Print... dialog box if shown.
|
||||||
void DismissDialog();
|
void DismissDialog();
|
||||||
|
|
||||||
HDC context() {
|
HDC context() {
|
||||||
return hdc_;
|
return hdc_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PrintSettings& settings() const {
|
const PrintSettings& settings() const {
|
||||||
return settings_;
|
return settings_;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Class that manages the PrintDlgEx() callbacks. This is meant to be a
|
// Class that manages the PrintDlgEx() callbacks. This is meant to be a
|
||||||
// temporary object used during the Print... dialog display.
|
// temporary object used during the Print... dialog display.
|
||||||
class CallbackHandler;
|
class CallbackHandler;
|
||||||
|
|
||||||
// Does bookkeeping when an error occurs.
|
// Does bookkeeping when an error occurs.
|
||||||
PrintingContext::Result OnError();
|
PrintingContext::Result OnError();
|
||||||
|
|
||||||
// Used in response to the user canceling the printing.
|
// Used in response to the user canceling the printing.
|
||||||
static BOOL CALLBACK AbortProc(HDC hdc, int nCode);
|
static BOOL CALLBACK AbortProc(HDC hdc, int nCode);
|
||||||
|
|
||||||
// Reads the settings from the selected device context. Updates settings_ and
|
// Reads the settings from the selected device context. Updates settings_ and
|
||||||
// its margins.
|
// its margins.
|
||||||
bool InitializeSettings(const DEVMODE& dev_mode,
|
bool InitializeSettings(const DEVMODE& dev_mode,
|
||||||
const std::wstring& new_device_name,
|
const std::wstring& new_device_name,
|
||||||
const PRINTPAGERANGE* ranges,
|
const PRINTPAGERANGE* ranges,
|
||||||
int number_ranges,
|
int number_ranges,
|
||||||
bool selection_only,
|
bool selection_only,
|
||||||
bool to_file);
|
bool to_file);
|
||||||
|
|
||||||
// Retrieves the printer's default low-level settings. hdc_ is allocated with
|
// Retrieves the printer's default low-level settings. hdc_ is allocated with
|
||||||
// this call.
|
// this call.
|
||||||
bool GetPrinterSettings(HANDLE printer,
|
bool GetPrinterSettings(HANDLE printer,
|
||||||
const std::wstring& device_name);
|
const std::wstring& device_name);
|
||||||
|
|
||||||
// Allocates the HDC for a specific DEVMODE.
|
// Allocates the HDC for a specific DEVMODE.
|
||||||
bool AllocateContext(const std::wstring& printer_name,
|
bool AllocateContext(const std::wstring& printer_name,
|
||||||
const DEVMODE* dev_mode);
|
const DEVMODE* dev_mode);
|
||||||
|
|
||||||
// Parses the result of a PRINTDLGEX result.
|
// Parses the result of a PRINTDLGEX result.
|
||||||
Result ParseDialogResultEx(const PRINTDLGEX& dialog_options);
|
Result ParseDialogResultEx(const PRINTDLGEX& dialog_options);
|
||||||
Result ParseDialogResult(const PRINTDLG& dialog_options);
|
Result ParseDialogResult(const PRINTDLG& dialog_options);
|
||||||
|
|
||||||
// The selected printer context.
|
// The selected printer context.
|
||||||
HDC hdc_;
|
HDC hdc_;
|
||||||
|
|
||||||
// Complete print context settings.
|
// Complete print context settings.
|
||||||
PrintSettings settings_;
|
PrintSettings settings_;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
// Current page number in the print job.
|
// Current page number in the print job.
|
||||||
int page_number_;
|
int page_number_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// The dialog box for the time it is shown.
|
// The dialog box for the time it is shown.
|
||||||
volatile HWND dialog_box_;
|
volatile HWND dialog_box_;
|
||||||
|
|
||||||
// The dialog box has been dismissed.
|
// The dialog box has been dismissed.
|
||||||
volatile bool dialog_box_dismissed_;
|
volatile bool dialog_box_dismissed_;
|
||||||
|
|
||||||
// Is a print job being done.
|
// Is a print job being done.
|
||||||
volatile bool in_print_job_;
|
volatile bool in_print_job_;
|
||||||
|
|
||||||
// Did the user cancel the print job.
|
// Did the user cancel the print job.
|
||||||
volatile bool abort_printing_;
|
volatile bool abort_printing_;
|
||||||
|
|
||||||
DISALLOW_EVIL_CONSTRUCTORS(PrintingContext);
|
DISALLOW_EVIL_CONSTRUCTORS(PrintingContext);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace printing
|
} // namespace printing
|
||||||
|
|
||||||
#endif // _PRINTING_WIN_PRINTING_CONTEXT_H
|
#endif // _PRINTING_WIN_PRINTING_CONTEXT_H
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. All rights
|
// 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
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
#include "request_impl.h"
|
#include "request_impl.h"
|
||||||
|
|
||||||
@ -154,21 +154,21 @@ void CefPostDataImpl::GetElements(ElementVector& elements)
|
|||||||
|
|
||||||
bool CefPostDataImpl::RemoveElement(CefRefPtr<CefPostDataElement> element)
|
bool CefPostDataImpl::RemoveElement(CefRefPtr<CefPostDataElement> element)
|
||||||
{
|
{
|
||||||
bool deleted = false;
|
bool deleted = false;
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
|
|
||||||
ElementVector::iterator it = elements_.begin();
|
ElementVector::iterator it = elements_.begin();
|
||||||
for(; it != elements_.end(); ++it) {
|
for(; it != elements_.end(); ++it) {
|
||||||
if(it->get() == element.get()) {
|
if(it->get() == element.get()) {
|
||||||
elements_.erase(it);
|
elements_.erase(it);
|
||||||
deleted = true;
|
deleted = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,12 +179,12 @@ bool CefPostDataImpl::AddElement(CefRefPtr<CefPostDataElement> element)
|
|||||||
Lock();
|
Lock();
|
||||||
|
|
||||||
// check that the element isn't already in the list before adding
|
// check that the element isn't already in the list before adding
|
||||||
ElementVector::const_iterator it = elements_.begin();
|
ElementVector::const_iterator it = elements_.begin();
|
||||||
for(; it != elements_.end(); ++it) {
|
for(; it != elements_.end(); ++it) {
|
||||||
if(it->get() == element.get()) {
|
if(it->get() == element.get()) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!found)
|
if(!found)
|
||||||
@ -206,12 +206,12 @@ void CefPostDataImpl::Set(const net::UploadData& data)
|
|||||||
Lock();
|
Lock();
|
||||||
|
|
||||||
CefRefPtr<CefPostDataElement> postelem;
|
CefRefPtr<CefPostDataElement> postelem;
|
||||||
const std::vector<net::UploadData::Element>& elements = data.elements();
|
const std::vector<net::UploadData::Element>& elements = data.elements();
|
||||||
std::vector<net::UploadData::Element>::const_iterator it = elements.begin();
|
std::vector<net::UploadData::Element>::const_iterator it = elements.begin();
|
||||||
for (; it != elements.end(); ++it) {
|
for (; it != elements.end(); ++it) {
|
||||||
postelem = CefPostDataElement::CreatePostDataElement();
|
postelem = CefPostDataElement::CreatePostDataElement();
|
||||||
static_cast<CefPostDataElementImpl*>(postelem.get())->Set(*it);
|
static_cast<CefPostDataElementImpl*>(postelem.get())->Set(*it);
|
||||||
AddElement(postelem);
|
AddElement(postelem);
|
||||||
}
|
}
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
@ -223,10 +223,10 @@ void CefPostDataImpl::Get(net::UploadData& data)
|
|||||||
|
|
||||||
net::UploadData::Element element;
|
net::UploadData::Element element;
|
||||||
std::vector<net::UploadData::Element> data_elements;
|
std::vector<net::UploadData::Element> data_elements;
|
||||||
ElementVector::iterator it = elements_.begin();
|
ElementVector::iterator it = elements_.begin();
|
||||||
for(; it != elements_.end(); ++it) {
|
for(; it != elements_.end(); ++it) {
|
||||||
static_cast<CefPostDataElementImpl*>(it->get())->Get(element);
|
static_cast<CefPostDataElementImpl*>(it->get())->Get(element);
|
||||||
data_elements.push_back(element);
|
data_elements.push_back(element);
|
||||||
}
|
}
|
||||||
data.set_elements(data_elements);
|
data.set_elements(data_elements);
|
||||||
|
|
||||||
@ -240,12 +240,12 @@ void CefPostDataImpl::Set(const WebKit::WebHTTPBody& data)
|
|||||||
CefRefPtr<CefPostDataElement> postelem;
|
CefRefPtr<CefPostDataElement> postelem;
|
||||||
WebKit::WebHTTPBody::Element element;
|
WebKit::WebHTTPBody::Element element;
|
||||||
size_t size = data.elementCount();
|
size_t size = data.elementCount();
|
||||||
for (size_t i = 0; i < size; ++i) {
|
for (size_t i = 0; i < size; ++i) {
|
||||||
if (data.elementAt(i, element)) {
|
if (data.elementAt(i, element)) {
|
||||||
postelem = CefPostDataElement::CreatePostDataElement();
|
postelem = CefPostDataElement::CreatePostDataElement();
|
||||||
static_cast<CefPostDataElementImpl*>(postelem.get())->Set(element);
|
static_cast<CefPostDataElementImpl*>(postelem.get())->Set(element);
|
||||||
AddElement(postelem);
|
AddElement(postelem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
@ -256,16 +256,16 @@ void CefPostDataImpl::Get(WebKit::WebHTTPBody& data)
|
|||||||
Lock();
|
Lock();
|
||||||
|
|
||||||
WebKit::WebHTTPBody::Element element;
|
WebKit::WebHTTPBody::Element element;
|
||||||
ElementVector::iterator it = elements_.begin();
|
ElementVector::iterator it = elements_.begin();
|
||||||
for(; it != elements_.end(); ++it) {
|
for(; it != elements_.end(); ++it) {
|
||||||
static_cast<CefPostDataElementImpl*>(it->get())->Get(element);
|
static_cast<CefPostDataElementImpl*>(it->get())->Get(element);
|
||||||
if(element.type == WebKit::WebHTTPBody::Element::TypeData) {
|
if(element.type == WebKit::WebHTTPBody::Element::TypeData) {
|
||||||
data.appendData(element.data);
|
data.appendData(element.data);
|
||||||
} else if(element.type == WebKit::WebHTTPBody::Element::TypeFile) {
|
} else if(element.type == WebKit::WebHTTPBody::Element::TypeFile) {
|
||||||
data.appendFile(element.filePath);
|
data.appendFile(element.filePath);
|
||||||
} else {
|
} else {
|
||||||
NOTREACHED();
|
NOTREACHED();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
@ -279,7 +279,7 @@ CefRefPtr<CefPostDataElement> CefPostDataElement::CreatePostDataElement()
|
|||||||
|
|
||||||
CefPostDataElementImpl::CefPostDataElementImpl()
|
CefPostDataElementImpl::CefPostDataElementImpl()
|
||||||
{
|
{
|
||||||
type_ = PDE_TYPE_EMPTY;
|
type_ = PDE_TYPE_EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefPostDataElementImpl::~CefPostDataElementImpl()
|
CefPostDataElementImpl::~CefPostDataElementImpl()
|
||||||
@ -290,11 +290,11 @@ CefPostDataElementImpl::~CefPostDataElementImpl()
|
|||||||
void CefPostDataElementImpl::SetToEmpty()
|
void CefPostDataElementImpl::SetToEmpty()
|
||||||
{
|
{
|
||||||
Lock();
|
Lock();
|
||||||
if(type_ == PDE_TYPE_BYTES)
|
if(type_ == PDE_TYPE_BYTES)
|
||||||
free(data_.bytes.bytes);
|
free(data_.bytes.bytes);
|
||||||
else if(type_ == PDE_TYPE_FILE)
|
else if(type_ == PDE_TYPE_FILE)
|
||||||
free(data_.filename);
|
free(data_.filename);
|
||||||
type_ = PDE_TYPE_EMPTY;
|
type_ = PDE_TYPE_EMPTY;
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,7 +316,7 @@ void CefPostDataElementImpl::SetToFile(const std::wstring& fileName)
|
|||||||
data[size] = 0;
|
data[size] = 0;
|
||||||
|
|
||||||
// Assign the new data
|
// Assign the new data
|
||||||
type_ = PDE_TYPE_FILE;
|
type_ = PDE_TYPE_FILE;
|
||||||
data_.filename = data;
|
data_.filename = data;
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
@ -335,7 +335,7 @@ void CefPostDataElementImpl::SetToBytes(size_t size, const void* bytes)
|
|||||||
|
|
||||||
memcpy(data, bytes, size);
|
memcpy(data, bytes, size);
|
||||||
|
|
||||||
type_ = PDE_TYPE_BYTES;
|
type_ = PDE_TYPE_BYTES;
|
||||||
data_.bytes.bytes = data;
|
data_.bytes.bytes = data;
|
||||||
data_.bytes.size = size;
|
data_.bytes.size = size;
|
||||||
Unlock();
|
Unlock();
|
||||||
@ -352,9 +352,9 @@ CefPostDataElement::Type CefPostDataElementImpl::GetType()
|
|||||||
std::wstring CefPostDataElementImpl::GetFile()
|
std::wstring CefPostDataElementImpl::GetFile()
|
||||||
{
|
{
|
||||||
Lock();
|
Lock();
|
||||||
DCHECK(type_ == PDE_TYPE_FILE);
|
DCHECK(type_ == PDE_TYPE_FILE);
|
||||||
std::wstring filename;
|
std::wstring filename;
|
||||||
if(type_ == PDE_TYPE_FILE)
|
if(type_ == PDE_TYPE_FILE)
|
||||||
filename = data_.filename;
|
filename = data_.filename;
|
||||||
Unlock();
|
Unlock();
|
||||||
return filename;
|
return filename;
|
||||||
@ -363,9 +363,9 @@ std::wstring CefPostDataElementImpl::GetFile()
|
|||||||
size_t CefPostDataElementImpl::GetBytesCount()
|
size_t CefPostDataElementImpl::GetBytesCount()
|
||||||
{
|
{
|
||||||
Lock();
|
Lock();
|
||||||
DCHECK(type_ == PDE_TYPE_BYTES);
|
DCHECK(type_ == PDE_TYPE_BYTES);
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
if(type_ == PDE_TYPE_BYTES)
|
if(type_ == PDE_TYPE_BYTES)
|
||||||
size = data_.bytes.size;
|
size = data_.bytes.size;
|
||||||
Unlock();
|
Unlock();
|
||||||
return size;
|
return size;
|
||||||
@ -374,9 +374,9 @@ size_t CefPostDataElementImpl::GetBytesCount()
|
|||||||
size_t CefPostDataElementImpl::GetBytes(size_t size, void* bytes)
|
size_t CefPostDataElementImpl::GetBytes(size_t size, void* bytes)
|
||||||
{
|
{
|
||||||
Lock();
|
Lock();
|
||||||
DCHECK(type_ == PDE_TYPE_BYTES);
|
DCHECK(type_ == PDE_TYPE_BYTES);
|
||||||
size_t rv = 0;
|
size_t rv = 0;
|
||||||
if(type_ == PDE_TYPE_BYTES) {
|
if(type_ == PDE_TYPE_BYTES) {
|
||||||
rv = (size < data_.bytes.size ? size : data_.bytes.size);
|
rv = (size < data_.bytes.size ? size : data_.bytes.size);
|
||||||
memcpy(bytes, data_.bytes.bytes, rv);
|
memcpy(bytes, data_.bytes.bytes, rv);
|
||||||
}
|
}
|
||||||
@ -388,15 +388,15 @@ void CefPostDataElementImpl::Set(const net::UploadData::Element& element)
|
|||||||
{
|
{
|
||||||
Lock();
|
Lock();
|
||||||
|
|
||||||
if (element.type() == net::UploadData::TYPE_BYTES) {
|
if (element.type() == net::UploadData::TYPE_BYTES) {
|
||||||
SetToBytes(element.bytes().size(),
|
SetToBytes(element.bytes().size(),
|
||||||
static_cast<const void*>(
|
static_cast<const void*>(
|
||||||
std::string(element.bytes().begin(),
|
std::string(element.bytes().begin(),
|
||||||
element.bytes().end()).c_str()));
|
element.bytes().end()).c_str()));
|
||||||
} else if (element.type() == net::UploadData::TYPE_FILE) {
|
} else if (element.type() == net::UploadData::TYPE_FILE) {
|
||||||
SetToFile(element.file_path().value());
|
SetToFile(element.file_path().value());
|
||||||
} else {
|
} else {
|
||||||
NOTREACHED();
|
NOTREACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
@ -406,12 +406,12 @@ void CefPostDataElementImpl::Get(net::UploadData::Element& element)
|
|||||||
{
|
{
|
||||||
Lock();
|
Lock();
|
||||||
|
|
||||||
if(type_ == PDE_TYPE_BYTES) {
|
if(type_ == PDE_TYPE_BYTES) {
|
||||||
element.SetToBytes(static_cast<char*>(data_.bytes.bytes), data_.bytes.size);
|
element.SetToBytes(static_cast<char*>(data_.bytes.bytes), data_.bytes.size);
|
||||||
} else if(type_ == PDE_TYPE_FILE) {
|
} else if(type_ == PDE_TYPE_FILE) {
|
||||||
element.SetToFilePath(FilePath(data_.filename));
|
element.SetToFilePath(FilePath(data_.filename));
|
||||||
} else {
|
} else {
|
||||||
NOTREACHED();
|
NOTREACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
@ -426,8 +426,8 @@ void CefPostDataElementImpl::Set(const WebKit::WebHTTPBody::Element& element)
|
|||||||
static_cast<const void*>(element.data.data()));
|
static_cast<const void*>(element.data.data()));
|
||||||
} else if(element.type == WebKit::WebHTTPBody::Element::TypeFile) {
|
} else if(element.type == WebKit::WebHTTPBody::Element::TypeFile) {
|
||||||
SetToFile(UTF8ToWide(webkit_glue::WebStringToStdString(element.filePath)));
|
SetToFile(UTF8ToWide(webkit_glue::WebStringToStdString(element.filePath)));
|
||||||
} else {
|
} else {
|
||||||
NOTREACHED();
|
NOTREACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
@ -437,16 +437,16 @@ void CefPostDataElementImpl::Get(WebKit::WebHTTPBody::Element& element)
|
|||||||
{
|
{
|
||||||
Lock();
|
Lock();
|
||||||
|
|
||||||
if(type_ == PDE_TYPE_BYTES) {
|
if(type_ == PDE_TYPE_BYTES) {
|
||||||
element.type = WebKit::WebHTTPBody::Element::TypeData;
|
element.type = WebKit::WebHTTPBody::Element::TypeData;
|
||||||
element.data.assign(
|
element.data.assign(
|
||||||
static_cast<char*>(data_.bytes.bytes), data_.bytes.size);
|
static_cast<char*>(data_.bytes.bytes), data_.bytes.size);
|
||||||
} else if(type_ == PDE_TYPE_FILE) {
|
} else if(type_ == PDE_TYPE_FILE) {
|
||||||
element.type = WebKit::WebHTTPBody::Element::TypeFile;
|
element.type = WebKit::WebHTTPBody::Element::TypeFile;
|
||||||
element.filePath.assign(
|
element.filePath.assign(
|
||||||
webkit_glue::StdStringToWebString(WideToUTF8(data_.filename)));
|
webkit_glue::StdStringToWebString(WideToUTF8(data_.filename)));
|
||||||
} else {
|
} else {
|
||||||
NOTREACHED();
|
NOTREACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. All rights
|
// 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
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef _REQUEST_IMPL_H
|
#ifndef _REQUEST_IMPL_H
|
||||||
#define _REQUEST_IMPL_H
|
#define _REQUEST_IMPL_H
|
||||||
|
|
||||||
|
@ -1,56 +1,56 @@
|
|||||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
#include "webkit/glue/webkit_glue.h"
|
#include "webkit/glue/webkit_glue.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "base/clipboard.h"
|
#include "base/clipboard.h"
|
||||||
#include "base/lazy_instance.h"
|
#include "base/lazy_instance.h"
|
||||||
#include "base/string16.h"
|
#include "base/string16.h"
|
||||||
#include "googleurl/src/gurl.h"
|
#include "googleurl/src/gurl.h"
|
||||||
#include "third_party/skia/include/core/SkBitmap.h"
|
#include "third_party/skia/include/core/SkBitmap.h"
|
||||||
#include "webkit/glue/scoped_clipboard_writer_glue.h"
|
#include "webkit/glue/scoped_clipboard_writer_glue.h"
|
||||||
|
|
||||||
// Clipboard glue
|
// Clipboard glue
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
void ScopedClipboardWriterGlue::WriteBitmapFromPixels(
|
void ScopedClipboardWriterGlue::WriteBitmapFromPixels(
|
||||||
const void* pixels, const gfx::Size& size) {
|
const void* pixels, const gfx::Size& size) {
|
||||||
ScopedClipboardWriter::WriteBitmapFromPixels(pixels, size);
|
ScopedClipboardWriter::WriteBitmapFromPixels(pixels, size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ScopedClipboardWriterGlue::~ScopedClipboardWriterGlue() {
|
ScopedClipboardWriterGlue::~ScopedClipboardWriterGlue() {
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace webkit_glue {
|
namespace webkit_glue {
|
||||||
|
|
||||||
base::LazyInstance<Clipboard> clipboard(base::LINKER_INITIALIZED);
|
base::LazyInstance<Clipboard> clipboard(base::LINKER_INITIALIZED);
|
||||||
|
|
||||||
Clipboard* ClipboardGetClipboard() {
|
Clipboard* ClipboardGetClipboard() {
|
||||||
return clipboard.Pointer();
|
return clipboard.Pointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClipboardIsFormatAvailable(const Clipboard::FormatType& format) {
|
bool ClipboardIsFormatAvailable(const Clipboard::FormatType& format) {
|
||||||
return ClipboardGetClipboard()->IsFormatAvailable(format);
|
return ClipboardGetClipboard()->IsFormatAvailable(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClipboardReadText(string16* result) {
|
void ClipboardReadText(string16* result) {
|
||||||
ClipboardGetClipboard()->ReadText(result);
|
ClipboardGetClipboard()->ReadText(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClipboardReadAsciiText(std::string* result) {
|
void ClipboardReadAsciiText(std::string* result) {
|
||||||
ClipboardGetClipboard()->ReadAsciiText(result);
|
ClipboardGetClipboard()->ReadAsciiText(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClipboardReadHTML(string16* markup, GURL* url) {
|
void ClipboardReadHTML(string16* markup, GURL* url) {
|
||||||
std::string url_str;
|
std::string url_str;
|
||||||
ClipboardGetClipboard()->ReadHTML(markup, url ? &url_str : NULL);
|
ClipboardGetClipboard()->ReadHTML(markup, url ? &url_str : NULL);
|
||||||
if (url)
|
if (url)
|
||||||
*url = GURL(url_str);
|
*url = GURL(url_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webkit_glue
|
} // namespace webkit_glue
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
#include "stream_impl.h"
|
#include "stream_impl.h"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef _STREAM_IMPL_H
|
#ifndef _STREAM_IMPL_H
|
||||||
#define _STREAM_IMPL_H
|
#define _STREAM_IMPL_H
|
||||||
|
|
||||||
|
258
libcef/tracker.h
258
libcef/tracker.h
@ -1,136 +1,136 @@
|
|||||||
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef _TRACKER_H
|
#ifndef _TRACKER_H
|
||||||
#define _TRACKER_H
|
#define _TRACKER_H
|
||||||
|
|
||||||
#include "include/cef.h"
|
#include "include/cef.h"
|
||||||
|
|
||||||
// Class extended by objects that must be tracked. After creating a tracked
|
|
||||||
// object you should add it to the appropriate track manager.
|
|
||||||
class CefTrackObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CefTrackObject()
|
|
||||||
{
|
|
||||||
track_next_ = NULL;
|
|
||||||
track_prev_ = NULL;
|
|
||||||
}
|
|
||||||
virtual ~CefTrackObject()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if the object is currently being tracked.
|
|
||||||
bool IsTracked() { return (track_prev_ || track_next_); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
CefTrackObject* GetTrackPrev() { return track_prev_; }
|
|
||||||
void SetTrackPrev(CefTrackObject* base) { track_prev_ = base; }
|
|
||||||
CefTrackObject* GetTrackNext() { return track_next_; }
|
|
||||||
void SetTrackNext(CefTrackObject* base) { track_next_ = base; }
|
|
||||||
|
|
||||||
// Insert a new object into the tracking list before this object.
|
|
||||||
void InsertTrackPrev(CefTrackObject* object)
|
|
||||||
{
|
|
||||||
if(track_prev_)
|
|
||||||
track_prev_->SetTrackNext(object);
|
|
||||||
object->SetTrackNext(this);
|
|
||||||
object->SetTrackPrev(track_prev_);
|
|
||||||
track_prev_ = object;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert a new object into the tracking list after this object.
|
|
||||||
void InsertTrackNext(CefTrackObject* object)
|
|
||||||
{
|
|
||||||
if(track_next_)
|
|
||||||
track_next_->SetTrackPrev(object);
|
|
||||||
object->SetTrackPrev(this);
|
|
||||||
object->SetTrackNext(track_next_);
|
|
||||||
track_next_ = object;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove this object from the tracking list.
|
|
||||||
void RemoveTracking()
|
|
||||||
{
|
|
||||||
if(track_next_)
|
|
||||||
track_next_->SetTrackPrev(track_prev_);
|
|
||||||
if(track_prev_)
|
|
||||||
track_prev_->SetTrackNext(track_next_);
|
|
||||||
track_next_ = NULL;
|
|
||||||
track_prev_ = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
CefTrackObject* track_next_;
|
|
||||||
CefTrackObject* track_prev_;
|
|
||||||
|
|
||||||
friend class CefTrackManager;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Class used to manage tracked objects. A single instance of this class
|
// Class extended by objects that must be tracked. After creating a tracked
|
||||||
// should be created for each intended usage. Any objects that have not been
|
// object you should add it to the appropriate track manager.
|
||||||
// removed by explicit calls to the Destroy() method will be removed when the
|
class CefTrackObject
|
||||||
// manager object is destroyed. A manager object can be created as either a
|
{
|
||||||
// member variable of another class or by using lazy initialization:
|
public:
|
||||||
// base::LazyInstance<CefTrackManager> g_singleton(base::LINKER_INITIALIZED);
|
CefTrackObject()
|
||||||
class CefTrackManager : public CefThreadSafeBase<CefBase>
|
{
|
||||||
{
|
track_next_ = NULL;
|
||||||
public:
|
track_prev_ = NULL;
|
||||||
CefTrackManager() : object_count_(0) {}
|
}
|
||||||
virtual ~CefTrackManager()
|
virtual ~CefTrackObject()
|
||||||
{
|
{
|
||||||
DeleteAll();
|
}
|
||||||
}
|
|
||||||
|
// Returns true if the object is currently being tracked.
|
||||||
// Add an object to be tracked by this manager.
|
bool IsTracked() { return (track_prev_ || track_next_); }
|
||||||
void Add(CefTrackObject* object)
|
|
||||||
{
|
private:
|
||||||
Lock();
|
CefTrackObject* GetTrackPrev() { return track_prev_; }
|
||||||
if(!object->IsTracked()) {
|
void SetTrackPrev(CefTrackObject* base) { track_prev_ = base; }
|
||||||
tracker_.InsertTrackNext(object);
|
CefTrackObject* GetTrackNext() { return track_next_; }
|
||||||
++object_count_;
|
void SetTrackNext(CefTrackObject* base) { track_next_ = base; }
|
||||||
}
|
|
||||||
Unlock();
|
// Insert a new object into the tracking list before this object.
|
||||||
}
|
void InsertTrackPrev(CefTrackObject* object)
|
||||||
|
{
|
||||||
// Delete an object tracked by this manager.
|
if(track_prev_)
|
||||||
bool Delete(CefTrackObject* object)
|
track_prev_->SetTrackNext(object);
|
||||||
{
|
object->SetTrackNext(this);
|
||||||
bool rv = false;
|
object->SetTrackPrev(track_prev_);
|
||||||
Lock();
|
track_prev_ = object;
|
||||||
if(object->IsTracked()) {
|
}
|
||||||
object->RemoveTracking();
|
|
||||||
delete object;
|
// Insert a new object into the tracking list after this object.
|
||||||
--object_count_;
|
void InsertTrackNext(CefTrackObject* object)
|
||||||
rv = true;
|
{
|
||||||
}
|
if(track_next_)
|
||||||
Unlock();
|
track_next_->SetTrackPrev(object);
|
||||||
return rv;
|
object->SetTrackPrev(this);
|
||||||
}
|
object->SetTrackNext(track_next_);
|
||||||
|
track_next_ = object;
|
||||||
// Delete all objects tracked by this manager.
|
}
|
||||||
void DeleteAll()
|
|
||||||
{
|
// Remove this object from the tracking list.
|
||||||
Lock();
|
void RemoveTracking()
|
||||||
CefTrackObject* next;
|
{
|
||||||
do {
|
if(track_next_)
|
||||||
next = tracker_.GetTrackNext();
|
track_next_->SetTrackPrev(track_prev_);
|
||||||
if(next) {
|
if(track_prev_)
|
||||||
next->RemoveTracking();
|
track_prev_->SetTrackNext(track_next_);
|
||||||
delete next;
|
track_next_ = NULL;
|
||||||
}
|
track_prev_ = NULL;
|
||||||
} while(next != NULL);
|
}
|
||||||
object_count_ = 0;
|
|
||||||
Unlock();
|
private:
|
||||||
}
|
CefTrackObject* track_next_;
|
||||||
|
CefTrackObject* track_prev_;
|
||||||
// Returns the number of objects currently being tracked.
|
|
||||||
long GetCount() { return object_count_; }
|
friend class CefTrackManager;
|
||||||
|
};
|
||||||
private:
|
|
||||||
CefTrackObject tracker_;
|
// Class used to manage tracked objects. A single instance of this class
|
||||||
long object_count_;
|
// should be created for each intended usage. Any objects that have not been
|
||||||
};
|
// removed by explicit calls to the Destroy() method will be removed when the
|
||||||
|
// manager object is destroyed. A manager object can be created as either a
|
||||||
|
// member variable of another class or by using lazy initialization:
|
||||||
|
// base::LazyInstance<CefTrackManager> g_singleton(base::LINKER_INITIALIZED);
|
||||||
|
class CefTrackManager : public CefThreadSafeBase<CefBase>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CefTrackManager() : object_count_(0) {}
|
||||||
|
virtual ~CefTrackManager()
|
||||||
|
{
|
||||||
|
DeleteAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add an object to be tracked by this manager.
|
||||||
|
void Add(CefTrackObject* object)
|
||||||
|
{
|
||||||
|
Lock();
|
||||||
|
if(!object->IsTracked()) {
|
||||||
|
tracker_.InsertTrackNext(object);
|
||||||
|
++object_count_;
|
||||||
|
}
|
||||||
|
Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete an object tracked by this manager.
|
||||||
|
bool Delete(CefTrackObject* object)
|
||||||
|
{
|
||||||
|
bool rv = false;
|
||||||
|
Lock();
|
||||||
|
if(object->IsTracked()) {
|
||||||
|
object->RemoveTracking();
|
||||||
|
delete object;
|
||||||
|
--object_count_;
|
||||||
|
rv = true;
|
||||||
|
}
|
||||||
|
Unlock();
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete all objects tracked by this manager.
|
||||||
|
void DeleteAll()
|
||||||
|
{
|
||||||
|
Lock();
|
||||||
|
CefTrackObject* next;
|
||||||
|
do {
|
||||||
|
next = tracker_.GetTrackNext();
|
||||||
|
if(next) {
|
||||||
|
next->RemoveTracking();
|
||||||
|
delete next;
|
||||||
|
}
|
||||||
|
} while(next != NULL);
|
||||||
|
object_count_ = 0;
|
||||||
|
Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the number of objects currently being tracked.
|
||||||
|
long GetCount() { return object_count_; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
CefTrackObject tracker_;
|
||||||
|
long object_count_;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // _TRACKER_H
|
#endif // _TRACKER_H
|
||||||
|
@ -1,49 +1,49 @@
|
|||||||
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
|
||||||
#include "v8_impl.h"
|
|
||||||
#include "context.h"
|
|
||||||
#include "tracker.h"
|
|
||||||
#include "base/lazy_instance.h"
|
|
||||||
#include "base/string_util.h"
|
|
||||||
#include "webkit/api/public/WebKit.h"
|
|
||||||
|
|
||||||
|
|
||||||
// Memory manager.
|
|
||||||
|
|
||||||
base::LazyInstance<CefTrackManager> g_v8_tracker(base::LINKER_INITIALIZED);
|
|
||||||
|
|
||||||
class TrackBase : public CefTrackObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TrackBase(CefBase* base) { base_ = base; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
CefRefPtr<CefBase> base_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class TrackString : public CefTrackObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TrackString(const std::string& str) : string_(str) {}
|
|
||||||
const char* GetString() { return string_.c_str(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string string_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static void TrackAdd(CefTrackObject* object)
|
|
||||||
{
|
|
||||||
g_v8_tracker.Pointer()->Add(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void TrackDelete(CefTrackObject* object)
|
#include "precompiled_libcef.h"
|
||||||
{
|
#include "v8_impl.h"
|
||||||
g_v8_tracker.Pointer()->Delete(object);
|
#include "context.h"
|
||||||
}
|
#include "tracker.h"
|
||||||
|
#include "base/lazy_instance.h"
|
||||||
|
#include "base/string_util.h"
|
||||||
|
#include "webkit/api/public/WebKit.h"
|
||||||
|
|
||||||
|
|
||||||
|
// Memory manager.
|
||||||
|
|
||||||
|
base::LazyInstance<CefTrackManager> g_v8_tracker(base::LINKER_INITIALIZED);
|
||||||
|
|
||||||
|
class TrackBase : public CefTrackObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TrackBase(CefBase* base) { base_ = base; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CefRefPtr<CefBase> base_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TrackString : public CefTrackObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TrackString(const std::string& str) : string_(str) {}
|
||||||
|
const char* GetString() { return string_.c_str(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string string_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void TrackAdd(CefTrackObject* object)
|
||||||
|
{
|
||||||
|
g_v8_tracker.Pointer()->Add(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TrackDelete(CefTrackObject* object)
|
||||||
|
{
|
||||||
|
g_v8_tracker.Pointer()->Delete(object);
|
||||||
|
}
|
||||||
|
|
||||||
// Callback for weak persistent reference destruction.
|
// Callback for weak persistent reference destruction.
|
||||||
static void TrackDestructor(v8::Persistent<v8::Value> object,
|
static void TrackDestructor(v8::Persistent<v8::Value> object,
|
||||||
@ -51,10 +51,10 @@ static void TrackDestructor(v8::Persistent<v8::Value> object,
|
|||||||
{
|
{
|
||||||
if(parameter)
|
if(parameter)
|
||||||
TrackDelete(static_cast<CefTrackObject*>(parameter));
|
TrackDelete(static_cast<CefTrackObject*>(parameter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Convert a wide string to a V8 string.
|
|
||||||
|
// Convert a wide string to a V8 string.
|
||||||
static v8::Handle<v8::String> GetV8String(const std::wstring& str)
|
static v8::Handle<v8::String> GetV8String(const std::wstring& str)
|
||||||
{
|
{
|
||||||
return v8::String::New(
|
return v8::String::New(
|
||||||
@ -64,84 +64,84 @@ static v8::Handle<v8::String> GetV8String(const std::wstring& str)
|
|||||||
// Convert a V8 string to a wide string.
|
// Convert a V8 string to a wide string.
|
||||||
static std::wstring GetWString(v8::Handle<v8::String> str)
|
static std::wstring GetWString(v8::Handle<v8::String> str)
|
||||||
{
|
{
|
||||||
uint16_t* buf = new uint16_t[str->Length()+1];
|
uint16_t* buf = new uint16_t[str->Length()+1];
|
||||||
str->Write(buf);
|
str->Write(buf);
|
||||||
std::wstring value = reinterpret_cast<wchar_t*>(buf);
|
std::wstring value = reinterpret_cast<wchar_t*>(buf);
|
||||||
delete [] buf;
|
delete [] buf;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// V8 function callback
|
// V8 function callback
|
||||||
static v8::Handle<v8::Value> FunctionCallbackImpl(const v8::Arguments& args)
|
static v8::Handle<v8::Value> FunctionCallbackImpl(const v8::Arguments& args)
|
||||||
{
|
{
|
||||||
v8::HandleScope handle_scope;
|
v8::HandleScope handle_scope;
|
||||||
CefV8Handler* handler =
|
CefV8Handler* handler =
|
||||||
static_cast<CefV8Handler*>(v8::External::Unwrap(args.Data()));
|
static_cast<CefV8Handler*>(v8::External::Unwrap(args.Data()));
|
||||||
|
|
||||||
CefV8ValueList params;
|
CefV8ValueList params;
|
||||||
for(int i = 0; i < args.Length(); i++)
|
for(int i = 0; i < args.Length(); i++)
|
||||||
params.push_back(new CefV8ValueImpl(args[i]));
|
params.push_back(new CefV8ValueImpl(args[i]));
|
||||||
|
|
||||||
std::wstring func_name =
|
std::wstring func_name =
|
||||||
GetWString(v8::Handle<v8::String>::Cast(args.Callee()->GetName()));
|
GetWString(v8::Handle<v8::String>::Cast(args.Callee()->GetName()));
|
||||||
CefRefPtr<CefV8Value> object = new CefV8ValueImpl(args.This());
|
CefRefPtr<CefV8Value> object = new CefV8ValueImpl(args.This());
|
||||||
CefRefPtr<CefV8Value> retval;
|
CefRefPtr<CefV8Value> retval;
|
||||||
std::wstring exception;
|
std::wstring exception;
|
||||||
v8::Handle<v8::Value> value = v8::Null();
|
v8::Handle<v8::Value> value = v8::Null();
|
||||||
|
|
||||||
if(handler->Execute(func_name, object, params, retval, exception)) {
|
if(handler->Execute(func_name, object, params, retval, exception)) {
|
||||||
if(!exception.empty())
|
if(!exception.empty())
|
||||||
value = v8::ThrowException(GetV8String(exception));
|
value = v8::ThrowException(GetV8String(exception));
|
||||||
else {
|
else {
|
||||||
CefV8ValueImpl* rv = static_cast<CefV8ValueImpl*>(retval.get());
|
CefV8ValueImpl* rv = static_cast<CefV8ValueImpl*>(retval.get());
|
||||||
if(rv)
|
if(rv)
|
||||||
value = rv->GetValue();
|
value = rv->GetValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// V8 extension registration.
|
// V8 extension registration.
|
||||||
|
|
||||||
class ExtensionWrapper : public v8::Extension {
|
class ExtensionWrapper : public v8::Extension {
|
||||||
public:
|
public:
|
||||||
ExtensionWrapper(const char* extension_name,
|
ExtensionWrapper(const char* extension_name,
|
||||||
const char* javascript_code,
|
const char* javascript_code,
|
||||||
CefV8Handler* handler)
|
CefV8Handler* handler)
|
||||||
: v8::Extension(extension_name, javascript_code), handler_(handler)
|
: v8::Extension(extension_name, javascript_code), handler_(handler)
|
||||||
{
|
{
|
||||||
// The reference will be released when the application exits.
|
// The reference will be released when the application exits.
|
||||||
TrackAdd(new TrackBase(handler));
|
TrackAdd(new TrackBase(handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
|
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
|
||||||
v8::Handle<v8::String> name)
|
v8::Handle<v8::String> name)
|
||||||
{
|
{
|
||||||
return v8::FunctionTemplate::New(FunctionCallbackImpl,
|
return v8::FunctionTemplate::New(FunctionCallbackImpl,
|
||||||
v8::External::New(handler_));
|
v8::External::New(handler_));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIT_RegisterExtension()
|
void UIT_RegisterExtension()
|
||||||
{
|
{
|
||||||
WebKit::registerExtension(this);
|
WebKit::registerExtension(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddRef() {}
|
void AddRef() {}
|
||||||
void Release() {}
|
void Release() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CefV8Handler* handler_;
|
CefV8Handler* handler_;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool CefRegisterExtension(const std::wstring& extension_name,
|
bool CefRegisterExtension(const std::wstring& extension_name,
|
||||||
const std::wstring& javascript_code,
|
const std::wstring& javascript_code,
|
||||||
CefRefPtr<CefV8Handler> handler)
|
CefRefPtr<CefV8Handler> handler)
|
||||||
{
|
{
|
||||||
// Verify that the context is already initialized
|
// Verify that the context is already initialized
|
||||||
if(!_Context.get())
|
if(!_Context.get())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(!handler.get())
|
if(!handler.get())
|
||||||
@ -158,7 +158,7 @@ bool CefRegisterExtension(const std::wstring& extension_name,
|
|||||||
PostTask(FROM_HERE, NewRunnableMethod(wrapper,
|
PostTask(FROM_HERE, NewRunnableMethod(wrapper,
|
||||||
&ExtensionWrapper::UIT_RegisterExtension));
|
&ExtensionWrapper::UIT_RegisterExtension));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// CefV8Value
|
// CefV8Value
|
||||||
@ -579,9 +579,9 @@ bool CefV8ValueImpl::GetKeys(std::vector<std::wstring>& keys)
|
|||||||
v8::Local<v8::Array> arr_keys = obj->GetPropertyNames();
|
v8::Local<v8::Array> arr_keys = obj->GetPropertyNames();
|
||||||
uint32_t len = arr_keys->Length();
|
uint32_t len = arr_keys->Length();
|
||||||
for(uint32_t i = 0; i < len; ++i) {
|
for(uint32_t i = 0; i < len; ++i) {
|
||||||
v8::Local<v8::Value> value = arr_keys->Get(v8::Integer::New(i));
|
v8::Local<v8::Value> value = arr_keys->Get(v8::Integer::New(i));
|
||||||
std::wstring str = GetWString(value->ToString());
|
std::wstring str = GetWString(value->ToString());
|
||||||
if(!IsReservedKey(str))
|
if(!IsReservedKey(str))
|
||||||
keys.push_back(str);
|
keys.push_back(str);
|
||||||
}
|
}
|
||||||
rv = true;
|
rv = true;
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef _V8_IMPL_H
|
#ifndef _V8_IMPL_H
|
||||||
#define _V8_IMPL_H
|
#define _V8_IMPL_H
|
||||||
|
|
||||||
#include "include/cef.h"
|
#include "include/cef.h"
|
||||||
#include "v8/include/v8.h"
|
#include "v8/include/v8.h"
|
||||||
|
|
||||||
class CefTrackObject;
|
class CefTrackObject;
|
||||||
|
|
||||||
class CefV8ValueImpl : public CefThreadSafeBase<CefV8Value>
|
class CefV8ValueImpl : public CefThreadSafeBase<CefV8Value>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -57,5 +57,5 @@ protected:
|
|||||||
v8::Persistent<v8::Value> v8_value_;
|
v8::Persistent<v8::Value> v8_value_;
|
||||||
CefTrackObject* tracker_;
|
CefTrackObject* tracker_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //_V8_IMPL_H
|
#endif //_V8_IMPL_H
|
||||||
|
@ -1,49 +1,49 @@
|
|||||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
#include "webview_host.h"
|
#include "webview_host.h"
|
||||||
|
|
||||||
#include "base/gfx/platform_canvas.h"
|
#include "base/gfx/platform_canvas.h"
|
||||||
#include "base/gfx/rect.h"
|
#include "base/gfx/rect.h"
|
||||||
#include "base/gfx/size.h"
|
#include "base/gfx/size.h"
|
||||||
#include "base/win_util.h"
|
#include "base/win_util.h"
|
||||||
#include "webkit/glue/webview.h"
|
#include "webkit/glue/webview.h"
|
||||||
|
|
||||||
static const wchar_t kWindowClassName[] = L"WebViewHost";
|
static const wchar_t kWindowClassName[] = L"WebViewHost";
|
||||||
|
|
||||||
/*static*/
|
/*static*/
|
||||||
WebViewHost* WebViewHost::Create(HWND parent_view,
|
WebViewHost* WebViewHost::Create(HWND parent_view,
|
||||||
WebViewDelegate* delegate,
|
WebViewDelegate* delegate,
|
||||||
const WebPreferences& prefs) {
|
const WebPreferences& prefs) {
|
||||||
WebViewHost* host = new WebViewHost();
|
WebViewHost* host = new WebViewHost();
|
||||||
|
|
||||||
static bool registered_class = false;
|
static bool registered_class = false;
|
||||||
if (!registered_class) {
|
if (!registered_class) {
|
||||||
WNDCLASSEX wcex = {0};
|
WNDCLASSEX wcex = {0};
|
||||||
wcex.cbSize = sizeof(wcex);
|
wcex.cbSize = sizeof(wcex);
|
||||||
wcex.style = CS_DBLCLKS;
|
wcex.style = CS_DBLCLKS;
|
||||||
wcex.lpfnWndProc = WebWidgetHost::WndProc;
|
wcex.lpfnWndProc = WebWidgetHost::WndProc;
|
||||||
wcex.hInstance = GetModuleHandle(NULL);
|
wcex.hInstance = GetModuleHandle(NULL);
|
||||||
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
wcex.lpszClassName = kWindowClassName;
|
wcex.lpszClassName = kWindowClassName;
|
||||||
RegisterClassEx(&wcex);
|
RegisterClassEx(&wcex);
|
||||||
registered_class = true;
|
registered_class = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
host->view_ = CreateWindow(kWindowClassName, NULL,
|
host->view_ = CreateWindow(kWindowClassName, NULL,
|
||||||
WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, 0, 0,
|
WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, 0, 0,
|
||||||
0, 0, parent_view, NULL,
|
0, 0, parent_view, NULL,
|
||||||
GetModuleHandle(NULL), NULL);
|
GetModuleHandle(NULL), NULL);
|
||||||
win_util::SetWindowUserData(host->view_, host);
|
win_util::SetWindowUserData(host->view_, host);
|
||||||
|
|
||||||
host->webwidget_ = WebView::Create(delegate, prefs);
|
host->webwidget_ = WebView::Create(delegate, prefs);
|
||||||
|
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebView* WebViewHost::webview() const {
|
WebView* WebViewHost::webview() const {
|
||||||
return static_cast<WebView*>(webwidget_);
|
return static_cast<WebView*>(webwidget_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,37 +1,37 @@
|
|||||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef _WEBVIEW_HOST_H
|
#ifndef _WEBVIEW_HOST_H
|
||||||
#define _WEBVIEW_HOST_H
|
#define _WEBVIEW_HOST_H
|
||||||
|
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
#include "base/gfx/native_widget_types.h"
|
#include "base/gfx/native_widget_types.h"
|
||||||
#include "base/gfx/rect.h"
|
#include "base/gfx/rect.h"
|
||||||
#include "webwidget_host.h"
|
#include "webwidget_host.h"
|
||||||
|
|
||||||
struct WebPreferences;
|
struct WebPreferences;
|
||||||
class WebView;
|
class WebView;
|
||||||
class WebViewDelegate;
|
class WebViewDelegate;
|
||||||
|
|
||||||
// This class is a simple ViewHandle-based host for a WebView
|
// This class is a simple ViewHandle-based host for a WebView
|
||||||
class WebViewHost : public WebWidgetHost {
|
class WebViewHost : public WebWidgetHost {
|
||||||
public:
|
public:
|
||||||
// The new instance is deleted once the associated ViewHandle is destroyed.
|
// The new instance is deleted once the associated ViewHandle is destroyed.
|
||||||
// The newly created window should be resized after it is created, using the
|
// The newly created window should be resized after it is created, using the
|
||||||
// MoveWindow (or equivalent) function.
|
// MoveWindow (or equivalent) function.
|
||||||
static WebViewHost* Create(gfx::NativeView parent_window,
|
static WebViewHost* Create(gfx::NativeView parent_window,
|
||||||
WebViewDelegate* delegate,
|
WebViewDelegate* delegate,
|
||||||
const WebPreferences& prefs);
|
const WebPreferences& prefs);
|
||||||
|
|
||||||
WebView* webview() const;
|
WebView* webview() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam) {
|
virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _WEBVIEW_HOST_H
|
#endif // _WEBVIEW_HOST_H
|
||||||
|
@ -1,366 +1,366 @@
|
|||||||
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
#include "webwidget_host.h"
|
#include "webwidget_host.h"
|
||||||
|
|
||||||
#include "base/gfx/platform_canvas.h"
|
#include "base/gfx/platform_canvas.h"
|
||||||
#include "base/gfx/rect.h"
|
#include "base/gfx/rect.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/win_util.h"
|
#include "base/win_util.h"
|
||||||
#include "webkit/api/public/WebInputEvent.h"
|
#include "webkit/api/public/WebInputEvent.h"
|
||||||
#include "webkit/api/public/WebPopupMenu.h"
|
#include "webkit/api/public/WebPopupMenu.h"
|
||||||
#include "webkit/api/public/WebScreenInfo.h"
|
#include "webkit/api/public/WebScreenInfo.h"
|
||||||
#include "webkit/api/public/WebSize.h"
|
#include "webkit/api/public/WebSize.h"
|
||||||
#include "webkit/api/public/win/WebInputEventFactory.h"
|
#include "webkit/api/public/win/WebInputEventFactory.h"
|
||||||
#include "webkit/api/public/win/WebScreenInfoFactory.h"
|
#include "webkit/api/public/win/WebScreenInfoFactory.h"
|
||||||
|
|
||||||
using WebKit::WebInputEvent;
|
using WebKit::WebInputEvent;
|
||||||
using WebKit::WebInputEventFactory;
|
using WebKit::WebInputEventFactory;
|
||||||
using WebKit::WebKeyboardEvent;
|
using WebKit::WebKeyboardEvent;
|
||||||
using WebKit::WebMouseEvent;
|
using WebKit::WebMouseEvent;
|
||||||
using WebKit::WebMouseWheelEvent;
|
using WebKit::WebMouseWheelEvent;
|
||||||
using WebKit::WebPopupMenu;
|
using WebKit::WebPopupMenu;
|
||||||
using WebKit::WebScreenInfo;
|
using WebKit::WebScreenInfo;
|
||||||
using WebKit::WebScreenInfoFactory;
|
using WebKit::WebScreenInfoFactory;
|
||||||
using WebKit::WebSize;
|
using WebKit::WebSize;
|
||||||
using WebKit::WebWidget;
|
using WebKit::WebWidget;
|
||||||
using WebKit::WebWidgetClient;
|
using WebKit::WebWidgetClient;
|
||||||
|
|
||||||
static const wchar_t kWindowClassName[] = L"WebWidgetHost";
|
static const wchar_t kWindowClassName[] = L"WebWidgetHost";
|
||||||
|
|
||||||
/*static*/
|
/*static*/
|
||||||
WebWidgetHost* WebWidgetHost::Create(HWND parent_view,
|
WebWidgetHost* WebWidgetHost::Create(HWND parent_view,
|
||||||
WebWidgetClient* client) {
|
WebWidgetClient* client) {
|
||||||
WebWidgetHost* host = new WebWidgetHost();
|
WebWidgetHost* host = new WebWidgetHost();
|
||||||
|
|
||||||
static bool registered_class = false;
|
static bool registered_class = false;
|
||||||
if (!registered_class) {
|
if (!registered_class) {
|
||||||
WNDCLASSEX wcex = {0};
|
WNDCLASSEX wcex = {0};
|
||||||
wcex.cbSize = sizeof(wcex);
|
wcex.cbSize = sizeof(wcex);
|
||||||
wcex.style = CS_DBLCLKS;
|
wcex.style = CS_DBLCLKS;
|
||||||
wcex.lpfnWndProc = WebWidgetHost::WndProc;
|
wcex.lpfnWndProc = WebWidgetHost::WndProc;
|
||||||
wcex.hInstance = GetModuleHandle(NULL);
|
wcex.hInstance = GetModuleHandle(NULL);
|
||||||
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
wcex.lpszClassName = kWindowClassName;
|
wcex.lpszClassName = kWindowClassName;
|
||||||
RegisterClassEx(&wcex);
|
RegisterClassEx(&wcex);
|
||||||
registered_class = true;
|
registered_class = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
host->view_ = CreateWindowEx(WS_EX_TOOLWINDOW,
|
host->view_ = CreateWindowEx(WS_EX_TOOLWINDOW,
|
||||||
kWindowClassName, kWindowClassName, WS_POPUP,
|
kWindowClassName, kWindowClassName, WS_POPUP,
|
||||||
0, 0, 0, 0,
|
0, 0, 0, 0,
|
||||||
parent_view, NULL, GetModuleHandle(NULL), NULL);
|
parent_view, NULL, GetModuleHandle(NULL), NULL);
|
||||||
|
|
||||||
win_util::SetWindowUserData(host->view_, host);
|
win_util::SetWindowUserData(host->view_, host);
|
||||||
|
|
||||||
host->webwidget_ = WebPopupMenu::create(client);
|
host->webwidget_ = WebPopupMenu::create(client);
|
||||||
|
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/
|
/*static*/
|
||||||
static WebWidgetHost* FromWindow(HWND view) {
|
static WebWidgetHost* FromWindow(HWND view) {
|
||||||
return reinterpret_cast<WebWidgetHost*>(win_util::GetWindowUserData(view));
|
return reinterpret_cast<WebWidgetHost*>(win_util::GetWindowUserData(view));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/
|
/*static*/
|
||||||
LRESULT CALLBACK WebWidgetHost::WndProc(HWND hwnd, UINT message, WPARAM wparam,
|
LRESULT CALLBACK WebWidgetHost::WndProc(HWND hwnd, UINT message, WPARAM wparam,
|
||||||
LPARAM lparam) {
|
LPARAM lparam) {
|
||||||
WebWidgetHost* host = FromWindow(hwnd);
|
WebWidgetHost* host = FromWindow(hwnd);
|
||||||
if (host && !host->WndProc(message, wparam, lparam)) {
|
if (host && !host->WndProc(message, wparam, lparam)) {
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case WM_PAINT: {
|
case WM_PAINT: {
|
||||||
RECT rect;
|
RECT rect;
|
||||||
if (GetUpdateRect(hwnd, &rect, FALSE)) {
|
if (GetUpdateRect(hwnd, &rect, FALSE)) {
|
||||||
host->UpdatePaintRect(gfx::Rect(rect));
|
host->UpdatePaintRect(gfx::Rect(rect));
|
||||||
}
|
}
|
||||||
host->Paint();
|
host->Paint();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_ERASEBKGND:
|
case WM_ERASEBKGND:
|
||||||
// Do nothing here to avoid flashing, the background will be erased
|
// Do nothing here to avoid flashing, the background will be erased
|
||||||
// during painting.
|
// during painting.
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
host->Resize(lparam);
|
host->Resize(lparam);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
case WM_MOUSELEAVE:
|
case WM_MOUSELEAVE:
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
case WM_MBUTTONDOWN:
|
case WM_MBUTTONDOWN:
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
case WM_MBUTTONUP:
|
case WM_MBUTTONUP:
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
case WM_LBUTTONDBLCLK:
|
case WM_LBUTTONDBLCLK:
|
||||||
case WM_MBUTTONDBLCLK:
|
case WM_MBUTTONDBLCLK:
|
||||||
case WM_RBUTTONDBLCLK:
|
case WM_RBUTTONDBLCLK:
|
||||||
host->MouseEvent(message, wparam, lparam);
|
host->MouseEvent(message, wparam, lparam);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
host->WheelEvent(wparam, lparam);
|
host->WheelEvent(wparam, lparam);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_CAPTURECHANGED:
|
case WM_CAPTURECHANGED:
|
||||||
case WM_CANCELMODE:
|
case WM_CANCELMODE:
|
||||||
host->CaptureLostEvent();
|
host->CaptureLostEvent();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// TODO(darin): add WM_SYSKEY{DOWN/UP} to capture ALT key actions
|
// TODO(darin): add WM_SYSKEY{DOWN/UP} to capture ALT key actions
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
case WM_SYSKEYDOWN:
|
case WM_SYSKEYDOWN:
|
||||||
case WM_SYSKEYUP:
|
case WM_SYSKEYUP:
|
||||||
case WM_CHAR:
|
case WM_CHAR:
|
||||||
case WM_SYSCHAR:
|
case WM_SYSCHAR:
|
||||||
case WM_IME_CHAR:
|
case WM_IME_CHAR:
|
||||||
host->KeyEvent(message, wparam, lparam);
|
host->KeyEvent(message, wparam, lparam);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SETFOCUS:
|
case WM_SETFOCUS:
|
||||||
host->SetFocus(true);
|
host->SetFocus(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_KILLFOCUS:
|
case WM_KILLFOCUS:
|
||||||
host->SetFocus(false);
|
host->SetFocus(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(hwnd, message, wparam, lparam);;
|
return DefWindowProc(hwnd, message, wparam, lparam);;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) {
|
void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) {
|
||||||
DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting";
|
DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting";
|
||||||
|
|
||||||
// If this invalidate overlaps with a pending scroll, then we have to
|
// If this invalidate overlaps with a pending scroll, then we have to
|
||||||
// downgrade to invalidating the scroll rect.
|
// downgrade to invalidating the scroll rect.
|
||||||
if (damaged_rect.Intersects(scroll_rect_)) {
|
if (damaged_rect.Intersects(scroll_rect_)) {
|
||||||
paint_rect_ = paint_rect_.Union(scroll_rect_);
|
paint_rect_ = paint_rect_.Union(scroll_rect_);
|
||||||
ResetScrollRect();
|
ResetScrollRect();
|
||||||
}
|
}
|
||||||
paint_rect_ = paint_rect_.Union(damaged_rect);
|
paint_rect_ = paint_rect_.Union(damaged_rect);
|
||||||
|
|
||||||
RECT r = damaged_rect.ToRECT();
|
RECT r = damaged_rect.ToRECT();
|
||||||
InvalidateRect(view_, &r, FALSE);
|
InvalidateRect(view_, &r, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) {
|
void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) {
|
||||||
if (dx != 0 && dy != 0) {
|
if (dx != 0 && dy != 0) {
|
||||||
// We only support uni-directional scroll
|
// We only support uni-directional scroll
|
||||||
DidScrollRect(0, dy, clip_rect);
|
DidScrollRect(0, dy, clip_rect);
|
||||||
dy = 0;
|
dy = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we already have a pending scroll operation or if this scroll operation
|
// If we already have a pending scroll operation or if this scroll operation
|
||||||
// intersects the existing paint region, then just failover to invalidating.
|
// intersects the existing paint region, then just failover to invalidating.
|
||||||
if (!scroll_rect_.IsEmpty() || paint_rect_.Intersects(clip_rect)) {
|
if (!scroll_rect_.IsEmpty() || paint_rect_.Intersects(clip_rect)) {
|
||||||
paint_rect_ = paint_rect_.Union(scroll_rect_);
|
paint_rect_ = paint_rect_.Union(scroll_rect_);
|
||||||
ResetScrollRect();
|
ResetScrollRect();
|
||||||
paint_rect_ = paint_rect_.Union(clip_rect);
|
paint_rect_ = paint_rect_.Union(clip_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We will perform scrolling lazily, when requested to actually paint.
|
// We will perform scrolling lazily, when requested to actually paint.
|
||||||
scroll_rect_ = clip_rect;
|
scroll_rect_ = clip_rect;
|
||||||
scroll_dx_ = dx;
|
scroll_dx_ = dx;
|
||||||
scroll_dy_ = dy;
|
scroll_dy_ = dy;
|
||||||
|
|
||||||
RECT r = clip_rect.ToRECT();
|
RECT r = clip_rect.ToRECT();
|
||||||
InvalidateRect(view_, &r, FALSE);
|
InvalidateRect(view_, &r, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebWidgetHost::SetCursor(HCURSOR cursor) {
|
void WebWidgetHost::SetCursor(HCURSOR cursor) {
|
||||||
SetClassLong(view_, GCL_HCURSOR,
|
SetClassLong(view_, GCL_HCURSOR,
|
||||||
static_cast<LONG>(reinterpret_cast<LONG_PTR>(cursor)));
|
static_cast<LONG>(reinterpret_cast<LONG_PTR>(cursor)));
|
||||||
::SetCursor(cursor);
|
::SetCursor(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebWidgetHost::DiscardBackingStore() {
|
void WebWidgetHost::DiscardBackingStore() {
|
||||||
canvas_.reset();
|
canvas_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
WebWidgetHost::WebWidgetHost()
|
WebWidgetHost::WebWidgetHost()
|
||||||
: view_(NULL),
|
: view_(NULL),
|
||||||
webwidget_(NULL),
|
webwidget_(NULL),
|
||||||
track_mouse_leave_(false),
|
track_mouse_leave_(false),
|
||||||
scroll_dx_(0),
|
scroll_dx_(0),
|
||||||
scroll_dy_(0) {
|
scroll_dy_(0) {
|
||||||
set_painting(false);
|
set_painting(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebWidgetHost::~WebWidgetHost() {
|
WebWidgetHost::~WebWidgetHost() {
|
||||||
win_util::SetWindowUserData(view_, 0);
|
win_util::SetWindowUserData(view_, 0);
|
||||||
|
|
||||||
TrackMouseLeave(false);
|
TrackMouseLeave(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebWidgetHost::WndProc(UINT message, WPARAM wparam, LPARAM lparam) {
|
bool WebWidgetHost::WndProc(UINT message, WPARAM wparam, LPARAM lparam) {
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case WM_ACTIVATE:
|
case WM_ACTIVATE:
|
||||||
if (wparam == WA_INACTIVE) {
|
if (wparam == WA_INACTIVE) {
|
||||||
PostMessage(view_, WM_CLOSE, 0, 0);
|
PostMessage(view_, WM_CLOSE, 0, 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) {
|
void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) {
|
||||||
paint_rect_ = paint_rect_.Union(rect);
|
paint_rect_ = paint_rect_.Union(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebWidgetHost::Paint() {
|
void WebWidgetHost::Paint() {
|
||||||
RECT r;
|
RECT r;
|
||||||
GetClientRect(view_, &r);
|
GetClientRect(view_, &r);
|
||||||
gfx::Rect client_rect(r);
|
gfx::Rect client_rect(r);
|
||||||
|
|
||||||
// Allocate a canvas if necessary
|
// Allocate a canvas if necessary
|
||||||
if (!canvas_.get()) {
|
if (!canvas_.get()) {
|
||||||
ResetScrollRect();
|
ResetScrollRect();
|
||||||
paint_rect_ = client_rect;
|
paint_rect_ = client_rect;
|
||||||
canvas_.reset(new skia::PlatformCanvas(
|
canvas_.reset(new skia::PlatformCanvas(
|
||||||
paint_rect_.width(), paint_rect_.height(), true));
|
paint_rect_.width(), paint_rect_.height(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This may result in more invalidation
|
// This may result in more invalidation
|
||||||
webwidget_->layout();
|
webwidget_->layout();
|
||||||
|
|
||||||
// Scroll the canvas if necessary
|
// Scroll the canvas if necessary
|
||||||
scroll_rect_ = client_rect.Intersect(scroll_rect_);
|
scroll_rect_ = client_rect.Intersect(scroll_rect_);
|
||||||
if (!scroll_rect_.IsEmpty()) {
|
if (!scroll_rect_.IsEmpty()) {
|
||||||
HDC hdc = canvas_->getTopPlatformDevice().getBitmapDC();
|
HDC hdc = canvas_->getTopPlatformDevice().getBitmapDC();
|
||||||
|
|
||||||
RECT damaged_rect, r = scroll_rect_.ToRECT();
|
RECT damaged_rect, r = scroll_rect_.ToRECT();
|
||||||
ScrollDC(hdc, scroll_dx_, scroll_dy_, NULL, &r, NULL, &damaged_rect);
|
ScrollDC(hdc, scroll_dx_, scroll_dy_, NULL, &r, NULL, &damaged_rect);
|
||||||
|
|
||||||
PaintRect(gfx::Rect(damaged_rect));
|
PaintRect(gfx::Rect(damaged_rect));
|
||||||
}
|
}
|
||||||
ResetScrollRect();
|
ResetScrollRect();
|
||||||
|
|
||||||
// Paint the canvas if necessary. Allow painting to generate extra rects the
|
// Paint the canvas if necessary. Allow painting to generate extra rects the
|
||||||
// first time we call it. This is necessary because some WebCore rendering
|
// first time we call it. This is necessary because some WebCore rendering
|
||||||
// objects update their layout only when painted.
|
// objects update their layout only when painted.
|
||||||
for (int i = 0; i < 2; ++i) {
|
for (int i = 0; i < 2; ++i) {
|
||||||
paint_rect_ = client_rect.Intersect(paint_rect_);
|
paint_rect_ = client_rect.Intersect(paint_rect_);
|
||||||
if (!paint_rect_.IsEmpty()) {
|
if (!paint_rect_.IsEmpty()) {
|
||||||
gfx::Rect rect(paint_rect_);
|
gfx::Rect rect(paint_rect_);
|
||||||
paint_rect_ = gfx::Rect();
|
paint_rect_ = gfx::Rect();
|
||||||
|
|
||||||
DLOG_IF(WARNING, i == 1) << "painting caused additional invalidations";
|
DLOG_IF(WARNING, i == 1) << "painting caused additional invalidations";
|
||||||
PaintRect(rect);
|
PaintRect(rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DCHECK(paint_rect_.IsEmpty());
|
DCHECK(paint_rect_.IsEmpty());
|
||||||
|
|
||||||
// Paint to the screen
|
// Paint to the screen
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
BeginPaint(view_, &ps);
|
BeginPaint(view_, &ps);
|
||||||
canvas_->getTopPlatformDevice().drawToHDC(ps.hdc,
|
canvas_->getTopPlatformDevice().drawToHDC(ps.hdc,
|
||||||
ps.rcPaint.left,
|
ps.rcPaint.left,
|
||||||
ps.rcPaint.top,
|
ps.rcPaint.top,
|
||||||
&ps.rcPaint);
|
&ps.rcPaint);
|
||||||
EndPaint(view_, &ps);
|
EndPaint(view_, &ps);
|
||||||
|
|
||||||
// Draw children
|
// Draw children
|
||||||
UpdateWindow(view_);
|
UpdateWindow(view_);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebScreenInfo WebWidgetHost::GetScreenInfo() {
|
WebScreenInfo WebWidgetHost::GetScreenInfo() {
|
||||||
return WebScreenInfoFactory::screenInfo(view_);
|
return WebScreenInfoFactory::screenInfo(view_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebWidgetHost::Resize(LPARAM lparam) {
|
void WebWidgetHost::Resize(LPARAM lparam) {
|
||||||
// Force an entire re-paint. TODO(darin): Maybe reuse this memory buffer.
|
// Force an entire re-paint. TODO(darin): Maybe reuse this memory buffer.
|
||||||
DiscardBackingStore();
|
DiscardBackingStore();
|
||||||
|
|
||||||
webwidget_->resize(WebSize(LOWORD(lparam), HIWORD(lparam)));
|
webwidget_->resize(WebSize(LOWORD(lparam), HIWORD(lparam)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebWidgetHost::MouseEvent(UINT message, WPARAM wparam, LPARAM lparam) {
|
void WebWidgetHost::MouseEvent(UINT message, WPARAM wparam, LPARAM lparam) {
|
||||||
const WebMouseEvent& event = WebInputEventFactory::mouseEvent(
|
const WebMouseEvent& event = WebInputEventFactory::mouseEvent(
|
||||||
view_, message, wparam, lparam);
|
view_, message, wparam, lparam);
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case WebInputEvent::MouseMove:
|
case WebInputEvent::MouseMove:
|
||||||
TrackMouseLeave(true);
|
TrackMouseLeave(true);
|
||||||
break;
|
break;
|
||||||
case WebInputEvent::MouseLeave:
|
case WebInputEvent::MouseLeave:
|
||||||
TrackMouseLeave(false);
|
TrackMouseLeave(false);
|
||||||
break;
|
break;
|
||||||
case WebInputEvent::MouseDown:
|
case WebInputEvent::MouseDown:
|
||||||
SetCapture(view_);
|
SetCapture(view_);
|
||||||
// This mimics a temporary workaround in RenderWidgetHostViewWin
|
// This mimics a temporary workaround in RenderWidgetHostViewWin
|
||||||
// for bug 765011 to get focus when the mouse is clicked. This
|
// for bug 765011 to get focus when the mouse is clicked. This
|
||||||
// happens after the mouse down event is sent to the renderer
|
// happens after the mouse down event is sent to the renderer
|
||||||
// because normally Windows does a WM_SETFOCUS after WM_LBUTTONDOWN.
|
// because normally Windows does a WM_SETFOCUS after WM_LBUTTONDOWN.
|
||||||
::SetFocus(view_);
|
::SetFocus(view_);
|
||||||
break;
|
break;
|
||||||
case WebInputEvent::MouseUp:
|
case WebInputEvent::MouseUp:
|
||||||
if (GetCapture() == view_)
|
if (GetCapture() == view_)
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
webwidget_->handleInputEvent(event);
|
webwidget_->handleInputEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebWidgetHost::WheelEvent(WPARAM wparam, LPARAM lparam) {
|
void WebWidgetHost::WheelEvent(WPARAM wparam, LPARAM lparam) {
|
||||||
const WebMouseWheelEvent& event = WebInputEventFactory::mouseWheelEvent(
|
const WebMouseWheelEvent& event = WebInputEventFactory::mouseWheelEvent(
|
||||||
view_, WM_MOUSEWHEEL, wparam, lparam);
|
view_, WM_MOUSEWHEEL, wparam, lparam);
|
||||||
webwidget_->handleInputEvent(event);
|
webwidget_->handleInputEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebWidgetHost::KeyEvent(UINT message, WPARAM wparam, LPARAM lparam) {
|
void WebWidgetHost::KeyEvent(UINT message, WPARAM wparam, LPARAM lparam) {
|
||||||
const WebKeyboardEvent& event = WebInputEventFactory::keyboardEvent(
|
const WebKeyboardEvent& event = WebInputEventFactory::keyboardEvent(
|
||||||
view_, message, wparam, lparam);
|
view_, message, wparam, lparam);
|
||||||
webwidget_->handleInputEvent(event);
|
webwidget_->handleInputEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebWidgetHost::CaptureLostEvent() {
|
void WebWidgetHost::CaptureLostEvent() {
|
||||||
webwidget_->mouseCaptureLost();
|
webwidget_->mouseCaptureLost();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebWidgetHost::SetFocus(bool enable) {
|
void WebWidgetHost::SetFocus(bool enable) {
|
||||||
webwidget_->setFocus(enable);
|
webwidget_->setFocus(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebWidgetHost::TrackMouseLeave(bool track) {
|
void WebWidgetHost::TrackMouseLeave(bool track) {
|
||||||
if (track == track_mouse_leave_)
|
if (track == track_mouse_leave_)
|
||||||
return;
|
return;
|
||||||
track_mouse_leave_ = track;
|
track_mouse_leave_ = track;
|
||||||
|
|
||||||
DCHECK(view_);
|
DCHECK(view_);
|
||||||
|
|
||||||
TRACKMOUSEEVENT tme;
|
TRACKMOUSEEVENT tme;
|
||||||
tme.cbSize = sizeof(TRACKMOUSEEVENT);
|
tme.cbSize = sizeof(TRACKMOUSEEVENT);
|
||||||
tme.dwFlags = TME_LEAVE;
|
tme.dwFlags = TME_LEAVE;
|
||||||
if (!track_mouse_leave_)
|
if (!track_mouse_leave_)
|
||||||
tme.dwFlags |= TME_CANCEL;
|
tme.dwFlags |= TME_CANCEL;
|
||||||
tme.hwndTrack = view_;
|
tme.hwndTrack = view_;
|
||||||
|
|
||||||
TrackMouseEvent(&tme);
|
TrackMouseEvent(&tme);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebWidgetHost::ResetScrollRect() {
|
void WebWidgetHost::ResetScrollRect() {
|
||||||
scroll_rect_ = gfx::Rect();
|
scroll_rect_ = gfx::Rect();
|
||||||
scroll_dx_ = 0;
|
scroll_dx_ = 0;
|
||||||
scroll_dy_ = 0;
|
scroll_dy_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebWidgetHost::PaintRect(const gfx::Rect& rect) {
|
void WebWidgetHost::PaintRect(const gfx::Rect& rect) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
DCHECK(!painting_);
|
DCHECK(!painting_);
|
||||||
#endif
|
#endif
|
||||||
DCHECK(canvas_.get());
|
DCHECK(canvas_.get());
|
||||||
|
|
||||||
set_painting(true);
|
set_painting(true);
|
||||||
webwidget_->paint(canvas_.get(), rect);
|
webwidget_->paint(canvas_.get(), rect);
|
||||||
set_painting(false);
|
set_painting(false);
|
||||||
}
|
}
|
||||||
|
@ -1,128 +1,128 @@
|
|||||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef _WEBWIDGET_HOST_H
|
#ifndef _WEBWIDGET_HOST_H
|
||||||
#define _WEBWIDGET_HOST_H
|
#define _WEBWIDGET_HOST_H
|
||||||
|
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
#include "base/gfx/native_widget_types.h"
|
#include "base/gfx/native_widget_types.h"
|
||||||
#include "base/gfx/platform_canvas.h"
|
#include "base/gfx/platform_canvas.h"
|
||||||
#include "base/gfx/rect.h"
|
#include "base/gfx/rect.h"
|
||||||
#include "base/scoped_ptr.h"
|
#include "base/scoped_ptr.h"
|
||||||
#include "skia/ext/platform_canvas.h"
|
#include "skia/ext/platform_canvas.h"
|
||||||
|
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
class Size;
|
class Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace WebKit {
|
namespace WebKit {
|
||||||
class WebWidget;
|
class WebWidget;
|
||||||
class WebWidgetClient;
|
class WebWidgetClient;
|
||||||
struct WebScreenInfo;
|
struct WebScreenInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This class is a simple ViewHandle-based host for a WebWidget
|
// This class is a simple ViewHandle-based host for a WebWidget
|
||||||
class WebWidgetHost {
|
class WebWidgetHost {
|
||||||
public:
|
public:
|
||||||
// The new instance is deleted once the associated ViewHandle is destroyed.
|
// The new instance is deleted once the associated ViewHandle is destroyed.
|
||||||
// The newly created window should be resized after it is created, using the
|
// The newly created window should be resized after it is created, using the
|
||||||
// MoveWindow (or equivalent) function.
|
// MoveWindow (or equivalent) function.
|
||||||
static WebWidgetHost* Create(gfx::NativeView parent_view,
|
static WebWidgetHost* Create(gfx::NativeView parent_view,
|
||||||
WebKit::WebWidgetClient* client);
|
WebKit::WebWidgetClient* client);
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
static void HandleEvent(gfx::NativeView view, NSEvent *event);
|
static void HandleEvent(gfx::NativeView view, NSEvent *event);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gfx::NativeView view_handle() const { return view_; }
|
gfx::NativeView view_handle() const { return view_; }
|
||||||
WebKit::WebWidget* webwidget() const { return webwidget_; }
|
WebKit::WebWidget* webwidget() const { return webwidget_; }
|
||||||
|
|
||||||
void DidInvalidateRect(const gfx::Rect& rect);
|
void DidInvalidateRect(const gfx::Rect& rect);
|
||||||
void DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect);
|
void DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect);
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
void SetCursor(HCURSOR cursor);
|
void SetCursor(HCURSOR cursor);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void DiscardBackingStore();
|
void DiscardBackingStore();
|
||||||
// Allow clients to update the paint rect. For example, if we get a gdk
|
// Allow clients to update the paint rect. For example, if we get a gdk
|
||||||
// expose or WM_PAINT event, we need to update the paint rect.
|
// expose or WM_PAINT event, we need to update the paint rect.
|
||||||
void UpdatePaintRect(const gfx::Rect& rect);
|
void UpdatePaintRect(const gfx::Rect& rect);
|
||||||
void Paint();
|
void Paint();
|
||||||
|
|
||||||
skia::PlatformCanvas* canvas() const { return canvas_.get(); }
|
skia::PlatformCanvas* canvas() const { return canvas_.get(); }
|
||||||
|
|
||||||
WebKit::WebScreenInfo GetScreenInfo();
|
WebKit::WebScreenInfo GetScreenInfo();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WebWidgetHost();
|
WebWidgetHost();
|
||||||
~WebWidgetHost();
|
~WebWidgetHost();
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
// Per-class wndproc. Returns true if the event should be swallowed.
|
// Per-class wndproc. Returns true if the event should be swallowed.
|
||||||
virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam);
|
virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam);
|
||||||
|
|
||||||
void Resize(LPARAM lparam);
|
void Resize(LPARAM lparam);
|
||||||
void MouseEvent(UINT message, WPARAM wparam, LPARAM lparam);
|
void MouseEvent(UINT message, WPARAM wparam, LPARAM lparam);
|
||||||
void WheelEvent(WPARAM wparam, LPARAM lparam);
|
void WheelEvent(WPARAM wparam, LPARAM lparam);
|
||||||
void KeyEvent(UINT message, WPARAM wparam, LPARAM lparam);
|
void KeyEvent(UINT message, WPARAM wparam, LPARAM lparam);
|
||||||
void CaptureLostEvent();
|
void CaptureLostEvent();
|
||||||
void SetFocus(bool enable);
|
void SetFocus(bool enable);
|
||||||
|
|
||||||
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
#elif defined(OS_MACOSX)
|
#elif defined(OS_MACOSX)
|
||||||
// These need to be called from a non-subclass, so they need to be public.
|
// These need to be called from a non-subclass, so they need to be public.
|
||||||
public:
|
public:
|
||||||
void Resize(const gfx::Rect& rect);
|
void Resize(const gfx::Rect& rect);
|
||||||
void MouseEvent(NSEvent *);
|
void MouseEvent(NSEvent *);
|
||||||
void WheelEvent(NSEvent *);
|
void WheelEvent(NSEvent *);
|
||||||
void KeyEvent(NSEvent *);
|
void KeyEvent(NSEvent *);
|
||||||
void SetFocus(bool enable);
|
void SetFocus(bool enable);
|
||||||
protected:
|
protected:
|
||||||
#elif defined(OS_LINUX)
|
#elif defined(OS_LINUX)
|
||||||
public:
|
public:
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// This is needed on Linux because the GtkWidget creation is the same between
|
// This is needed on Linux because the GtkWidget creation is the same between
|
||||||
// both web view hosts and web widget hosts. The Windows code manages this by
|
// both web view hosts and web widget hosts. The Windows code manages this by
|
||||||
// reusing the WndProc function (static, above). However, GTK doesn't use a
|
// reusing the WndProc function (static, above). However, GTK doesn't use a
|
||||||
// single big callback function like that so we have a static function that
|
// single big callback function like that so we have a static function that
|
||||||
// sets up a GtkWidget correctly.
|
// sets up a GtkWidget correctly.
|
||||||
// parent: a GtkBox to pack the new widget at the end of
|
// parent: a GtkBox to pack the new widget at the end of
|
||||||
// host: a pointer to a WebWidgetHost (or subclass thereof)
|
// host: a pointer to a WebWidgetHost (or subclass thereof)
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
static gfx::NativeView CreateWindow(gfx::NativeView parent_view,
|
static gfx::NativeView CreateWindow(gfx::NativeView parent_view,
|
||||||
WebWidgetHost* host);
|
WebWidgetHost* host);
|
||||||
void WindowDestroyed();
|
void WindowDestroyed();
|
||||||
void Resize(const gfx::Size& size);
|
void Resize(const gfx::Size& size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void TrackMouseLeave(bool enable);
|
void TrackMouseLeave(bool enable);
|
||||||
void ResetScrollRect();
|
void ResetScrollRect();
|
||||||
void PaintRect(const gfx::Rect& rect);
|
void PaintRect(const gfx::Rect& rect);
|
||||||
|
|
||||||
void set_painting(bool value) {
|
void set_painting(bool value) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
painting_ = value;
|
painting_ = value;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::NativeView view_;
|
gfx::NativeView view_;
|
||||||
WebKit::WebWidget* webwidget_;
|
WebKit::WebWidget* webwidget_;
|
||||||
scoped_ptr<skia::PlatformCanvas> canvas_;
|
scoped_ptr<skia::PlatformCanvas> canvas_;
|
||||||
|
|
||||||
// specifies the portion of the webwidget that needs painting
|
// specifies the portion of the webwidget that needs painting
|
||||||
gfx::Rect paint_rect_;
|
gfx::Rect paint_rect_;
|
||||||
|
|
||||||
// specifies the portion of the webwidget that needs scrolling
|
// specifies the portion of the webwidget that needs scrolling
|
||||||
gfx::Rect scroll_rect_;
|
gfx::Rect scroll_rect_;
|
||||||
int scroll_dx_;
|
int scroll_dx_;
|
||||||
int scroll_dy_;
|
int scroll_dy_;
|
||||||
|
|
||||||
bool track_mouse_leave_;
|
bool track_mouse_leave_;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
bool painting_;
|
bool painting_;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _WEBWIDGET_HOST_H
|
#endif // _WEBWIDGET_HOST_H
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#ifdef BUILDING_CEF_SHARED
|
#ifdef BUILDING_CEF_SHARED
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#else
|
#else
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#define DCHECK(condition) assert(condition)
|
#define DCHECK(condition) assert(condition)
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
#include "cef.h"
|
#include "cef.h"
|
||||||
#include "cef_capi.h"
|
#include "cef_capi.h"
|
||||||
@ -17,7 +17,7 @@
|
|||||||
#include "cpptoc/v8value_cpptoc.h"
|
#include "cpptoc/v8value_cpptoc.h"
|
||||||
#include "ctocpp/handler_ctocpp.h"
|
#include "ctocpp/handler_ctocpp.h"
|
||||||
#include "ctocpp/v8handler_ctocpp.h"
|
#include "ctocpp/v8handler_ctocpp.h"
|
||||||
#include "base/string_util.h"
|
#include "base/string_util.h"
|
||||||
|
|
||||||
|
|
||||||
CEF_EXPORT int cef_initialize(int multi_threaded_message_loop,
|
CEF_EXPORT int cef_initialize(int multi_threaded_message_loop,
|
||||||
@ -33,7 +33,7 @@ CEF_EXPORT void cef_shutdown()
|
|||||||
{
|
{
|
||||||
CefShutdown();
|
CefShutdown();
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// Check that all wrapper objects have been destroyed
|
// Check that all wrapper objects have been destroyed
|
||||||
DCHECK(CefBrowserCppToC::DebugObjCt == 0);
|
DCHECK(CefBrowserCppToC::DebugObjCt == 0);
|
||||||
DCHECK(CefRequestCppToC::DebugObjCt == 0);
|
DCHECK(CefRequestCppToC::DebugObjCt == 0);
|
||||||
@ -44,7 +44,7 @@ CEF_EXPORT void cef_shutdown()
|
|||||||
DCHECK(CefV8ValueCppToC::DebugObjCt == 0);
|
DCHECK(CefV8ValueCppToC::DebugObjCt == 0);
|
||||||
DCHECK(CefHandlerCToCpp::DebugObjCt == 0);
|
DCHECK(CefHandlerCToCpp::DebugObjCt == 0);
|
||||||
DCHECK(CefV8HandlerCToCpp::DebugObjCt == 0);
|
DCHECK(CefV8HandlerCToCpp::DebugObjCt == 0);
|
||||||
#endif // _DEBUG
|
#endif // _DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
CEF_EXPORT void cef_do_message_loop_work()
|
CEF_EXPORT void cef_do_message_loop_work()
|
||||||
@ -81,24 +81,24 @@ CEF_EXPORT int cef_register_plugin(const cef_plugin_info_t* plugin_info)
|
|||||||
pluginInfo.version = plugin_info->version;
|
pluginInfo.version = plugin_info->version;
|
||||||
pluginInfo.description = plugin_info->description;
|
pluginInfo.description = plugin_info->description;
|
||||||
|
|
||||||
std::vector<std::wstring> mime_types, file_extensions;
|
std::vector<std::wstring> mime_types, file_extensions;
|
||||||
std::vector<std::wstring> descriptions;
|
std::vector<std::wstring> descriptions;
|
||||||
SplitString(plugin_info->mime_types, '|', &mime_types);
|
SplitString(plugin_info->mime_types, '|', &mime_types);
|
||||||
SplitString(plugin_info->file_extensions, '|', &file_extensions);
|
SplitString(plugin_info->file_extensions, '|', &file_extensions);
|
||||||
SplitString(plugin_info->type_descriptions, '|', &descriptions);
|
SplitString(plugin_info->type_descriptions, '|', &descriptions);
|
||||||
|
|
||||||
for (size_t i = 0; i < mime_types.size(); ++i) {
|
for (size_t i = 0; i < mime_types.size(); ++i) {
|
||||||
CefPluginMimeType mimeType;
|
CefPluginMimeType mimeType;
|
||||||
|
|
||||||
mimeType.mime_type = mime_types[i];
|
mimeType.mime_type = mime_types[i];
|
||||||
|
|
||||||
if (file_extensions.size() > i)
|
if (file_extensions.size() > i)
|
||||||
SplitString(file_extensions[i], ',', &mimeType.file_extensions);
|
SplitString(file_extensions[i], ',', &mimeType.file_extensions);
|
||||||
|
|
||||||
if (descriptions.size() > i)
|
if (descriptions.size() > i)
|
||||||
mimeType.description = descriptions[i];
|
mimeType.description = descriptions[i];
|
||||||
|
|
||||||
pluginInfo.mime_types.push_back(mimeType);
|
pluginInfo.mime_types.push_back(mimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginInfo.np_getentrypoints = plugin_info->np_getentrypoints;
|
pluginInfo.np_getentrypoints = plugin_info->np_getentrypoints;
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioPropertySheet
|
<VisualStudioPropertySheet
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="8.00"
|
Version="8.00"
|
||||||
Name="cefclient"
|
Name="cefclient"
|
||||||
InheritedPropertySheets="$(SolutionDir)libcef\libcef.vsprops;"
|
InheritedPropertySheets="$(SolutionDir)libcef\libcef.vsprops;"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalIncludeDirectories=""$(SolutionDir)\include";"$(OutDir)""
|
AdditionalIncludeDirectories=""$(SolutionDir)\include";"$(OutDir)""
|
||||||
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;BUILDING_CEF_SHARED"
|
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;BUILDING_CEF_SHARED"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies=""
|
AdditionalDependencies=""
|
||||||
AdditionalLibraryDirectories=""$(OutDir)""
|
AdditionalLibraryDirectories=""$(OutDir)""
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
AdditionalIncludeDirectories=""$(SolutionDir)";"$(IntDir)\..\""
|
AdditionalIncludeDirectories=""$(SolutionDir)";"$(IntDir)\..\""
|
||||||
/>
|
/>
|
||||||
</VisualStudioPropertySheet>
|
</VisualStudioPropertySheet>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "precompiled_libcef.h"
|
#include "precompiled_libcef.h"
|
||||||
@ -45,13 +45,13 @@ void transfer_string_map_contents(const std::map<std::wstring, std::wstring>& fr
|
|||||||
void transfer_string_contents(const std::wstring& fromString,
|
void transfer_string_contents(const std::wstring& fromString,
|
||||||
cef_string_t* toString)
|
cef_string_t* toString)
|
||||||
{
|
{
|
||||||
if(*toString == NULL || *toString != fromString) {
|
if(*toString == NULL || *toString != fromString) {
|
||||||
if(*toString) {
|
if(*toString) {
|
||||||
cef_string_free(*toString);
|
cef_string_free(*toString);
|
||||||
*toString = NULL;
|
*toString = NULL;
|
||||||
}
|
}
|
||||||
if(!fromString.empty())
|
if(!fromString.empty())
|
||||||
*toString = cef_string_alloc(fromString.c_str());
|
*toString = cef_string_alloc(fromString.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef _TRANSFER_UTIL_H
|
#ifndef _TRANSFER_UTIL_H
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "../precompiled_libcef.h"
|
#include "../precompiled_libcef.h"
|
||||||
#include "cef.h"
|
#include "cef.h"
|
||||||
#include "cef_capi.h"
|
#include "cef_capi.h"
|
||||||
@ -28,7 +28,7 @@ void CefShutdown()
|
|||||||
{
|
{
|
||||||
cef_shutdown();
|
cef_shutdown();
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// Check that all wrapper objects have been destroyed
|
// Check that all wrapper objects have been destroyed
|
||||||
DCHECK(CefHandlerCppToC::DebugObjCt == 0);
|
DCHECK(CefHandlerCppToC::DebugObjCt == 0);
|
||||||
DCHECK(CefV8HandlerCppToC::DebugObjCt == 0);
|
DCHECK(CefV8HandlerCppToC::DebugObjCt == 0);
|
||||||
@ -39,7 +39,7 @@ void CefShutdown()
|
|||||||
DCHECK(CefStreamReaderCToCpp::DebugObjCt == 0);
|
DCHECK(CefStreamReaderCToCpp::DebugObjCt == 0);
|
||||||
DCHECK(CefStreamWriterCToCpp::DebugObjCt == 0);
|
DCHECK(CefStreamWriterCToCpp::DebugObjCt == 0);
|
||||||
DCHECK(CefV8ValueCToCpp::DebugObjCt == 0);
|
DCHECK(CefV8ValueCToCpp::DebugObjCt == 0);
|
||||||
#endif // _DEBUG
|
#endif // _DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefDoMessageLoopWork()
|
void CefDoMessageLoopWork()
|
||||||
@ -59,38 +59,38 @@ bool CefRegisterPlugin(const struct CefPluginInfo& plugin_info)
|
|||||||
{
|
{
|
||||||
cef_plugin_info_t pluginInfo;
|
cef_plugin_info_t pluginInfo;
|
||||||
|
|
||||||
pluginInfo.unique_name = plugin_info.unique_name.c_str();
|
pluginInfo.unique_name = plugin_info.unique_name.c_str();
|
||||||
pluginInfo.display_name = plugin_info.display_name.c_str();
|
pluginInfo.display_name = plugin_info.display_name.c_str();
|
||||||
pluginInfo.version =plugin_info.version.c_str();
|
pluginInfo.version =plugin_info.version.c_str();
|
||||||
pluginInfo.description = plugin_info.description.c_str();
|
pluginInfo.description = plugin_info.description.c_str();
|
||||||
|
|
||||||
std::wstring mimeTypes, fileExtensions, typeDescriptions;
|
std::wstring mimeTypes, fileExtensions, typeDescriptions;
|
||||||
|
|
||||||
for(size_t i = 0; i < plugin_info.mime_types.size(); ++i) {
|
for(size_t i = 0; i < plugin_info.mime_types.size(); ++i) {
|
||||||
if(i > 0) {
|
if(i > 0) {
|
||||||
mimeTypes += L"|";
|
mimeTypes += L"|";
|
||||||
fileExtensions += L"|";
|
fileExtensions += L"|";
|
||||||
typeDescriptions += L"|";
|
typeDescriptions += L"|";
|
||||||
}
|
}
|
||||||
|
|
||||||
mimeTypes += plugin_info.mime_types[i].mime_type;
|
mimeTypes += plugin_info.mime_types[i].mime_type;
|
||||||
typeDescriptions += plugin_info.mime_types[i].description;
|
typeDescriptions += plugin_info.mime_types[i].description;
|
||||||
|
|
||||||
for(size_t j = 0;
|
for(size_t j = 0;
|
||||||
j < plugin_info.mime_types[i].file_extensions.size(); ++j) {
|
j < plugin_info.mime_types[i].file_extensions.size(); ++j) {
|
||||||
if(j > 0) {
|
if(j > 0) {
|
||||||
fileExtensions += L",";
|
fileExtensions += L",";
|
||||||
}
|
}
|
||||||
fileExtensions += plugin_info.mime_types[i].file_extensions[j];
|
fileExtensions += plugin_info.mime_types[i].file_extensions[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginInfo.mime_types = mimeTypes.c_str();
|
pluginInfo.mime_types = mimeTypes.c_str();
|
||||||
pluginInfo.file_extensions = fileExtensions.c_str();
|
pluginInfo.file_extensions = fileExtensions.c_str();
|
||||||
pluginInfo.type_descriptions = typeDescriptions.c_str();
|
pluginInfo.type_descriptions = typeDescriptions.c_str();
|
||||||
|
|
||||||
pluginInfo.np_getentrypoints = plugin_info.np_getentrypoints;
|
pluginInfo.np_getentrypoints = plugin_info.np_getentrypoints;
|
||||||
pluginInfo.np_initialize = plugin_info.np_initialize;
|
pluginInfo.np_initialize = plugin_info.np_initialize;
|
||||||
pluginInfo.np_shutdown = plugin_info.np_shutdown;
|
pluginInfo.np_shutdown = plugin_info.np_shutdown;
|
||||||
|
|
||||||
return (cef_register_plugin(&pluginInfo) ? true : false);
|
return (cef_register_plugin(&pluginInfo) ? true : false);
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioPropertySheet
|
<VisualStudioPropertySheet
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="8.00"
|
Version="8.00"
|
||||||
Name="libcef_dll_wrapper"
|
Name="libcef_dll_wrapper"
|
||||||
InheritedPropertySheets="$(SolutionDir)libcef\libcef.vsprops;"
|
InheritedPropertySheets="$(SolutionDir)libcef\libcef.vsprops;"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalIncludeDirectories=""$(SolutionDir)\include";"$(OutDir)";"..\""
|
AdditionalIncludeDirectories=""$(SolutionDir)\include";"$(OutDir)";"..\""
|
||||||
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;USING_CEF_SHARED"
|
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;USING_CEF_SHARED"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="comctl32.lib shlwapi.lib rpcrt4.lib winmm.lib"
|
AdditionalDependencies="comctl32.lib shlwapi.lib rpcrt4.lib winmm.lib"
|
||||||
AdditionalLibraryDirectories=""$(OutDir)""
|
AdditionalLibraryDirectories=""$(OutDir)""
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
AdditionalIncludeDirectories=""$(SolutionDir)";"$(IntDir)\..\""
|
AdditionalIncludeDirectories=""$(SolutionDir)";"$(IntDir)\..\""
|
||||||
/>
|
/>
|
||||||
</VisualStudioPropertySheet>
|
</VisualStudioPropertySheet>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. All rights
|
// 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
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "cefclient.h"
|
#include "cefclient.h"
|
||||||
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#define MAX_LOADSTRING 100
|
#define MAX_LOADSTRING 100
|
||||||
#define MAX_URL_LENGTH 255
|
#define MAX_URL_LENGTH 255
|
||||||
#define BUTTON_WIDTH 72
|
#define BUTTON_WIDTH 72
|
||||||
#define URLBAR_HEIGHT 24
|
#define URLBAR_HEIGHT 24
|
||||||
|
|
||||||
// Define this value to run CEF with messages processed using the current
|
// Define this value to run CEF with messages processed using the current
|
||||||
@ -135,24 +135,24 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
|||||||
|
|
||||||
// Register a V8 extension with the below JavaScript code that calls native
|
// Register a V8 extension with the below JavaScript code that calls native
|
||||||
// methods implemented in ClientV8ExtensionHandler.
|
// methods implemented in ClientV8ExtensionHandler.
|
||||||
std::wstring code = L"var cef;"
|
std::wstring code = L"var cef;"
|
||||||
L"if (!cef)"
|
L"if (!cef)"
|
||||||
L" cef = {};"
|
L" cef = {};"
|
||||||
L"if (!cef.test)"
|
L"if (!cef.test)"
|
||||||
L" cef.test = {};"
|
L" cef.test = {};"
|
||||||
L"(function() {"
|
L"(function() {"
|
||||||
L" cef.test.__defineGetter__('test_param', function() {"
|
L" cef.test.__defineGetter__('test_param', function() {"
|
||||||
L" native function GetTestParam();"
|
L" native function GetTestParam();"
|
||||||
L" return GetTestParam();"
|
L" return GetTestParam();"
|
||||||
L" });"
|
L" });"
|
||||||
L" cef.test.__defineSetter__('test_param', function(b) {"
|
L" cef.test.__defineSetter__('test_param', function(b) {"
|
||||||
L" native function SetTestParam();"
|
L" native function SetTestParam();"
|
||||||
L" if(b) SetTestParam(b);"
|
L" if(b) SetTestParam(b);"
|
||||||
L" });"
|
L" });"
|
||||||
L" cef.test.test_object = function() {"
|
L" cef.test.test_object = function() {"
|
||||||
L" native function GetTestObject();"
|
L" native function GetTestObject();"
|
||||||
L" return GetTestObject();"
|
L" return GetTestObject();"
|
||||||
L" };"
|
L" };"
|
||||||
L"})();";
|
L"})();";
|
||||||
CefRegisterExtension(L"v8/test", code, new ClientV8ExtensionHandler());
|
CefRegisterExtension(L"v8/test", code, new ClientV8ExtensionHandler());
|
||||||
|
|
||||||
@ -704,33 +704,33 @@ public:
|
|||||||
// or RV_HANDLED if you displayed a custom alert.
|
// or RV_HANDLED if you displayed a custom alert.
|
||||||
virtual RetVal HandleJSAlert(CefRefPtr<CefBrowser> browser,
|
virtual RetVal HandleJSAlert(CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
const std::wstring& message)
|
const std::wstring& message)
|
||||||
{
|
{
|
||||||
return RV_CONTINUE;
|
return RV_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run a JS confirm request. Return RV_CONTINUE to display the default alert
|
// Run a JS confirm request. Return RV_CONTINUE to display the default alert
|
||||||
// or RV_HANDLED if you displayed a custom alert. If you handled the alert
|
// or RV_HANDLED if you displayed a custom alert. If you handled the alert
|
||||||
// set |retval| to true if the user accepted the confirmation.
|
// set |retval| to true if the user accepted the confirmation.
|
||||||
virtual RetVal HandleJSConfirm(CefRefPtr<CefBrowser> browser,
|
virtual RetVal HandleJSConfirm(CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
const std::wstring& message, bool& retval)
|
const std::wstring& message, bool& retval)
|
||||||
{
|
{
|
||||||
return RV_CONTINUE;
|
return RV_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run a JS prompt request. Return RV_CONTINUE to display the default prompt
|
// Run a JS prompt request. Return RV_CONTINUE to display the default prompt
|
||||||
// or RV_HANDLED if you displayed a custom prompt. If you handled the prompt
|
// or RV_HANDLED if you displayed a custom prompt. If you handled the prompt
|
||||||
// set |retval| to true if the user accepted the prompt and request and
|
// set |retval| to true if the user accepted the prompt and request and
|
||||||
// |result| to the resulting value.
|
// |result| to the resulting value.
|
||||||
virtual RetVal HandleJSPrompt(CefRefPtr<CefBrowser> browser,
|
virtual RetVal HandleJSPrompt(CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
const std::wstring& message,
|
const std::wstring& message,
|
||||||
const std::wstring& defaultValue,
|
const std::wstring& defaultValue,
|
||||||
bool& retval,
|
bool& retval,
|
||||||
std::wstring& result)
|
std::wstring& result)
|
||||||
{
|
{
|
||||||
return RV_CONTINUE;
|
return RV_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called just before a window is closed. The return value is currently
|
// Called just before a window is closed. The return value is currently
|
||||||
@ -863,25 +863,25 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
if(hWnd == editWnd)
|
if(hWnd == editWnd)
|
||||||
{
|
{
|
||||||
// Callback for the edit window
|
// Callback for the edit window
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_CHAR:
|
case WM_CHAR:
|
||||||
if (wParam == VK_RETURN && handler.get())
|
if (wParam == VK_RETURN && handler.get())
|
||||||
{
|
{
|
||||||
// When the user hits the enter key load the URL
|
// When the user hits the enter key load the URL
|
||||||
CefRefPtr<CefBrowser> browser = handler->GetBrowser();
|
CefRefPtr<CefBrowser> browser = handler->GetBrowser();
|
||||||
wchar_t strPtr[MAX_URL_LENGTH] = {0};
|
wchar_t strPtr[MAX_URL_LENGTH] = {0};
|
||||||
*((LPWORD)strPtr) = MAX_URL_LENGTH;
|
*((LPWORD)strPtr) = MAX_URL_LENGTH;
|
||||||
LRESULT strLen = SendMessage(hWnd, EM_GETLINE, 0, (LPARAM)strPtr);
|
LRESULT strLen = SendMessage(hWnd, EM_GETLINE, 0, (LPARAM)strPtr);
|
||||||
if (strLen > 0) {
|
if (strLen > 0) {
|
||||||
strPtr[strLen] = 0;
|
strPtr[strLen] = 0;
|
||||||
browser->GetMainFrame()->LoadURL(strPtr);
|
browser->GetMainFrame()->LoadURL(strPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (LRESULT)CallWindowProc(editWndOldProc, hWnd, message, wParam, lParam);
|
return (LRESULT)CallWindowProc(editWndOldProc, hWnd, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -897,46 +897,46 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
// Create the child windows used for navigation
|
// Create the child windows used for navigation
|
||||||
RECT rect;
|
RECT rect;
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
|
||||||
GetClientRect(hWnd, &rect);
|
GetClientRect(hWnd, &rect);
|
||||||
|
|
||||||
backWnd = CreateWindow(L"BUTTON", L"Back",
|
backWnd = CreateWindow(L"BUTTON", L"Back",
|
||||||
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
||||||
| WS_DISABLED, x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
|
| WS_DISABLED, x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
|
||||||
hWnd, (HMENU) IDC_NAV_BACK, hInst, 0);
|
hWnd, (HMENU) IDC_NAV_BACK, hInst, 0);
|
||||||
x += BUTTON_WIDTH;
|
x += BUTTON_WIDTH;
|
||||||
|
|
||||||
forwardWnd = CreateWindow(L"BUTTON", L"Forward",
|
forwardWnd = CreateWindow(L"BUTTON", L"Forward",
|
||||||
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
||||||
| WS_DISABLED, x, 0, BUTTON_WIDTH,
|
| WS_DISABLED, x, 0, BUTTON_WIDTH,
|
||||||
URLBAR_HEIGHT, hWnd, (HMENU) IDC_NAV_FORWARD,
|
URLBAR_HEIGHT, hWnd, (HMENU) IDC_NAV_FORWARD,
|
||||||
hInst, 0);
|
hInst, 0);
|
||||||
x += BUTTON_WIDTH;
|
x += BUTTON_WIDTH;
|
||||||
|
|
||||||
reloadWnd = CreateWindow(L"BUTTON", L"Reload",
|
reloadWnd = CreateWindow(L"BUTTON", L"Reload",
|
||||||
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
||||||
| WS_DISABLED, x, 0, BUTTON_WIDTH,
|
| WS_DISABLED, x, 0, BUTTON_WIDTH,
|
||||||
URLBAR_HEIGHT, hWnd, (HMENU) IDC_NAV_RELOAD,
|
URLBAR_HEIGHT, hWnd, (HMENU) IDC_NAV_RELOAD,
|
||||||
hInst, 0);
|
hInst, 0);
|
||||||
x += BUTTON_WIDTH;
|
x += BUTTON_WIDTH;
|
||||||
|
|
||||||
stopWnd = CreateWindow(L"BUTTON", L"Stop",
|
stopWnd = CreateWindow(L"BUTTON", L"Stop",
|
||||||
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
||||||
| WS_DISABLED, x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
|
| WS_DISABLED, x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
|
||||||
hWnd, (HMENU) IDC_NAV_STOP, hInst, 0);
|
hWnd, (HMENU) IDC_NAV_STOP, hInst, 0);
|
||||||
x += BUTTON_WIDTH;
|
x += BUTTON_WIDTH;
|
||||||
|
|
||||||
editWnd = CreateWindow(L"EDIT", 0,
|
editWnd = CreateWindow(L"EDIT", 0,
|
||||||
WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT |
|
WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT |
|
||||||
ES_AUTOVSCROLL | ES_AUTOHSCROLL| WS_DISABLED,
|
ES_AUTOVSCROLL | ES_AUTOHSCROLL| WS_DISABLED,
|
||||||
x, 0, rect.right - BUTTON_WIDTH * 4,
|
x, 0, rect.right - BUTTON_WIDTH * 4,
|
||||||
URLBAR_HEIGHT, hWnd, 0, hInst, 0);
|
URLBAR_HEIGHT, hWnd, 0, hInst, 0);
|
||||||
|
|
||||||
// Assign the edit window's WNDPROC to this function so that we can
|
// Assign the edit window's WNDPROC to this function so that we can
|
||||||
// capture the enter key
|
// capture the enter key
|
||||||
editWndOldProc =
|
editWndOldProc =
|
||||||
reinterpret_cast<WNDPROC>(GetWindowLongPtr(editWnd, GWLP_WNDPROC));
|
reinterpret_cast<WNDPROC>(GetWindowLongPtr(editWnd, GWLP_WNDPROC));
|
||||||
SetWindowLongPtr(editWnd, GWLP_WNDPROC,
|
SetWindowLongPtr(editWnd, GWLP_WNDPROC,
|
||||||
reinterpret_cast<LONG_PTR>(WndProc));
|
reinterpret_cast<LONG_PTR>(WndProc));
|
||||||
handler->SetEditHwnd(editWnd);
|
handler->SetEditHwnd(editWnd);
|
||||||
@ -1148,14 +1148,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_ERASEBKGND:
|
case WM_ERASEBKGND:
|
||||||
if(handler.get() && handler->GetBrowserHwnd())
|
if(handler.get() && handler->GetBrowserHwnd())
|
||||||
{
|
{
|
||||||
// Dont erase the background if the browser window has been loaded
|
// Dont erase the background if the browser window has been loaded
|
||||||
// (this avoids flashing)
|
// (this avoids flashing)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
// The frame window has exited
|
// The frame window has exited
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioPropertySheet
|
<VisualStudioPropertySheet
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="8.00"
|
Version="8.00"
|
||||||
Name="cefclient"
|
Name="cefclient"
|
||||||
InheritedPropertySheets="$(SolutionDir)libcef\libcef.vsprops;"
|
InheritedPropertySheets="$(SolutionDir)libcef\libcef.vsprops;"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalIncludeDirectories=""$(SolutionDir)\include";"$(OutDir)""
|
AdditionalIncludeDirectories=""$(SolutionDir)\include";"$(OutDir)""
|
||||||
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE"
|
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="comctl32.lib shlwapi.lib rpcrt4.lib winmm.lib"
|
AdditionalDependencies="comctl32.lib shlwapi.lib rpcrt4.lib winmm.lib"
|
||||||
AdditionalLibraryDirectories=""$(OutDir)""
|
AdditionalLibraryDirectories=""$(OutDir)""
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
AdditionalIncludeDirectories=""$(SolutionDir)";"$(IntDir)\..\""
|
AdditionalIncludeDirectories=""$(SolutionDir)";"$(IntDir)\..\""
|
||||||
/>
|
/>
|
||||||
</VisualStudioPropertySheet>
|
</VisualStudioPropertySheet>
|
||||||
|
@ -1,185 +1,185 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "clientplugin.h"
|
#include "clientplugin.h"
|
||||||
|
|
||||||
// Initialized in NP_Initialize.
|
// Initialized in NP_Initialize.
|
||||||
NPNetscapeFuncs* g_browser = NULL;
|
NPNetscapeFuncs* g_browser = NULL;
|
||||||
|
|
||||||
|
|
||||||
NPError NPP_New(NPMIMEType plugin_type, NPP instance, uint16 mode, int16 argc,
|
|
||||||
char* argn[], char* argv[], NPSavedData* saved) {
|
|
||||||
if (instance == NULL)
|
|
||||||
return NPERR_INVALID_INSTANCE_ERROR;
|
|
||||||
|
|
||||||
ClientPlugin* plugin_impl = new ClientPlugin(mode);
|
|
||||||
plugin_impl->Initialize(GetModuleHandle(NULL), instance, plugin_type, argc,
|
|
||||||
argn, argv);
|
|
||||||
instance->pdata = reinterpret_cast<void*>(plugin_impl);
|
|
||||||
return NPERR_NO_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
NPError NPP_Destroy(NPP instance, NPSavedData** save) {
|
|
||||||
ClientPlugin* plugin_impl = reinterpret_cast<ClientPlugin*>(instance->pdata);
|
|
||||||
|
|
||||||
if (plugin_impl) {
|
|
||||||
plugin_impl->Shutdown();
|
|
||||||
delete plugin_impl;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NPERR_NO_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
NPError NPP_SetWindow(NPP instance, NPWindow* window_info) {
|
|
||||||
if (instance == NULL)
|
|
||||||
return NPERR_INVALID_INSTANCE_ERROR;
|
|
||||||
|
|
||||||
if (window_info == NULL)
|
|
||||||
return NPERR_GENERIC_ERROR;
|
|
||||||
|
|
||||||
ClientPlugin* plugin_impl = reinterpret_cast<ClientPlugin*>(instance->pdata);
|
|
||||||
|
|
||||||
if (plugin_impl == NULL)
|
|
||||||
return NPERR_GENERIC_ERROR;
|
|
||||||
|
|
||||||
HWND window_handle = reinterpret_cast<HWND>(window_info->window);
|
|
||||||
if (!plugin_impl->SetWindow(window_handle)) {
|
|
||||||
delete plugin_impl;
|
|
||||||
return NPERR_GENERIC_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NPERR_NO_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* pFuncs)
|
NPError NPP_New(NPMIMEType plugin_type, NPP instance, uint16 mode, int16 argc,
|
||||||
{
|
char* argn[], char* argv[], NPSavedData* saved) {
|
||||||
pFuncs->newp = NPP_New;
|
if (instance == NULL)
|
||||||
pFuncs->destroy = NPP_Destroy;
|
return NPERR_INVALID_INSTANCE_ERROR;
|
||||||
pFuncs->setwindow = NPP_SetWindow;
|
|
||||||
return NPERR_NO_ERROR;
|
ClientPlugin* plugin_impl = new ClientPlugin(mode);
|
||||||
}
|
plugin_impl->Initialize(GetModuleHandle(NULL), instance, plugin_type, argc,
|
||||||
|
argn, argv);
|
||||||
NPError API_CALL NP_Initialize(NPNetscapeFuncs* pFuncs)
|
instance->pdata = reinterpret_cast<void*>(plugin_impl);
|
||||||
{
|
return NPERR_NO_ERROR;
|
||||||
g_browser = pFuncs;
|
}
|
||||||
return NPERR_NO_ERROR;
|
|
||||||
}
|
NPError NPP_Destroy(NPP instance, NPSavedData** save) {
|
||||||
|
ClientPlugin* plugin_impl = reinterpret_cast<ClientPlugin*>(instance->pdata);
|
||||||
NPError API_CALL NP_Shutdown(void)
|
|
||||||
{
|
if (plugin_impl) {
|
||||||
g_browser = NULL;
|
plugin_impl->Shutdown();
|
||||||
return NPERR_NO_ERROR;
|
delete plugin_impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return NPERR_NO_ERROR;
|
||||||
// ClientPlugin Implementation
|
}
|
||||||
|
|
||||||
ClientPlugin::ClientPlugin(int16 mode)
|
NPError NPP_SetWindow(NPP instance, NPWindow* window_info) {
|
||||||
: mode_(mode)
|
if (instance == NULL)
|
||||||
{
|
return NPERR_INVALID_INSTANCE_ERROR;
|
||||||
}
|
|
||||||
|
if (window_info == NULL)
|
||||||
ClientPlugin::~ClientPlugin()
|
return NPERR_GENERIC_ERROR;
|
||||||
{
|
|
||||||
}
|
ClientPlugin* plugin_impl = reinterpret_cast<ClientPlugin*>(instance->pdata);
|
||||||
|
|
||||||
bool ClientPlugin::Initialize(HINSTANCE module_handle, NPP instance,
|
if (plugin_impl == NULL)
|
||||||
NPMIMEType mime_type, int16 argc, char* argn[],
|
return NPERR_GENERIC_ERROR;
|
||||||
char* argv[])
|
|
||||||
{
|
HWND window_handle = reinterpret_cast<HWND>(window_info->window);
|
||||||
RefreshDisplay();
|
if (!plugin_impl->SetWindow(window_handle)) {
|
||||||
return true;
|
delete plugin_impl;
|
||||||
}
|
return NPERR_GENERIC_ERROR;
|
||||||
|
}
|
||||||
bool ClientPlugin::SetWindow(HWND parent_window)
|
|
||||||
{
|
return NPERR_NO_ERROR;
|
||||||
if (!::IsWindow(parent_window)) {
|
}
|
||||||
// No window created yet. Ignore this call.
|
|
||||||
if (!IsWindow())
|
NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* pFuncs)
|
||||||
return true;
|
{
|
||||||
// Parent window has been destroyed.
|
pFuncs->newp = NPP_New;
|
||||||
Shutdown();
|
pFuncs->destroy = NPP_Destroy;
|
||||||
return true;
|
pFuncs->setwindow = NPP_SetWindow;
|
||||||
}
|
return NPERR_NO_ERROR;
|
||||||
|
}
|
||||||
RECT parent_rect;
|
|
||||||
|
NPError API_CALL NP_Initialize(NPNetscapeFuncs* pFuncs)
|
||||||
if (IsWindow()) {
|
{
|
||||||
::GetClientRect(parent_window, &parent_rect);
|
g_browser = pFuncs;
|
||||||
SetWindowPos(NULL, &parent_rect, SWP_SHOWWINDOW);
|
return NPERR_NO_ERROR;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
// First time in -- no window created by plugin yet.
|
NPError API_CALL NP_Shutdown(void)
|
||||||
::GetClientRect(parent_window, &parent_rect);
|
{
|
||||||
Create(parent_window, parent_rect, NULL, WS_CHILD | WS_BORDER);
|
g_browser = NULL;
|
||||||
|
return NPERR_NO_ERROR;
|
||||||
UpdateWindow();
|
}
|
||||||
ShowWindow(SW_SHOW);
|
|
||||||
|
|
||||||
return true;
|
// ClientPlugin Implementation
|
||||||
}
|
|
||||||
|
ClientPlugin::ClientPlugin(int16 mode)
|
||||||
void ClientPlugin::Shutdown()
|
: mode_(mode)
|
||||||
{
|
{
|
||||||
if (IsWindow()) {
|
}
|
||||||
DestroyWindow();
|
|
||||||
}
|
ClientPlugin::~ClientPlugin()
|
||||||
}
|
{
|
||||||
|
}
|
||||||
LRESULT ClientPlugin::OnPaint(UINT message, WPARAM wparam, LPARAM lparam,
|
|
||||||
BOOL& handled)
|
bool ClientPlugin::Initialize(HINSTANCE module_handle, NPP instance,
|
||||||
{
|
NPMIMEType mime_type, int16 argc, char* argn[],
|
||||||
static LPCWSTR text = L"Left click in the green area for a message box!";
|
char* argv[])
|
||||||
|
{
|
||||||
PAINTSTRUCT paint_struct;
|
RefreshDisplay();
|
||||||
BeginPaint(&paint_struct);
|
return true;
|
||||||
|
}
|
||||||
RECT client_rect;
|
|
||||||
GetClientRect(&client_rect);
|
bool ClientPlugin::SetWindow(HWND parent_window)
|
||||||
|
{
|
||||||
int old_mode = SetBkMode(paint_struct.hdc, TRANSPARENT);
|
if (!::IsWindow(parent_window)) {
|
||||||
COLORREF old_color = SetTextColor(paint_struct.hdc, RGB(0, 0, 255));
|
// No window created yet. Ignore this call.
|
||||||
|
if (!IsWindow())
|
||||||
RECT text_rect = client_rect;
|
return true;
|
||||||
DrawText(paint_struct.hdc, text, -1, &text_rect, DT_CENTER | DT_CALCRECT);
|
// Parent window has been destroyed.
|
||||||
|
Shutdown();
|
||||||
client_rect.top = ((client_rect.bottom - client_rect.top)
|
return true;
|
||||||
- (text_rect.bottom - text_rect.top)) / 2;
|
}
|
||||||
DrawText(paint_struct.hdc, text, -1, &client_rect, DT_CENTER);
|
|
||||||
|
RECT parent_rect;
|
||||||
SetBkMode(paint_struct.hdc, old_mode);
|
|
||||||
SetTextColor(paint_struct.hdc, old_color);
|
if (IsWindow()) {
|
||||||
|
::GetClientRect(parent_window, &parent_rect);
|
||||||
EndPaint(&paint_struct);
|
SetWindowPos(NULL, &parent_rect, SWP_SHOWWINDOW);
|
||||||
return 0;
|
return true;
|
||||||
}
|
}
|
||||||
|
// First time in -- no window created by plugin yet.
|
||||||
LRESULT ClientPlugin::OnEraseBackGround(UINT message, WPARAM wparam,
|
::GetClientRect(parent_window, &parent_rect);
|
||||||
LPARAM lparam, BOOL& handled)
|
Create(parent_window, parent_rect, NULL, WS_CHILD | WS_BORDER);
|
||||||
{
|
|
||||||
HDC paint_device_context = reinterpret_cast<HDC>(wparam);
|
UpdateWindow();
|
||||||
RECT erase_rect;
|
ShowWindow(SW_SHOW);
|
||||||
GetClipBox(paint_device_context, &erase_rect);
|
|
||||||
HBRUSH brush = CreateSolidBrush(RGB(0, 255, 0));
|
return true;
|
||||||
FillRect(paint_device_context, &erase_rect, brush);
|
}
|
||||||
DeleteObject(brush);
|
|
||||||
return 1;
|
void ClientPlugin::Shutdown()
|
||||||
}
|
{
|
||||||
|
if (IsWindow()) {
|
||||||
LRESULT ClientPlugin::OnLButtonDown(UINT message, WPARAM wparam, LPARAM lparam,
|
DestroyWindow();
|
||||||
BOOL& handled)
|
}
|
||||||
{
|
}
|
||||||
MessageBox(L"You clicked on the client plugin!", L"Client Plugin", MB_OK);
|
|
||||||
return 0;
|
LRESULT ClientPlugin::OnPaint(UINT message, WPARAM wparam, LPARAM lparam,
|
||||||
}
|
BOOL& handled)
|
||||||
|
{
|
||||||
void ClientPlugin::RefreshDisplay() {
|
static LPCWSTR text = L"Left click in the green area for a message box!";
|
||||||
if (!IsWindow())
|
|
||||||
return;
|
PAINTSTRUCT paint_struct;
|
||||||
|
BeginPaint(&paint_struct);
|
||||||
InvalidateRect(NULL, TRUE);
|
|
||||||
UpdateWindow();
|
RECT client_rect;
|
||||||
}
|
GetClientRect(&client_rect);
|
||||||
|
|
||||||
|
int old_mode = SetBkMode(paint_struct.hdc, TRANSPARENT);
|
||||||
|
COLORREF old_color = SetTextColor(paint_struct.hdc, RGB(0, 0, 255));
|
||||||
|
|
||||||
|
RECT text_rect = client_rect;
|
||||||
|
DrawText(paint_struct.hdc, text, -1, &text_rect, DT_CENTER | DT_CALCRECT);
|
||||||
|
|
||||||
|
client_rect.top = ((client_rect.bottom - client_rect.top)
|
||||||
|
- (text_rect.bottom - text_rect.top)) / 2;
|
||||||
|
DrawText(paint_struct.hdc, text, -1, &client_rect, DT_CENTER);
|
||||||
|
|
||||||
|
SetBkMode(paint_struct.hdc, old_mode);
|
||||||
|
SetTextColor(paint_struct.hdc, old_color);
|
||||||
|
|
||||||
|
EndPaint(&paint_struct);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT ClientPlugin::OnEraseBackGround(UINT message, WPARAM wparam,
|
||||||
|
LPARAM lparam, BOOL& handled)
|
||||||
|
{
|
||||||
|
HDC paint_device_context = reinterpret_cast<HDC>(wparam);
|
||||||
|
RECT erase_rect;
|
||||||
|
GetClipBox(paint_device_context, &erase_rect);
|
||||||
|
HBRUSH brush = CreateSolidBrush(RGB(0, 255, 0));
|
||||||
|
FillRect(paint_device_context, &erase_rect, brush);
|
||||||
|
DeleteObject(brush);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT ClientPlugin::OnLButtonDown(UINT message, WPARAM wparam, LPARAM lparam,
|
||||||
|
BOOL& handled)
|
||||||
|
{
|
||||||
|
MessageBox(L"You clicked on the client plugin!", L"Client Plugin", MB_OK);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClientPlugin::RefreshDisplay() {
|
||||||
|
if (!IsWindow())
|
||||||
|
return;
|
||||||
|
|
||||||
|
InvalidateRect(NULL, TRUE);
|
||||||
|
UpdateWindow();
|
||||||
|
}
|
||||||
|
@ -1,88 +1,88 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// Portions of this implementation are borrowed from webkit\default_plugin\
|
// Portions of this implementation are borrowed from webkit\default_plugin\
|
||||||
// plugin_impl.h
|
// plugin_impl.h
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <atlbase.h>
|
#include <atlbase.h>
|
||||||
#include <atlwin.h>
|
#include <atlwin.h>
|
||||||
#include "cef_nplugin.h"
|
#include "cef_nplugin.h"
|
||||||
|
|
||||||
extern NPNetscapeFuncs* g_browser;
|
extern NPNetscapeFuncs* g_browser;
|
||||||
|
|
||||||
NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* pFuncs);
|
NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* pFuncs);
|
||||||
NPError API_CALL NP_Initialize(NPNetscapeFuncs* pFuncs);
|
NPError API_CALL NP_Initialize(NPNetscapeFuncs* pFuncs);
|
||||||
NPError API_CALL NP_Shutdown(void);
|
NPError API_CALL NP_Shutdown(void);
|
||||||
|
|
||||||
|
|
||||||
// Provides the client plugin functionality.
|
// Provides the client plugin functionality.
|
||||||
class ClientPlugin : public CWindowImpl<ClientPlugin> {
|
class ClientPlugin : public CWindowImpl<ClientPlugin> {
|
||||||
public:
|
public:
|
||||||
// mode is the plugin instantiation mode, i.e. whether it is a full
|
// mode is the plugin instantiation mode, i.e. whether it is a full
|
||||||
// page plugin (NP_FULL) or an embedded plugin (NP_EMBED)
|
// page plugin (NP_FULL) or an embedded plugin (NP_EMBED)
|
||||||
explicit ClientPlugin(int16 mode);
|
explicit ClientPlugin(int16 mode);
|
||||||
virtual ~ClientPlugin();
|
virtual ~ClientPlugin();
|
||||||
|
|
||||||
BEGIN_MSG_MAP(ClientPlugin)
|
BEGIN_MSG_MAP(ClientPlugin)
|
||||||
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackGround)
|
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackGround)
|
||||||
MESSAGE_HANDLER(WM_PAINT, OnPaint)
|
MESSAGE_HANDLER(WM_PAINT, OnPaint)
|
||||||
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
|
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
|
||||||
END_MSG_MAP()
|
END_MSG_MAP()
|
||||||
|
|
||||||
// Initializes the plugin with the instance information, mime type
|
// Initializes the plugin with the instance information, mime type
|
||||||
// and the list of parameters passed down to the plugin from the webpage.
|
// and the list of parameters passed down to the plugin from the webpage.
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// module_handle
|
// module_handle
|
||||||
// The handle to the dll in which this object is instantiated.
|
// The handle to the dll in which this object is instantiated.
|
||||||
// instance
|
// instance
|
||||||
// The plugins opaque instance handle.
|
// The plugins opaque instance handle.
|
||||||
// mime_type
|
// mime_type
|
||||||
// Identifies the third party plugin which would be eventually installed.
|
// Identifies the third party plugin which would be eventually installed.
|
||||||
// argc
|
// argc
|
||||||
// Indicates the count of arguments passed in from the webpage.
|
// Indicates the count of arguments passed in from the webpage.
|
||||||
// argv
|
// argv
|
||||||
// Pointer to the arguments.
|
// Pointer to the arguments.
|
||||||
// Returns true on success.
|
// Returns true on success.
|
||||||
bool Initialize(HINSTANCE module_handle, NPP instance, NPMIMEType mime_type,
|
bool Initialize(HINSTANCE module_handle, NPP instance, NPMIMEType mime_type,
|
||||||
int16 argc, char* argn[], char* argv[]);
|
int16 argc, char* argn[], char* argv[]);
|
||||||
|
|
||||||
// Displays the default plugin UI.
|
// Displays the default plugin UI.
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// parent_window
|
// parent_window
|
||||||
// Handle to the parent window.
|
// Handle to the parent window.
|
||||||
bool SetWindow(HWND parent_window);
|
bool SetWindow(HWND parent_window);
|
||||||
|
|
||||||
// Destroys the install dialog and the plugin window.
|
// Destroys the install dialog and the plugin window.
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
HWND window() const { return m_hWnd; }
|
HWND window() const { return m_hWnd; }
|
||||||
|
|
||||||
// Getter for the NPP instance member.
|
// Getter for the NPP instance member.
|
||||||
const NPP instance() const {
|
const NPP instance() const {
|
||||||
return instance_;
|
return instance_;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Window message handlers.
|
// Window message handlers.
|
||||||
LRESULT OnPaint(UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled);
|
LRESULT OnPaint(UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled);
|
||||||
LRESULT OnEraseBackGround(UINT message, WPARAM wparam, LPARAM lparam,
|
LRESULT OnEraseBackGround(UINT message, WPARAM wparam, LPARAM lparam,
|
||||||
BOOL& handled);
|
BOOL& handled);
|
||||||
LRESULT OnLButtonDown(UINT message, WPARAM wparam, LPARAM lparam,
|
LRESULT OnLButtonDown(UINT message, WPARAM wparam, LPARAM lparam,
|
||||||
BOOL& handled);
|
BOOL& handled);
|
||||||
|
|
||||||
// Enables the plugin window if required and initiates an update of the
|
// Enables the plugin window if required and initiates an update of the
|
||||||
// the plugin window.
|
// the plugin window.
|
||||||
void RefreshDisplay();
|
void RefreshDisplay();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The plugins opaque instance handle
|
// The plugins opaque instance handle
|
||||||
NPP instance_;
|
NPP instance_;
|
||||||
// The plugin instantiation mode (NP_FULL or NP_EMBED)
|
// The plugin instantiation mode (NP_FULL or NP_EMBED)
|
||||||
int16 mode_;
|
int16 mode_;
|
||||||
};
|
};
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
//{{NO_DEPENDENCIES}}
|
//{{NO_DEPENDENCIES}}
|
||||||
// Microsoft Visual C++ generated include file.
|
// Microsoft Visual C++ generated include file.
|
||||||
// Used by cefclient.rc
|
// Used by cefclient.rc
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
// stdafx.cpp : source file that includes just the standard includes
|
// stdafx.cpp : source file that includes just the standard includes
|
||||||
// cefclient.pch will be the pre-compiled header
|
// cefclient.pch will be the pre-compiled header
|
||||||
// stdafx.obj will contain the pre-compiled type information
|
// stdafx.obj will contain the pre-compiled type information
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights
|
// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
// stdafx.h : include file for standard system include files,
|
// stdafx.h : include file for standard system include files,
|
||||||
// or project specific include files that are used frequently, but
|
// or project specific include files that are used frequently, but
|
||||||
// are changed infrequently
|
// are changed infrequently
|
||||||
|
Reference in New Issue
Block a user