Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(984)

Side by Side Diff: chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.cc

Issue 21696003: views/location_bar: Eliminate TouchableLocationBarView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/pdf/pdf_tab_helper.h" 7 #include "chrome/browser/ui/pdf/pdf_tab_helper.h"
8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
8 #include "chrome/browser/ui/views/open_pdf_in_reader_bubble_view.h" 9 #include "chrome/browser/ui/views/open_pdf_in_reader_bubble_view.h"
9 #include "grit/generated_resources.h" 10 #include "grit/generated_resources.h"
10 #include "grit/theme_resources.h" 11 #include "grit/theme_resources.h"
11 #include "ui/base/accessibility/accessible_view_state.h" 12 #include "ui/base/accessibility/accessible_view_state.h"
12 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
13 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
14 #include "ui/views/widget/widget.h" 15 #include "ui/views/widget/widget.h"
15 16
16 OpenPDFInReaderView::OpenPDFInReaderView(LocationBarView* location_bar_view) 17 OpenPDFInReaderView::OpenPDFInReaderView(LocationBarView* location_bar_view)
17 : location_bar_view_(location_bar_view), 18 : location_bar_view_(location_bar_view),
18 bubble_(NULL), 19 bubble_(NULL),
19 model_(NULL) { 20 model_(NULL) {
20 set_accessibility_focusable(true); 21 set_accessibility_focusable(true);
21 SetImage( 22 SetImage(
22 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 23 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
23 IDR_OMNIBOX_PDF_ICON)); 24 IDR_OMNIBOX_PDF_ICON));
24 SetTooltipText( 25 SetTooltipText(
25 l10n_util::GetStringUTF16(IDS_PDF_BUBBLE_OPEN_IN_READER_LINK)); 26 l10n_util::GetStringUTF16(IDS_PDF_BUBBLE_OPEN_IN_READER_LINK));
26 TouchableLocationBarView::Init(this); 27 LocationBarView::InitTouchableLocationBarView(this);
27 } 28 }
28 29
29 OpenPDFInReaderView::~OpenPDFInReaderView() { 30 OpenPDFInReaderView::~OpenPDFInReaderView() {
30 if (bubble_) 31 if (bubble_)
31 bubble_->GetWidget()->RemoveObserver(this); 32 bubble_->GetWidget()->RemoveObserver(this);
32 } 33 }
33 34
34 void OpenPDFInReaderView::Update(content::WebContents* web_contents) { 35 void OpenPDFInReaderView::Update(content::WebContents* web_contents) {
35 model_ = NULL; 36 model_ = NULL;
36 if (web_contents) { 37 if (web_contents) {
37 PDFTabHelper* pdf_tab_helper = PDFTabHelper::FromWebContents(web_contents); 38 PDFTabHelper* pdf_tab_helper = PDFTabHelper::FromWebContents(web_contents);
38 model_ = pdf_tab_helper->open_in_reader_prompt(); 39 model_ = pdf_tab_helper->open_in_reader_prompt();
39 } 40 }
40 41
41 SetVisible(!!model_); 42 SetVisible(!!model_);
42 } 43 }
43 44
44 int OpenPDFInReaderView::GetBuiltInHorizontalPadding() const {
45 return GetBuiltInHorizontalPaddingImpl();
46 }
47
48 void OpenPDFInReaderView::ShowBubble() { 45 void OpenPDFInReaderView::ShowBubble() {
49 if (bubble_) 46 if (bubble_)
50 return; 47 return;
51 48
52 DCHECK(model_); 49 DCHECK(model_);
53 bubble_ = new OpenPDFInReaderBubbleView(this, model_); 50 bubble_ = new OpenPDFInReaderBubbleView(this, model_);
54 views::BubbleDelegateView::CreateBubble(bubble_); 51 views::BubbleDelegateView::CreateBubble(bubble_);
55 bubble_->GetWidget()->AddObserver(this); 52 bubble_->GetWidget()->AddObserver(this);
56 bubble_->GetWidget()->Show(); 53 bubble_->GetWidget()->Show();
57 } 54 }
(...skipping 23 matching lines...) Expand all
81 return true; 78 return true;
82 } 79 }
83 80
84 void OpenPDFInReaderView::OnWidgetDestroying(views::Widget* widget) { 81 void OpenPDFInReaderView::OnWidgetDestroying(views::Widget* widget) {
85 if (!bubble_) 82 if (!bubble_)
86 return; 83 return;
87 84
88 bubble_->GetWidget()->RemoveObserver(this); 85 bubble_->GetWidget()->RemoveObserver(this);
89 bubble_ = NULL; 86 bubble_ = NULL;
90 } 87 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698