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

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

Issue 10388251: Support maximize window command. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: "Since the python bindings are to a newer version now, update chromedriver_tests.py accordingly." Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 handler_map["GetViews"] = 1693 handler_map["GetViews"] =
1694 &TestingAutomationProvider::GetViews; 1694 &TestingAutomationProvider::GetViews;
1695 handler_map["IsTabIdValid"] = 1695 handler_map["IsTabIdValid"] =
1696 &TestingAutomationProvider::IsTabIdValid; 1696 &TestingAutomationProvider::IsTabIdValid;
1697 handler_map["DoesAutomationObjectExist"] = 1697 handler_map["DoesAutomationObjectExist"] =
1698 &TestingAutomationProvider::DoesAutomationObjectExist; 1698 &TestingAutomationProvider::DoesAutomationObjectExist;
1699 handler_map["CloseTab"] = 1699 handler_map["CloseTab"] =
1700 &TestingAutomationProvider::CloseTabJSON; 1700 &TestingAutomationProvider::CloseTabJSON;
1701 handler_map["SetViewBounds"] = 1701 handler_map["SetViewBounds"] =
1702 &TestingAutomationProvider::SetViewBounds; 1702 &TestingAutomationProvider::SetViewBounds;
1703 handler_map["MaximizeView"] =
1704 &TestingAutomationProvider::MaximizeView;
1703 handler_map["WebkitMouseMove"] = 1705 handler_map["WebkitMouseMove"] =
1704 &TestingAutomationProvider::WebkitMouseMove; 1706 &TestingAutomationProvider::WebkitMouseMove;
1705 handler_map["WebkitMouseClick"] = 1707 handler_map["WebkitMouseClick"] =
1706 &TestingAutomationProvider::WebkitMouseClick; 1708 &TestingAutomationProvider::WebkitMouseClick;
1707 handler_map["WebkitMouseDrag"] = 1709 handler_map["WebkitMouseDrag"] =
1708 &TestingAutomationProvider::WebkitMouseDrag; 1710 &TestingAutomationProvider::WebkitMouseDrag;
1709 handler_map["WebkitMouseButtonUp"] = 1711 handler_map["WebkitMouseButtonUp"] =
1710 &TestingAutomationProvider::WebkitMouseButtonUp; 1712 &TestingAutomationProvider::WebkitMouseButtonUp;
1711 handler_map["WebkitMouseButtonDown"] = 1713 handler_map["WebkitMouseButtonDown"] =
1712 &TestingAutomationProvider::WebkitMouseButtonDown; 1714 &TestingAutomationProvider::WebkitMouseButtonDown;
(...skipping 4781 matching lines...) Expand 10 before | Expand all | Expand 10 after
6494 !args->GetInteger("bounds.height", &height)) { 6496 !args->GetInteger("bounds.height", &height)) {
6495 reply.SendError("Missing or invalid 'bounds'"); 6497 reply.SendError("Missing or invalid 'bounds'");
6496 return; 6498 return;
6497 } 6499 }
6498 Browser* browser; 6500 Browser* browser;
6499 std::string error; 6501 std::string error;
6500 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { 6502 if (!GetBrowserFromJSONArgs(args, &browser, &error)) {
6501 reply.SendError(Error(automation::kInvalidId, error)); 6503 reply.SendError(Error(automation::kInvalidId, error));
6502 return; 6504 return;
6503 } 6505 }
6504 browser->window()->SetBounds(gfx::Rect(x, y, width, height)); 6506 BrowserWindow* browser_window = browser->window();
6507 if (browser_window->IsMaximized()) {
6508 browser_window->Restore();
6509 }
6510 browser_window->SetBounds(gfx::Rect(x, y, width, height));
6505 reply.SendSuccess(NULL); 6511 reply.SendSuccess(NULL);
6506 } 6512 }
6507 6513
6514 void TestingAutomationProvider::MaximizeView(
6515 base::DictionaryValue* args,
6516 IPC::Message* reply_message) {
6517 Browser* browser;
6518 std::string error;
6519 if (!GetBrowserFromJSONArgs(args, &browser, &error)) {
6520 AutomationJSONReply(this, reply_message)
6521 .SendError(Error(automation::kInvalidId, error));
6522 return;
6523 }
6524
6525 #if defined(OS_LINUX)
6526 // Maximization on Linux is asynchronous, so create an observer object to be
6527 // notified upon maximization completion.
6528 new WindowMaximizedObserver(this, reply_message);
6529 #endif // defined(OS_LINUX)
6530
6531 browser->window()->Maximize();
6532
6533 #if !defined(OS_LINUX)
6534 // Send success reply right away for OS's with synchronous maximize command.
6535 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
6536 #endif // !defined(OS_LINUX)
6537 }
6538
6508 void TestingAutomationProvider::ActivateTabJSON( 6539 void TestingAutomationProvider::ActivateTabJSON(
6509 DictionaryValue* args, 6540 DictionaryValue* args,
6510 IPC::Message* reply_message) { 6541 IPC::Message* reply_message) {
6511 if (SendErrorIfModalDialogActive(this, reply_message)) 6542 if (SendErrorIfModalDialogActive(this, reply_message))
6512 return; 6543 return;
6513 6544
6514 AutomationJSONReply reply(this, reply_message); 6545 AutomationJSONReply reply(this, reply_message);
6515 Browser* browser; 6546 Browser* browser;
6516 WebContents* web_contents; 6547 WebContents* web_contents;
6517 std::string error; 6548 std::string error;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
6656 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 6687 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
6657 } 6688 }
6658 6689
6659 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, 6690 void TestingAutomationProvider::EnsureTabSelected(Browser* browser,
6660 WebContents* tab) { 6691 WebContents* tab) {
6661 if (browser->GetActiveWebContents() != tab) { 6692 if (browser->GetActiveWebContents() != tab) {
6662 browser->ActivateTabAt(browser->GetIndexOfController( 6693 browser->ActivateTabAt(browser->GetIndexOfController(
6663 &tab->GetController()), true); 6694 &tab->GetController()), true);
6664 } 6695 }
6665 } 6696 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.h ('k') | chrome/browser/ui/gtk/browser_window_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698