OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/autofill/card_unmask_prompt_views.h" | 5 #include "chrome/browser/ui/views/autofill/card_unmask_prompt_views.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 new_card_link_->SetUnderline(false); | 206 new_card_link_->SetUnderline(false); |
207 new_card_link_->set_listener(this); | 207 new_card_link_->set_listener(this); |
208 input_row_->AddChildView(new_card_link_); | 208 input_row_->AddChildView(new_card_link_); |
209 } | 209 } |
210 | 210 |
211 views::View* CardUnmaskPromptViews::GetContentsView() { | 211 views::View* CardUnmaskPromptViews::GetContentsView() { |
212 InitIfNecessary(); | 212 InitIfNecessary(); |
213 return this; | 213 return this; |
214 } | 214 } |
215 | 215 |
216 views::View* CardUnmaskPromptViews::CreateFootnoteView() { | 216 scoped_ptr<views::View> CardUnmaskPromptViews::CreateFootnoteView() { |
217 if (!controller_->CanStoreLocally()) | 217 if (!controller_->CanStoreLocally()) |
218 return nullptr; | 218 return nullptr; |
219 | 219 |
220 // Local storage checkbox and (?) tooltip. | 220 // Local storage checkbox and (?) tooltip. |
221 storage_row_ = new FadeOutView(); | 221 storage_row_ = new FadeOutView(); |
222 views::BoxLayout* storage_row_layout = new views::BoxLayout( | 222 views::BoxLayout* storage_row_layout = new views::BoxLayout( |
223 views::BoxLayout::kHorizontal, kEdgePadding, kEdgePadding, 0); | 223 views::BoxLayout::kHorizontal, kEdgePadding, kEdgePadding, 0); |
224 storage_row_->SetLayoutManager(storage_row_layout); | 224 storage_row_->SetLayoutManager(storage_row_layout); |
225 storage_row_->SetBorder( | 225 storage_row_->SetBorder( |
226 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, kSubtleBorderColor)); | 226 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, kSubtleBorderColor)); |
227 storage_row_->set_background( | 227 storage_row_->set_background( |
228 views::Background::CreateSolidBackground(kLightShadingColor)); | 228 views::Background::CreateSolidBackground(kLightShadingColor)); |
229 | 229 |
230 storage_checkbox_ = new views::Checkbox(l10n_util::GetStringUTF16( | 230 storage_checkbox_ = new views::Checkbox(l10n_util::GetStringUTF16( |
231 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_CHECKBOX)); | 231 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_CHECKBOX)); |
232 storage_checkbox_->SetChecked(controller_->GetStoreLocallyStartState()); | 232 storage_checkbox_->SetChecked(controller_->GetStoreLocallyStartState()); |
233 storage_row_->AddChildView(storage_checkbox_); | 233 storage_row_->AddChildView(storage_checkbox_); |
234 storage_row_layout->SetFlexForView(storage_checkbox_, 1); | 234 storage_row_layout->SetFlexForView(storage_checkbox_, 1); |
235 | 235 |
236 storage_row_->AddChildView(new TooltipIcon(l10n_util::GetStringUTF16( | 236 storage_row_->AddChildView(new TooltipIcon(l10n_util::GetStringUTF16( |
237 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_TOOLTIP))); | 237 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_TOOLTIP))); |
238 | 238 |
239 return storage_row_; | 239 return scoped_ptr<views::View>(storage_row_); |
240 } | 240 } |
241 | 241 |
242 gfx::Size CardUnmaskPromptViews::GetPreferredSize() const { | 242 gfx::Size CardUnmaskPromptViews::GetPreferredSize() const { |
243 // Must hardcode a width so the label knows where to wrap. | 243 // Must hardcode a width so the label knows where to wrap. |
244 const int kWidth = 375; | 244 const int kWidth = 375; |
245 return gfx::Size(kWidth, GetHeightForWidth(kWidth)); | 245 return gfx::Size(kWidth, GetHeightForWidth(kWidth)); |
246 } | 246 } |
247 | 247 |
248 void CardUnmaskPromptViews::Layout() { | 248 void CardUnmaskPromptViews::Layout() { |
249 gfx::Rect contents_bounds = GetContentsBounds(); | 249 gfx::Rect contents_bounds = GetContentsBounds(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 } | 281 } |
282 | 282 |
283 base::string16 CardUnmaskPromptViews::GetWindowTitle() const { | 283 base::string16 CardUnmaskPromptViews::GetWindowTitle() const { |
284 return controller_->GetWindowTitle(); | 284 return controller_->GetWindowTitle(); |
285 } | 285 } |
286 | 286 |
287 void CardUnmaskPromptViews::DeleteDelegate() { | 287 void CardUnmaskPromptViews::DeleteDelegate() { |
288 delete this; | 288 delete this; |
289 } | 289 } |
290 | 290 |
291 int CardUnmaskPromptViews::GetDialogButtons() const { | |
292 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; | |
293 } | |
294 | |
295 base::string16 CardUnmaskPromptViews::GetDialogButtonLabel( | 291 base::string16 CardUnmaskPromptViews::GetDialogButtonLabel( |
296 ui::DialogButton button) const { | 292 ui::DialogButton button) const { |
297 if (button == ui::DIALOG_BUTTON_OK) | 293 if (button == ui::DIALOG_BUTTON_OK) |
298 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CARD_UNMASK_CONFIRM_BUTTON); | 294 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CARD_UNMASK_CONFIRM_BUTTON); |
299 | 295 |
300 return DialogDelegateView::GetDialogButtonLabel(button); | 296 return DialogDelegateView::GetDialogButtonLabel(button); |
301 } | 297 } |
302 | 298 |
303 bool CardUnmaskPromptViews::ShouldDefaultButtonBeBlue() const { | 299 bool CardUnmaskPromptViews::ShouldDefaultButtonBeBlue() const { |
304 return true; | 300 return true; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 views::View::OnPaint(canvas); | 519 views::View::OnPaint(canvas); |
524 canvas->Restore(); | 520 canvas->Restore(); |
525 } | 521 } |
526 | 522 |
527 void CardUnmaskPromptViews::FadeOutView::SetAlpha(uint8_t alpha) { | 523 void CardUnmaskPromptViews::FadeOutView::SetAlpha(uint8_t alpha) { |
528 alpha_ = alpha; | 524 alpha_ = alpha; |
529 SchedulePaint(); | 525 SchedulePaint(); |
530 } | 526 } |
531 | 527 |
532 } // namespace autofill | 528 } // namespace autofill |
OLD | NEW |