| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" | 7 #include "app/message_box_flags.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 1811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1822 if (browser_tracker_->ContainsHandle(handle)) { | 1822 if (browser_tracker_->ContainsHandle(handle)) { |
| 1823 Browser* browser = browser_tracker_->GetResource(handle); | 1823 Browser* browser = browser_tracker_->GetResource(handle); |
| 1824 browser->profile()->GetPrefs()->SetBoolean(name.c_str(), value); | 1824 browser->profile()->GetPrefs()->SetBoolean(name.c_str(), value); |
| 1825 *success = true; | 1825 *success = true; |
| 1826 } | 1826 } |
| 1827 } | 1827 } |
| 1828 | 1828 |
| 1829 void TestingAutomationProvider::GetShowingAppModalDialog(bool* showing_dialog, | 1829 void TestingAutomationProvider::GetShowingAppModalDialog(bool* showing_dialog, |
| 1830 int* dialog_button) { | 1830 int* dialog_button) { |
| 1831 AppModalDialog* active_dialog = | 1831 AppModalDialog* active_dialog = |
| 1832 Singleton<AppModalDialogQueue>()->active_dialog(); | 1832 AppModalDialogQueue::GetInstance()->active_dialog(); |
| 1833 if (!active_dialog) { | 1833 if (!active_dialog) { |
| 1834 *showing_dialog = false; | 1834 *showing_dialog = false; |
| 1835 *dialog_button = MessageBoxFlags::DIALOGBUTTON_NONE; | 1835 *dialog_button = MessageBoxFlags::DIALOGBUTTON_NONE; |
| 1836 return; | 1836 return; |
| 1837 } | 1837 } |
| 1838 NativeAppModalDialog* native_dialog = active_dialog->native_dialog(); | 1838 NativeAppModalDialog* native_dialog = active_dialog->native_dialog(); |
| 1839 *showing_dialog = (native_dialog != NULL); | 1839 *showing_dialog = (native_dialog != NULL); |
| 1840 if (*showing_dialog) | 1840 if (*showing_dialog) |
| 1841 *dialog_button = native_dialog->GetAppModalDialogButtons(); | 1841 *dialog_button = native_dialog->GetAppModalDialogButtons(); |
| 1842 else | 1842 else |
| 1843 *dialog_button = MessageBoxFlags::DIALOGBUTTON_NONE; | 1843 *dialog_button = MessageBoxFlags::DIALOGBUTTON_NONE; |
| 1844 } | 1844 } |
| 1845 | 1845 |
| 1846 void TestingAutomationProvider::ClickAppModalDialogButton(int button, | 1846 void TestingAutomationProvider::ClickAppModalDialogButton(int button, |
| 1847 bool* success) { | 1847 bool* success) { |
| 1848 *success = false; | 1848 *success = false; |
| 1849 | 1849 |
| 1850 NativeAppModalDialog* native_dialog = | 1850 NativeAppModalDialog* native_dialog = |
| 1851 Singleton<AppModalDialogQueue>()->active_dialog()->native_dialog(); | 1851 AppModalDialogQueue::GetInstance()->active_dialog()->native_dialog(); |
| 1852 if (native_dialog && | 1852 if (native_dialog && |
| 1853 (native_dialog->GetAppModalDialogButtons() & button) == button) { | 1853 (native_dialog->GetAppModalDialogButtons() & button) == button) { |
| 1854 if ((button & MessageBoxFlags::DIALOGBUTTON_OK) == | 1854 if ((button & MessageBoxFlags::DIALOGBUTTON_OK) == |
| 1855 MessageBoxFlags::DIALOGBUTTON_OK) { | 1855 MessageBoxFlags::DIALOGBUTTON_OK) { |
| 1856 native_dialog->AcceptAppModalDialog(); | 1856 native_dialog->AcceptAppModalDialog(); |
| 1857 *success = true; | 1857 *success = true; |
| 1858 } | 1858 } |
| 1859 if ((button & MessageBoxFlags::DIALOGBUTTON_CANCEL) == | 1859 if ((button & MessageBoxFlags::DIALOGBUTTON_CANCEL) == |
| 1860 MessageBoxFlags::DIALOGBUTTON_CANCEL) { | 1860 MessageBoxFlags::DIALOGBUTTON_CANCEL) { |
| 1861 DCHECK(!*success) << "invalid param, OK and CANCEL specified"; | 1861 DCHECK(!*success) << "invalid param, OK and CANCEL specified"; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1873 Send(reply_message); | 1873 Send(reply_message); |
| 1874 return; | 1874 return; |
| 1875 } | 1875 } |
| 1876 | 1876 |
| 1877 // Set up an observer (it will delete itself). | 1877 // Set up an observer (it will delete itself). |
| 1878 new BrowserCountChangeNotificationObserver(target_count, this, reply_message); | 1878 new BrowserCountChangeNotificationObserver(target_count, this, reply_message); |
| 1879 } | 1879 } |
| 1880 | 1880 |
| 1881 void TestingAutomationProvider::WaitForAppModalDialogToBeShown( | 1881 void TestingAutomationProvider::WaitForAppModalDialogToBeShown( |
| 1882 IPC::Message* reply_message) { | 1882 IPC::Message* reply_message) { |
| 1883 if (Singleton<AppModalDialogQueue>()->HasActiveDialog()) { | 1883 if (AppModalDialogQueue::GetInstance()->HasActiveDialog()) { |
| 1884 AutomationMsg_WaitForAppModalDialogToBeShown::WriteReplyParams( | 1884 AutomationMsg_WaitForAppModalDialogToBeShown::WriteReplyParams( |
| 1885 reply_message, true); | 1885 reply_message, true); |
| 1886 Send(reply_message); | 1886 Send(reply_message); |
| 1887 return; | 1887 return; |
| 1888 } | 1888 } |
| 1889 | 1889 |
| 1890 // Set up an observer (it will delete itself). | 1890 // Set up an observer (it will delete itself). |
| 1891 new AppModalDialogShownObserver(this, reply_message); | 1891 new AppModalDialogShownObserver(this, reply_message); |
| 1892 } | 1892 } |
| 1893 | 1893 |
| (...skipping 2621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4515 // If you change this, update Observer for NotificationType::SESSION_END | 4515 // If you change this, update Observer for NotificationType::SESSION_END |
| 4516 // below. | 4516 // below. |
| 4517 MessageLoop::current()->PostTask(FROM_HERE, | 4517 MessageLoop::current()->PostTask(FROM_HERE, |
| 4518 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); | 4518 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); |
| 4519 } | 4519 } |
| 4520 } | 4520 } |
| 4521 | 4521 |
| 4522 void TestingAutomationProvider::OnRemoveProvider() { | 4522 void TestingAutomationProvider::OnRemoveProvider() { |
| 4523 AutomationProviderList::GetInstance()->RemoveProvider(this); | 4523 AutomationProviderList::GetInstance()->RemoveProvider(this); |
| 4524 } | 4524 } |
| OLD | NEW |