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

Unified Diff: chrome/browser/ui/views/infobars/link_infobar.cc

Issue 11721003: Eliminate the LinkInfoBar[Delegate] classes entirely. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address some nits - testing-automation matters? Created 7 years, 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/infobars/link_infobar.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/infobars/link_infobar.cc
diff --git a/chrome/browser/ui/views/infobars/link_infobar.cc b/chrome/browser/ui/views/infobars/link_infobar.cc
deleted file mode 100644
index 46caaf4c6418300633ee697921c8f329a8aa2f7c..0000000000000000000000000000000000000000
--- a/chrome/browser/ui/views/infobars/link_infobar.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/views/infobars/link_infobar.h"
-
-#include "base/logging.h"
-#include "chrome/browser/api/infobars/link_infobar_delegate.h"
-#include "chrome/browser/event_disposition.h"
-#include "ui/views/controls/label.h"
-#include "ui/views/controls/link.h"
-
-// LinkInfoBarDelegate --------------------------------------------------------
-
-InfoBar* LinkInfoBarDelegate::CreateInfoBar(InfoBarService* owner) {
- return new LinkInfoBar(owner, this);
-}
-
-// LinkInfoBar ----------------------------------------------------------------
-
-LinkInfoBar::LinkInfoBar(InfoBarService* owner,
- LinkInfoBarDelegate* delegate)
- : InfoBarView(owner, delegate),
- label_1_(NULL),
- link_(NULL),
- label_2_(NULL) {
-}
-
-LinkInfoBar::~LinkInfoBar() {
-}
-
-void LinkInfoBar::Layout() {
- InfoBarView::Layout();
-
- // TODO(pkasting): This isn't perfect; there are points when we should elide a
- // view because its subsequent view will be too small to show an ellipsis.
- gfx::Size label_1_size = label_1_->GetPreferredSize();
- int available_width = EndX() - StartX();
- label_1_->SetBounds(StartX(), OffsetY(label_1_size),
- std::min(label_1_size.width(), available_width), label_1_size.height());
- available_width = std::max(0, available_width - label_1_size.width());
-
- gfx::Size link_size = link_->GetPreferredSize();
- link_->SetBounds(label_1_->bounds().right(), OffsetY(link_size),
- std::min(link_size.width(), available_width), link_size.height());
- available_width = std::max(0, available_width - link_size.width());
-
- gfx::Size label_2_size = label_2_->GetPreferredSize();
- label_2_->SetBounds(link_->bounds().right(), OffsetY(label_2_size),
- std::min(label_2_size.width(), available_width), label_2_size.height());
-}
-
-void LinkInfoBar::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
- if (is_add && (child == this) && (label_1_ == NULL)) {
- LinkInfoBarDelegate* delegate = GetDelegate();
- size_t offset;
- string16 message_text = delegate->GetMessageTextWithOffset(&offset);
- DCHECK_NE(string16::npos, offset);
- label_1_ = CreateLabel(message_text.substr(0, offset));
- AddChildView(label_1_);
-
- link_ = CreateLink(delegate->GetLinkText(), this);
- AddChildView(link_);
-
- label_2_ = CreateLabel(message_text.substr(offset));
- AddChildView(label_2_);
- }
-
- // This must happen after adding all other children so InfoBarView can ensure
- // the close button is the last child.
- InfoBarView::ViewHierarchyChanged(is_add, parent, child);
-}
-
-void LinkInfoBar::LinkClicked(views::Link* source, int event_flags) {
- if (!owned())
- return; // We're closing; don't call anything, it might access the owner.
- DCHECK(link_ != NULL);
- DCHECK_EQ(link_, source);
- if (GetDelegate()->LinkClicked(
- chrome::DispositionFromEventFlags(event_flags)))
- RemoveSelf();
-}
-
-LinkInfoBarDelegate* LinkInfoBar::GetDelegate() {
- return delegate()->AsLinkInfoBarDelegate();
-}
« no previous file with comments | « chrome/browser/ui/views/infobars/link_infobar.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698