1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_
6 #define CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_
8 #include "base/callback_forward.h"
9 #include "base/process/kill.h"
10 #include "base/strings/string16.h"
11 #include "base/values.h"
12 #include "content/common/content_export.h"
13 #include "content/public/common/browser_plugin_permission_type.h"
14 #include "ui/gfx/size.h"
19 struct NativeWebKeyboardEvent;
21 // Objects implement this interface to get notified about changes in the guest
22 // WebContents and to provide necessary functionality.
23 class CONTENT_EXPORT BrowserPluginGuestDelegate {
25 virtual ~BrowserPluginGuestDelegate() {}
27 // Add a message to the console.
28 virtual void AddMessageToConsole(int32 level,
29 const base::string16& message,
31 const base::string16& source_id) {}
33 // Request the delegate to close this guest, and do whatever cleanup it needs
35 virtual void Close() {}
37 // Notification that the embedder has completed attachment.
38 virtual void DidAttach() {}
40 // Informs the delegate that the guest render process is gone. |status|
41 // indicates whether the guest was killed, crashed, or was terminated
43 virtual void GuestProcessGone(base::TerminationStatus status) {}
45 // Informs the delegate that the embedder has been destroyed.
46 virtual void EmbedderDestroyed() {}
48 virtual bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
50 virtual bool IsDragAndDropEnabled();
52 // Returns whether the user agent for the guest is being overridden.
53 virtual bool IsOverridingUserAgent() const;
55 // Notification that a load in the guest resulted in abort. Note that |url|
57 virtual void LoadAbort(bool is_top_level,
59 const std::string& error_type) {}
61 // Notification that the page has made some progress loading. |progress| is a
62 // value between 0.0 (nothing loaded) and 1.0 (page loaded completely).
63 virtual void LoadProgressed(double progress) {}
65 // Notification that the guest is no longer hung.
66 virtual void RendererResponsive() {}
68 // Notification that the guest is hung.
69 virtual void RendererUnresponsive() {}
71 typedef base::Callback<void(bool /* allow */,
72 const std::string& /* user_input */)>
73 PermissionResponseCallback;
75 // Request permission from the delegate to perform an action of the provided
76 // |permission_type|. Details of the permission request are found in
77 // |request_info|. A |callback| is provided to make the decision.
78 // Returns whether the delegate has, or will handle the permission request.
79 virtual bool RequestPermission(
80 BrowserPluginPermissionType permission_type,
81 const base::DictionaryValue& request_info,
82 const PermissionResponseCallback& callback,
83 bool allowed_by_default);
85 // Requests resolution of a potentially relative URL.
86 virtual GURL ResolveURL(const std::string& src);
88 // Notifies that the content size of the guest has changed in autosize mode.
89 virtual void SizeChanged(const gfx::Size& old_size,
90 const gfx::Size& new_size) {}
93 } // namespace content
95 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_