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

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

Issue 193118: Revert "First part of automated_ui_tests improvements." (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
« no previous file with comments | « no previous file | chrome/test/automated_ui_tests/automated_ui_test_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 if (browser->command_updater()->SupportsCommand(command) && 754 if (browser->command_updater()->SupportsCommand(command) &&
755 browser->command_updater()->IsCommandEnabled(command)) { 755 browser->command_updater()->IsCommandEnabled(command)) {
756 browser->ExecuteCommand(command); 756 browser->ExecuteCommand(command);
757 *success = true; 757 *success = true;
758 } 758 }
759 } 759 }
760 } 760 }
761 761
762 void AutomationProvider::ExecuteBrowserCommand( 762 void AutomationProvider::ExecuteBrowserCommand(
763 int handle, int command, IPC::Message* reply_message) { 763 int handle, int command, IPC::Message* reply_message) {
764 // List of commands which just finish synchronously and don't require
765 // setting up an observer.
766 static const int kSynchronousCommands[] = {
767 IDC_HOME,
768 IDC_SELECT_NEXT_TAB,
769 IDC_SELECT_PREVIOUS_TAB,
770 IDC_SHOW_DOWNLOADS,
771 IDC_SHOW_HISTORY,
772 };
773 if (browser_tracker_->ContainsHandle(handle)) { 764 if (browser_tracker_->ContainsHandle(handle)) {
774 Browser* browser = browser_tracker_->GetResource(handle); 765 Browser* browser = browser_tracker_->GetResource(handle);
775 if (browser->command_updater()->SupportsCommand(command) && 766 if (browser->command_updater()->SupportsCommand(command) &&
776 browser->command_updater()->IsCommandEnabled(command)) { 767 browser->command_updater()->IsCommandEnabled(command)) {
777 // First check if we can handle the command without using an observer.
778 for (size_t i = 0; i < arraysize(kSynchronousCommands); i++) {
779 if (command == kSynchronousCommands[i]) {
780 browser->ExecuteCommand(command);
781 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message,
782 true);
783 Send(reply_message);
784 return;
785 }
786 }
787
788 // Use an observer if we have one, otherwise fail.
789 if (ExecuteBrowserCommandObserver::CreateAndRegisterObserver( 768 if (ExecuteBrowserCommandObserver::CreateAndRegisterObserver(
790 this, browser, command, reply_message)) { 769 this, browser, command, reply_message)) {
791 browser->ExecuteCommand(command); 770 browser->ExecuteCommand(command);
792 return; 771 return;
793 } 772 }
794 } 773 }
795 } 774 }
796 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message, false); 775 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message, false);
797 Send(reply_message); 776 Send(reply_message);
798 } 777 }
(...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 for (;iter != BrowserList::end(); ++iter) { 2063 for (;iter != BrowserList::end(); ++iter) {
2085 gfx::NativeWindow this_window = (*iter)->window()->GetNativeHandle(); 2064 gfx::NativeWindow this_window = (*iter)->window()->GetNativeHandle();
2086 if (window == this_window) { 2065 if (window == this_window) {
2087 // Add() returns the existing handle for the resource if any. 2066 // Add() returns the existing handle for the resource if any.
2088 *browser_handle = browser_tracker_->Add(*iter); 2067 *browser_handle = browser_tracker_->Add(*iter);
2089 *success = true; 2068 *success = true;
2090 return; 2069 return;
2091 } 2070 }
2092 } 2071 }
2093 } 2072 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/automated_ui_tests/automated_ui_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698