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/geometry/rect.h"
15 #include "ui/gfx/size.h"
20 struct NativeWebKeyboardEvent;
22 // Objects implement this interface to get notified about changes in the guest
23 // WebContents and to provide necessary functionality.
24 class CONTENT_EXPORT BrowserPluginGuestDelegate {
26 virtual ~BrowserPluginGuestDelegate() {}
28 // Add a message to the console.
29 virtual void AddMessageToConsole(int32 level,
30 const base::string16& message,
32 const base::string16& source_id) {}
34 // Request the delegate to close this guest, and do whatever cleanup it needs
36 virtual void Close() {}
38 // Notification that the embedder has completed attachment.
39 virtual void DidAttach() {}
41 // Informs the delegate that the guest render process is gone. |status|
42 // indicates whether the guest was killed, crashed, or was terminated
44 virtual void GuestProcessGone(base::TerminationStatus status) {}
46 // Informs the delegate that the embedder has been destroyed.
47 virtual void EmbedderDestroyed() {}
49 // Informs the delegate of a reply to the find request specified by
51 virtual void FindReply(int request_id,
52 int number_of_matches,
53 const gfx::Rect& selection_rect,
54 int active_match_ordinal,
57 virtual bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
59 // Requests setting the zoom level to the provided |zoom_level|.
60 virtual void SetZoom(double zoom_factor) {}
62 virtual bool IsDragAndDropEnabled();
64 // Returns whether the user agent for the guest is being overridden.
65 virtual bool IsOverridingUserAgent() const;
67 // Notification that a load in the guest resulted in abort. Note that |url|
69 virtual void LoadAbort(bool is_top_level,
71 const std::string& error_type) {}
73 // Notification that the page has made some progress loading. |progress| is a
74 // value between 0.0 (nothing loaded) and 1.0 (page loaded completely).
75 virtual void LoadProgressed(double progress) {}
77 // Notification that the guest is no longer hung.
78 virtual void RendererResponsive() {}
80 // Notification that the guest is hung.
81 virtual void RendererUnresponsive() {}
83 typedef base::Callback<void(bool /* allow */,
84 const std::string& /* user_input */)>
85 PermissionResponseCallback;
87 // Request permission from the delegate to perform an action of the provided
88 // |permission_type|. Details of the permission request are found in
89 // |request_info|. A |callback| is provided to make the decision.
90 // Returns whether the delegate has, or will handle the permission request.
91 virtual bool RequestPermission(
92 BrowserPluginPermissionType permission_type,
93 const base::DictionaryValue& request_info,
94 const PermissionResponseCallback& callback,
95 bool allowed_by_default);
97 // Requests resolution of a potentially relative URL.
98 virtual GURL ResolveURL(const std::string& src);
100 // Notifies that the content size of the guest has changed in autosize mode.
101 virtual void SizeChanged(const gfx::Size& old_size,
102 const gfx::Size& new_size) {}
105 } // namespace content
107 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_