summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/password_form_dom_manager.cc9
-rw-r--r--webkit/glue/password_form_dom_manager.h9
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.cc8
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.h34
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_gtk.cc2
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_mac.cc2
-rw-r--r--webkit/glue/scoped_clipboard_writer_glue.h7
-rw-r--r--webkit/glue/webkit_glue.cc49
-rw-r--r--webkit/glue/webplugin_delegate.h49
9 files changed, 102 insertions, 67 deletions
diff --git a/webkit/glue/password_form_dom_manager.cc b/webkit/glue/password_form_dom_manager.cc
index 956a55e..4a372e8 100644
--- a/webkit/glue/password_form_dom_manager.cc
+++ b/webkit/glue/password_form_dom_manager.cc
@@ -62,15 +62,13 @@ PasswordForm* PasswordFormDomManager::CreatePasswordForm(
}
// static
-PasswordFormDomManager::FillData* PasswordFormDomManager::CreateFillData(
+void PasswordFormDomManager::InitFillData(
const PasswordForm& form_on_page,
const PasswordFormMap& matches,
const PasswordForm* const preferred_match,
- bool wait_for_username_before_autofill) {
+ bool wait_for_username_before_autofill,
+ PasswordFormDomManager::FillData* result) {
DCHECK(preferred_match);
- PasswordFormDomManager::FillData* result =
- new PasswordFormDomManager::FillData();
-
// Fill basic form data.
result->basic_data.origin = form_on_page.origin;
result->basic_data.action = form_on_page.action;
@@ -87,7 +85,6 @@ PasswordFormDomManager::FillData* PasswordFormDomManager::CreateFillData(
if (iter->second != preferred_match)
result->additional_logins[iter->first] = iter->second->password_value;
}
- return result;
}
// static
diff --git a/webkit/glue/password_form_dom_manager.h b/webkit/glue/password_form_dom_manager.h
index 9f827de..fcca8c7 100644
--- a/webkit/glue/password_form_dom_manager.h
+++ b/webkit/glue/password_form_dom_manager.h
@@ -52,10 +52,11 @@ class PasswordFormDomManager {
// preferred_match should equal (address) one of matches.
// wait_for_username_before_autofill is true if we should not autofill
// anything until the user typed in a valid username and blurred the field.
- static FillData* CreateFillData(const PasswordForm& form_on_page,
- const PasswordFormMap& matches,
- const PasswordForm* const preferred_match,
- bool wait_for_username_before_autofill);
+ static void InitFillData(const PasswordForm& form_on_page,
+ const PasswordFormMap& matches,
+ const PasswordForm* const preferred_match,
+ bool wait_for_username_before_autofill,
+ FillData* result);
private:
// Helper structure to locate username, passwords and submit fields.
struct PasswordFormFields {
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.cc b/webkit/glue/plugins/webplugin_delegate_impl.cc
index 839cbd5..0ab5c02 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl.cc
@@ -58,7 +58,7 @@ base::LazyInstance<iat_patch::IATPatchFunction> g_iat_patch_set_cursor(
} // namespace
-WebPluginDelegateImpl* WebPluginDelegateImpl::Create(
+WebPluginDelegate* WebPluginDelegate::Create(
const FilePath& filename,
const std::string& mime_type,
gfx::NativeView containing_view) {
@@ -800,7 +800,7 @@ LRESULT CALLBACK WebPluginDelegateImpl::NativeWndProc(
}
if (message == delegate->last_message_ &&
- delegate->quirks() & PLUGIN_QUIRK_DONT_CALL_WND_PROC_RECURSIVELY &&
+ delegate->GetQuirks() & PLUGIN_QUIRK_DONT_CALL_WND_PROC_RECURSIVELY &&
delegate->is_calling_wndproc) {
// Real may go into a state where it recursively dispatches the same event
// when subclassed. See https://bugzilla.mozilla.org/show_bug.cgi?id=192914
@@ -852,7 +852,7 @@ LRESULT CALLBACK WebPluginDelegateImpl::NativeWndProc(
// usage. See https://bugzilla.mozilla.org/show_bug.cgi?id=132759. We
// prevent this by throttling the messages.
case WM_USER + 1: {
- if (delegate->quirks() & PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE) {
+ if (delegate->GetQuirks() & PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE) {
WebPluginDelegateImpl::ThrottleMessage(delegate->plugin_wnd_proc_, hwnd,
message, wparam, lparam);
g_current_plugin_instance = last_plugin_instance;
@@ -1172,7 +1172,7 @@ HCURSOR WINAPI WebPluginDelegateImpl::SetCursorPatch(HCURSOR cursor) {
if (!g_current_plugin_instance)
return GetCursor();
- if (!g_current_plugin_instance->windowless()) {
+ if (!g_current_plugin_instance->IsWindowless()) {
return SetCursor(cursor);
}
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h
index f196c6e..46d0f95 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.h
+++ b/webkit/glue/plugins/webplugin_delegate_impl.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef WEBKIT_GLUE_PLUGIN_WEBPLUGIN_DELEGATE_IMPL_H__
-#define WEBKIT_GLUE_PLUGIN_WEBPLUGIN_DELEGATE_IMPL_H__
+#ifndef WEBKIT_GLUE_PLUGIN_WEBPLUGIN_DELEGATE_IMPL_H_
+#define WEBKIT_GLUE_PLUGIN_WEBPLUGIN_DELEGATE_IMPL_H_
#include "build/build_config.h"
@@ -26,9 +26,6 @@ namespace NPAPI {
// the plugin process.
class WebPluginDelegateImpl : public WebPluginDelegate {
public:
- static WebPluginDelegateImpl* Create(const FilePath& filename,
- const std::string& mime_type,
- gfx::NativeView containing_view);
static bool IsPluginDelegateWindow(gfx::NativeWindow window);
static bool GetPluginNameFromWindow(gfx::NativeWindow window,
std::wstring *plugin_name);
@@ -82,24 +79,10 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
virtual void URLRequestRouted(const std::string&url, bool notify_needed,
void* notify_data);
- bool windowless() const { return windowless_ ; }
- gfx::Rect rect() const { return window_rect_; }
- gfx::Rect clip_rect() const { return clip_rect_; }
-
-#if defined(OS_WIN)
- enum PluginQuirks {
- PLUGIN_QUIRK_SETWINDOW_TWICE = 1 << 0,
- PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE = 1 << 1,
- PLUGIN_QUIRK_DONT_CALL_WND_PROC_RECURSIVELY = 1 << 2,
- PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES = 1 << 3,
- PLUGIN_QUIRK_DIE_AFTER_UNLOAD = 1 << 4,
- PLUGIN_QUIRK_PATCH_TRACKPOPUP_MENU = 1 << 5,
- PLUGIN_QUIRK_PATCH_SETCURSOR = 1 << 6,
- PLUGIN_QUIRK_BLOCK_NONSTANDARD_GETURL_REQUESTS = 1 << 7,
- };
-#endif
-
- int quirks() { return quirks_; }
+ virtual bool IsWindowless() const { return windowless_ ; }
+ virtual const gfx::Rect& GetRect() const { return window_rect_; }
+ virtual const gfx::Rect& GetClipRect() const { return clip_rect_; }
+ virtual int GetQuirks() const { return quirks_; }
private:
WebPluginDelegateImpl(gfx::NativeView containing_view,
@@ -279,8 +262,9 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
// Holds the current cursor set by the windowless plugin.
WebCursor current_windowless_cursor_;
+ friend class WebPluginDelegate;
+
DISALLOW_EVIL_CONSTRUCTORS(WebPluginDelegateImpl);
};
-#endif // #ifndef WEBKIT_GLUE_PLUGIN_WEBPLUGIN_DELEGATE_IMPL_H__
-
+#endif // #ifndef WEBKIT_GLUE_PLUGIN_WEBPLUGIN_DELEGATE_IMPL_H_
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
index 58d853e..40da272b 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
@@ -37,7 +37,7 @@
#include "webkit/glue/plugins/plugin_stream_url.h"
#include "webkit/glue/webkit_glue.h"
-WebPluginDelegateImpl* WebPluginDelegateImpl::Create(
+WebPluginDelegate* WebPluginDelegate::Create(
const FilePath& filename,
const std::string& mime_type,
gfx::NativeView containing_view) {
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.cc b/webkit/glue/plugins/webplugin_delegate_impl_mac.cc
index 8c62dbc..1a25ad6c 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.cc
@@ -50,7 +50,7 @@ WebPluginDelegateImpl* g_current_plugin_instance = NULL;
} // namespace
-WebPluginDelegateImpl* WebPluginDelegateImpl::Create(
+WebPluginDelegate* WebPluginDelegate::Create(
const FilePath& filename,
const std::string& mime_type,
gfx::NativeView containing_view) {
diff --git a/webkit/glue/scoped_clipboard_writer_glue.h b/webkit/glue/scoped_clipboard_writer_glue.h
index 6307e6a..db7c428 100644
--- a/webkit/glue/scoped_clipboard_writer_glue.h
+++ b/webkit/glue/scoped_clipboard_writer_glue.h
@@ -5,9 +5,14 @@
#ifndef SCOPED_CLIPBOARD_WRITER_GLUE_H_
#define SCOPED_CLIPBOARD_WRITER_GLUE_H_
-#include "base/clipboard.h"
#include "base/scoped_clipboard_writer.h"
+class SkBitmap;
+
+namespace base {
+class SharedMemory;
+}
+
class ScopedClipboardWriterGlue : public ScopedClipboardWriter {
public:
ScopedClipboardWriterGlue(Clipboard* clipboard)
diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc
index ebcb3e8..c98c987 100644
--- a/webkit/glue/webkit_glue.cc
+++ b/webkit/glue/webkit_glue.cc
@@ -35,6 +35,7 @@ MSVC_POP_WARNING();
#include "webkit/glue/webkit_glue.h"
#include "base/file_version_info.h"
+#include "base/singleton.h"
#include "base/string_util.h"
#include "skia/include/SkBitmap.h"
#include "webkit/glue/event_conversion.h"
@@ -316,9 +317,19 @@ std::string GetWebKitVersion() {
namespace {
-const std::string* user_agent = NULL;
-bool user_agent_requested = false;
-bool user_agent_is_overridden = false;
+struct UserAgentState {
+ UserAgentState()
+ : user_agent_requested(false),
+ user_agent_is_overridden(false) {
+ }
+
+ std::string user_agent;
+ std::string mimic_safari_user_agent;
+ bool user_agent_requested;
+ bool user_agent_is_overridden;
+};
+
+Singleton<UserAgentState> g_user_agent;
void BuildUserAgent(bool mimic_safari, std::string* result) {
#if defined(OS_WIN) || defined(OS_MACOSX)
@@ -392,38 +403,34 @@ void BuildUserAgent(bool mimic_safari, std::string* result) {
}
void SetUserAgentToDefault() {
- static std::string default_user_agent;
- BuildUserAgent(false, &default_user_agent);
- user_agent = &default_user_agent;
+ BuildUserAgent(false, &g_user_agent->user_agent);
}
} // namespace
void SetUserAgent(const std::string& new_user_agent) {
- DCHECK(!user_agent_requested) << "Setting the user agent after someone has "
+ // If you combine this with the previous line, the function only works the
+ // first time.
+ DCHECK(!g_user_agent->user_agent_requested) <<
+ "Setting the user agent after someone has "
"already requested it can result in unexpected behavior.";
- static std::string overridden_user_agent;
- overridden_user_agent = new_user_agent; // If you combine this with the
- // previous line, the function only
- // works the first time.
- user_agent_is_overridden = true;
- user_agent = &overridden_user_agent;
+ g_user_agent->user_agent_is_overridden = true;
+ g_user_agent->user_agent = new_user_agent;
}
const std::string& GetUserAgent(const GURL& url) {
- if (!user_agent)
+ if (g_user_agent->user_agent.empty())
SetUserAgentToDefault();
- user_agent_requested = true;
- if (!user_agent_is_overridden) {
- static std::string mimic_safari_user_agent;
+ g_user_agent->user_agent_requested = true;
+ if (!g_user_agent->user_agent_is_overridden) {
// For hotmail, we need to spoof as Safari (bug 4111).
if (MatchPattern(url.host(), "*.mail.live.com")) {
- if (mimic_safari_user_agent.empty())
- BuildUserAgent(true, &mimic_safari_user_agent);
- return mimic_safari_user_agent;
+ if (g_user_agent->mimic_safari_user_agent.empty())
+ BuildUserAgent(true, &g_user_agent->mimic_safari_user_agent);
+ return g_user_agent->mimic_safari_user_agent;
}
}
- return *user_agent;
+ return g_user_agent->user_agent;
}
void NotifyJSOutOfMemory(WebCore::Frame* frame) {
diff --git a/webkit/glue/webplugin_delegate.h b/webkit/glue/webplugin_delegate.h
index 122503f0..b1a17cf 100644
--- a/webkit/glue/webplugin_delegate.h
+++ b/webkit/glue/webplugin_delegate.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef WEBKIT_GLUE_WEBPLUGIN_DELEGATE_H__
-#define WEBKIT_GLUE_WEBPLUGIN_DELEGATE_H__
+#ifndef WEBKIT_GLUE_WEBPLUGIN_DELEGATE_H_
+#define WEBKIT_GLUE_WEBPLUGIN_DELEGATE_H_
#include <string>
#include <vector>
@@ -27,9 +27,26 @@ class WebPluginResourceClient;
// This is the interface that a plugin implementation needs to provide.
class WebPluginDelegate {
public:
+#if defined(OS_WIN)
+ enum PluginQuirks {
+ PLUGIN_QUIRK_SETWINDOW_TWICE = 1 << 0,
+ PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE = 1 << 1,
+ PLUGIN_QUIRK_DONT_CALL_WND_PROC_RECURSIVELY = 1 << 2,
+ PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES = 1 << 3,
+ PLUGIN_QUIRK_DIE_AFTER_UNLOAD = 1 << 4,
+ PLUGIN_QUIRK_PATCH_TRACKPOPUP_MENU = 1 << 5,
+ PLUGIN_QUIRK_PATCH_SETCURSOR = 1 << 6,
+ PLUGIN_QUIRK_BLOCK_NONSTANDARD_GETURL_REQUESTS = 1 << 7,
+ };
+#endif
+
WebPluginDelegate() {}
virtual ~WebPluginDelegate() {}
+ static WebPluginDelegate* Create(const FilePath& filename,
+ const std::string& mime_type,
+ gfx::NativeView containing_view);
+
// Initializes the plugin implementation with the given (UTF8) arguments.
// Note that the lifetime of WebPlugin must be longer than this delegate.
// If this function returns false the plugin isn't started and shouldn't be
@@ -120,9 +137,33 @@ class WebPluginDelegate {
// Notifies the delegate about a Get/Post URL request getting routed.
virtual void URLRequestRouted(const std::string&url, bool notify_needed,
void* notify_data) = 0;
+
+ virtual bool IsWindowless() const {
+ NOTREACHED();
+ return false;
+ }
+
+ virtual const gfx::Rect& GetRect() const {
+ NOTREACHED();
+ static gfx::Rect dummy;
+ return dummy;
+ }
+
+ virtual const gfx::Rect& GetClipRect() const {
+ NOTREACHED();
+ return GetRect();
+ }
+
+#if defined(OS_WIN)
+ // Returns a combinaison of PluginQuirks.
+ virtual int GetQuirks() const {
+ NOTREACHED();
+ return 0;
+ }
+#endif
+
private:
DISALLOW_EVIL_CONSTRUCTORS(WebPluginDelegate);
};
-#endif // #ifndef WEBKIT_GLUE_WEBPLUGIN_DELEGATE_H__
-
+#endif // #ifndef WEBKIT_GLUE_WEBPLUGIN_DELEGATE_H_