| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "chrome/common/l10n_util.h" | 6 #include "chrome/common/l10n_util.h" |
| 7 #include "chrome/browser/profile.h" | 7 #include "chrome/browser/profile.h" |
| 8 #include "chrome/browser/views/password_manager_view.h" | 8 #include "chrome/browser/views/password_manager_view.h" |
| 9 #include "chrome/browser/views/standard_layout.h" | 9 #include "chrome/browser/views/standard_layout.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // MultiLabelButtons | 29 // MultiLabelButtons |
| 30 // | 30 // |
| 31 MultiLabelButtons::MultiLabelButtons(const std::wstring& label, | 31 MultiLabelButtons::MultiLabelButtons(const std::wstring& label, |
| 32 const std::wstring& alt_label) | 32 const std::wstring& alt_label) |
| 33 : NativeButton(label), | 33 : NativeButton(label), |
| 34 label_(label), | 34 label_(label), |
| 35 alt_label_(alt_label), | 35 alt_label_(alt_label), |
| 36 pref_size_(-1, -1) { | 36 pref_size_(-1, -1) { |
| 37 } | 37 } |
| 38 | 38 |
| 39 void MultiLabelButtons::GetPreferredSize(CSize *out) { | 39 gfx::Size MultiLabelButtons::GetPreferredSize() { |
| 40 if (pref_size_.cx == -1 && pref_size_.cy == -1) { | 40 if (pref_size_.width() == -1 && pref_size_.height() == -1) { |
| 41 // Let's compute our preferred size. | 41 // Let's compute our preferred size. |
| 42 std::wstring current_label = GetLabel(); | 42 std::wstring current_label = GetLabel(); |
| 43 SetLabel(label_); | 43 SetLabel(label_); |
| 44 NativeButton::GetPreferredSize(&pref_size_); | 44 pref_size_ = NativeButton::GetPreferredSize(); |
| 45 SetLabel(alt_label_); | 45 SetLabel(alt_label_); |
| 46 CSize alt_pref_size; | 46 gfx::Size alt_pref_size = NativeButton::GetPreferredSize(); |
| 47 NativeButton::GetPreferredSize(&alt_pref_size); | |
| 48 // Revert to the original label. | 47 // Revert to the original label. |
| 49 SetLabel(current_label); | 48 SetLabel(current_label); |
| 50 pref_size_.cx = std::max(pref_size_.cx, alt_pref_size.cx); | 49 pref_size_.SetSize(std::max(pref_size_.width(), alt_pref_size.width()), |
| 51 pref_size_.cy = std::max(pref_size_.cy, alt_pref_size.cy); | 50 std::max(pref_size_.height(), alt_pref_size.height())); |
| 52 } | 51 } |
| 53 *out = pref_size_; | 52 return gfx::Size(pref_size_.width(), pref_size_.height()); |
| 54 } | 53 } |
| 55 | 54 |
| 56 //////////////////////////////////////////////////////////////////// | 55 //////////////////////////////////////////////////////////////////// |
| 57 // PasswordManagerTableModel::PasswordRow | 56 // PasswordManagerTableModel::PasswordRow |
| 58 PasswordManagerTableModel::PasswordRow::~PasswordRow() { | 57 PasswordManagerTableModel::PasswordRow::~PasswordRow() { |
| 59 delete form; | 58 delete form; |
| 60 } | 59 } |
| 61 | 60 |
| 62 //////////////////////////////////////////////////////////////////// | 61 //////////////////////////////////////////////////////////////////// |
| 63 // PasswordManagerTableModel | 62 // PasswordManagerTableModel |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 PasswordManagerView::~PasswordManagerView() { | 288 PasswordManagerView::~PasswordManagerView() { |
| 290 } | 289 } |
| 291 | 290 |
| 292 void PasswordManagerView::Layout() { | 291 void PasswordManagerView::Layout() { |
| 293 GetLayoutManager()->Layout(this); | 292 GetLayoutManager()->Layout(this); |
| 294 | 293 |
| 295 // Manually lay out the Remove All button in the same row as | 294 // Manually lay out the Remove All button in the same row as |
| 296 // the close button. | 295 // the close button. |
| 297 CRect parent_bounds; | 296 CRect parent_bounds; |
| 298 GetParent()->GetLocalBounds(&parent_bounds, false); | 297 GetParent()->GetLocalBounds(&parent_bounds, false); |
| 299 CSize prefsize; | 298 gfx::Size prefsize = remove_all_button_.GetPreferredSize(); |
| 300 remove_all_button_.GetPreferredSize(&prefsize); | 299 int button_y = parent_bounds.bottom - prefsize.height() - kButtonVEdgeMargin; |
| 301 int button_y = parent_bounds.bottom - prefsize.cy - kButtonVEdgeMargin; | 300 remove_all_button_.SetBounds(kPanelHorizMargin, button_y, prefsize.width(), |
| 302 remove_all_button_.SetBounds(kPanelHorizMargin, button_y, prefsize.cx, | 301 prefsize.height()); |
| 303 prefsize.cy); | |
| 304 } | 302 } |
| 305 | 303 |
| 306 void PasswordManagerView::GetPreferredSize(CSize* out) { | 304 gfx::Size PasswordManagerView::GetPreferredSize() { |
| 307 out->cx = kDefaultWindowWidth; | 305 return gfx::Size(kDefaultWindowWidth, kDefaultWindowHeight); |
| 308 out->cy = kDefaultWindowHeight; | |
| 309 } | 306 } |
| 310 | 307 |
| 311 void PasswordManagerView::ViewHierarchyChanged(bool is_add, | 308 void PasswordManagerView::ViewHierarchyChanged(bool is_add, |
| 312 ChromeViews::View* parent, | 309 ChromeViews::View* parent, |
| 313 ChromeViews::View* child) { | 310 ChromeViews::View* child) { |
| 314 if (child == this) { | 311 if (child == this) { |
| 315 // Add and remove the Remove All button from the ClientView's hierarchy. | 312 // Add and remove the Remove All button from the ClientView's hierarchy. |
| 316 if (is_add) { | 313 if (is_add) { |
| 317 parent->AddChildView(&remove_all_button_); | 314 parent->AddChildView(&remove_all_button_); |
| 318 } else { | 315 } else { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 table_view_->SetModel(NULL); | 389 table_view_->SetModel(NULL); |
| 393 | 390 |
| 394 // Clear the static instance so the next time Show() is called, a new | 391 // Clear the static instance so the next time Show() is called, a new |
| 395 // instance is created. | 392 // instance is created. |
| 396 instance_ = NULL; | 393 instance_ = NULL; |
| 397 } | 394 } |
| 398 | 395 |
| 399 ChromeViews::View* PasswordManagerView::GetContentsView() { | 396 ChromeViews::View* PasswordManagerView::GetContentsView() { |
| 400 return this; | 397 return this; |
| 401 } | 398 } |
| OLD | NEW |