| 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/tab_contents/tab_contents.h" | |
| 8 #include "chrome/browser/ui/pdf/pdf_tab_helper.h" | 7 #include "chrome/browser/ui/pdf/pdf_tab_helper.h" |
| 9 #include "chrome/browser/ui/views/open_pdf_in_reader_bubble_view.h" | 8 #include "chrome/browser/ui/views/open_pdf_in_reader_bubble_view.h" |
| 10 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
| 11 #include "grit/theme_resources.h" | 10 #include "grit/theme_resources.h" |
| 12 #include "ui/base/accessibility/accessible_view_state.h" | 11 #include "ui/base/accessibility/accessible_view_state.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
| 16 | 15 |
| 17 OpenPDFInReaderView::OpenPDFInReaderView(LocationBarView* location_bar_view) | 16 OpenPDFInReaderView::OpenPDFInReaderView(LocationBarView* location_bar_view) |
| 18 : location_bar_view_(location_bar_view), | 17 : location_bar_view_(location_bar_view), |
| 19 bubble_(NULL), | 18 bubble_(NULL), |
| 20 model_(NULL) { | 19 model_(NULL) { |
| 21 set_accessibility_focusable(true); | 20 set_accessibility_focusable(true); |
| 22 SetImage( | 21 SetImage( |
| 23 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 22 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 24 IDR_OMNIBOX_PDF_ICON)); | 23 IDR_OMNIBOX_PDF_ICON)); |
| 25 SetTooltipText( | 24 SetTooltipText( |
| 26 l10n_util::GetStringUTF16(IDS_PDF_BUBBLE_OPEN_IN_READER_LINK)); | 25 l10n_util::GetStringUTF16(IDS_PDF_BUBBLE_OPEN_IN_READER_LINK)); |
| 27 TouchableLocationBarView::Init(this); | 26 TouchableLocationBarView::Init(this); |
| 28 } | 27 } |
| 29 | 28 |
| 30 OpenPDFInReaderView::~OpenPDFInReaderView() { | 29 OpenPDFInReaderView::~OpenPDFInReaderView() { |
| 31 if (bubble_) | 30 if (bubble_) |
| 32 bubble_->GetWidget()->RemoveObserver(this); | 31 bubble_->GetWidget()->RemoveObserver(this); |
| 33 } | 32 } |
| 34 | 33 |
| 35 void OpenPDFInReaderView::Update(TabContents* tab_contents) { | 34 void OpenPDFInReaderView::Update(content::WebContents* web_contents) { |
| 36 model_ = NULL; | 35 model_ = NULL; |
| 37 if (tab_contents) { | 36 if (web_contents) { |
| 38 PDFTabHelper* pdf_tab_helper = | 37 PDFTabHelper* pdf_tab_helper = PDFTabHelper::FromWebContents(web_contents); |
| 39 PDFTabHelper::FromWebContents(tab_contents->web_contents()); | |
| 40 model_ = pdf_tab_helper->open_in_reader_prompt(); | 38 model_ = pdf_tab_helper->open_in_reader_prompt(); |
| 41 } | 39 } |
| 42 | 40 |
| 43 SetVisible(!!model_); | 41 SetVisible(!!model_); |
| 44 } | 42 } |
| 45 | 43 |
| 46 int OpenPDFInReaderView::GetBuiltInHorizontalPadding() const { | 44 int OpenPDFInReaderView::GetBuiltInHorizontalPadding() const { |
| 47 return GetBuiltInHorizontalPaddingImpl(); | 45 return GetBuiltInHorizontalPaddingImpl(); |
| 48 } | 46 } |
| 49 | 47 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 return true; | 81 return true; |
| 84 } | 82 } |
| 85 | 83 |
| 86 void OpenPDFInReaderView::OnWidgetClosing(views::Widget* widget) { | 84 void OpenPDFInReaderView::OnWidgetClosing(views::Widget* widget) { |
| 87 if (!bubble_) | 85 if (!bubble_) |
| 88 return; | 86 return; |
| 89 | 87 |
| 90 bubble_->GetWidget()->RemoveObserver(this); | 88 bubble_->GetWidget()->RemoveObserver(this); |
| 91 bubble_ = NULL; | 89 bubble_ = NULL; |
| 92 } | 90 } |
| OLD | NEW |