Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/global_error_bubble_view.h" | 5 #include "chrome/browser/ui/views/global_error_bubble_view.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/ui/global_error/global_error.h" | 10 #include "chrome/browser/ui/global_error/global_error.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 enum { | 28 enum { |
| 29 TAG_ACCEPT_BUTTON = 1, | 29 TAG_ACCEPT_BUTTON = 1, |
| 30 TAG_CANCEL_BUTTON, | 30 TAG_CANCEL_BUTTON, |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 const int kMaxBubbleViewWidth = 262; | 33 const int kMaxBubbleViewWidth = 262; |
| 34 | 34 |
| 35 // The vertical inset of the wrench bubble anchor from the wrench menu button. | 35 // The vertical inset of the wrench bubble anchor from the wrench menu button. |
| 36 const int kAnchorVerticalInset = 5; | 36 const int kAnchorVerticalInset = 5; |
| 37 | 37 |
| 38 // Align bubble text with the title. | |
| 39 const int kBubbleLeftPadding = 14; | |
| 40 | |
| 38 const int kBubblePadding = 6; | 41 const int kBubblePadding = 6; |
| 39 | 42 |
| 40 } // namespace | 43 } // namespace |
| 41 | 44 |
| 42 // GlobalErrorBubbleViewBase --------------------------------------------------- | 45 // GlobalErrorBubbleViewBase --------------------------------------------------- |
| 43 | 46 |
| 44 // static | 47 // static |
| 45 GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowStandardBubbleView( | 48 GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowStandardBubbleView( |
| 46 Browser* browser, | 49 Browser* browser, |
| 47 const base::WeakPtr<GlobalErrorWithStandardBubble>& error) { | 50 const base::WeakPtr<GlobalErrorWithStandardBubble>& error) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 if (!cancel_string.empty()) { | 102 if (!cancel_string.empty()) { |
| 100 cancel_button.reset(new views::LabelButton(this, cancel_string)); | 103 cancel_button.reset(new views::LabelButton(this, cancel_string)); |
| 101 cancel_button->SetStyle(views::Button::STYLE_BUTTON); | 104 cancel_button->SetStyle(views::Button::STYLE_BUTTON); |
| 102 cancel_button->set_tag(TAG_CANCEL_BUTTON); | 105 cancel_button->set_tag(TAG_CANCEL_BUTTON); |
| 103 } | 106 } |
| 104 | 107 |
| 105 views::GridLayout* layout = new views::GridLayout(this); | 108 views::GridLayout* layout = new views::GridLayout(this); |
| 106 SetLayoutManager(layout); | 109 SetLayoutManager(layout); |
| 107 | 110 |
| 108 // BubbleFrameView adds enough padding below title, no top padding needed. | 111 // BubbleFrameView adds enough padding below title, no top padding needed. |
| 109 layout->SetInsets(0, kBubblePadding, kBubblePadding, kBubblePadding); | 112 layout->SetInsets(0, kBubbleLeftPadding, kBubblePadding, kBubblePadding); |
|
msw
2015/02/27 01:57:05
You should probably leave the layout's insets empt
xiaoling
2015/02/27 02:24:12
Done.
| |
| 110 | 113 |
| 111 // First row, message labels. | 114 // First row, message labels. |
| 112 views::ColumnSet* cs = layout->AddColumnSet(0); | 115 views::ColumnSet* cs = layout->AddColumnSet(0); |
| 113 cs->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, | 116 cs->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, |
| 114 1, views::GridLayout::USE_PREF, 0, 0); | 117 1, views::GridLayout::USE_PREF, 0, 0); |
| 115 | 118 |
| 116 // Second row, accept and cancel button. | 119 // Second row, accept and cancel button. |
| 117 cs = layout->AddColumnSet(1); | 120 cs = layout->AddColumnSet(1); |
| 118 cs->AddPaddingColumn(1, views::kRelatedControlHorizontalSpacing); | 121 cs->AddPaddingColumn(1, views::kRelatedControlHorizontalSpacing); |
| 119 cs->AddColumn(views::GridLayout::TRAILING, views::GridLayout::LEADING, | 122 cs->AddColumn(views::GridLayout::TRAILING, views::GridLayout::LEADING, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 error_->BubbleViewDidClose(browser_); | 188 error_->BubbleViewDidClose(browser_); |
| 186 } | 189 } |
| 187 | 190 |
| 188 bool GlobalErrorBubbleView::ShouldShowCloseButton() const { | 191 bool GlobalErrorBubbleView::ShouldShowCloseButton() const { |
| 189 return error_ && error_->ShouldShowCloseButton(); | 192 return error_ && error_->ShouldShowCloseButton(); |
| 190 } | 193 } |
| 191 | 194 |
| 192 void GlobalErrorBubbleView::CloseBubbleView() { | 195 void GlobalErrorBubbleView::CloseBubbleView() { |
| 193 GetWidget()->Close(); | 196 GetWidget()->Close(); |
| 194 } | 197 } |
| OLD | NEW |