| 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 30 matching lines...) Expand all Loading... |
| 41 browser_(browser), | 41 browser_(browser), |
| 42 #endif | 42 #endif |
| 43 extension_(extension), | 43 extension_(extension), |
| 44 closing_(false) { | 44 closing_(false) { |
| 45 extension_view_host_.reset( | 45 extension_view_host_.reset( |
| 46 extensions::ExtensionViewHostFactory::CreateInfobarHost(url, browser)); | 46 extensions::ExtensionViewHostFactory::CreateInfobarHost(url, browser)); |
| 47 extension_view_host_->SetAssociatedWebContents(web_contents); | 47 extension_view_host_->SetAssociatedWebContents(web_contents); |
| 48 | 48 |
| 49 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, | 49 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
| 50 content::Source<Profile>(browser->profile())); | 50 content::Source<Profile>(browser->profile())); |
| 51 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 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 // ExtensionInfoBarDelegate::CreateInfoBar() is implemented in platform-specific | 60 // ExtensionInfoBarDelegate::CreateInfoBar() is implemented in platform-specific |
| 61 // files. | 61 // files. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 91 | 91 |
| 92 void ExtensionInfoBarDelegate::Observe( | 92 void ExtensionInfoBarDelegate::Observe( |
| 93 int type, | 93 int type, |
| 94 const content::NotificationSource& source, | 94 const content::NotificationSource& source, |
| 95 const content::NotificationDetails& details) { | 95 const content::NotificationDetails& details) { |
| 96 if (type == chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE) { | 96 if (type == chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE) { |
| 97 if (extension_view_host_.get() == | 97 if (extension_view_host_.get() == |
| 98 content::Details<extensions::ExtensionHost>(details).ptr()) | 98 content::Details<extensions::ExtensionHost>(details).ptr()) |
| 99 infobar()->RemoveSelf(); | 99 infobar()->RemoveSelf(); |
| 100 } else { | 100 } else { |
| 101 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED); | 101 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED); |
| 102 if (extension_ == content::Details<extensions::UnloadedExtensionInfo>( | 102 if (extension_ == content::Details<extensions::UnloadedExtensionInfo>( |
| 103 details)->extension) | 103 details)->extension) |
| 104 infobar()->RemoveSelf(); | 104 infobar()->RemoveSelf(); |
| 105 } | 105 } |
| 106 } | 106 } |
| OLD | NEW |