Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: chrome/browser/automation/automation_provider.cc

Issue 174396: Fix another source of flakiness in ErrorPageTest (Closed)
Patch Set: Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 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 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/automation_provider.h" 5 #include "chrome/browser/automation/automation_provider.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/message_box_flags.h" 10 #include "app/message_box_flags.h"
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 IPC_MESSAGE_HANDLER(AutomationMsg_Copy, Copy) 1157 IPC_MESSAGE_HANDLER(AutomationMsg_Copy, Copy)
1158 IPC_MESSAGE_HANDLER(AutomationMsg_Paste, Paste) 1158 IPC_MESSAGE_HANDLER(AutomationMsg_Paste, Paste)
1159 IPC_MESSAGE_HANDLER(AutomationMsg_ReloadAsync, ReloadAsync) 1159 IPC_MESSAGE_HANDLER(AutomationMsg_ReloadAsync, ReloadAsync)
1160 IPC_MESSAGE_HANDLER(AutomationMsg_StopAsync, StopAsync) 1160 IPC_MESSAGE_HANDLER(AutomationMsg_StopAsync, StopAsync)
1161 IPC_MESSAGE_HANDLER_DELAY_REPLY( 1161 IPC_MESSAGE_HANDLER_DELAY_REPLY(
1162 AutomationMsg_WaitForBrowserWindowCountToBecome, 1162 AutomationMsg_WaitForBrowserWindowCountToBecome,
1163 WaitForBrowserWindowCountToBecome) 1163 WaitForBrowserWindowCountToBecome)
1164 IPC_MESSAGE_HANDLER_DELAY_REPLY( 1164 IPC_MESSAGE_HANDLER_DELAY_REPLY(
1165 AutomationMsg_WaitForAppModalDialogToBeShown, 1165 AutomationMsg_WaitForAppModalDialogToBeShown,
1166 WaitForAppModalDialogToBeShown) 1166 WaitForAppModalDialogToBeShown)
1167 IPC_MESSAGE_HANDLER_DELAY_REPLY(
1168 AutomationMsg_GoBackBlockUntilNavigationsComplete,
1169 GoBackBlockUntilNavigationsComplete)
1170 IPC_MESSAGE_HANDLER_DELAY_REPLY(
1171 AutomationMsg_GoForwardBlockUntilNavigationsComplete,
1172 GoForwardBlockUntilNavigationsComplete)
1167 IPC_END_MESSAGE_MAP() 1173 IPC_END_MESSAGE_MAP()
1168 } 1174 }
1169 1175
1170 void AutomationProvider::ActivateTab(int handle, int at_index, int* status) { 1176 void AutomationProvider::ActivateTab(int handle, int at_index, int* status) {
1171 *status = -1; 1177 *status = -1;
1172 if (browser_tracker_->ContainsHandle(handle) && at_index > -1) { 1178 if (browser_tracker_->ContainsHandle(handle) && at_index > -1) {
1173 Browser* browser = browser_tracker_->GetResource(handle); 1179 Browser* browser = browser_tracker_->GetResource(handle);
1174 if (at_index >= 0 && at_index < browser->tab_count()) { 1180 if (at_index >= 0 && at_index < browser->tab_count()) {
1175 browser->SelectTabContentsAt(at_index, true); 1181 browser->SelectTabContentsAt(at_index, true);
1176 *status = 0; 1182 *status = 0;
(...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after
2721 AutomationMsg_WaitForAppModalDialogToBeShown::WriteReplyParams( 2727 AutomationMsg_WaitForAppModalDialogToBeShown::WriteReplyParams(
2722 reply_message, true); 2728 reply_message, true);
2723 Send(reply_message); 2729 Send(reply_message);
2724 return; 2730 return;
2725 } 2731 }
2726 2732
2727 // Set up an observer (it will delete itself). 2733 // Set up an observer (it will delete itself).
2728 new AppModalDialogShownObserver(this, reply_message); 2734 new AppModalDialogShownObserver(this, reply_message);
2729 } 2735 }
2730 2736
2737 void AutomationProvider::GoBackBlockUntilNavigationsComplete(
2738 int handle, int number_of_navigations, IPC::Message* reply_message) {
2739 if (tab_tracker_->ContainsHandle(handle)) {
2740 NavigationController* tab = tab_tracker_->GetResource(handle);
2741 Browser* browser = FindAndActivateTab(tab);
2742 if (browser && browser->command_updater()->IsCommandEnabled(IDC_BACK)) {
2743 AddNavigationStatusListener(tab, reply_message, number_of_navigations);
2744 browser->GoBack(CURRENT_TAB);
2745 return;
2746 }
2747 }
2748
2749 AutomationMsg_GoBackBlockUntilNavigationsComplete::WriteReplyParams(
2750 reply_message, AUTOMATION_MSG_NAVIGATION_ERROR);
2751 Send(reply_message);
2752 }
2753
2754 void AutomationProvider::GoForwardBlockUntilNavigationsComplete(
2755 int handle, int number_of_navigations, IPC::Message* reply_message) {
2756 if (tab_tracker_->ContainsHandle(handle)) {
2757 NavigationController* tab = tab_tracker_->GetResource(handle);
2758 Browser* browser = FindAndActivateTab(tab);
2759 if (browser && browser->command_updater()->IsCommandEnabled(IDC_FORWARD)) {
2760 AddNavigationStatusListener(tab, reply_message, number_of_navigations);
2761 browser->GoForward(CURRENT_TAB);
2762 return;
2763 }
2764 }
2765
2766 AutomationMsg_GoForwardBlockUntilNavigationsComplete::WriteReplyParams(
2767 reply_message, AUTOMATION_MSG_NAVIGATION_ERROR);
2768 Send(reply_message);
2769 }
2770
2731 RenderViewHost* AutomationProvider::GetViewForTab(int tab_handle) { 2771 RenderViewHost* AutomationProvider::GetViewForTab(int tab_handle) {
2732 if (tab_tracker_->ContainsHandle(tab_handle)) { 2772 if (tab_tracker_->ContainsHandle(tab_handle)) {
2733 NavigationController* tab = tab_tracker_->GetResource(tab_handle); 2773 NavigationController* tab = tab_tracker_->GetResource(tab_handle);
2734 if (!tab) { 2774 if (!tab) {
2735 NOTREACHED(); 2775 NOTREACHED();
2736 return NULL; 2776 return NULL;
2737 } 2777 }
2738 2778
2739 TabContents* tab_contents = tab->tab_contents(); 2779 TabContents* tab_contents = tab->tab_contents();
2740 if (!tab_contents) { 2780 if (!tab_contents) {
2741 NOTREACHED(); 2781 NOTREACHED();
2742 return NULL; 2782 return NULL;
2743 } 2783 }
2744 2784
2745 RenderViewHost* view_host = tab_contents->render_view_host(); 2785 RenderViewHost* view_host = tab_contents->render_view_host();
2746 return view_host; 2786 return view_host;
2747 } 2787 }
2748 2788
2749 return NULL; 2789 return NULL;
2750 } 2790 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698