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

Side by Side Diff: chrome/browser/ui/views/pdf_password_dialog.cc

Issue 477263003: pdf: Create a separate component for using the pdf pepper plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/pdf/pdf_tab_helper.h"
6
7 #include "chrome/browser/ui/views/constrained_window_views.h" 5 #include "chrome/browser/ui/views/constrained_window_views.h"
8 #include "chrome/grit/generated_resources.h" 6 #include "chrome/grit/generated_resources.h"
7 #include "components/pdf/browser/pdf_tab_helper_delegate.h"
9 #include "content/public/browser/web_contents.h" 8 #include "content/public/browser/web_contents.h"
10 #include "ui/base/l10n/l10n_util.h" 9 #include "ui/base/l10n/l10n_util.h"
11 #include "ui/views/controls/message_box_view.h" 10 #include "ui/views/controls/message_box_view.h"
12 #include "ui/views/controls/textfield/textfield.h" 11 #include "ui/views/controls/textfield/textfield.h"
13 #include "ui/views/layout/layout_constants.h" 12 #include "ui/views/layout/layout_constants.h"
14 #include "ui/views/widget/widget.h" 13 #include "ui/views/widget/widget.h"
15 #include "ui/views/window/dialog_delegate.h" 14 #include "ui/views/window/dialog_delegate.h"
16 15
17 namespace { 16 namespace {
18 17
19 // Runs a tab-modal dialog that asks the user for a password. 18 // Runs a tab-modal dialog that asks the user for a password.
20 class PDFPasswordDialogViews : public views::DialogDelegate { 19 class PDFPasswordDialogViews : public views::DialogDelegate {
21 public: 20 public:
22 PDFPasswordDialogViews(content::WebContents* web_contents, 21 PDFPasswordDialogViews(content::WebContents* web_contents,
23 const base::string16& prompt, 22 const base::string16& prompt,
24 const PasswordDialogClosedCallback& callback); 23 const pdf::PasswordDialogClosedCallback& callback);
25 virtual ~PDFPasswordDialogViews(); 24 virtual ~PDFPasswordDialogViews();
26 25
27 // views::DialogDelegate: 26 // views::DialogDelegate:
28 virtual base::string16 GetWindowTitle() const OVERRIDE; 27 virtual base::string16 GetWindowTitle() const OVERRIDE;
29 virtual base::string16 GetDialogButtonLabel( 28 virtual base::string16 GetDialogButtonLabel(
30 ui::DialogButton button) const OVERRIDE; 29 ui::DialogButton button) const OVERRIDE;
31 virtual bool Cancel() OVERRIDE; 30 virtual bool Cancel() OVERRIDE;
32 virtual bool Accept() OVERRIDE; 31 virtual bool Accept() OVERRIDE;
33 32
34 // views::WidgetDelegate: 33 // views::WidgetDelegate:
35 virtual views::View* GetInitiallyFocusedView() OVERRIDE; 34 virtual views::View* GetInitiallyFocusedView() OVERRIDE;
36 virtual views::View* GetContentsView() OVERRIDE; 35 virtual views::View* GetContentsView() OVERRIDE;
37 virtual views::Widget* GetWidget() OVERRIDE; 36 virtual views::Widget* GetWidget() OVERRIDE;
38 virtual const views::Widget* GetWidget() const OVERRIDE; 37 virtual const views::Widget* GetWidget() const OVERRIDE;
39 virtual void DeleteDelegate() OVERRIDE; 38 virtual void DeleteDelegate() OVERRIDE;
40 virtual ui::ModalType GetModalType() const OVERRIDE; 39 virtual ui::ModalType GetModalType() const OVERRIDE;
41 40
42 private: 41 private:
43 // The message box view whose commands we handle. 42 // The message box view whose commands we handle.
44 views::MessageBoxView* message_box_view_; 43 views::MessageBoxView* message_box_view_;
45 44
46 PasswordDialogClosedCallback callback_; 45 pdf::PasswordDialogClosedCallback callback_;
47 46
48 DISALLOW_COPY_AND_ASSIGN(PDFPasswordDialogViews); 47 DISALLOW_COPY_AND_ASSIGN(PDFPasswordDialogViews);
49 }; 48 };
50 49
51 PDFPasswordDialogViews::PDFPasswordDialogViews( 50 PDFPasswordDialogViews::PDFPasswordDialogViews(
52 content::WebContents* web_contents, 51 content::WebContents* web_contents,
53 const base::string16& prompt, 52 const base::string16& prompt,
54 const PasswordDialogClosedCallback& callback) 53 const pdf::PasswordDialogClosedCallback& callback)
55 : message_box_view_(NULL), 54 : message_box_view_(NULL), callback_(callback) {
56 callback_(callback) {
57 views::MessageBoxView::InitParams init_params(prompt); 55 views::MessageBoxView::InitParams init_params(prompt);
58 init_params.options = views::MessageBoxView::HAS_PROMPT_FIELD; 56 init_params.options = views::MessageBoxView::HAS_PROMPT_FIELD;
59 init_params.inter_row_vertical_spacing = 57 init_params.inter_row_vertical_spacing =
60 views::kUnrelatedControlVerticalSpacing; 58 views::kUnrelatedControlVerticalSpacing;
61 message_box_view_ = new views::MessageBoxView(init_params); 59 message_box_view_ = new views::MessageBoxView(init_params);
62 message_box_view_->text_box()->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 60 message_box_view_->text_box()->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
63 ShowWebModalDialogViews(this, web_contents); 61 ShowWebModalDialogViews(this, web_contents);
64 } 62 }
65 63
66 PDFPasswordDialogViews::~PDFPasswordDialogViews() { 64 PDFPasswordDialogViews::~PDFPasswordDialogViews() {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 121 }
124 122
125 ui::ModalType PDFPasswordDialogViews::GetModalType() const { 123 ui::ModalType PDFPasswordDialogViews::GetModalType() const {
126 return ui::MODAL_TYPE_CHILD; 124 return ui::MODAL_TYPE_CHILD;
127 } 125 }
128 126
129 } // namespace 127 } // namespace
130 128
131 void ShowPDFPasswordDialog(content::WebContents* web_contents, 129 void ShowPDFPasswordDialog(content::WebContents* web_contents,
132 const base::string16& prompt, 130 const base::string16& prompt,
133 const PasswordDialogClosedCallback& callback) { 131 const pdf::PasswordDialogClosedCallback& callback) {
134 new PDFPasswordDialogViews(web_contents, prompt, callback); 132 new PDFPasswordDialogViews(web_contents, prompt, callback);
135 } 133 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698