| Index: chrome/browser/automation/testing_automation_provider.cc
|
| diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
|
| index 18c57e438aab135f6649f6d73386ffe14b1bb38f..2a9adc4adeb0704c4bd1bae386f38d3500abfcf7 100644
|
| --- a/chrome/browser/automation/testing_automation_provider.cc
|
| +++ b/chrome/browser/automation/testing_automation_provider.cc
|
| @@ -40,6 +40,7 @@
|
| #include "chrome/browser/extensions/extension_host.h"
|
| #include "chrome/browser/extensions/extensions_service.h"
|
| #include "chrome/browser/find_bar.h"
|
| +#include "chrome/browser/history/top_sites.h"
|
| #include "chrome/browser/location_bar.h"
|
| #include "chrome/browser/login_prompt.h"
|
| #include "chrome/browser/native_app_modal_dialog.h"
|
| @@ -2141,6 +2142,17 @@ void TestingAutomationProvider::SendJSONRequest(int handle,
|
| handler_map["DisableSyncForDatatypes"] =
|
| &TestingAutomationProvider::DisableSyncForDatatypes;
|
|
|
| + handler_map["GetNTPInfo"] =
|
| + &TestingAutomationProvider::GetNTPInfo;
|
| + handler_map["MoveNTPMostVisitedThumbnail"] =
|
| + &TestingAutomationProvider::MoveNTPMostVisitedThumbnail;
|
| + handler_map["RemoveNTPMostVisitedThumbnail"] =
|
| + &TestingAutomationProvider::RemoveNTPMostVisitedThumbnail;
|
| + handler_map["UnpinNTPMostVisitedThumbnail"] =
|
| + &TestingAutomationProvider::UnpinNTPMostVisitedThumbnail;
|
| + handler_map["RestoreAllNTPMostVisitedThumbnails"] =
|
| + &TestingAutomationProvider::RestoreAllNTPMostVisitedThumbnails;
|
| +
|
| if (handler_map.find(std::string(command)) != handler_map.end()) {
|
| (this->*handler_map[command])(browser, dict_value, reply_message);
|
| } else {
|
| @@ -4305,6 +4317,102 @@ void TestingAutomationProvider::WaitForNotificationCount(
|
| this, reply_message, collection, count);
|
| }
|
|
|
| +// Sample JSON input: { "command": "GetNTPInfo" }
|
| +// For output, refer to chrome/test/pyautolib/ntp_model.py.
|
| +void TestingAutomationProvider::GetNTPInfo(
|
| + Browser* browser,
|
| + DictionaryValue* args,
|
| + IPC::Message* reply_message) {
|
| + // This observer will delete itself.
|
| + new NTPInfoObserver(this, reply_message, &consumer_);
|
| +}
|
| +
|
| +void TestingAutomationProvider::MoveNTPMostVisitedThumbnail(
|
| + Browser* browser,
|
| + DictionaryValue* args,
|
| + IPC::Message* reply_message) {
|
| + AutomationJSONReply reply(this, reply_message);
|
| + std::string url, error;
|
| + int index, old_index;
|
| + if (!args->GetString("url", &url)) {
|
| + reply.SendError("Missing or invalid 'url' key.");
|
| + return;
|
| + }
|
| + if (!args->GetInteger("index", &index)) {
|
| + reply.SendError("Missing or invalid 'index' key.");
|
| + return;
|
| + }
|
| + if (!args->GetInteger("old_index", &old_index)) {
|
| + reply.SendError("Missing or invalid 'old_index' key");
|
| + return;
|
| + }
|
| + history::TopSites* top_sites = browser->profile()->GetTopSites();
|
| + if (!top_sites) {
|
| + reply.SendError("TopSites service is not initialized.");
|
| + return;
|
| + }
|
| + GURL swapped;
|
| + // If thumbnail A is switching positions with a pinned thumbnail B, B
|
| + // should be pinned in the old index of A.
|
| + if (top_sites->GetPinnedURLAtIndex(index, &swapped)) {
|
| + top_sites->AddPinnedURL(swapped, old_index);
|
| + }
|
| + top_sites->AddPinnedURL(GURL(url), index);
|
| + reply.SendSuccess(NULL);
|
| +}
|
| +
|
| +void TestingAutomationProvider::RemoveNTPMostVisitedThumbnail(
|
| + Browser* browser,
|
| + DictionaryValue* args,
|
| + IPC::Message* reply_message) {
|
| + AutomationJSONReply reply(this, reply_message);
|
| + std::string url;
|
| + if (!args->GetString("url", &url)) {
|
| + reply.SendError("Missing or invalid 'url' key.");
|
| + return;
|
| + }
|
| + history::TopSites* top_sites = browser->profile()->GetTopSites();
|
| + if (!top_sites) {
|
| + reply.SendError("TopSites service is not initialized.");
|
| + return;
|
| + }
|
| + top_sites->AddBlacklistedURL(GURL(url));
|
| + reply.SendSuccess(NULL);
|
| +}
|
| +
|
| +void TestingAutomationProvider::UnpinNTPMostVisitedThumbnail(
|
| + Browser* browser,
|
| + DictionaryValue* args,
|
| + IPC::Message* reply_message) {
|
| + AutomationJSONReply reply(this, reply_message);
|
| + std::string url;
|
| + if (!args->GetString("url", &url)) {
|
| + reply.SendError("Missing or invalid 'url' key.");
|
| + return;
|
| + }
|
| + history::TopSites* top_sites = browser->profile()->GetTopSites();
|
| + if (!top_sites) {
|
| + reply.SendError("TopSites service is not initialized.");
|
| + return;
|
| + }
|
| + top_sites->RemovePinnedURL(GURL(url));
|
| + reply.SendSuccess(NULL);
|
| +}
|
| +
|
| +void TestingAutomationProvider::RestoreAllNTPMostVisitedThumbnails(
|
| + Browser* browser,
|
| + DictionaryValue* args,
|
| + IPC::Message* reply_message) {
|
| + AutomationJSONReply reply(this, reply_message);
|
| + history::TopSites* top_sites = browser->profile()->GetTopSites();
|
| + if (!top_sites) {
|
| + reply.SendError("TopSites service is not initialized.");
|
| + return;
|
| + }
|
| + top_sites->ClearBlacklistedURLs();
|
| + reply.SendSuccess(NULL);
|
| +}
|
| +
|
| void TestingAutomationProvider::WaitForTabCountToBecome(
|
| int browser_handle,
|
| int target_tab_count,
|
|
|