| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/extensions/extension_infobar_delegate.h" | 5 #include "chrome/browser/extensions/extension_infobar_delegate.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/extensions/extension_view_host.h" | 8 #include "chrome/browser/extensions/extension_view_host.h" |
| 9 #include "chrome/browser/extensions/extension_view_host_factory.h" | 9 #include "chrome/browser/extensions/extension_view_host_factory.h" |
| 10 #include "chrome/browser/infobars/infobar.h" | 10 #include "chrome/browser/infobars/infobar.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 content::Source<Profile>(browser->profile())); | 50 content::Source<Profile>(browser->profile())); |
| 51 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 51 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 52 content::Source<Profile>(browser->profile())); | 52 content::Source<Profile>(browser->profile())); |
| 53 | 53 |
| 54 height_ = std::max(0, height); | 54 height_ = std::max(0, height); |
| 55 height_ = std::min(2 * InfoBar::kDefaultBarTargetHeight, height_); | 55 height_ = std::min(2 * InfoBar::kDefaultBarTargetHeight, height_); |
| 56 if (height_ == 0) | 56 if (height_ == 0) |
| 57 height_ = InfoBar::kDefaultBarTargetHeight; | 57 height_ = InfoBar::kDefaultBarTargetHeight; |
| 58 } | 58 } |
| 59 | 59 |
| 60 content::WebContents* ExtensionInfoBarDelegate::GetWebContents() { |
| 61 return InfoBarService::WebContentsFromInfoBar(infobar()); |
| 62 } |
| 63 |
| 60 // ExtensionInfoBarDelegate::CreateInfoBar() is implemented in platform-specific | 64 // ExtensionInfoBarDelegate::CreateInfoBar() is implemented in platform-specific |
| 61 // files. | 65 // files. |
| 62 | 66 |
| 63 bool ExtensionInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { | 67 bool ExtensionInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { |
| 64 ExtensionInfoBarDelegate* extension_delegate = | 68 ExtensionInfoBarDelegate* extension_delegate = |
| 65 delegate->AsExtensionInfoBarDelegate(); | 69 delegate->AsExtensionInfoBarDelegate(); |
| 66 // When an extension crashes, an InfoBar is shown (for the crashed extension). | 70 // When an extension crashes, an InfoBar is shown (for the crashed extension). |
| 67 // That will result in a call to this function (to see if this InfoBarDelegate | 71 // That will result in a call to this function (to see if this InfoBarDelegate |
| 68 // is already showing the 'extension crashed InfoBar', which it never is), but | 72 // is already showing the 'extension crashed InfoBar', which it never is), but |
| 69 // if it is our extension that crashes, the extension delegate is NULL so | 73 // if it is our extension that crashes, the extension delegate is NULL so |
| (...skipping 27 matching lines...) Expand all Loading... |
| 97 if (extension_view_host_.get() == | 101 if (extension_view_host_.get() == |
| 98 content::Details<extensions::ExtensionHost>(details).ptr()) | 102 content::Details<extensions::ExtensionHost>(details).ptr()) |
| 99 infobar()->RemoveSelf(); | 103 infobar()->RemoveSelf(); |
| 100 } else { | 104 } else { |
| 101 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED); | 105 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED); |
| 102 if (extension_ == content::Details<extensions::UnloadedExtensionInfo>( | 106 if (extension_ == content::Details<extensions::UnloadedExtensionInfo>( |
| 103 details)->extension) | 107 details)->extension) |
| 104 infobar()->RemoveSelf(); | 108 infobar()->RemoveSelf(); |
| 105 } | 109 } |
| 106 } | 110 } |
| OLD | NEW |