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

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

Issue 2033753002: Remove use of deprecated MessageLoop methods in chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: manual change Created 4 years, 6 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/certificate_viewer.h" 5 #include "chrome/browser/certificate_viewer.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <cryptuiapi.h> 8 #include <cryptuiapi.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/single_thread_task_runner.h"
16 #include "base/task_runner.h" 16 #include "base/task_runner.h"
17 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "base/threading/thread_task_runner_handle.h"
18 #include "net/cert/x509_certificate.h" 19 #include "net/cert/x509_certificate.h"
19 #include "ui/aura/window.h" 20 #include "ui/aura/window.h"
20 #include "ui/aura/window_tree_host.h" 21 #include "ui/aura/window_tree_host.h"
21 #include "ui/shell_dialogs/base_shell_dialog_win.h" 22 #include "ui/shell_dialogs/base_shell_dialog_win.h"
22 23
23 namespace { 24 namespace {
24 25
25 // Shows a Windows certificate viewer dialog on a background thread to avoid 26 // Shows a Windows certificate viewer dialog on a background thread to avoid
26 // nested message loops. 27 // nested message loops.
27 class CertificateViewerDialog : public ui::BaseShellDialogImpl { 28 class CertificateViewerDialog : public ui::BaseShellDialogImpl {
28 public: 29 public:
29 CertificateViewerDialog() {} 30 CertificateViewerDialog() {}
30 31
31 // Shows the dialog and calls |callback| when the dialog closes. The caller 32 // Shows the dialog and calls |callback| when the dialog closes. The caller
32 // must ensure the CertificateViewerDialog remains valid until then. 33 // must ensure the CertificateViewerDialog remains valid until then.
33 void Show(HWND parent, 34 void Show(HWND parent,
34 net::X509Certificate* cert, 35 net::X509Certificate* cert,
35 const base::Closure& callback) { 36 const base::Closure& callback) {
36 if (IsRunningDialogForOwner(parent)) { 37 if (IsRunningDialogForOwner(parent)) {
37 base::MessageLoop::current()->PostTask(FROM_HERE, callback); 38 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback);
38 return; 39 return;
39 } 40 }
40 41
41 RunState run_state = BeginRun(parent); 42 RunState run_state = BeginRun(parent);
42 run_state.dialog_thread->task_runner()->PostTaskAndReply( 43 run_state.dialog_thread->task_runner()->PostTaskAndReply(
43 FROM_HERE, 44 FROM_HERE,
44 base::Bind(&CertificateViewerDialog::ShowOnDialogThread, 45 base::Bind(&CertificateViewerDialog::ShowOnDialogThread,
45 base::Unretained(this), run_state, make_scoped_refptr(cert)), 46 base::Unretained(this), run_state, make_scoped_refptr(cert)),
46 base::Bind(&CertificateViewerDialog::OnDialogClosed, 47 base::Bind(&CertificateViewerDialog::OnDialogClosed,
47 base::Unretained(this), run_state, callback)); 48 base::Unretained(this), run_state, callback));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } // namespace 85 } // namespace
85 86
86 void ShowCertificateViewer(content::WebContents* web_contents, 87 void ShowCertificateViewer(content::WebContents* web_contents,
87 gfx::NativeWindow parent, 88 gfx::NativeWindow parent,
88 net::X509Certificate* cert) { 89 net::X509Certificate* cert) {
89 CertificateViewerDialog* dialog = new CertificateViewerDialog; 90 CertificateViewerDialog* dialog = new CertificateViewerDialog;
90 dialog->Show( 91 dialog->Show(
91 parent->GetHost()->GetAcceleratedWidget(), cert, 92 parent->GetHost()->GetAcceleratedWidget(), cert,
92 base::Bind(&base::DeletePointer<CertificateViewerDialog>, dialog)); 93 base::Bind(&base::DeletePointer<CertificateViewerDialog>, dialog));
93 } 94 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc ('k') | chrome/browser/ui/views/chrome_views_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698