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 "chrome/browser/ui/pdf/open_pdf_in_reader_prompt_delegate.h"
8 #include "grit/generated_resources.h"
9 #include "ui/base/l10n/l10n_util.h"
10 #include "ui/views/controls/button/label_button.h"
11 #include "ui/views/controls/label.h"
12 #include "ui/views/controls/link.h"
13 #include "ui/views/controls/separator.h"
14 #include "ui/views/layout/grid_layout.h"
15 #include "ui/views/layout/layout_constants.h"
17 OpenPDFInReaderBubbleView::~OpenPDFInReaderBubbleView() {}
19 OpenPDFInReaderBubbleView::OpenPDFInReaderBubbleView(
20 views::View
* anchor_view
,
21 OpenPDFInReaderPromptDelegate
* model
)
22 : views::BubbleDelegateView(anchor_view
, views::BubbleBorder::TOP_RIGHT
),
24 open_in_reader_link_(NULL
),
29 void OpenPDFInReaderBubbleView::Init() {
30 using views::GridLayout
;
32 GridLayout
* layout
= new views::GridLayout(this);
33 SetLayoutManager(layout
);
35 const int single_column_set_id
= 0;
36 views::ColumnSet
* column_set
= layout
->AddColumnSet(single_column_set_id
);
37 column_set
->AddColumn(GridLayout::LEADING
, GridLayout::FILL
, 1,
38 GridLayout::USE_PREF
, 0, 0);
40 base::string16 title
= model_
->GetMessageText();
41 views::Label
* title_label
= new views::Label(title
);
42 layout
->StartRow(0, single_column_set_id
);
43 layout
->AddView(title_label
);
45 layout
->AddPaddingRow(0, views::kRelatedControlVerticalSpacing
);
47 base::string16 accept_text
= model_
->GetAcceptButtonText();
48 open_in_reader_link_
= new views::Link(accept_text
);
49 open_in_reader_link_
->SetEnabled(true);
50 open_in_reader_link_
->set_listener(this);
51 layout
->StartRow(0, single_column_set_id
);
52 layout
->AddView(open_in_reader_link_
);
54 layout
->AddPaddingRow(0, views::kRelatedControlVerticalSpacing
);
55 layout
->StartRow(0, single_column_set_id
);
56 layout
->AddView(new views::Separator(views::Separator::HORIZONTAL
), 1, 1,
57 GridLayout::FILL
, GridLayout::FILL
);
58 layout
->AddPaddingRow(0, views::kRelatedControlVerticalSpacing
);
60 close_button_
= new views::LabelButton(this, model_
->GetCancelButtonText());
61 close_button_
->SetStyle(views::Button::STYLE_BUTTON
);
62 layout
->StartRow(0, single_column_set_id
);
63 layout
->AddView(close_button_
);
66 void OpenPDFInReaderBubbleView::ButtonPressed(views::Button
* sender
,
67 const ui::Event
& event
) {
68 DCHECK_EQ(close_button_
, sender
);
74 void OpenPDFInReaderBubbleView::LinkClicked(views::Link
* source
,
76 DCHECK_EQ(open_in_reader_link_
, source
);