Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: chrome/browser/extensions/extension_infobar_delegate.cc

Issue 190063006: Infobar Componentization Proof of Concept (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor fixes Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 22 matching lines...) Expand all
33 ExtensionInfoBarDelegate::ExtensionInfoBarDelegate( 33 ExtensionInfoBarDelegate::ExtensionInfoBarDelegate(
34 Browser* browser, 34 Browser* browser,
35 const extensions::Extension* extension, 35 const extensions::Extension* extension,
36 const GURL& url, 36 const GURL& url,
37 content::WebContents* web_contents, 37 content::WebContents* web_contents,
38 int height) 38 int height)
39 : InfoBarDelegate(), 39 : InfoBarDelegate(),
40 #if defined(TOOLKIT_VIEWS) 40 #if defined(TOOLKIT_VIEWS)
41 browser_(browser), 41 browser_(browser),
42 #endif 42 #endif
43 web_contents_(web_contents),
43 extension_(extension), 44 extension_(extension),
44 closing_(false) { 45 closing_(false) {
45 extension_view_host_.reset( 46 extension_view_host_.reset(
46 extensions::ExtensionViewHostFactory::CreateInfobarHost(url, browser)); 47 extensions::ExtensionViewHostFactory::CreateInfobarHost(url, browser));
47 extension_view_host_->SetAssociatedWebContents(web_contents); 48 extension_view_host_->SetAssociatedWebContents(web_contents);
48 49
49 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, 50 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
50 content::Source<Profile>(browser->profile())); 51 content::Source<Profile>(browser->profile()));
51 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 52 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
52 content::Source<Profile>(browser->profile())); 53 content::Source<Profile>(browser->profile()));
(...skipping 29 matching lines...) Expand all
82 83
83 InfoBarDelegate::Type ExtensionInfoBarDelegate::GetInfoBarType() const { 84 InfoBarDelegate::Type ExtensionInfoBarDelegate::GetInfoBarType() const {
84 return PAGE_ACTION_TYPE; 85 return PAGE_ACTION_TYPE;
85 } 86 }
86 87
87 ExtensionInfoBarDelegate* 88 ExtensionInfoBarDelegate*
88 ExtensionInfoBarDelegate::AsExtensionInfoBarDelegate() { 89 ExtensionInfoBarDelegate::AsExtensionInfoBarDelegate() {
89 return this; 90 return this;
90 } 91 }
91 92
93 void ExtensionInfoBarDelegate::CleanUp() { web_contents_ = NULL; }
94
92 void ExtensionInfoBarDelegate::Observe( 95 void ExtensionInfoBarDelegate::Observe(
93 int type, 96 int type,
94 const content::NotificationSource& source, 97 const content::NotificationSource& source,
95 const content::NotificationDetails& details) { 98 const content::NotificationDetails& details) {
96 if (type == chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE) { 99 if (type == chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE) {
97 if (extension_view_host_.get() == 100 if (extension_view_host_.get() ==
98 content::Details<extensions::ExtensionHost>(details).ptr()) 101 content::Details<extensions::ExtensionHost>(details).ptr())
99 infobar()->RemoveSelf(); 102 infobar()->RemoveSelf();
100 } else { 103 } else {
101 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED); 104 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED);
102 if (extension_ == content::Details<extensions::UnloadedExtensionInfo>( 105 if (extension_ == content::Details<extensions::UnloadedExtensionInfo>(
103 details)->extension) 106 details)->extension)
104 infobar()->RemoveSelf(); 107 infobar()->RemoveSelf();
105 } 108 }
106 } 109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698