OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/test/chromedriver/chrome/javascript_dialog_manager.h" | 5 #include "chrome/test/chromedriver/chrome/javascript_dialog_manager.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/test/chromedriver/chrome/devtools_client.h" | 8 #include "chrome/test/chromedriver/chrome/devtools_client.h" |
9 #include "chrome/test/chromedriver/chrome/status.h" | 9 #include "chrome/test/chromedriver/chrome/status.h" |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... | |
30 Status JavaScriptDialogManager::HandleDialog(bool accept, | 30 Status JavaScriptDialogManager::HandleDialog(bool accept, |
31 const std::string* text) { | 31 const std::string* text) { |
32 if (!IsDialogOpen()) | 32 if (!IsDialogOpen()) |
33 return Status(kNoAlertOpen); | 33 return Status(kNoAlertOpen); |
34 | 34 |
35 base::DictionaryValue params; | 35 base::DictionaryValue params; |
36 params.SetBoolean("accept", accept); | 36 params.SetBoolean("accept", accept); |
37 if (text) | 37 if (text) |
38 params.SetString("promptText", *text); | 38 params.SetString("promptText", *text); |
39 Status status = client_->SendCommand("Page.handleJavaScriptDialog", params); | 39 Status status = client_->SendCommand("Page.handleJavaScriptDialog", params); |
40 if (status.IsError()) | 40 if (status.IsError()) { |
samuong
2016/11/16 22:53:34
sorry, one more thing: can you add a comment here
gmanikpure
2016/11/16 23:03:42
Done.
| |
41 return status; | 41 status = client_->SendCommand("Page.handleJavaScriptDialog", params); |
42 if (status.IsError()) | |
43 return status; | |
44 } | |
42 | 45 |
43 // Remove a dialog from the queue. Need to check the queue is not empty here, | 46 // Remove a dialog from the queue. Need to check the queue is not empty here, |
44 // because it could have been cleared during waiting for the command | 47 // because it could have been cleared during waiting for the command |
45 // response. | 48 // response. |
46 if (unhandled_dialog_queue_.size()) | 49 if (unhandled_dialog_queue_.size()) |
47 unhandled_dialog_queue_.pop_front(); | 50 unhandled_dialog_queue_.pop_front(); |
48 return Status(kOk); | 51 return Status(kOk); |
49 } | 52 } |
50 | 53 |
51 Status JavaScriptDialogManager::OnConnected(DevToolsClient* client) { | 54 Status JavaScriptDialogManager::OnConnected(DevToolsClient* client) { |
(...skipping 11 matching lines...) Expand all Loading... | |
63 return Status(kUnknownError, "dialog event missing or invalid 'message'"); | 66 return Status(kUnknownError, "dialog event missing or invalid 'message'"); |
64 | 67 |
65 unhandled_dialog_queue_.push_back(message); | 68 unhandled_dialog_queue_.push_back(message); |
66 } else if (method == "Page.javascriptDialogClosed") { | 69 } else if (method == "Page.javascriptDialogClosed") { |
67 // Inspector only sends this event when all dialogs have been closed. | 70 // Inspector only sends this event when all dialogs have been closed. |
68 // Clear the unhandled queue in case the user closed a dialog manually. | 71 // Clear the unhandled queue in case the user closed a dialog manually. |
69 unhandled_dialog_queue_.clear(); | 72 unhandled_dialog_queue_.clear(); |
70 } | 73 } |
71 return Status(kOk); | 74 return Status(kOk); |
72 } | 75 } |
OLD | NEW |