1// Copyright (c) 2011 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_INFOBARS_EXTENSION_INFOBAR_H_ 6#define CHROME_BROWSER_UI_VIEWS_INFOBARS_EXTENSION_INFOBAR_H_ 7#pragma once 8 9#include "chrome/browser/extensions/extension_infobar_delegate.h" 10#include "chrome/browser/extensions/image_loading_tracker.h" 11#include "chrome/browser/ui/views/extensions/extension_view.h" 12#include "chrome/browser/ui/views/infobars/infobar_view.h" 13#include "views/controls/menu/view_menu_delegate.h" 14 15class ExtensionContextMenuModel; 16namespace views { 17class MenuButton; 18class Menu2; 19} 20 21class ExtensionInfoBar : public InfoBarView, 22 public ExtensionView::Container, 23 public ImageLoadingTracker::Observer, 24 public ExtensionInfoBarDelegate::DelegateObserver, 25 public views::ViewMenuDelegate { 26 public: 27 explicit ExtensionInfoBar(ExtensionInfoBarDelegate* delegate); 28 29 private: 30 virtual ~ExtensionInfoBar(); 31 32 // InfoBarView: 33 virtual void Layout(); 34 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); 35 virtual int ContentMinimumWidth() const; 36 37 // ExtensionView::Container: 38 virtual void OnExtensionMouseMove(ExtensionView* view); 39 virtual void OnExtensionMouseLeave(ExtensionView* view); 40 virtual void OnExtensionPreferredSizeChanged(ExtensionView* view); 41 42 // ImageLoadingTracker::Observer: 43 virtual void OnImageLoaded(SkBitmap* image, 44 const ExtensionResource& resource, 45 int index); 46 47 // ExtensionInfoBarDelegate::DelegateObserver: 48 virtual void OnDelegateDeleted(); 49 50 // views::ViewMenuDelegate: 51 virtual void RunMenu(View* source, const gfx::Point& pt); 52 53 ExtensionInfoBarDelegate* GetDelegate(); 54 55 // TODO(pkasting): This shadows InfoBarView::delegate_. Get rid of this once 56 // InfoBars own their delegates (and thus we don't need the DelegateObserver 57 // functionality). For now, almost everyone should use GetDelegate() instead. 58 InfoBarDelegate* delegate_; 59 60 // The dropdown menu for accessing the contextual extension actions. 61 scoped_refptr<ExtensionContextMenuModel> options_menu_contents_; 62 scoped_ptr<views::Menu2> options_menu_menu_; 63 views::MenuButton* menu_; 64 65 // Keeps track of images being loaded on the File thread. 66 ImageLoadingTracker tracker_; 67 68 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBar); 69}; 70 71#endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_EXTENSION_INFOBAR_H_ 72