- add sources.
[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/size.h"
15 #include "url/gurl.h"
16
17 namespace content {
18
19 struct NativeWebKeyboardEvent;
20
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 {
24  public:
25   virtual ~BrowserPluginGuestDelegate() {}
26
27   // Add a message to the console.
28   virtual void AddMessageToConsole(int32 level,
29                                    const string16& message,
30                                    int32 line_no,
31                                    const string16& source_id) {}
32
33   // Request the delegate to close this guest, and do whatever cleanup it needs
34   // to do.
35   virtual void Close() {}
36
37   // Informs the delegate that the guest render process is gone. |status|
38   // indicates whether the guest was killed, crashed, or was terminated
39   // gracefully.
40   virtual void GuestProcessGone(base::TerminationStatus status) {}
41
42   // Informs the delegate that the embedder has been destroyed.
43   virtual void EmbedderDestroyed() {}
44
45   virtual bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
46
47   virtual bool IsDragAndDropEnabled();
48
49   // Returns whether the user agent for the guest is being overridden.
50   virtual bool IsOverridingUserAgent() const;
51
52   // Notification that a load in the guest resulted in abort. Note that |url|
53   // may be invalid.
54   virtual void LoadAbort(bool is_top_level,
55                          const GURL& url,
56                          const std::string& error_type) {}
57
58   // Notification that the page has made some progress loading. |progress| is a
59   // value between 0.0 (nothing loaded) and 1.0 (page loaded completely).
60   virtual void LoadProgressed(double progress) {}
61
62   // Notification that the guest is no longer hung.
63   virtual void RendererResponsive() {}
64
65   // Notification that the guest is hung.
66   virtual void RendererUnresponsive() {}
67
68   typedef base::Callback<void(bool /* allow */,
69                               const std::string& /* user_input */)>
70       PermissionResponseCallback;
71
72   // Request permission from the delegate to perform an action of the provided
73   // |permission_type|. Details of the permission request are found in
74   // |request_info|. A |callback| is provided to make the decision.
75   // Returns whether the delegate has, or will handle the permission request.
76   virtual bool RequestPermission(
77       BrowserPluginPermissionType permission_type,
78       const base::DictionaryValue& request_info,
79       const PermissionResponseCallback& callback,
80       bool allowed_by_default);
81
82   // Requests resolution of a potentially relative URL.
83   virtual GURL ResolveURL(const std::string& src);
84
85   // Notifies that the content size of the guest has changed in autosize mode.
86   virtual void SizeChanged(const gfx::Size& old_size,
87                            const gfx::Size& new_size) {}
88 };
89
90 }  // namespace content
91
92 #endif  // CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_