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 15 namespace content { 16 17 struct NativeWebKeyboardEvent; 18 19 // Objects implement this interface to get notified about changes in the guest 20 // WebContents and to provide necessary functionality. 21 class CONTENT_EXPORT BrowserPluginGuestDelegate { 22 public: 23 virtual ~BrowserPluginGuestDelegate() {} 24 25 // Add a message to the console. 26 virtual void AddMessageToConsole(int32 level, 27 const string16& message, 28 int32 line_no, 29 const string16& source_id) {} 30 31 // Request the delegate to close this guest, and do whatever cleanup it needs 32 // to do. 33 virtual void Close() {} 34 35 // Informs the delegate that the guest render process is gone. |status| 36 // indicates whether the guest was killed, crashed, or was terminated 37 // gracefully. 38 virtual void GuestProcessGone(base::TerminationStatus status) {} 39 40 virtual bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event); 41 42 // Notification that the guest is no longer hung. 43 virtual void RendererResponsive() {} 44 45 // Notification that the guest is hung. 46 virtual void RendererUnresponsive() {} 47 48 typedef base::Callback<void(bool /* allow */, 49 const std::string& /* user_input */)> 50 PermissionResponseCallback; 51 52 // Request permission from the delegate to perform an action of the provided 53 // |permission_type|. Details of the permission request are found in 54 // |request_info|. A |callback| is provided to make the decision. 55 // Returns whether the delegate has, or will handle the permission request. 56 virtual bool RequestPermission( 57 BrowserPluginPermissionType permission_type, 58 const base::DictionaryValue& request_info, 59 const PermissionResponseCallback& callback); 60 }; 61 62 } // namespace content 63 64 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_ 65