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

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: "Use notification only when maximization happens asynchronously (OS Linux)." 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 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 handler_map["GetViews"] = 1691 handler_map["GetViews"] =
1692 &TestingAutomationProvider::GetViews; 1692 &TestingAutomationProvider::GetViews;
1693 handler_map["IsTabIdValid"] = 1693 handler_map["IsTabIdValid"] =
1694 &TestingAutomationProvider::IsTabIdValid; 1694 &TestingAutomationProvider::IsTabIdValid;
1695 handler_map["DoesAutomationObjectExist"] = 1695 handler_map["DoesAutomationObjectExist"] =
1696 &TestingAutomationProvider::DoesAutomationObjectExist; 1696 &TestingAutomationProvider::DoesAutomationObjectExist;
1697 handler_map["CloseTab"] = 1697 handler_map["CloseTab"] =
1698 &TestingAutomationProvider::CloseTabJSON; 1698 &TestingAutomationProvider::CloseTabJSON;
1699 handler_map["SetViewBounds"] = 1699 handler_map["SetViewBounds"] =
1700 &TestingAutomationProvider::SetViewBounds; 1700 &TestingAutomationProvider::SetViewBounds;
1701 handler_map["MaximizeView"] =
1702 &TestingAutomationProvider::MaximizeView;
1701 handler_map["WebkitMouseMove"] = 1703 handler_map["WebkitMouseMove"] =
1702 &TestingAutomationProvider::WebkitMouseMove; 1704 &TestingAutomationProvider::WebkitMouseMove;
1703 handler_map["WebkitMouseClick"] = 1705 handler_map["WebkitMouseClick"] =
1704 &TestingAutomationProvider::WebkitMouseClick; 1706 &TestingAutomationProvider::WebkitMouseClick;
1705 handler_map["WebkitMouseDrag"] = 1707 handler_map["WebkitMouseDrag"] =
1706 &TestingAutomationProvider::WebkitMouseDrag; 1708 &TestingAutomationProvider::WebkitMouseDrag;
1707 handler_map["WebkitMouseButtonUp"] = 1709 handler_map["WebkitMouseButtonUp"] =
1708 &TestingAutomationProvider::WebkitMouseButtonUp; 1710 &TestingAutomationProvider::WebkitMouseButtonUp;
1709 handler_map["WebkitMouseButtonDown"] = 1711 handler_map["WebkitMouseButtonDown"] =
1710 &TestingAutomationProvider::WebkitMouseButtonDown; 1712 &TestingAutomationProvider::WebkitMouseButtonDown;
(...skipping 4767 matching lines...) Expand 10 before | Expand all | Expand 10 after
6478 !args->GetInteger("bounds.height", &height)) { 6480 !args->GetInteger("bounds.height", &height)) {
6479 reply.SendError("Missing or invalid 'bounds'"); 6481 reply.SendError("Missing or invalid 'bounds'");
6480 return; 6482 return;
6481 } 6483 }
6482 Browser* browser; 6484 Browser* browser;
6483 std::string error; 6485 std::string error;
6484 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { 6486 if (!GetBrowserFromJSONArgs(args, &browser, &error)) {
6485 reply.SendError(Error(automation::kInvalidId, error)); 6487 reply.SendError(Error(automation::kInvalidId, error));
6486 return; 6488 return;
6487 } 6489 }
6488 browser->window()->SetBounds(gfx::Rect(x, y, width, height)); 6490 BrowserWindow* browser_window = browser->window();
6491 if (browser_window->IsMaximized()) {
6492 browser_window->Restore();
6493 }
6494 browser_window->SetBounds(gfx::Rect(x, y, width, height));
6489 reply.SendSuccess(NULL); 6495 reply.SendSuccess(NULL);
6490 } 6496 }
6491 6497
6498 void TestingAutomationProvider::MaximizeView(
6499 base::DictionaryValue* args,
6500 IPC::Message* reply_message) {
6501 Browser* browser;
6502 std::string error;
6503 if (!GetBrowserFromJSONArgs(args, &browser, &error)) {
6504 AutomationJSONReply(this, reply_message)
6505 .SendError(Error(automation::kInvalidId, error));
6506 return;
6507 }
6508
6509 #if defined(OS_LINUX)
6510 // Maximization on Linux is asynchronous, so create an observer object to be
6511 // notified upon maximization completion.
6512 new WindowMaximizedObserver(this, reply_message);
6513 #endif // defined(OS_LINUX)
6514
6515 browser->window()->Maximize();
6516
6517 #if !defined(OS_LINUX)
6518 // Send success reply right away for OS's with synchronous maximize command.
6519 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
6520 #endif // !defined(OS_LINUX)
6521 }
6522
6492 void TestingAutomationProvider::ActivateTabJSON( 6523 void TestingAutomationProvider::ActivateTabJSON(
6493 DictionaryValue* args, 6524 DictionaryValue* args,
6494 IPC::Message* reply_message) { 6525 IPC::Message* reply_message) {
6495 if (SendErrorIfModalDialogActive(this, reply_message)) 6526 if (SendErrorIfModalDialogActive(this, reply_message))
6496 return; 6527 return;
6497 6528
6498 AutomationJSONReply reply(this, reply_message); 6529 AutomationJSONReply reply(this, reply_message);
6499 Browser* browser; 6530 Browser* browser;
6500 WebContents* web_contents; 6531 WebContents* web_contents;
6501 std::string error; 6532 std::string error;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
6642 } 6673 }
6643 6674
6644 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, 6675 void TestingAutomationProvider::EnsureTabSelected(Browser* browser,
6645 WebContents* tab) { 6676 WebContents* tab) {
6646 if (browser->GetSelectedWebContents() != tab || 6677 if (browser->GetSelectedWebContents() != tab ||
6647 browser != BrowserList::GetLastActive()) { 6678 browser != BrowserList::GetLastActive()) {
6648 browser->ActivateTabAt(browser->GetIndexOfController(&tab->GetController()), 6679 browser->ActivateTabAt(browser->GetIndexOfController(&tab->GetController()),
6649 true /* user_gesture */); 6680 true /* user_gesture */);
6650 } 6681 }
6651 } 6682 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698