OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 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 #ifndef CHROME_FRAME_TEST_NET_DIALOG_WATCHDOG_H_ |
| 6 #define CHROME_FRAME_TEST_NET_DIALOG_WATCHDOG_H_ |
| 7 |
| 8 #include <windows.h> |
| 9 |
| 10 #include <string> |
| 11 #include <vector> |
| 12 |
| 13 struct FunctionStub; |
| 14 |
| 15 class DialogWatchdogObserver { // NOLINT |
| 16 public: |
| 17 // returns true if this observer handled the dialog. |
| 18 virtual bool OnDialogDetected(HWND hwnd, const std::string& caption) = 0; |
| 19 }; |
| 20 |
| 21 class SupplyProxyCredentials : public DialogWatchdogObserver { |
| 22 public: |
| 23 SupplyProxyCredentials(const char* username, const char* password); |
| 24 |
| 25 protected: |
| 26 struct DialogProps { |
| 27 HWND username_; |
| 28 HWND password_; |
| 29 }; |
| 30 |
| 31 virtual bool OnDialogDetected(HWND hwnd, const std::string& caption); |
| 32 static BOOL CALLBACK EnumChildren(HWND hwnd, LPARAM param); |
| 33 |
| 34 protected: |
| 35 std::string username_; |
| 36 std::string password_; |
| 37 }; |
| 38 |
| 39 class DialogWatchdog { |
| 40 public: |
| 41 DialogWatchdog(); |
| 42 ~DialogWatchdog(); |
| 43 |
| 44 inline void AddObserver(DialogWatchdogObserver* observer) { |
| 45 observers_.push_back(observer); |
| 46 } |
| 47 |
| 48 bool Initialize(); |
| 49 void Uninitialize(); |
| 50 |
| 51 protected: |
| 52 static void CALLBACK WinEventHook(DialogWatchdog* me, HWINEVENTHOOK hook, |
| 53 DWORD event, HWND hwnd, LONG object_id, LONG child_id, |
| 54 DWORD event_thread_id, DWORD event_time); |
| 55 |
| 56 void OnDialogFound(HWND hwnd, const std::string& caption); |
| 57 |
| 58 protected: |
| 59 HWINEVENTHOOK hook_; |
| 60 std::vector<DialogWatchdogObserver*> observers_; |
| 61 FunctionStub* hook_stub_; |
| 62 }; |
| 63 |
| 64 #endif // CHROME_FRAME_TEST_NET_DIALOG_WATCHDOG_H_ |
OLD | NEW |