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

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

Issue 11493003: Remove the protector service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix implicit ExtensionSystem -> TemplateURLService dependency Created 8 years 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 #include "chrome/browser/password_manager/password_store.h" 73 #include "chrome/browser/password_manager/password_store.h"
74 #include "chrome/browser/password_manager/password_store_change.h" 74 #include "chrome/browser/password_manager/password_store_change.h"
75 #include "chrome/browser/password_manager/password_store_factory.h" 75 #include "chrome/browser/password_manager/password_store_factory.h"
76 #include "chrome/browser/platform_util.h" 76 #include "chrome/browser/platform_util.h"
77 #include "chrome/browser/plugins/plugin_prefs.h" 77 #include "chrome/browser/plugins/plugin_prefs.h"
78 #include "chrome/browser/prefs/pref_service.h" 78 #include "chrome/browser/prefs/pref_service.h"
79 #include "chrome/browser/printing/print_preview_tab_controller.h" 79 #include "chrome/browser/printing/print_preview_tab_controller.h"
80 #include "chrome/browser/profiles/profile.h" 80 #include "chrome/browser/profiles/profile.h"
81 #include "chrome/browser/profiles/profile_info_cache.h" 81 #include "chrome/browser/profiles/profile_info_cache.h"
82 #include "chrome/browser/profiles/profile_manager.h" 82 #include "chrome/browser/profiles/profile_manager.h"
83 #include "chrome/browser/protector/protector_service.h"
84 #include "chrome/browser/protector/protector_service_factory.h"
85 #include "chrome/browser/protector/protector_utils.h"
86 #include "chrome/browser/search_engines/template_url.h" 83 #include "chrome/browser/search_engines/template_url.h"
87 #include "chrome/browser/search_engines/template_url_service.h" 84 #include "chrome/browser/search_engines/template_url_service.h"
88 #include "chrome/browser/search_engines/template_url_service_factory.h" 85 #include "chrome/browser/search_engines/template_url_service_factory.h"
89 #include "chrome/browser/sessions/session_service_factory.h" 86 #include "chrome/browser/sessions/session_service_factory.h"
90 #include "chrome/browser/sessions/session_tab_helper.h" 87 #include "chrome/browser/sessions/session_tab_helper.h"
91 #include "chrome/browser/sync/profile_sync_service.h" 88 #include "chrome/browser/sync/profile_sync_service.h"
92 #include "chrome/browser/sync/profile_sync_service_factory.h" 89 #include "chrome/browser/sync/profile_sync_service_factory.h"
93 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" 90 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
94 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" 91 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
95 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" 92 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h"
(...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 1899
1903 browser_handler_map_["LoadSearchEngineInfo"] = 1900 browser_handler_map_["LoadSearchEngineInfo"] =
1904 &TestingAutomationProvider::LoadSearchEngineInfo; 1901 &TestingAutomationProvider::LoadSearchEngineInfo;
1905 browser_handler_map_["GetSearchEngineInfo"] = 1902 browser_handler_map_["GetSearchEngineInfo"] =
1906 &TestingAutomationProvider::GetSearchEngineInfo; 1903 &TestingAutomationProvider::GetSearchEngineInfo;
1907 browser_handler_map_["AddOrEditSearchEngine"] = 1904 browser_handler_map_["AddOrEditSearchEngine"] =
1908 &TestingAutomationProvider::AddOrEditSearchEngine; 1905 &TestingAutomationProvider::AddOrEditSearchEngine;
1909 browser_handler_map_["PerformActionOnSearchEngine"] = 1906 browser_handler_map_["PerformActionOnSearchEngine"] =
1910 &TestingAutomationProvider::PerformActionOnSearchEngine; 1907 &TestingAutomationProvider::PerformActionOnSearchEngine;
1911 1908
1912 #if defined(ENABLE_PROTECTOR_SERVICE)
1913 browser_handler_map_["GetProtectorState"] =
1914 &TestingAutomationProvider::GetProtectorState;
1915 browser_handler_map_["PerformProtectorAction"] =
1916 &TestingAutomationProvider::PerformProtectorAction;
1917 #endif
1918
1919 browser_handler_map_["SetWindowDimensions"] = 1909 browser_handler_map_["SetWindowDimensions"] =
1920 &TestingAutomationProvider::SetWindowDimensions; 1910 &TestingAutomationProvider::SetWindowDimensions;
1921 1911
1922 browser_handler_map_["GetDownloadsInfo"] = 1912 browser_handler_map_["GetDownloadsInfo"] =
1923 &TestingAutomationProvider::GetDownloadsInfo; 1913 &TestingAutomationProvider::GetDownloadsInfo;
1924 browser_handler_map_["WaitForAllDownloadsToComplete"] = 1914 browser_handler_map_["WaitForAllDownloadsToComplete"] =
1925 &TestingAutomationProvider::WaitForAllDownloadsToComplete; 1915 &TestingAutomationProvider::WaitForAllDownloadsToComplete;
1926 browser_handler_map_["PerformActionOnDownload"] = 1916 browser_handler_map_["PerformActionOnDownload"] =
1927 &TestingAutomationProvider::PerformActionOnDownload; 1917 &TestingAutomationProvider::PerformActionOnDownload;
1928 1918
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
2892 } else if (action == "default") { 2882 } else if (action == "default") {
2893 url_model->AddObserver(new AutomationProviderSearchEngineObserver( 2883 url_model->AddObserver(new AutomationProviderSearchEngineObserver(
2894 this, browser->profile(), reply_message)); 2884 this, browser->profile(), reply_message));
2895 url_model->SetDefaultSearchProvider(template_url); 2885 url_model->SetDefaultSearchProvider(template_url);
2896 } else { 2886 } else {
2897 AutomationJSONReply(this, reply_message).SendError( 2887 AutomationJSONReply(this, reply_message).SendError(
2898 "Invalid action: " + action); 2888 "Invalid action: " + action);
2899 } 2889 }
2900 } 2890 }
2901 2891
2902 #if defined(ENABLE_PROTECTOR_SERVICE)
2903 // Sample json output: { "enabled": true,
2904 // "showing_change": false }
2905 void TestingAutomationProvider::GetProtectorState(
2906 Browser* browser,
2907 DictionaryValue* args,
2908 IPC::Message* reply_message) {
2909 protector::ProtectorService* protector_service =
2910 protector::ProtectorServiceFactory::GetForProfile(browser->profile());
2911 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
2912 return_value->SetBoolean("enabled", protector::IsEnabled());
2913 return_value->SetBoolean("showing_change",
2914 protector_service->IsShowingChange());
2915 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
2916 }
2917
2918 // Sample json inputs:
2919 // { "command": "PerformProtectorAction", "action": "apply_change" }
2920 // { "command": "PerformProtectorAction", "action": "discard_change" }
2921 void TestingAutomationProvider::PerformProtectorAction(
2922 Browser* browser,
2923 base::DictionaryValue* args,
2924 IPC::Message* reply_message) {
2925 protector::ProtectorService* protector_service =
2926 protector::ProtectorServiceFactory::GetForProfile(browser->profile());
2927 AutomationJSONReply reply(this, reply_message);
2928 if (!protector::IsEnabled()) {
2929 reply.SendError("Protector is disabled");
2930 return;
2931 }
2932 std::string action;
2933 if (!args->GetString("action", &action)) {
2934 reply.SendError("Missing 'action' value");
2935 return;
2936 }
2937 protector::BaseSettingChange* change =
2938 protector_service->GetLastChange();
2939 if (action == "apply_change")
2940 protector_service->ApplyChange(change, browser);
2941 else if (action == "discard_change")
2942 protector_service->DiscardChange(change, browser);
2943 else
2944 return reply.SendError("Invalid 'action' value");
2945 reply.SendSuccess(NULL);
2946 }
2947 #endif // defined(ENABLE_PROTECTOR_SERVICE)
2948
2949 // Sample json input: { "command": "GetLocalStatePrefsInfo" } 2892 // Sample json input: { "command": "GetLocalStatePrefsInfo" }
2950 // Refer chrome/test/pyautolib/prefs_info.py for sample json output. 2893 // Refer chrome/test/pyautolib/prefs_info.py for sample json output.
2951 void TestingAutomationProvider::GetLocalStatePrefsInfo( 2894 void TestingAutomationProvider::GetLocalStatePrefsInfo(
2952 DictionaryValue* args, 2895 DictionaryValue* args,
2953 IPC::Message* reply_message) { 2896 IPC::Message* reply_message) {
2954 DictionaryValue* items = g_browser_process->local_state()-> 2897 DictionaryValue* items = g_browser_process->local_state()->
2955 GetPreferenceValues(); 2898 GetPreferenceValues();
2956 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 2899 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
2957 return_value->Set("prefs", items); // return_value owns items. 2900 return_value->Set("prefs", items); // return_value owns items.
2958 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); 2901 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
(...skipping 3373 matching lines...) Expand 10 before | Expand all | Expand 10 after
6332 if (g_browser_process) 6275 if (g_browser_process)
6333 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 6276 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
6334 } 6277 }
6335 6278
6336 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, 6279 void TestingAutomationProvider::EnsureTabSelected(Browser* browser,
6337 WebContents* tab) { 6280 WebContents* tab) {
6338 TabStripModel* tab_strip = browser->tab_strip_model(); 6281 TabStripModel* tab_strip = browser->tab_strip_model();
6339 if (tab_strip->GetActiveWebContents() != tab) 6282 if (tab_strip->GetActiveWebContents() != tab)
6340 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); 6283 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true);
6341 } 6284 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.h ('k') | chrome/browser/extensions/extension_system_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698