Home | History | Annotate | Download | only in tab_contents
      1 // Copyright (c) 2012 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_UI_VIEWS_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_VIEWS_H_
      6 #define CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_VIEWS_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "base/compiler_specific.h"
     10 #include "base/memory/scoped_ptr.h"
     11 #include "content/public/browser/web_contents_view_delegate.h"
     12 
     13 class RenderViewContextMenuViews;
     14 
     15 namespace content {
     16 class WebContents;
     17 class WebDragDestDelegate;
     18 }
     19 
     20 namespace views {
     21 class FocusManager;
     22 class Widget;
     23 }
     24 
     25 // A chrome specific class that extends WebContentsViewWin with features like
     26 // focus management, which live in chrome.
     27 class ChromeWebContentsViewDelegateViews
     28     : public content::WebContentsViewDelegate {
     29  public:
     30   explicit ChromeWebContentsViewDelegateViews(
     31       content::WebContents* web_contents);
     32   virtual ~ChromeWebContentsViewDelegateViews();
     33 
     34   // Overridden from WebContentsViewDelegate:
     35   virtual content::WebDragDestDelegate* GetDragDestDelegate() OVERRIDE;
     36   virtual void StoreFocus() OVERRIDE;
     37   virtual void RestoreFocus() OVERRIDE;
     38   virtual bool Focus() OVERRIDE;
     39   virtual void TakeFocus(bool reverse) OVERRIDE;
     40   virtual void ShowContextMenu(
     41       const content::ContextMenuParams& params) OVERRIDE;
     42   virtual void SizeChanged(const gfx::Size& size) OVERRIDE;
     43 
     44  private:
     45   views::Widget* GetTopLevelWidget();
     46   views::FocusManager* GetFocusManager();
     47   void SetInitialFocus();
     48 
     49   // The id used in the ViewStorage to store the last focused view.
     50   int last_focused_view_storage_id_;
     51 
     52   // The context menu is reset every time we show it, but we keep a pointer to
     53   // between uses so that it won't go out of scope before we're done with it.
     54   scoped_ptr<RenderViewContextMenuViews> context_menu_;
     55 
     56   // The chrome specific delegate that receives events from WebDragDest.
     57   scoped_ptr<content::WebDragDestDelegate> bookmark_handler_;
     58 
     59   content::WebContents* web_contents_;
     60 
     61   DISALLOW_COPY_AND_ASSIGN(ChromeWebContentsViewDelegateViews);
     62 };
     63 
     64 #endif  // CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_VIEWS_H_
     65