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_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/infobar_container_delegate.h" |
13 #include "components/infobars/core/infobar.h" | 14 #include "components/infobars/core/infobar.h" |
14 #include "content/public/browser/notification_details.h" | 15 #include "content/public/browser/notification_details.h" |
15 #include "content/public/browser/notification_source.h" | 16 #include "content/public/browser/notification_source.h" |
16 #include "extensions/browser/extension_registry.h" | 17 #include "extensions/browser/extension_registry.h" |
17 #include "extensions/common/extension.h" | 18 #include "extensions/common/extension.h" |
18 | 19 |
19 ExtensionInfoBarDelegate::~ExtensionInfoBarDelegate() { | 20 ExtensionInfoBarDelegate::~ExtensionInfoBarDelegate() { |
20 } | 21 } |
21 | 22 |
22 // static | 23 // static |
(...skipping 25 matching lines...) Expand all Loading... |
48 extensions::ExtensionViewHostFactory::CreateInfobarHost(url, browser)); | 49 extensions::ExtensionViewHostFactory::CreateInfobarHost(url, browser)); |
49 extension_view_host_->SetAssociatedWebContents(web_contents); | 50 extension_view_host_->SetAssociatedWebContents(web_contents); |
50 | 51 |
51 extension_registry_observer_.Add( | 52 extension_registry_observer_.Add( |
52 extensions::ExtensionRegistry::Get(browser->profile())); | 53 extensions::ExtensionRegistry::Get(browser->profile())); |
53 registrar_.Add(this, | 54 registrar_.Add(this, |
54 extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, | 55 extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
55 content::Source<Profile>(browser->profile())); | 56 content::Source<Profile>(browser->profile())); |
56 | 57 |
57 height_ = std::max(0, height); | 58 height_ = std::max(0, height); |
58 height_ = std::min(2 * infobars::InfoBar::kDefaultBarTargetHeight, height_); | 59 height_ = |
| 60 std::min(2 * InfoBarContainerDelegate::kDefaultBarTargetHeight, height_); |
59 if (height_ == 0) | 61 if (height_ == 0) |
60 height_ = infobars::InfoBar::kDefaultBarTargetHeight; | 62 height_ = InfoBarContainerDelegate::kDefaultBarTargetHeight; |
61 } | 63 } |
62 | 64 |
63 content::WebContents* ExtensionInfoBarDelegate::GetWebContents() { | 65 content::WebContents* ExtensionInfoBarDelegate::GetWebContents() { |
64 return InfoBarService::WebContentsFromInfoBar(infobar()); | 66 return InfoBarService::WebContentsFromInfoBar(infobar()); |
65 } | 67 } |
66 | 68 |
67 // ExtensionInfoBarDelegate::CreateInfoBar() is implemented in platform-specific | 69 // ExtensionInfoBarDelegate::CreateInfoBar() is implemented in platform-specific |
68 // files. | 70 // files. |
69 | 71 |
70 bool ExtensionInfoBarDelegate::EqualsDelegate( | 72 bool ExtensionInfoBarDelegate::EqualsDelegate( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 110 |
109 void ExtensionInfoBarDelegate::Observe( | 111 void ExtensionInfoBarDelegate::Observe( |
110 int type, | 112 int type, |
111 const content::NotificationSource& source, | 113 const content::NotificationSource& source, |
112 const content::NotificationDetails& details) { | 114 const content::NotificationDetails& details) { |
113 DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE); | 115 DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE); |
114 if (extension_view_host_.get() == | 116 if (extension_view_host_.get() == |
115 content::Details<extensions::ExtensionHost>(details).ptr()) | 117 content::Details<extensions::ExtensionHost>(details).ptr()) |
116 infobar()->RemoveSelf(); | 118 infobar()->RemoveSelf(); |
117 } | 119 } |
OLD | NEW |