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

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

Issue 2079233004: Add the Windows.IsPinnedToTaskbar metric. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Constexpr TimeDelta 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/shell_handler_win.h ('k') | tools/metrics/histograms/histograms.xml » ('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/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 ShellHandler::ShellHandler() {}
17 ShellHandler::~ShellHandler() {}
18
19 bool ShellHandler::OnMessageReceived(const IPC::Message& message) {
20 bool handled = true;
21 IPC_BEGIN_MESSAGE_MAP(ShellHandler, message)
22 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetOpenFileName,
23 OnGetOpenFileName)
24 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetSaveFileName,
25 OnGetSaveFileName)
26 IPC_MESSAGE_UNHANDLED(handled = false)
27 IPC_END_MESSAGE_MAP()
28 return handled;
29 }
30
31 void ShellHandler::OnGetOpenFileName(
32 HWND owner,
33 DWORD flags,
34 const GetOpenFileNameFilter& filter,
35 const base::FilePath& initial_directory,
36 const base::FilePath& filename) {
37 ui::win::OpenFileName open_file_name(owner, flags);
38 open_file_name.SetInitialSelection(initial_directory, filename);
39 open_file_name.SetFilters(filter);
40
41 base::FilePath directory;
42 std::vector<base::FilePath> filenames;
43
44 if (::GetOpenFileName(open_file_name.GetOPENFILENAME()))
45 open_file_name.GetResult(&directory, &filenames);
46
47 if (filenames.size()) {
48 content::UtilityThread::Get()->Send(
49 new ChromeUtilityHostMsg_GetOpenFileName_Result(directory, filenames));
50 } else {
51 content::UtilityThread::Get()->Send(
52 new ChromeUtilityHostMsg_GetOpenFileName_Failed());
53 }
54 }
55
56 void ShellHandler::OnGetSaveFileName(
57 const ChromeUtilityMsg_GetSaveFileName_Params& params) {
58 ui::win::OpenFileName open_file_name(params.owner, params.flags);
59 open_file_name.SetInitialSelection(params.initial_directory,
60 params.suggested_filename);
61 open_file_name.SetFilters(params.filters);
62 open_file_name.GetOPENFILENAME()->nFilterIndex =
63 params.one_based_filter_index;
64 open_file_name.GetOPENFILENAME()->lpstrDefExt =
65 params.default_extension.c_str();
66
67 open_file_name.MaybeInstallWindowPositionHookForSaveAsOnXP();
68
69 if (::GetSaveFileName(open_file_name.GetOPENFILENAME())) {
70 content::UtilityThread::Get()->Send(
71 new ChromeUtilityHostMsg_GetSaveFileName_Result(
72 base::FilePath(open_file_name.GetOPENFILENAME()->lpstrFile),
73 open_file_name.GetOPENFILENAME()->nFilterIndex));
74 return;
75 }
76
77 // Zero means the dialog was closed, otherwise we had an error.
78 DWORD error_code = ::CommDlgExtendedError();
79 if (error_code != 0)
80 NOTREACHED() << "GetSaveFileName failed with code: " << error_code;
81
82 content::UtilityThread::Get()->Send(
83 new ChromeUtilityHostMsg_GetSaveFileName_Failed());
84 }
OLDNEW
« no previous file with comments | « chrome/utility/shell_handler_win.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698