| 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/location_bar/open_pdf_in_reader_view.h" | 5 #include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/views/open_pdf_in_reader_bubble_view.h" | 7 #include "chrome/browser/ui/views/open_pdf_in_reader_bubble_view.h" |
| 8 #include "chrome/grit/generated_resources.h" | 8 #include "chrome/grit/generated_resources.h" |
| 9 #include "components/pdf/browser/open_pdf_in_reader_prompt_client.h" | 9 #include "components/pdf/browser/open_pdf_in_reader_prompt_client.h" |
| 10 #include "components/pdf/browser/pdf_web_contents_helper.h" | 10 #include "components/pdf/browser/pdf_web_contents_helper.h" |
| 11 #include "ui/accessibility/ax_view_state.h" | 11 #include "ui/accessibility/ax_node_data.h" |
| 12 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 13 #include "ui/gfx/color_utils.h" | 13 #include "ui/gfx/color_utils.h" |
| 14 #include "ui/gfx/paint_vector_icon.h" | 14 #include "ui/gfx/paint_vector_icon.h" |
| 15 #include "ui/gfx/vector_icons_public.h" | 15 #include "ui/gfx/vector_icons_public.h" |
| 16 #include "ui/native_theme/native_theme.h" | 16 #include "ui/native_theme/native_theme.h" |
| 17 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 18 | 18 |
| 19 OpenPDFInReaderView::OpenPDFInReaderView() : bubble_(nullptr), model_(nullptr) { | 19 OpenPDFInReaderView::OpenPDFInReaderView() : bubble_(nullptr), model_(nullptr) { |
| 20 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); | 20 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); |
| 21 SetTooltipText(l10n_util::GetStringUTF16(IDS_PDF_BUBBLE_OPEN_IN_READER_LINK)); | 21 SetTooltipText(l10n_util::GetStringUTF16(IDS_PDF_BUBBLE_OPEN_IN_READER_LINK)); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 45 if (bubble_) | 45 if (bubble_) |
| 46 return; | 46 return; |
| 47 | 47 |
| 48 DCHECK(model_); | 48 DCHECK(model_); |
| 49 bubble_ = new OpenPDFInReaderBubbleView(this, model_); | 49 bubble_ = new OpenPDFInReaderBubbleView(this, model_); |
| 50 views::BubbleDialogDelegateView::CreateBubble(bubble_); | 50 views::BubbleDialogDelegateView::CreateBubble(bubble_); |
| 51 bubble_->GetWidget()->AddObserver(this); | 51 bubble_->GetWidget()->AddObserver(this); |
| 52 bubble_->GetWidget()->Show(); | 52 bubble_->GetWidget()->Show(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void OpenPDFInReaderView::GetAccessibleState(ui::AXViewState* state) { | 55 void OpenPDFInReaderView::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 56 ImageView::GetAccessibleState(state); | 56 ImageView::GetAccessibleNodeData(node_data); |
| 57 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_OPEN_PDF_IN_READER); | 57 node_data->SetName(l10n_util::GetStringUTF8(IDS_ACCNAME_OPEN_PDF_IN_READER)); |
| 58 state->role = ui::AX_ROLE_BUTTON; | 58 node_data->role = ui::AX_ROLE_BUTTON; |
| 59 } | 59 } |
| 60 | 60 |
| 61 bool OpenPDFInReaderView::OnMousePressed(const ui::MouseEvent& event) { | 61 bool OpenPDFInReaderView::OnMousePressed(const ui::MouseEvent& event) { |
| 62 // Show the bubble on mouse release; that is standard button behavior. | 62 // Show the bubble on mouse release; that is standard button behavior. |
| 63 return true; | 63 return true; |
| 64 } | 64 } |
| 65 | 65 |
| 66 void OpenPDFInReaderView::OnMouseReleased(const ui::MouseEvent& event) { | 66 void OpenPDFInReaderView::OnMouseReleased(const ui::MouseEvent& event) { |
| 67 if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location())) | 67 if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location())) |
| 68 ShowBubble(); | 68 ShowBubble(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 86 ui::NativeTheme::kColorId_TextfieldDefaultColor)))); | 86 ui::NativeTheme::kColorId_TextfieldDefaultColor)))); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void OpenPDFInReaderView::OnWidgetDestroying(views::Widget* widget) { | 89 void OpenPDFInReaderView::OnWidgetDestroying(views::Widget* widget) { |
| 90 if (!bubble_) | 90 if (!bubble_) |
| 91 return; | 91 return; |
| 92 | 92 |
| 93 bubble_->GetWidget()->RemoveObserver(this); | 93 bubble_->GetWidget()->RemoveObserver(this); |
| 94 bubble_ = nullptr; | 94 bubble_ = nullptr; |
| 95 } | 95 } |
| OLD | NEW |