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

Side by Side Diff: chrome/browser/ui/views/infobars/extension_infobar.cc

Issue 10913243: extensions: Add ExtensionView interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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/ui/views/infobars/extension_infobar.h" 5 #include "chrome/browser/ui/views/infobars/extension_infobar.h"
6 6
7 #include "chrome/browser/extensions/extension_context_menu_model.h" 7 #include "chrome/browser/extensions/extension_context_menu_model.h"
8 #include "chrome/browser/extensions/extension_host.h" 8 #include "chrome/browser/extensions/extension_host.h"
9 #include "chrome/browser/extensions/extension_infobar_delegate.h" 9 #include "chrome/browser/extensions/extension_infobar_delegate.h"
10 #include "chrome/browser/infobars/infobar_tab_helper.h" 10 #include "chrome/browser/infobars/infobar_tab_helper.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 GetDelegate()->set_observer(NULL); 94 GetDelegate()->set_observer(NULL);
95 } 95 }
96 96
97 void ExtensionInfoBar::Layout() { 97 void ExtensionInfoBar::Layout() {
98 InfoBarView::Layout(); 98 InfoBarView::Layout();
99 99
100 gfx::Size menu_size = menu_->GetPreferredSize(); 100 gfx::Size menu_size = menu_->GetPreferredSize();
101 menu_->SetBounds(StartX(), OffsetY(menu_size), menu_size.width(), 101 menu_->SetBounds(StartX(), OffsetY(menu_size), menu_size.width(),
102 menu_size.height()); 102 menu_size.height());
103 103
104 GetDelegate()->extension_host()->view()->SetBounds( 104 GetDelegate()->extension_host()->extension_view()->SetBounds(
105 menu_->bounds().right() + kMenuHorizontalMargin, 105 menu_->bounds().right() + kMenuHorizontalMargin,
106 arrow_height(), 106 arrow_height(),
107 std::max(0, EndX() - StartX() - ContentMinimumWidth()), 107 std::max(0, EndX() - StartX() - ContentMinimumWidth()),
108 height() - arrow_height() - 1); 108 height() - arrow_height() - 1);
109 } 109 }
110 110
111 void ExtensionInfoBar::ViewHierarchyChanged(bool is_add, 111 void ExtensionInfoBar::ViewHierarchyChanged(bool is_add,
112 views::View* parent, 112 views::View* parent,
113 views::View* child) { 113 views::View* child) {
114 if (!is_add || (child != this) || (menu_ != NULL)) { 114 if (!is_add || (child != this) || (menu_ != NULL)) {
115 InfoBarView::ViewHierarchyChanged(is_add, parent, child); 115 InfoBarView::ViewHierarchyChanged(is_add, parent, child);
116 return; 116 return;
117 } 117 }
118 118
119 menu_ = new views::MenuButton(NULL, string16(), this, false); 119 menu_ = new views::MenuButton(NULL, string16(), this, false);
120 menu_->SetVisible(false); 120 menu_->SetVisible(false);
121 menu_->set_focusable(true); 121 menu_->set_focusable(true);
122 AddChildView(menu_); 122 AddChildView(menu_);
123 123
124 extensions::ExtensionHost* extension_host = GetDelegate()->extension_host(); 124 extensions::ExtensionHost* extension_host = GetDelegate()->extension_host();
125 AddChildView(extension_host->view()); 125 AddChildView(extension_host->extension_view());
tfarina 2012/09/13 03:23:07 we can't do this way, because extension_view/Exten
126 126
127 // This must happen after adding all other children so InfoBarView can ensure 127 // This must happen after adding all other children so InfoBarView can ensure
128 // the close button is the last child. 128 // the close button is the last child.
129 InfoBarView::ViewHierarchyChanged(is_add, parent, child); 129 InfoBarView::ViewHierarchyChanged(is_add, parent, child);
130 130
131 // This must happen after adding all children because it can trigger layout, 131 // This must happen after adding all children because it can trigger layout,
132 // which assumes that particular children (e.g. the close button) have already 132 // which assumes that particular children (e.g. the close button) have already
133 // been added. 133 // been added.
134 const extensions::Extension* extension = extension_host->extension(); 134 const extensions::Extension* extension = extension_host->extension();
135 extension_misc::ExtensionIcons image_size = 135 extension_misc::ExtensionIcons image_size =
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 scoped_refptr<ExtensionContextMenuModel> options_menu_contents = 185 scoped_refptr<ExtensionContextMenuModel> options_menu_contents =
186 new ExtensionContextMenuModel(extension, browser_); 186 new ExtensionContextMenuModel(extension, browser_);
187 DCHECK_EQ(menu_, source); 187 DCHECK_EQ(menu_, source);
188 RunMenuAt(options_menu_contents.get(), menu_, views::MenuItemView::TOPLEFT); 188 RunMenuAt(options_menu_contents.get(), menu_, views::MenuItemView::TOPLEFT);
189 } 189 }
190 190
191 ExtensionInfoBarDelegate* ExtensionInfoBar::GetDelegate() { 191 ExtensionInfoBarDelegate* ExtensionInfoBar::GetDelegate() {
192 return delegate_ ? delegate_->AsExtensionInfoBarDelegate() : NULL; 192 return delegate_ ? delegate_->AsExtensionInfoBarDelegate() : NULL;
193 } 193 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/extensions/extension_view_views.cc ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698