1b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org// Copyright (c) 2013 The Chromium Authors. All rights reserved.
2b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org// Use of this source code is governed by a BSD-style license that can be
3b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org// found in the LICENSE file.
4b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org
5b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org#ifndef WIN8_TEST_OPEN_WITH_DIALOG_ASYNC_H_
6b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org#define WIN8_TEST_OPEN_WITH_DIALOG_ASYNC_H_
7b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org
8b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org#include <windows.h>
9b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org
10b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org#include "base/callback_forward.h"
11b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org#include "base/strings/string16.h"
12b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org
13b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.orgnamespace win8 {
14b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org
15b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org// Expected HRESULTS:
16b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org//   S_OK - A choice was made.
17b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org//   HRESULT_FROM_WIN32(ERROR_CANCELLED) - The dialog was dismissed.
18b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org//   HRESULT_FROM_WIN32(RPC_S_CALL_FAILED) - OpenWith.exe died.
19b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.orgtypedef base::Callback<void(HRESULT)> OpenWithDialogCallback;
20b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org
21b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org// Calls SHOpenWithDialog on a dedicated thread, returning the result to the
22b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org// caller via |callback| on the current thread.  The Windows SHOpenWithDialog
23b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org// function blocks until the user makes a choice or dismisses the dialog (there
24b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org// is no natural timeout nor a means by which it can be cancelled).  Note that
25b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org// the dedicated thread will be leaked if the calling thread's message loop goes
26b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org// away before the interaction completes.
27b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.orgvoid OpenWithDialogAsync(HWND parent_window,
28b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org                         const base::string16& file_name,
29b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org                         const base::string16& file_type_class,
30b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org                         int open_as_info_flags,
31b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org                         const OpenWithDialogCallback& callback);
32b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org
33b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org}  // namespace win8
34b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org
35b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org#endif  // WIN8_TEST_OPEN_WITH_DIALOG_ASYNC_H_
36b56484028c6eff42dc71fd4b9fc6bc82e856fb78jshin@chromium.org