| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/automation/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
| 6 | 6 |
| 7 #include "app/message_box_flags.h" | |
| 8 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 9 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 11 #include "base/json/string_escape.h" | 10 #include "base/json/string_escape.h" |
| 12 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 13 #include "base/process.h" | 12 #include "base/process.h" |
| 14 #include "base/process_util.h" | 13 #include "base/process_util.h" |
| 15 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
| 16 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
| 17 #include "base/time.h" | 16 #include "base/time.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 67 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 69 #include "chrome/common/chrome_constants.h" | 68 #include "chrome/common/chrome_constants.h" |
| 70 #include "chrome/common/chrome_paths.h" | 69 #include "chrome/common/chrome_paths.h" |
| 71 #include "chrome/common/chrome_switches.h" | 70 #include "chrome/common/chrome_switches.h" |
| 72 #include "chrome/common/net/url_request_context_getter.h" | 71 #include "chrome/common/net/url_request_context_getter.h" |
| 73 #include "chrome/common/notification_service.h" | 72 #include "chrome/common/notification_service.h" |
| 74 #include "chrome/common/url_constants.h" | 73 #include "chrome/common/url_constants.h" |
| 75 #include "chrome/common/automation_messages.h" | 74 #include "chrome/common/automation_messages.h" |
| 76 #include "net/base/cookie_store.h" | 75 #include "net/base/cookie_store.h" |
| 77 #include "net/url_request/url_request_context.h" | 76 #include "net/url_request/url_request_context.h" |
| 77 #include "ui/base/message_box_flags.h" |
| 78 #include "views/event.h" | 78 #include "views/event.h" |
| 79 #include "webkit/plugins/npapi/plugin_list.h" | 79 #include "webkit/plugins/npapi/plugin_list.h" |
| 80 | 80 |
| 81 namespace { | 81 namespace { |
| 82 | 82 |
| 83 void GetCookiesOnIOThread( | 83 void GetCookiesOnIOThread( |
| 84 const GURL& url, | 84 const GURL& url, |
| 85 const scoped_refptr<URLRequestContextGetter>& context_getter, | 85 const scoped_refptr<URLRequestContextGetter>& context_getter, |
| 86 base::WaitableEvent* event, | 86 base::WaitableEvent* event, |
| 87 std::string* cookies) { | 87 std::string* cookies) { |
| (...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1773 *success = true; | 1773 *success = true; |
| 1774 } | 1774 } |
| 1775 } | 1775 } |
| 1776 | 1776 |
| 1777 void TestingAutomationProvider::GetShowingAppModalDialog(bool* showing_dialog, | 1777 void TestingAutomationProvider::GetShowingAppModalDialog(bool* showing_dialog, |
| 1778 int* dialog_button) { | 1778 int* dialog_button) { |
| 1779 AppModalDialog* active_dialog = | 1779 AppModalDialog* active_dialog = |
| 1780 AppModalDialogQueue::GetInstance()->active_dialog(); | 1780 AppModalDialogQueue::GetInstance()->active_dialog(); |
| 1781 if (!active_dialog) { | 1781 if (!active_dialog) { |
| 1782 *showing_dialog = false; | 1782 *showing_dialog = false; |
| 1783 *dialog_button = MessageBoxFlags::DIALOGBUTTON_NONE; | 1783 *dialog_button = ui::MessageBoxFlags::DIALOGBUTTON_NONE; |
| 1784 return; | 1784 return; |
| 1785 } | 1785 } |
| 1786 NativeAppModalDialog* native_dialog = active_dialog->native_dialog(); | 1786 NativeAppModalDialog* native_dialog = active_dialog->native_dialog(); |
| 1787 *showing_dialog = (native_dialog != NULL); | 1787 *showing_dialog = (native_dialog != NULL); |
| 1788 if (*showing_dialog) | 1788 if (*showing_dialog) |
| 1789 *dialog_button = native_dialog->GetAppModalDialogButtons(); | 1789 *dialog_button = native_dialog->GetAppModalDialogButtons(); |
| 1790 else | 1790 else |
| 1791 *dialog_button = MessageBoxFlags::DIALOGBUTTON_NONE; | 1791 *dialog_button = ui::MessageBoxFlags::DIALOGBUTTON_NONE; |
| 1792 } | 1792 } |
| 1793 | 1793 |
| 1794 void TestingAutomationProvider::ClickAppModalDialogButton(int button, | 1794 void TestingAutomationProvider::ClickAppModalDialogButton(int button, |
| 1795 bool* success) { | 1795 bool* success) { |
| 1796 *success = false; | 1796 *success = false; |
| 1797 | 1797 |
| 1798 NativeAppModalDialog* native_dialog = | 1798 NativeAppModalDialog* native_dialog = |
| 1799 AppModalDialogQueue::GetInstance()->active_dialog()->native_dialog(); | 1799 AppModalDialogQueue::GetInstance()->active_dialog()->native_dialog(); |
| 1800 if (native_dialog && | 1800 if (native_dialog && |
| 1801 (native_dialog->GetAppModalDialogButtons() & button) == button) { | 1801 (native_dialog->GetAppModalDialogButtons() & button) == button) { |
| 1802 if ((button & MessageBoxFlags::DIALOGBUTTON_OK) == | 1802 if ((button & ui::MessageBoxFlags::DIALOGBUTTON_OK) == |
| 1803 MessageBoxFlags::DIALOGBUTTON_OK) { | 1803 ui::MessageBoxFlags::DIALOGBUTTON_OK) { |
| 1804 native_dialog->AcceptAppModalDialog(); | 1804 native_dialog->AcceptAppModalDialog(); |
| 1805 *success = true; | 1805 *success = true; |
| 1806 } | 1806 } |
| 1807 if ((button & MessageBoxFlags::DIALOGBUTTON_CANCEL) == | 1807 if ((button & ui::MessageBoxFlags::DIALOGBUTTON_CANCEL) == |
| 1808 MessageBoxFlags::DIALOGBUTTON_CANCEL) { | 1808 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL) { |
| 1809 DCHECK(!*success) << "invalid param, OK and CANCEL specified"; | 1809 DCHECK(!*success) << "invalid param, OK and CANCEL specified"; |
| 1810 native_dialog->CancelAppModalDialog(); | 1810 native_dialog->CancelAppModalDialog(); |
| 1811 *success = true; | 1811 *success = true; |
| 1812 } | 1812 } |
| 1813 } | 1813 } |
| 1814 } | 1814 } |
| 1815 | 1815 |
| 1816 void TestingAutomationProvider::WaitForBrowserWindowCountToBecome( | 1816 void TestingAutomationProvider::WaitForBrowserWindowCountToBecome( |
| 1817 int target_count, IPC::Message* reply_message) { | 1817 int target_count, IPC::Message* reply_message) { |
| 1818 if (static_cast<int>(BrowserList::size()) == target_count) { | 1818 if (static_cast<int>(BrowserList::size()) == target_count) { |
| (...skipping 2692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4511 // If you change this, update Observer for NotificationType::SESSION_END | 4511 // If you change this, update Observer for NotificationType::SESSION_END |
| 4512 // below. | 4512 // below. |
| 4513 MessageLoop::current()->PostTask(FROM_HERE, | 4513 MessageLoop::current()->PostTask(FROM_HERE, |
| 4514 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); | 4514 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); |
| 4515 } | 4515 } |
| 4516 } | 4516 } |
| 4517 | 4517 |
| 4518 void TestingAutomationProvider::OnRemoveProvider() { | 4518 void TestingAutomationProvider::OnRemoveProvider() { |
| 4519 AutomationProviderList::GetInstance()->RemoveProvider(this); | 4519 AutomationProviderList::GetInstance()->RemoveProvider(this); |
| 4520 } | 4520 } |
| OLD | NEW |