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

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

Issue 11644059: Change infobar creation to use a public static Create() method on the infobar delegate classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
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/api/infobars/infobar_service.h" 7 #include "chrome/browser/api/infobars/infobar_service.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_process_manager.h"
10 #include "chrome/browser/extensions/extension_system.h" 10 #include "chrome/browser/extensions/extension_system.h"
11 #include "chrome/browser/infobars/infobar.h" 11 #include "chrome/browser/infobars/infobar.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/common/chrome_notification_types.h" 14 #include "chrome/common/chrome_notification_types.h"
15 #include "chrome/common/extensions/extension.h" 15 #include "chrome/common/extensions/extension.h"
16 #include "content/public/browser/notification_details.h" 16 #include "content/public/browser/notification_details.h"
17 #include "content/public/browser/notification_source.h" 17 #include "content/public/browser/notification_source.h"
18 18
19
20 ExtensionInfoBarDelegate::~ExtensionInfoBarDelegate() {
21 if (observer_)
22 observer_->OnDelegateDeleted();
23 }
24
25 // static
26 void ExtensionInfoBarDelegate::Create(InfoBarService* infobar_service,
27 Browser* browser,
28 const extensions::Extension* extension,
29 const GURL& url,
30 int height) {
31 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
32 new ExtensionInfoBarDelegate(browser, infobar_service, extension, url,
33 height)));
34 }
35
19 ExtensionInfoBarDelegate::ExtensionInfoBarDelegate( 36 ExtensionInfoBarDelegate::ExtensionInfoBarDelegate(
20 Browser* browser, 37 Browser* browser,
21 InfoBarService* infobar_service, 38 InfoBarService* infobar_service,
22 const extensions::Extension* extension, 39 const extensions::Extension* extension,
23 const GURL& url, 40 const GURL& url,
24 int height) 41 int height)
25 : InfoBarDelegate(infobar_service), 42 : InfoBarDelegate(infobar_service),
26 browser_(browser), 43 browser_(browser),
27 observer_(NULL), 44 observer_(NULL),
28 extension_(extension), 45 extension_(extension),
(...skipping 18 matching lines...) Expand all
47 // TODO(dtrainor): This is not used. Might need to pull this from Android UI 64 // TODO(dtrainor): This is not used. Might need to pull this from Android UI
48 // level in the future. Tracked via issue 115303. 65 // level in the future. Tracked via issue 115303.
49 int default_height = 36; 66 int default_height = 36;
50 #endif 67 #endif
51 height_ = std::max(0, height); 68 height_ = std::max(0, height);
52 height_ = std::min(2 * default_height, height_); 69 height_ = std::min(2 * default_height, height_);
53 if (height_ == 0) 70 if (height_ == 0)
54 height_ = default_height; 71 height_ = default_height;
55 } 72 }
56 73
57 ExtensionInfoBarDelegate::~ExtensionInfoBarDelegate() {
58 if (observer_)
59 observer_->OnDelegateDeleted();
60 }
61
62 bool ExtensionInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { 74 bool ExtensionInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
63 ExtensionInfoBarDelegate* extension_delegate = 75 ExtensionInfoBarDelegate* extension_delegate =
64 delegate->AsExtensionInfoBarDelegate(); 76 delegate->AsExtensionInfoBarDelegate();
65 // When an extension crashes, an InfoBar is shown (for the crashed extension). 77 // When an extension crashes, an InfoBar is shown (for the crashed extension).
66 // That will result in a call to this function (to see if this InfoBarDelegate 78 // That will result in a call to this function (to see if this InfoBarDelegate
67 // is already showing the 'extension crashed InfoBar', which it never is), but 79 // is already showing the 'extension crashed InfoBar', which it never is), but
68 // if it is our extension that crashes, the extension delegate is NULL so 80 // if it is our extension that crashes, the extension delegate is NULL so
69 // we cannot check. 81 // we cannot check.
70 if (!extension_delegate) 82 if (!extension_delegate)
71 return false; 83 return false;
(...skipping 26 matching lines...) Expand all
98 RemoveSelf(); 110 RemoveSelf();
99 } else { 111 } else {
100 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED); 112 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED);
101 if (extension_ == 113 if (extension_ ==
102 content::Details<extensions::UnloadedExtensionInfo>( 114 content::Details<extensions::UnloadedExtensionInfo>(
103 details)->extension) { 115 details)->extension) {
104 RemoveSelf(); 116 RemoveSelf();
105 } 117 }
106 } 118 }
107 } 119 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_infobar_delegate.h ('k') | chrome/browser/extensions/extension_install_ui_default.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698