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

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

Issue 7635019: Set Extension Infobars to have a fixed height determined by the developer (clamped to sane min an... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extensions/extension_host.h" 7 #include "chrome/browser/extensions/extension_host.h"
8 #include "chrome/browser/extensions/extension_process_manager.h" 8 #include "chrome/browser/extensions/extension_process_manager.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/tab_contents/infobar.h"
10 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
11 #include "chrome/common/chrome_notification_types.h" 12 #include "chrome/common/chrome_notification_types.h"
12 #include "chrome/common/extensions/extension.h" 13 #include "chrome/common/extensions/extension.h"
13 #include "content/common/notification_details.h" 14 #include "content/common/notification_details.h"
14 #include "content/common/notification_source.h" 15 #include "content/common/notification_source.h"
15 16
16 ExtensionInfoBarDelegate::ExtensionInfoBarDelegate(Browser* browser, 17 ExtensionInfoBarDelegate::ExtensionInfoBarDelegate(Browser* browser,
17 TabContents* tab_contents, 18 TabContents* tab_contents,
18 const Extension* extension, 19 const Extension* extension,
19 const GURL& url) 20 const GURL& url,
21 int height)
20 : InfoBarDelegate(tab_contents), 22 : InfoBarDelegate(tab_contents),
21 observer_(NULL), 23 observer_(NULL),
22 extension_(extension), 24 extension_(extension),
23 closing_(false) { 25 closing_(false) {
24 ExtensionProcessManager* manager = 26 ExtensionProcessManager* manager =
25 browser->profile()->GetExtensionProcessManager(); 27 browser->profile()->GetExtensionProcessManager();
26 extension_host_.reset(manager->CreateInfobarHost(url, browser)); 28 extension_host_.reset(manager->CreateInfobarHost(url, browser));
27 extension_host_->set_associated_tab_contents(tab_contents); 29 extension_host_->set_associated_tab_contents(tab_contents);
28 30
29 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, 31 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
30 Source<Profile>(browser->profile())); 32 Source<Profile>(browser->profile()));
31 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 33 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
32 Source<Profile>(browser->profile())); 34 Source<Profile>(browser->profile()));
35
36 height_ = std::max(0, height);
37 height_ = std::min(2 * InfoBar::kDefaultBarTargetHeight, height_);
38 if (height_ == 0)
39 height_ = InfoBar::kDefaultBarTargetHeight;
33 } 40 }
34 41
35 ExtensionInfoBarDelegate::~ExtensionInfoBarDelegate() { 42 ExtensionInfoBarDelegate::~ExtensionInfoBarDelegate() {
36 if (observer_) 43 if (observer_)
37 observer_->OnDelegateDeleted(); 44 observer_->OnDelegateDeleted();
38 } 45 }
39 46
40 bool ExtensionInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { 47 bool ExtensionInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
41 ExtensionInfoBarDelegate* extension_delegate = 48 ExtensionInfoBarDelegate* extension_delegate =
42 delegate->AsExtensionInfoBarDelegate(); 49 delegate->AsExtensionInfoBarDelegate();
(...skipping 28 matching lines...) Expand all
71 const NotificationDetails& details) { 78 const NotificationDetails& details) {
72 if (type == chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE) { 79 if (type == chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE) {
73 if (extension_host_.get() == Details<ExtensionHost>(details).ptr()) 80 if (extension_host_.get() == Details<ExtensionHost>(details).ptr())
74 RemoveSelf(); 81 RemoveSelf();
75 } else { 82 } else {
76 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED); 83 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED);
77 if (extension_ == Details<UnloadedExtensionInfo>(details)->extension) 84 if (extension_ == Details<UnloadedExtensionInfo>(details)->extension)
78 RemoveSelf(); 85 RemoveSelf();
79 } 86 }
80 } 87 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698