1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// found in the LICENSE file. 4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#ifndef CONTENT_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_ 6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#define CONTENT_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_ 7868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#include <string> 923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) 10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/callback_forward.h" 11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/common/content_export.h" 12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ipc/ipc_listener.h" 13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ipc/ipc_sender.h" 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/gfx/native_widget_types.h" 15116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "ui/gfx/rect.h" 16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "url/gurl.h" 17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace base { 19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class Value; 20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 21868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace content { 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class RenderProcessHost; 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class RenderViewHost; 25116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass ServiceRegistry; 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class SiteInstance; 27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// The interface provides a communication conduit with a frame in the renderer. 29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class CONTENT_EXPORT RenderFrameHost : public IPC::Listener, 30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public IPC::Sender { 31424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) public: 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Returns the RenderFrameHost given its ID and the ID of its render process. 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Returns NULL if the IDs do not correspond to a live RenderFrameHost. 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) static RenderFrameHost* FromID(int render_process_id, int render_frame_id); 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 36424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) virtual ~RenderFrameHost() {} 37424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 38a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Returns the route id for this frame. 39a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual int GetRoutingID() = 0; 40a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 41a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Returns the SiteInstance grouping all RenderFrameHosts that have script 42a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // access to this RenderFrameHost, and must therefore live in the same 43a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // process. 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual SiteInstance* GetSiteInstance() = 0; 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Returns the process for this frame. 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual RenderProcessHost* GetProcess() = 0; 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 49a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Returns the current RenderFrameHost of the parent frame, or NULL if there 50a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // is no parent. The result may be in a different process than the current 51a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // RenderFrameHost. 52a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual RenderFrameHost* GetParent() = 0; 53a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 54effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch // Returns the assigned name of the frame, the name of the iframe tag 55effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch // declaring it. For example, <iframe name="framename">[...]</iframe>. It is 5623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) // quite possible for a frame to have no name, in which case GetFrameName will 5723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) // return an empty string. 5823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) virtual const std::string& GetFrameName() = 0; 5923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) 60a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Returns true if the frame is out of process. 61a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual bool IsCrossProcessSubframe() = 0; 62a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 63a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Returns the last committed URL of the frame. 64a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual GURL GetLastCommittedURL() = 0; 65a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Returns the associated widget's native view. 675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual gfx::NativeView GetNativeView() = 0; 685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 69a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Runs some JavaScript in this frame's context. If a callback is provided, it 70a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // will be used to return the result, when the result is available. 71a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) typedef base::Callback<void(const base::Value*)> JavaScriptResultCallback; 72a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual void ExecuteJavaScript(const base::string16& javascript) = 0; 73a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual void ExecuteJavaScript(const base::string16& javascript, 74a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const JavaScriptResultCallback& callback) = 0; 75a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 761320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // ONLY FOR TESTS: Same as above but adds a fake UserGestureIndicator around 771320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // execution. (crbug.com/408426) 781320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual void ExecuteJavaScriptForTests(const base::string16& javascript) = 0; 791320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 80116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Accessibility actions. 81116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual void AccessibilitySetFocus(int acc_obj_id) = 0; 82116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual void AccessibilityDoDefaultAction(int acc_obj_id) = 0; 83116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual void AccessibilityScrollToMakeVisible( 84116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch int acc_obj_id, const gfx::Rect& subfocus) = 0; 85116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual void AccessibilitySetTextSelection( 86116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch int acc_obj_id, int start_offset, int end_offset) = 0; 87116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Temporary until we get rid of RenderViewHost. 895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual RenderViewHost* GetRenderViewHost() = 0; 905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 91116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Returns the ServiceRegistry for this frame. 92116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual ServiceRegistry* GetServiceRegistry() = 0; 93116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 94868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) private: 95868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // This interface should only be implemented inside content. 96868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) friend class RenderFrameHostImpl; 97868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) RenderFrameHost() {} 98868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}; 99868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 100868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} // namespace content 101868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 102868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#endif // CONTENT_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_ 103