Update V8 to version 4.7.56.
[chromium-blink-merge.git] / win8 / test / ui_automation_client.h
blobe8b89f75166c9f1b0baf1aa4bc85a4b52442c057
1 // Copyright (c) 2013 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.
5 #ifndef WIN8_TEST_UI_AUTOMATION_CLIENT_H_
6 #define WIN8_TEST_UI_AUTOMATION_CLIENT_H_
8 // This file contains UI automation implementation details for the
9 // OpenWithDialogController. See that class for consumable entrypoints.
11 #include <windows.h>
12 #include <vector>
14 #include "base/basictypes.h"
15 #include "base/callback_forward.h"
16 #include "base/memory/weak_ptr.h"
17 #include "base/strings/string16.h"
18 #include "base/threading/thread.h"
19 #include "base/threading/thread_checker.h"
21 namespace win8 {
22 namespace internal {
24 // An asynchronous UI automation client that waits for the appearance of a
25 // Window of a particular class and then invokes one of its children identified
26 // by name. An instance may be destroyed at any time after Begin() is invoked.
27 // Any pending operation is cancelled.
28 class UIAutomationClient {
29 public:
30 // If the HRESULT argument indicates success, the automation client has been
31 // initialized, has installed its Window observer, and is ready to process
32 // the named window. Otherwise, initialization has failed and ResultCallback
33 // will not be invoked.
34 typedef base::Callback<void(HRESULT)> InitializedCallback;
36 // If the HRESULT argument indicates success, the desired item in the window
37 // was invoked. Otherwise, the string vector (if not empty) contains the list
38 // of possible items in the window.
39 typedef base::Callback<void(HRESULT, std::vector<base::string16>)>
40 ResultCallback;
42 UIAutomationClient();
43 ~UIAutomationClient();
45 // Starts the client. Invokes |callback| once the client is ready or upon
46 // failure to start, in which case |result_callback| will never be called.
47 // Otherwise, |result_callback| will be invoked once |item_name| has been
48 // invoked.
49 void Begin(const wchar_t* class_name,
50 const base::string16& item_name,
51 const InitializedCallback& init_callback,
52 const ResultCallback& result_callback);
54 private:
55 class Context;
57 base::ThreadChecker thread_checker_;
59 // A thread in the COM MTA in which automation calls are made.
60 base::Thread automation_thread_;
62 // A pointer to the context object that lives on the automation thread.
63 base::WeakPtr<Context> context_;
65 DISALLOW_COPY_AND_ASSIGN(UIAutomationClient);
68 } // namespace internal
69 } // namespace win8
71 #endif // WIN8_TEST_UI_AUTOMATION_CLIENT_H_