summaryrefslogtreecommitdiffstats
path: root/win8/test/open_with_dialog_async.h
blob: 62ddbed01ce1044b8aa538af7c5849eaf5a06967 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef WIN8_TEST_OPEN_WITH_DIALOG_ASYNC_H_
#define WIN8_TEST_OPEN_WITH_DIALOG_ASYNC_H_

#include <windows.h>

#include "base/callback_forward.h"
#include "base/strings/string16.h"

namespace win8 {

// Expected HRESULTS:
//   S_OK - A choice was made.
//   HRESULT_FROM_WIN32(ERROR_CANCELLED) - The dialog was dismissed.
//   HRESULT_FROM_WIN32(RPC_S_CALL_FAILED) - OpenWith.exe died.
typedef base::Callback<void(HRESULT)> OpenWithDialogCallback;

// Calls SHOpenWithDialog on a dedicated thread, returning the result to the
// caller via |callback| on the current thread.  The Windows SHOpenWithDialog
// function blocks until the user makes a choice or dismisses the dialog (there
// is no natural timeout nor a means by which it can be cancelled).  Note that
// the dedicated thread will be leaked if the calling thread's message loop goes
// away before the interaction completes.
void OpenWithDialogAsync(HWND parent_window,
                         const base::string16& file_name,
                         const base::string16& file_type_class,
                         int open_as_info_flags,
                         const OpenWithDialogCallback& callback);

}  // namespace win8

#endif  // WIN8_TEST_OPEN_WITH_DIALOG_ASYNC_H_