| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/views/open_pdf_in_reader_bubble_view.h" | |
| 6 | |
| 7 #include "components/pdf/browser/open_pdf_in_reader_prompt_client.h" | |
| 8 #include "ui/views/controls/button/label_button.h" | |
| 9 #include "ui/views/controls/label.h" | |
| 10 #include "ui/views/controls/link.h" | |
| 11 #include "ui/views/controls/separator.h" | |
| 12 #include "ui/views/layout/grid_layout.h" | |
| 13 #include "ui/views/layout/layout_constants.h" | |
| 14 | |
| 15 OpenPDFInReaderBubbleView::~OpenPDFInReaderBubbleView() {} | |
| 16 | |
| 17 OpenPDFInReaderBubbleView::OpenPDFInReaderBubbleView( | |
| 18 views::View* anchor_view, | |
| 19 pdf::OpenPDFInReaderPromptClient* model) | |
| 20 : views::BubbleDialogDelegateView(anchor_view, | |
| 21 views::BubbleBorder::TOP_RIGHT), | |
| 22 model_(model), | |
| 23 open_in_reader_link_(nullptr) { | |
| 24 DCHECK(model); | |
| 25 } | |
| 26 | |
| 27 void OpenPDFInReaderBubbleView::Init() { | |
| 28 using views::GridLayout; | |
| 29 | |
| 30 GridLayout* layout = new views::GridLayout(this); | |
| 31 SetLayoutManager(layout); | |
| 32 | |
| 33 const int single_column_set_id = 0; | |
| 34 views::ColumnSet* column_set = layout->AddColumnSet(single_column_set_id); | |
| 35 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, | |
| 36 GridLayout::USE_PREF, 0, 0); | |
| 37 | |
| 38 base::string16 title = model_->GetMessageText(); | |
| 39 views::Label* title_label = new views::Label(title); | |
| 40 layout->StartRow(0, single_column_set_id); | |
| 41 layout->AddView(title_label); | |
| 42 | |
| 43 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | |
| 44 | |
| 45 base::string16 accept_text = model_->GetAcceptButtonText(); | |
| 46 open_in_reader_link_ = new views::Link(accept_text); | |
| 47 open_in_reader_link_->set_listener(this); | |
| 48 layout->StartRow(0, single_column_set_id); | |
| 49 layout->AddView(open_in_reader_link_); | |
| 50 } | |
| 51 | |
| 52 int OpenPDFInReaderBubbleView::GetDialogButtons() const { | |
| 53 return ui::DIALOG_BUTTON_CANCEL; | |
| 54 } | |
| 55 | |
| 56 base::string16 OpenPDFInReaderBubbleView::GetDialogButtonLabel( | |
| 57 ui::DialogButton button) const { | |
| 58 return model_->GetCancelButtonText(); | |
| 59 } | |
| 60 | |
| 61 bool OpenPDFInReaderBubbleView::Cancel() { | |
| 62 model_->Cancel(); | |
| 63 return true; | |
| 64 } | |
| 65 | |
| 66 void OpenPDFInReaderBubbleView::LinkClicked(views::Link* source, | |
| 67 int event_flags) { | |
| 68 DCHECK_EQ(open_in_reader_link_, source); | |
| 69 | |
| 70 model_->Accept(); | |
| 71 GetWidget()->Close(); | |
| 72 } | |
| 73 | |
| OLD | NEW |