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.
5 #include "chrome/browser/ui/views/open_pdf_in_reader_bubble_view.h"
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"
15 OpenPDFInReaderBubbleView::~OpenPDFInReaderBubbleView() {}
17 OpenPDFInReaderBubbleView::OpenPDFInReaderBubbleView(
18 views::View
* anchor_view
,
19 pdf::OpenPDFInReaderPromptClient
* model
)
20 : views::BubbleDelegateView(anchor_view
, views::BubbleBorder::TOP_RIGHT
),
22 open_in_reader_link_(NULL
),
27 void OpenPDFInReaderBubbleView::Init() {
28 using views::GridLayout
;
30 GridLayout
* layout
= new views::GridLayout(this);
31 SetLayoutManager(layout
);
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);
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
);
43 layout
->AddPaddingRow(0, views::kRelatedControlVerticalSpacing
);
45 base::string16 accept_text
= model_
->GetAcceptButtonText();
46 open_in_reader_link_
= new views::Link(accept_text
);
47 open_in_reader_link_
->SetEnabled(true);
48 open_in_reader_link_
->set_listener(this);
49 layout
->StartRow(0, single_column_set_id
);
50 layout
->AddView(open_in_reader_link_
);
52 layout
->AddPaddingRow(0, views::kRelatedControlVerticalSpacing
);
53 layout
->StartRow(0, single_column_set_id
);
54 layout
->AddView(new views::Separator(views::Separator::HORIZONTAL
), 1, 1,
55 GridLayout::FILL
, GridLayout::FILL
);
56 layout
->AddPaddingRow(0, views::kRelatedControlVerticalSpacing
);
58 close_button_
= new views::LabelButton(this, model_
->GetCancelButtonText());
59 close_button_
->SetStyle(views::Button::STYLE_BUTTON
);
60 layout
->StartRow(0, single_column_set_id
);
61 layout
->AddView(close_button_
);
64 void OpenPDFInReaderBubbleView::ButtonPressed(views::Button
* sender
,
65 const ui::Event
& event
) {
66 DCHECK_EQ(close_button_
, sender
);
72 void OpenPDFInReaderBubbleView::LinkClicked(views::Link
* source
,
74 DCHECK_EQ(open_in_reader_link_
, source
);