OLD | NEW |
---|---|
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 #include "chrome/browser/password_manager/password_store_change.h" | 70 #include "chrome/browser/password_manager/password_store_change.h" |
71 #include "chrome/browser/password_manager/password_store_factory.h" | 71 #include "chrome/browser/password_manager/password_store_factory.h" |
72 #include "chrome/browser/platform_util.h" | 72 #include "chrome/browser/platform_util.h" |
73 #include "chrome/browser/plugin_prefs.h" | 73 #include "chrome/browser/plugin_prefs.h" |
74 #include "chrome/browser/prefs/pref_service.h" | 74 #include "chrome/browser/prefs/pref_service.h" |
75 #include "chrome/browser/printing/print_preview_tab_controller.h" | 75 #include "chrome/browser/printing/print_preview_tab_controller.h" |
76 #include "chrome/browser/printing/print_view_manager.h" | 76 #include "chrome/browser/printing/print_view_manager.h" |
77 #include "chrome/browser/profiles/profile.h" | 77 #include "chrome/browser/profiles/profile.h" |
78 #include "chrome/browser/profiles/profile_info_cache.h" | 78 #include "chrome/browser/profiles/profile_info_cache.h" |
79 #include "chrome/browser/profiles/profile_manager.h" | 79 #include "chrome/browser/profiles/profile_manager.h" |
80 #include "chrome/browser/protector/protector.h" | |
80 #include "chrome/browser/protector/protector_service.h" | 81 #include "chrome/browser/protector/protector_service.h" |
81 #include "chrome/browser/protector/protector_service_factory.h" | 82 #include "chrome/browser/protector/protector_service_factory.h" |
82 #include "chrome/browser/search_engines/template_url.h" | 83 #include "chrome/browser/search_engines/template_url.h" |
83 #include "chrome/browser/search_engines/template_url_service.h" | 84 #include "chrome/browser/search_engines/template_url_service.h" |
84 #include "chrome/browser/search_engines/template_url_service_factory.h" | 85 #include "chrome/browser/search_engines/template_url_service_factory.h" |
85 #include "chrome/browser/sessions/restore_tab_helper.h" | 86 #include "chrome/browser/sessions/restore_tab_helper.h" |
86 #include "chrome/browser/sessions/session_service_factory.h" | 87 #include "chrome/browser/sessions/session_service_factory.h" |
87 #include "chrome/browser/sync/profile_sync_service.h" | 88 #include "chrome/browser/sync/profile_sync_service.h" |
88 #include "chrome/browser/sync/profile_sync_service_factory.h" | 89 #include "chrome/browser/sync/profile_sync_service_factory.h" |
89 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 90 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
(...skipping 2431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2521 | 2522 |
2522 browser_handler_map["LoadSearchEngineInfo"] = | 2523 browser_handler_map["LoadSearchEngineInfo"] = |
2523 &TestingAutomationProvider::LoadSearchEngineInfo; | 2524 &TestingAutomationProvider::LoadSearchEngineInfo; |
2524 browser_handler_map["GetSearchEngineInfo"] = | 2525 browser_handler_map["GetSearchEngineInfo"] = |
2525 &TestingAutomationProvider::GetSearchEngineInfo; | 2526 &TestingAutomationProvider::GetSearchEngineInfo; |
2526 browser_handler_map["AddOrEditSearchEngine"] = | 2527 browser_handler_map["AddOrEditSearchEngine"] = |
2527 &TestingAutomationProvider::AddOrEditSearchEngine; | 2528 &TestingAutomationProvider::AddOrEditSearchEngine; |
2528 browser_handler_map["PerformActionOnSearchEngine"] = | 2529 browser_handler_map["PerformActionOnSearchEngine"] = |
2529 &TestingAutomationProvider::PerformActionOnSearchEngine; | 2530 &TestingAutomationProvider::PerformActionOnSearchEngine; |
2530 | 2531 |
2532 #if defined(ENABLE_PROTECTOR_SERVICE) | |
Yaron
2012/03/28 21:23:22
Hmm. This shouldn't really be necessary as chrome/
| |
2531 browser_handler_map["GetProtectorState"] = | 2533 browser_handler_map["GetProtectorState"] = |
2532 &TestingAutomationProvider::GetProtectorState; | 2534 &TestingAutomationProvider::GetProtectorState; |
2533 browser_handler_map["PerformProtectorAction"] = | 2535 browser_handler_map["PerformProtectorAction"] = |
2534 &TestingAutomationProvider::PerformProtectorAction; | 2536 &TestingAutomationProvider::PerformProtectorAction; |
2537 #endif | |
2535 | 2538 |
2536 browser_handler_map["SetWindowDimensions"] = | 2539 browser_handler_map["SetWindowDimensions"] = |
2537 &TestingAutomationProvider::SetWindowDimensions; | 2540 &TestingAutomationProvider::SetWindowDimensions; |
2538 | 2541 |
2539 browser_handler_map["GetDownloadsInfo"] = | 2542 browser_handler_map["GetDownloadsInfo"] = |
2540 &TestingAutomationProvider::GetDownloadsInfo; | 2543 &TestingAutomationProvider::GetDownloadsInfo; |
2541 browser_handler_map["WaitForAllDownloadsToComplete"] = | 2544 browser_handler_map["WaitForAllDownloadsToComplete"] = |
2542 &TestingAutomationProvider::WaitForAllDownloadsToComplete; | 2545 &TestingAutomationProvider::WaitForAllDownloadsToComplete; |
2543 browser_handler_map["PerformActionOnDownload"] = | 2546 browser_handler_map["PerformActionOnDownload"] = |
2544 &TestingAutomationProvider::PerformActionOnDownload; | 2547 &TestingAutomationProvider::PerformActionOnDownload; |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3447 } else if (action == "default") { | 3450 } else if (action == "default") { |
3448 url_model->AddObserver(new AutomationProviderSearchEngineObserver( | 3451 url_model->AddObserver(new AutomationProviderSearchEngineObserver( |
3449 this, reply_message)); | 3452 this, reply_message)); |
3450 url_model->SetDefaultSearchProvider(template_url); | 3453 url_model->SetDefaultSearchProvider(template_url); |
3451 } else { | 3454 } else { |
3452 AutomationJSONReply(this, reply_message).SendError( | 3455 AutomationJSONReply(this, reply_message).SendError( |
3453 "Invalid action: " + action); | 3456 "Invalid action: " + action); |
3454 } | 3457 } |
3455 } | 3458 } |
3456 | 3459 |
3460 #if defined(ENABLE_PROTECTOR_SERVICE) | |
3457 // Sample json output: { "enabled": true, | 3461 // Sample json output: { "enabled": true, |
3458 // "showing_change": false } | 3462 // "showing_change": false } |
3459 void TestingAutomationProvider::GetProtectorState( | 3463 void TestingAutomationProvider::GetProtectorState( |
3460 Browser* browser, | 3464 Browser* browser, |
3461 DictionaryValue* args, | 3465 DictionaryValue* args, |
3462 IPC::Message* reply_message) { | 3466 IPC::Message* reply_message) { |
3463 protector::ProtectorService* protector_service = | 3467 protector::ProtectorService* protector_service = |
3464 protector::ProtectorServiceFactory::GetForProfile(browser->profile()); | 3468 protector::ProtectorServiceFactory::GetForProfile(browser->profile()); |
3465 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 3469 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
3466 return_value->SetBoolean("enabled", protector::IsEnabled()); | 3470 return_value->SetBoolean("enabled", protector::IsEnabled()); |
(...skipping 24 matching lines...) Expand all Loading... | |
3491 protector::BaseSettingChange* change = | 3495 protector::BaseSettingChange* change = |
3492 protector_service->GetLastChange(); | 3496 protector_service->GetLastChange(); |
3493 if (action == "apply_change") | 3497 if (action == "apply_change") |
3494 protector_service->ApplyChange(change, browser); | 3498 protector_service->ApplyChange(change, browser); |
3495 else if (action == "discard_change") | 3499 else if (action == "discard_change") |
3496 protector_service->DiscardChange(change, browser); | 3500 protector_service->DiscardChange(change, browser); |
3497 else | 3501 else |
3498 return reply.SendError("Invalid 'action' value"); | 3502 return reply.SendError("Invalid 'action' value"); |
3499 reply.SendSuccess(NULL); | 3503 reply.SendSuccess(NULL); |
3500 } | 3504 } |
3505 #endif | |
Yaron
2012/03/28 21:23:22
When this is far enough away from the #if, add: #e
nilesh
2012/03/28 23:35:11
Done.
| |
3501 | 3506 |
3502 // Sample json input: { "command": "GetLocalStatePrefsInfo" } | 3507 // Sample json input: { "command": "GetLocalStatePrefsInfo" } |
3503 // Refer chrome/test/pyautolib/prefs_info.py for sample json output. | 3508 // Refer chrome/test/pyautolib/prefs_info.py for sample json output. |
3504 void TestingAutomationProvider::GetLocalStatePrefsInfo( | 3509 void TestingAutomationProvider::GetLocalStatePrefsInfo( |
3505 DictionaryValue* args, | 3510 DictionaryValue* args, |
3506 IPC::Message* reply_message) { | 3511 IPC::Message* reply_message) { |
3507 DictionaryValue* items = g_browser_process->local_state()-> | 3512 DictionaryValue* items = g_browser_process->local_state()-> |
3508 GetPreferenceValues(); | 3513 GetPreferenceValues(); |
3509 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 3514 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
3510 return_value->Set("prefs", items); // return_value owns items. | 3515 return_value->Set("prefs", items); // return_value owns items. |
(...skipping 3573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7084 | 7089 |
7085 Send(reply_message_); | 7090 Send(reply_message_); |
7086 redirect_query_ = 0; | 7091 redirect_query_ = 0; |
7087 reply_message_ = NULL; | 7092 reply_message_ = NULL; |
7088 } | 7093 } |
7089 | 7094 |
7090 void TestingAutomationProvider::OnRemoveProvider() { | 7095 void TestingAutomationProvider::OnRemoveProvider() { |
7091 if (g_browser_process) | 7096 if (g_browser_process) |
7092 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 7097 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
7093 } | 7098 } |
OLD | NEW |