Home | History | Annotate | Download | only in tabs
      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 CHROME_BROWSER_EXTENSIONS_API_TABS_ASH_PANEL_CONTENTS_H_
      6 #define CHROME_BROWSER_EXTENSIONS_API_TABS_ASH_PANEL_CONTENTS_H_
      7 
      8 #include <vector>
      9 
     10 #include "apps/app_window.h"
     11 #include "base/basictypes.h"
     12 #include "base/memory/scoped_ptr.h"
     13 #include "chrome/browser/ui/ash/launcher/launcher_favicon_loader.h"
     14 #include "content/public/browser/web_contents_observer.h"
     15 #include "extensions/browser/extension_function_dispatcher.h"
     16 
     17 class AshPanelWindowController;
     18 class GURL;
     19 
     20 namespace content {
     21 class RenderViewHost;
     22 }
     23 
     24 namespace extensions {
     25 struct DraggableRegion;
     26 }
     27 
     28 // apps::AppWindowContents class specific to panel windows created by v1
     29 // extenstions. This class maintains a WebContents instance and observes it for
     30 // the purpose of passing messages to the extensions system. It also creates
     31 // an extensions::WindowController instance for interfacing with the v1
     32 // extensions API.
     33 class AshPanelContents
     34     : public apps::AppWindowContents,
     35       public content::WebContentsObserver,
     36       public LauncherFaviconLoader::Delegate,
     37       public extensions::ExtensionFunctionDispatcher::Delegate {
     38  public:
     39   explicit AshPanelContents(apps::AppWindow* host);
     40   virtual ~AshPanelContents();
     41 
     42   // apps::AppWindowContents
     43   virtual void Initialize(content::BrowserContext* context,
     44                           const GURL& url) OVERRIDE;
     45   virtual void LoadContents(int32 creator_process_id) OVERRIDE;
     46   virtual void NativeWindowChanged(apps::NativeAppWindow* native_app_window)
     47       OVERRIDE;
     48   virtual void NativeWindowClosed() OVERRIDE;
     49   virtual void DispatchWindowShownForTests() const OVERRIDE;
     50   virtual content::WebContents* GetWebContents() const OVERRIDE;
     51 
     52   // LauncherFaviconLoader::Delegate overrides:
     53   virtual void FaviconUpdated() OVERRIDE;
     54 
     55   // extensions::ExtensionFunctionDispatcher::Delegate
     56   virtual extensions::WindowController* GetExtensionWindowController() const
     57       OVERRIDE;
     58   virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE;
     59 
     60   LauncherFaviconLoader* launcher_favicon_loader_for_test() {
     61     return launcher_favicon_loader_.get();
     62   }
     63 
     64  private:
     65   // content::WebContentsObserver
     66   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
     67 
     68   void OnRequest(const ExtensionHostMsg_Request_Params& params);
     69 
     70   apps::AppWindow* host_;
     71   GURL url_;
     72   scoped_ptr<content::WebContents> web_contents_;
     73   scoped_ptr<extensions::ExtensionFunctionDispatcher>
     74       extension_function_dispatcher_;
     75   scoped_ptr<AshPanelWindowController> window_controller_;
     76   scoped_ptr<LauncherFaviconLoader> launcher_favicon_loader_;
     77 
     78   DISALLOW_COPY_AND_ASSIGN(AshPanelContents);
     79 };
     80 
     81 #endif  // CHROME_BROWSER_EXTENSIONS_API_TABS_ASH_PANEL_CONTENTS_H_
     82