Upstream version 6.35.121.0
[platform/framework/web/crosswalk.git] / src / content / public / browser / browser_plugin_guest_delegate.h
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.
4
5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_
6 #define CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_
7
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"
16 #include "url/gurl.h"
17
18 namespace content {
19
20 struct NativeWebKeyboardEvent;
21
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 {
25  public:
26   virtual ~BrowserPluginGuestDelegate() {}
27
28   // Add a message to the console.
29   virtual void AddMessageToConsole(int32 level,
30                                    const base::string16& message,
31                                    int32 line_no,
32                                    const base::string16& source_id) {}
33
34   // Request the delegate to close this guest, and do whatever cleanup it needs
35   // to do.
36   virtual void Close() {}
37
38   // Notification that the embedder has completed attachment.
39   virtual void DidAttach() {}
40
41   // Informs the delegate that the guest render process is gone. |status|
42   // indicates whether the guest was killed, crashed, or was terminated
43   // gracefully.
44   virtual void GuestProcessGone(base::TerminationStatus status) {}
45
46   // Informs the delegate that the embedder has been destroyed.
47   virtual void EmbedderDestroyed() {}
48
49   // Informs the delegate of a reply to the find request specified by
50   // |request_id|.
51   virtual void FindReply(int request_id,
52                          int number_of_matches,
53                          const gfx::Rect& selection_rect,
54                          int active_match_ordinal,
55                          bool final_update) {}
56
57   virtual bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
58
59   // Requests setting the zoom level to the provided |zoom_level|.
60   virtual void SetZoom(double zoom_factor) {}
61
62   virtual bool IsDragAndDropEnabled();
63
64   // Returns whether the user agent for the guest is being overridden.
65   virtual bool IsOverridingUserAgent() const;
66
67   // Notification that a load in the guest resulted in abort. Note that |url|
68   // may be invalid.
69   virtual void LoadAbort(bool is_top_level,
70                          const GURL& url,
71                          const std::string& error_type) {}
72
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) {}
76
77   // Notification that the guest is no longer hung.
78   virtual void RendererResponsive() {}
79
80   // Notification that the guest is hung.
81   virtual void RendererUnresponsive() {}
82
83   typedef base::Callback<void(bool /* allow */,
84                               const std::string& /* user_input */)>
85       PermissionResponseCallback;
86
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);
96
97   // Requests resolution of a potentially relative URL.
98   virtual GURL ResolveURL(const std::string& src);
99
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) {}
103 };
104
105 }  // namespace content
106
107 #endif  // CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_