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

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

Issue 2348853004: Remove non-md code in location bar (Views). (Closed)
Patch Set: images Created 4 years, 3 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
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/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 "chrome/grit/theme_resources.h" 9 #include "chrome/grit/theme_resources.h"
10 #include "components/pdf/browser/open_pdf_in_reader_prompt_client.h" 10 #include "components/pdf/browser/open_pdf_in_reader_prompt_client.h"
11 #include "components/pdf/browser/pdf_web_contents_helper.h" 11 #include "components/pdf/browser/pdf_web_contents_helper.h"
12 #include "ui/accessibility/ax_view_state.h" 12 #include "ui/accessibility/ax_view_state.h"
13 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/material_design/material_design_controller.h"
15 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/color_utils.h" 15 #include "ui/gfx/color_utils.h"
17 #include "ui/gfx/paint_vector_icon.h" 16 #include "ui/gfx/paint_vector_icon.h"
18 #include "ui/gfx/vector_icons_public.h" 17 #include "ui/gfx/vector_icons_public.h"
19 #include "ui/native_theme/native_theme.h" 18 #include "ui/native_theme/native_theme.h"
20 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
21 20
22 OpenPDFInReaderView::OpenPDFInReaderView() : bubble_(NULL), model_(NULL) { 21 OpenPDFInReaderView::OpenPDFInReaderView() : bubble_(nullptr), model_(nullptr) {
23 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); 22 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
24 if (!ui::MaterialDesignController::IsModeMaterial()) {
25 SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
26 IDR_OMNIBOX_PDF_ICON));
27 }
28 SetTooltipText(l10n_util::GetStringUTF16(IDS_PDF_BUBBLE_OPEN_IN_READER_LINK)); 23 SetTooltipText(l10n_util::GetStringUTF16(IDS_PDF_BUBBLE_OPEN_IN_READER_LINK));
29 } 24 }
30 25
31 OpenPDFInReaderView::~OpenPDFInReaderView() { 26 OpenPDFInReaderView::~OpenPDFInReaderView() {
32 if (bubble_) 27 if (bubble_)
33 bubble_->GetWidget()->RemoveObserver(this); 28 bubble_->GetWidget()->RemoveObserver(this);
34 } 29 }
35 30
36 void OpenPDFInReaderView::Update(content::WebContents* web_contents) { 31 void OpenPDFInReaderView::Update(content::WebContents* web_contents) {
37 model_ = NULL; 32 model_ = nullptr;
38 if (web_contents) { 33 if (web_contents) {
39 pdf::PDFWebContentsHelper* pdf_tab_helper = 34 pdf::PDFWebContentsHelper* pdf_tab_helper =
40 pdf::PDFWebContentsHelper::FromWebContents(web_contents); 35 pdf::PDFWebContentsHelper::FromWebContents(web_contents);
41 model_ = pdf_tab_helper->open_in_reader_prompt(); 36 model_ = pdf_tab_helper->open_in_reader_prompt();
42 } 37 }
43 38
44 SetVisible(!!model_); 39 SetVisible(!!model_);
45 40
46 // Hide the bubble if it is currently shown and the icon is hidden. 41 // Hide the bubble if it is currently shown and the icon is hidden.
47 if (!model_ && bubble_) 42 if (!model_ && bubble_)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 event.key_code() != ui::VKEY_RETURN) { 75 event.key_code() != ui::VKEY_RETURN) {
81 return false; 76 return false;
82 } 77 }
83 78
84 ShowBubble(); 79 ShowBubble();
85 return true; 80 return true;
86 } 81 }
87 82
88 void OpenPDFInReaderView::OnNativeThemeChanged( 83 void OpenPDFInReaderView::OnNativeThemeChanged(
89 const ui::NativeTheme* native_theme) { 84 const ui::NativeTheme* native_theme) {
90 if (ui::MaterialDesignController::IsModeMaterial()) { 85 SetImage(gfx::CreateVectorIcon(
91 SetImage(gfx::CreateVectorIcon( 86 gfx::VectorIconId::PDF,
92 gfx::VectorIconId::PDF, 87 color_utils::DeriveDefaultIconColor(native_theme->GetSystemColor(
93 color_utils::DeriveDefaultIconColor(native_theme->GetSystemColor( 88 ui::NativeTheme::kColorId_TextfieldDefaultColor))));
94 ui::NativeTheme::kColorId_TextfieldDefaultColor))));
95 }
96 } 89 }
97 90
98 void OpenPDFInReaderView::OnWidgetDestroying(views::Widget* widget) { 91 void OpenPDFInReaderView::OnWidgetDestroying(views::Widget* widget) {
99 if (!bubble_) 92 if (!bubble_)
100 return; 93 return;
101 94
102 bubble_->GetWidget()->RemoveObserver(this); 95 bubble_->GetWidget()->RemoveObserver(this);
103 bubble_ = NULL; 96 bubble_ = nullptr;
104 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698