| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| 11 #include "content/browser/tab_contents/navigation_controller.h" | 11 #include "content/browser/tab_contents/navigation_controller.h" |
| 12 #include "webkit/glue/window_open_disposition.h" | 12 #include "webkit/glue/window_open_disposition.h" |
| 13 | 13 |
| 14 class ConfirmInfoBarDelegate; | 14 class ConfirmInfoBarDelegate; |
| 15 class ExtensionInfoBarDelegate; | 15 class ExtensionInfoBarDelegate; |
| 16 class InfoBar; | 16 class InfoBar; |
| 17 class LinkInfoBarDelegate; | 17 class LinkInfoBarDelegate; |
| 18 class PluginInstallerInfoBarDelegate; | 18 class PluginInstallerInfoBarDelegate; |
| 19 class TabContents; |
| 20 class TabContentsWrapper; |
| 19 class ThemeInstalledInfoBarDelegate; | 21 class ThemeInstalledInfoBarDelegate; |
| 20 class TranslateInfoBarDelegate; | 22 class TranslateInfoBarDelegate; |
| 21 | 23 |
| 22 namespace gfx { | 24 namespace gfx { |
| 23 class Image; | 25 class Image; |
| 24 } | 26 } |
| 25 | 27 |
| 26 // An interface implemented by objects wishing to control an InfoBar. | 28 // An interface implemented by objects wishing to control an InfoBar. |
| 27 // Implementing this interface is not sufficient to use an InfoBar, since it | 29 // Implementing this interface is not sufficient to use an InfoBar, since it |
| 28 // does not map to a specific InfoBar type. Instead, you must implement either | 30 // does not map to a specific InfoBar type. Instead, you must implement either |
| 29 // LinkInfoBarDelegate or ConfirmInfoBarDelegate, or override with your own | 31 // LinkInfoBarDelegate or ConfirmInfoBarDelegate, or override with your own |
| 30 // delegate for your own InfoBar variety. | 32 // delegate for your own InfoBar variety. |
| 31 class InfoBarDelegate { | 33 class InfoBarDelegate { |
| 32 public: | 34 public: |
| 33 // The type of the infobar. It controls its appearance, such as its background | 35 // The type of the infobar. It controls its appearance, such as its background |
| 34 // color. | 36 // color. |
| 35 enum Type { | 37 enum Type { |
| 36 WARNING_TYPE, | 38 WARNING_TYPE, |
| 37 PAGE_ACTION_TYPE, | 39 PAGE_ACTION_TYPE, |
| 38 }; | 40 }; |
| 39 | 41 |
| 40 virtual ~InfoBarDelegate(); | 42 virtual ~InfoBarDelegate(); |
| 41 | 43 |
| 42 // Called to create the InfoBar. Implementation of this method is | 44 // Called to create the InfoBar. Implementation of this method is |
| 43 // platform-specific. | 45 // platform-specific. |
| 44 virtual InfoBar* CreateInfoBar() = 0; | 46 virtual InfoBar* CreateInfoBar(TabContentsWrapper* owner) = 0; |
| 45 | 47 |
| 46 // Returns true if the supplied |delegate| is equal to this one. Equality is | 48 // Returns true if the supplied |delegate| is equal to this one. Equality is |
| 47 // left to the implementation to define. This function is called by the | 49 // left to the implementation to define. This function is called by the |
| 48 // TabContents when determining whether or not a delegate should be added | 50 // TabContentsWrapper when determining whether or not a delegate should be |
| 49 // because a matching one already exists. If this function returns true, the | 51 // added because a matching one already exists. If this function returns true, |
| 50 // TabContents will not add the new delegate because it considers one to | 52 // the TabContentsWrapper will not add the new delegate because it considers |
| 51 // already be present. | 53 // one to already be present. |
| 52 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; | 54 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; |
| 53 | 55 |
| 54 // Returns true if the InfoBar should be closed automatically after the page | 56 // Returns true if the InfoBar should be closed automatically after the page |
| 55 // is navigated. The default behavior is to return true if the user initiated | 57 // is navigated. The default behavior is to return true if the user initiated |
| 56 // navigation somewhere else or reloaded. | 58 // navigation somewhere else or reloaded. |
| 57 virtual bool ShouldExpire( | 59 virtual bool ShouldExpire( |
| 58 const NavigationController::LoadCommittedDetails& details) const; | 60 const NavigationController::LoadCommittedDetails& details) const; |
| 59 | 61 |
| 60 // Called when the user clicks on the close button to dismiss the infobar. | 62 // Called when the user clicks on the close button to dismiss the infobar. |
| 61 virtual void InfoBarDismissed(); | 63 virtual void InfoBarDismissed(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 99 |
| 98 private: | 100 private: |
| 99 // The unique id of the active NavigationEntry of the TabContents that we were | 101 // The unique id of the active NavigationEntry of the TabContents that we were |
| 100 // opened for. Used to help expire on navigations. | 102 // opened for. Used to help expire on navigations. |
| 101 int contents_unique_id_; | 103 int contents_unique_id_; |
| 102 | 104 |
| 103 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); | 105 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); |
| 104 }; | 106 }; |
| 105 | 107 |
| 106 #endif // CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ | 108 #endif // CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ |
| OLD | NEW |