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_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
9 #include "chrome/browser/extensions/extension_process_manager.h" | 9 #include "chrome/browser/extensions/extension_host_factory.h" |
10 #include "chrome/browser/extensions/extension_system.h" | |
11 #include "chrome/browser/infobars/infobar.h" | 10 #include "chrome/browser/infobars/infobar.h" |
12 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
13 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
16 #include "content/public/browser/notification_details.h" | 15 #include "content/public/browser/notification_details.h" |
17 #include "content/public/browser/notification_source.h" | 16 #include "content/public/browser/notification_source.h" |
18 | 17 |
19 | |
20 ExtensionInfoBarDelegate::~ExtensionInfoBarDelegate() { | 18 ExtensionInfoBarDelegate::~ExtensionInfoBarDelegate() { |
21 if (observer_) | 19 if (observer_) |
22 observer_->OnDelegateDeleted(); | 20 observer_->OnDelegateDeleted(); |
23 } | 21 } |
24 | 22 |
25 // static | 23 // static |
26 void ExtensionInfoBarDelegate::Create(InfoBarService* infobar_service, | 24 void ExtensionInfoBarDelegate::Create(InfoBarService* infobar_service, |
27 Browser* browser, | 25 Browser* browser, |
28 const extensions::Extension* extension, | 26 const extensions::Extension* extension, |
29 const GURL& url, | 27 const GURL& url, |
(...skipping 10 matching lines...) Expand all Loading... |
40 const GURL& url, | 38 const GURL& url, |
41 content::WebContents* web_contents, | 39 content::WebContents* web_contents, |
42 int height) | 40 int height) |
43 : InfoBarDelegate(infobar_service), | 41 : InfoBarDelegate(infobar_service), |
44 #if defined(TOOLKIT_VIEWS) | 42 #if defined(TOOLKIT_VIEWS) |
45 browser_(browser), | 43 browser_(browser), |
46 #endif | 44 #endif |
47 observer_(NULL), | 45 observer_(NULL), |
48 extension_(extension), | 46 extension_(extension), |
49 closing_(false) { | 47 closing_(false) { |
50 ExtensionProcessManager* manager = | 48 extension_host_.reset( |
51 extensions::ExtensionSystem::Get(browser->profile())->process_manager(); | 49 extensions::ExtensionHostFactory::CreateInfobarHost(url, browser)); |
52 extension_host_.reset(manager->CreateInfobarHost(url, browser)); | |
53 extension_host_->SetAssociatedWebContents(web_contents); | 50 extension_host_->SetAssociatedWebContents(web_contents); |
54 | 51 |
55 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, | 52 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
56 content::Source<Profile>(browser->profile())); | 53 content::Source<Profile>(browser->profile())); |
57 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 54 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
58 content::Source<Profile>(browser->profile())); | 55 content::Source<Profile>(browser->profile())); |
59 | 56 |
60 #if defined(TOOLKIT_VIEWS) || defined(TOOLKIT_GTK) || defined(OS_ANDROID) | 57 #if defined(TOOLKIT_VIEWS) || defined(TOOLKIT_GTK) || defined(OS_ANDROID) |
61 // TODO(dtrainor): On Android, this is not used. Might need to pull this from | 58 // TODO(dtrainor): On Android, this is not used. Might need to pull this from |
62 // Android UI level in the future. Tracked via issue 115303. | 59 // Android UI level in the future. Tracked via issue 115303. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 if (extension_host_.get() == | 106 if (extension_host_.get() == |
110 content::Details<extensions::ExtensionHost>(details).ptr()) | 107 content::Details<extensions::ExtensionHost>(details).ptr()) |
111 RemoveSelf(); | 108 RemoveSelf(); |
112 } else { | 109 } else { |
113 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED); | 110 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED); |
114 if (extension_ == content::Details<extensions::UnloadedExtensionInfo>( | 111 if (extension_ == content::Details<extensions::UnloadedExtensionInfo>( |
115 details)->extension) | 112 details)->extension) |
116 RemoveSelf(); | 113 RemoveSelf(); |
117 } | 114 } |
118 } | 115 } |
OLD | NEW |