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" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 void OpenPDFInReaderView::Update(content::WebContents* web_contents) { | 29 void OpenPDFInReaderView::Update(content::WebContents* web_contents) { |
30 model_ = NULL; | 30 model_ = NULL; |
31 if (web_contents) { | 31 if (web_contents) { |
32 pdf::PDFWebContentsHelper* pdf_tab_helper = | 32 pdf::PDFWebContentsHelper* pdf_tab_helper = |
33 pdf::PDFWebContentsHelper::FromWebContents(web_contents); | 33 pdf::PDFWebContentsHelper::FromWebContents(web_contents); |
34 model_ = pdf_tab_helper->open_in_reader_prompt(); | 34 model_ = pdf_tab_helper->open_in_reader_prompt(); |
35 } | 35 } |
36 | 36 |
37 SetVisible(!!model_); | 37 SetVisible(!!model_); |
| 38 |
| 39 // Hide the bubble if it is currently shown and the icon is hidden. |
| 40 if (!model_ && bubble_) |
| 41 bubble_->GetWidget()->Hide(); |
38 } | 42 } |
39 | 43 |
40 void OpenPDFInReaderView::ShowBubble() { | 44 void OpenPDFInReaderView::ShowBubble() { |
41 if (bubble_) | 45 if (bubble_) |
42 return; | 46 return; |
43 | 47 |
44 DCHECK(model_); | 48 DCHECK(model_); |
45 bubble_ = new OpenPDFInReaderBubbleView(this, model_); | 49 bubble_ = new OpenPDFInReaderBubbleView(this, model_); |
46 views::BubbleDelegateView::CreateBubble(bubble_); | 50 views::BubbleDelegateView::CreateBubble(bubble_); |
47 bubble_->GetWidget()->AddObserver(this); | 51 bubble_->GetWidget()->AddObserver(this); |
(...skipping 25 matching lines...) Expand all Loading... |
73 return true; | 77 return true; |
74 } | 78 } |
75 | 79 |
76 void OpenPDFInReaderView::OnWidgetDestroying(views::Widget* widget) { | 80 void OpenPDFInReaderView::OnWidgetDestroying(views::Widget* widget) { |
77 if (!bubble_) | 81 if (!bubble_) |
78 return; | 82 return; |
79 | 83 |
80 bubble_->GetWidget()->RemoveObserver(this); | 84 bubble_->GetWidget()->RemoveObserver(this); |
81 bubble_ = NULL; | 85 bubble_ = NULL; |
82 } | 86 } |
OLD | NEW |