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

Side by Side Diff: chrome/utility/ipc_shell_handler_win.cc

Issue 2151643002: Revert of Revive experiment to isolate shell operations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « chrome/utility/ipc_shell_handler_win.h ('k') | chrome/utility/shell_handler_impl_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/utility/ipc_shell_handler_win.h"
6
7 #include <commdlg.h>
8
9 #include <memory>
10
11 #include "base/files/file_path.h"
12 #include "chrome/common/chrome_utility_messages.h"
13 #include "content/public/utility/utility_thread.h"
14 #include "ui/base/win/open_file_name_win.h"
15
16 IPCShellHandler::IPCShellHandler() {}
17 IPCShellHandler::~IPCShellHandler() {}
18
19 bool IPCShellHandler::OnMessageReceived(const IPC::Message& message) {
20 bool handled = true;
21 IPC_BEGIN_MESSAGE_MAP(IPCShellHandler, message)
22 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetOpenFileName, OnGetOpenFileName)
23 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetSaveFileName, OnGetSaveFileName)
24 IPC_MESSAGE_UNHANDLED(handled = false)
25 IPC_END_MESSAGE_MAP()
26 return handled;
27 }
28
29 void IPCShellHandler::OnGetOpenFileName(HWND owner,
30 DWORD flags,
31 const GetOpenFileNameFilter& filter,
32 const base::FilePath& initial_directory,
33 const base::FilePath& filename) {
34 ui::win::OpenFileName open_file_name(owner, flags);
35 open_file_name.SetInitialSelection(initial_directory, filename);
36 open_file_name.SetFilters(filter);
37
38 base::FilePath directory;
39 std::vector<base::FilePath> filenames;
40
41 if (::GetOpenFileName(open_file_name.GetOPENFILENAME()))
42 open_file_name.GetResult(&directory, &filenames);
43
44 if (filenames.size()) {
45 content::UtilityThread::Get()->Send(
46 new ChromeUtilityHostMsg_GetOpenFileName_Result(directory, filenames));
47 } else {
48 content::UtilityThread::Get()->Send(
49 new ChromeUtilityHostMsg_GetOpenFileName_Failed());
50 }
51 }
52
53 void IPCShellHandler::OnGetSaveFileName(
54 const ChromeUtilityMsg_GetSaveFileName_Params& params) {
55 ui::win::OpenFileName open_file_name(params.owner, params.flags);
56 open_file_name.SetInitialSelection(params.initial_directory,
57 params.suggested_filename);
58 open_file_name.SetFilters(params.filters);
59 open_file_name.GetOPENFILENAME()->nFilterIndex =
60 params.one_based_filter_index;
61 open_file_name.GetOPENFILENAME()->lpstrDefExt =
62 params.default_extension.c_str();
63
64 if (::GetSaveFileName(open_file_name.GetOPENFILENAME())) {
65 content::UtilityThread::Get()->Send(
66 new ChromeUtilityHostMsg_GetSaveFileName_Result(
67 base::FilePath(open_file_name.GetOPENFILENAME()->lpstrFile),
68 open_file_name.GetOPENFILENAME()->nFilterIndex));
69 return;
70 }
71
72 // Zero means the dialog was closed, otherwise we had an error.
73 DWORD error_code = ::CommDlgExtendedError();
74 if (error_code != 0)
75 NOTREACHED() << "GetSaveFileName failed with code: " << error_code;
76
77 content::UtilityThread::Get()->Send(
78 new ChromeUtilityHostMsg_GetSaveFileName_Failed());
79 }
OLDNEW
« no previous file with comments | « chrome/utility/ipc_shell_handler_win.h ('k') | chrome/utility/shell_handler_impl_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698