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

Side by Side Diff: chrome/browser/ui/webui/options/advanced_options_utils_win.cc

Issue 1250823005: Run the certificate management dialog with BaseShellDialogImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: check for existing dialog Created 5 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/webui/options/advanced_options_utils.h" 5 #include "chrome/browser/ui/webui/options/advanced_options_utils.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <cryptuiapi.h> 8 #include <cryptuiapi.h>
9 #pragma comment(lib, "cryptui.lib") 9 #pragma comment(lib, "cryptui.lib")
10 #include <shellapi.h> 10 #include <shellapi.h>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h"
14 #include "base/location.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/message_loop/message_loop.h"
13 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #include "base/single_thread_task_runner.h"
14 #include "base/threading/thread.h" 19 #include "base/threading/thread.h"
15 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
16 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
23 #include "ui/shell_dialogs/base_shell_dialog_win.h"
18 #include "ui/views/win/hwnd_util.h" 24 #include "ui/views/win/hwnd_util.h"
19 25
20 using content::BrowserThread; 26 using content::BrowserThread;
21 using content::WebContents; 27 using content::WebContents;
22 28
23 namespace options { 29 namespace options {
24 30
31 namespace {
32
33 // Shows a Windows certificate management dialog on the dialog thread.
34 class ManageCertificatesDialog : public ui::BaseShellDialogImpl {
35 public:
36 explicit ManageCertificatesDialog(WebContents* web_contents)
37 : web_contents_(web_contents) {}
mmenke 2015/07/27 18:45:33 optional: Should we take the WebContents as a par
davidben 2015/07/27 18:47:45 I guess the question here is "what is a dialog obj
mmenke 2015/07/27 19:08:14 I agree, and I'm with you on having no clue.
davidben 2015/07/27 19:24:19 ananta? You wrote BaseShellDialogImpl. How are dia
ananta 2015/07/27 19:59:23 That is upto the caller. Please look at SelectFile
38
39 ~ManageCertificatesDialog() override {}
40
41 // Shows the dialog and calls |callback| when the dialog closes. The caller
42 // must ensure the ManageCertificatesDialog remains valid until then.
43 void Show(const base::Closure& callback) {
44 HWND parent =
45 views::HWNDForNativeWindow(web_contents_->GetTopLevelNativeWindow());
46 if (IsRunningDialogForOwner(parent)) {
47 base::MessageLoop::current()->PostTask(FROM_HERE, callback);
48 return;
49 }
50
51 RunState run_state = BeginRun(parent);
52 run_state.dialog_thread->task_runner()->PostTaskAndReply(
53 FROM_HERE, base::Bind(&ManageCertificatesDialog::ShowOnDialogThread,
54 base::Unretained(this), run_state),
55 base::Bind(&ManageCertificatesDialog::OnDialogClosed,
56 base::Unretained(this), run_state, callback));
57 }
58
59 private:
60 void ShowOnDialogThread(const RunState& run_state) {
61 CRYPTUI_CERT_MGR_STRUCT cert_mgr = {0};
62 cert_mgr.dwSize = sizeof(CRYPTUI_CERT_MGR_STRUCT);
63 cert_mgr.hwndParent = run_state.owner;
64 ::CryptUIDlgCertMgr(&cert_mgr);
65 }
66
67 void OnDialogClosed(const RunState& run_state,
68 const base::Closure& callback) {
mmenke 2015/07/27 19:08:14 Should we have a weak pointer here? Or this shoul
mmenke 2015/07/27 19:13:30 Oh, right...with your ownership model, not needed.
69 EndRun(run_state);
70 // May delete |this|.
71 callback.Run();
72 }
73
74 WebContents* web_contents_;
75
76 DISALLOW_COPY_AND_ASSIGN(ManageCertificatesDialog);
77 };
78
79 } // namespace
80
25 // Callback that opens the Internet Options control panel dialog with the 81 // Callback that opens the Internet Options control panel dialog with the
26 // Connections tab selected. 82 // Connections tab selected.
27 void OpenConnectionDialogCallback() { 83 void OpenConnectionDialogCallback() {
28 // Using rundll32 seems better than LaunchConnectionDialog which causes a 84 // Using rundll32 seems better than LaunchConnectionDialog which causes a
29 // new dialog to be made for each call. rundll32 uses the same global 85 // new dialog to be made for each call. rundll32 uses the same global
30 // dialog and it seems to share with the shortcut in control panel. 86 // dialog and it seems to share with the shortcut in control panel.
31 base::FilePath rundll32; 87 base::FilePath rundll32;
32 PathService::Get(base::DIR_SYSTEM, &rundll32); 88 PathService::Get(base::DIR_SYSTEM, &rundll32);
33 rundll32 = rundll32.AppendASCII("rundll32.exe"); 89 rundll32 = rundll32.AppendASCII("rundll32.exe");
34 90
(...skipping 16 matching lines...) Expand all
51 void AdvancedOptionsUtilities::ShowNetworkProxySettings( 107 void AdvancedOptionsUtilities::ShowNetworkProxySettings(
52 WebContents* web_contents) { 108 WebContents* web_contents) {
53 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::FILE)); 109 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::FILE));
54 BrowserThread::PostTask(BrowserThread::FILE, 110 BrowserThread::PostTask(BrowserThread::FILE,
55 FROM_HERE, 111 FROM_HERE,
56 base::Bind(&OpenConnectionDialogCallback)); 112 base::Bind(&OpenConnectionDialogCallback));
57 } 113 }
58 114
59 void AdvancedOptionsUtilities::ShowManageSSLCertificates( 115 void AdvancedOptionsUtilities::ShowManageSSLCertificates(
60 WebContents* web_contents) { 116 WebContents* web_contents) {
61 CRYPTUI_CERT_MGR_STRUCT cert_mgr = { 0 }; 117 ManageCertificatesDialog* dialog = new ManageCertificatesDialog(web_contents);
62 cert_mgr.dwSize = sizeof(CRYPTUI_CERT_MGR_STRUCT); 118 dialog->Show(
63 cert_mgr.hwndParent = views::HWNDForNativeWindow( 119 base::Bind(&base::DeletePointer<ManageCertificatesDialog>, dialog));
64 web_contents->GetTopLevelNativeWindow());
65 ::CryptUIDlgCertMgr(&cert_mgr);
66 } 120 }
67 121
68 } // namespace options 122 } // namespace options
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698