1// Copyright 2014 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 EXTENSIONS_BROWSER_GUEST_VIEW_EXTENSION_OPTIONS_EXTENSION_OPTIONS_GUEST_H_ 6#define EXTENSIONS_BROWSER_GUEST_VIEW_EXTENSION_OPTIONS_EXTENSION_OPTIONS_GUEST_H_ 7 8#include "base/macros.h" 9#include "extensions/browser/extension_function_dispatcher.h" 10#include "extensions/browser/guest_view/extension_options/extension_options_guest_delegate.h" 11#include "extensions/browser/guest_view/guest_view.h" 12#include "url/gurl.h" 13 14namespace content { 15class BrowserContext; 16} 17 18namespace extensions { 19 20class ExtensionOptionsGuest 21 : public extensions::GuestView<ExtensionOptionsGuest>, 22 public extensions::ExtensionFunctionDispatcher::Delegate { 23 public: 24 static const char Type[]; 25 static extensions::GuestViewBase* Create( 26 content::BrowserContext* browser_context, 27 int guest_instance_id); 28 29 // GuestViewBase implementation. 30 virtual void CreateWebContents( 31 const std::string& embedder_extension_id, 32 int embedder_render_process_id, 33 const GURL& embedder_site_url, 34 const base::DictionaryValue& create_params, 35 const WebContentsCreatedCallback& callback) OVERRIDE; 36 virtual void DidAttachToEmbedder() OVERRIDE; 37 virtual void DidInitialize() OVERRIDE; 38 virtual void DidStopLoading() OVERRIDE; 39 virtual const char* GetAPINamespace() const OVERRIDE; 40 virtual int GetTaskPrefix() const OVERRIDE; 41 virtual void GuestSizeChangedDueToAutoSize( 42 const gfx::Size& old_size, 43 const gfx::Size& new_size) OVERRIDE; 44 virtual bool IsAutoSizeSupported() const OVERRIDE; 45 46 // ExtensionFunctionDispatcher::Delegate implementation. 47 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; 48 49 // content::WebContentsDelegate implementation. 50 virtual content::WebContents* OpenURLFromTab( 51 content::WebContents* source, 52 const content::OpenURLParams& params) OVERRIDE; 53 virtual void CloseContents(content::WebContents* source) OVERRIDE; 54 virtual bool HandleContextMenu( 55 const content::ContextMenuParams& params) OVERRIDE; 56 virtual bool ShouldCreateWebContents( 57 content::WebContents* web_contents, 58 int route_id, 59 WindowContainerType window_container_type, 60 const base::string16& frame_name, 61 const GURL& target_url, 62 const std::string& partition_id, 63 content::SessionStorageNamespace* session_storage_namespace) OVERRIDE; 64 65 // content::WebContentsObserver implementation. 66 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 67 68 private: 69 ExtensionOptionsGuest(content::BrowserContext* browser_context, 70 int guest_instance_id); 71 virtual ~ExtensionOptionsGuest(); 72 void OnRequest(const ExtensionHostMsg_Request_Params& params); 73 void SetUpAutoSize(); 74 75 scoped_ptr<extensions::ExtensionFunctionDispatcher> 76 extension_function_dispatcher_; 77 scoped_ptr<extensions::ExtensionOptionsGuestDelegate> 78 extension_options_guest_delegate_; 79 GURL options_page_; 80 81 DISALLOW_COPY_AND_ASSIGN(ExtensionOptionsGuest); 82}; 83 84} // namespace extensions 85 86#endif // EXTENSIONS_BROWSER_GUEST_VIEW_EXTENSION_OPTIONS_EXTENSION_OPTIONS_GUEST_H_ 87