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

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

Issue 6756044: Remove extension automation support that was used only by CEEE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to lkgr. Created 9 years, 8 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/automation_provider.h" 5 #include "chrome/browser/automation/automation_provider.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 16 matching lines...) Expand all
27 #include "chrome/browser/autocomplete/autocomplete_edit.h" 27 #include "chrome/browser/autocomplete/autocomplete_edit.h"
28 #include "chrome/browser/autofill/autofill_manager.h" 28 #include "chrome/browser/autofill/autofill_manager.h"
29 #include "chrome/browser/automation/automation_autocomplete_edit_tracker.h" 29 #include "chrome/browser/automation/automation_autocomplete_edit_tracker.h"
30 #include "chrome/browser/automation/automation_browser_tracker.h" 30 #include "chrome/browser/automation/automation_browser_tracker.h"
31 #include "chrome/browser/automation/automation_extension_tracker.h" 31 #include "chrome/browser/automation/automation_extension_tracker.h"
32 #include "chrome/browser/automation/automation_provider_list.h" 32 #include "chrome/browser/automation/automation_provider_list.h"
33 #include "chrome/browser/automation/automation_provider_observers.h" 33 #include "chrome/browser/automation/automation_provider_observers.h"
34 #include "chrome/browser/automation/automation_resource_message_filter.h" 34 #include "chrome/browser/automation/automation_resource_message_filter.h"
35 #include "chrome/browser/automation/automation_tab_tracker.h" 35 #include "chrome/browser/automation/automation_tab_tracker.h"
36 #include "chrome/browser/automation/automation_window_tracker.h" 36 #include "chrome/browser/automation/automation_window_tracker.h"
37 #include "chrome/browser/automation/extension_port_container.h"
38 #include "chrome/browser/automation/ui_controls.h" 37 #include "chrome/browser/automation/ui_controls.h"
39 #include "chrome/browser/blocked_content_container.h" 38 #include "chrome/browser/blocked_content_container.h"
40 #include "chrome/browser/bookmarks/bookmark_model.h" 39 #include "chrome/browser/bookmarks/bookmark_model.h"
41 #include "chrome/browser/bookmarks/bookmark_storage.h" 40 #include "chrome/browser/bookmarks/bookmark_storage.h"
42 #include "chrome/browser/browser_list.h" 41 #include "chrome/browser/browser_list.h"
43 #include "chrome/browser/browser_process.h" 42 #include "chrome/browser/browser_process.h"
44 #include "chrome/browser/browser_window.h" 43 #include "chrome/browser/browser_window.h"
45 #include "chrome/browser/browsing_data_remover.h" 44 #include "chrome/browser/browsing_data_remover.h"
46 #include "chrome/browser/character_encoding.h" 45 #include "chrome/browser/character_encoding.h"
47 #include "chrome/browser/content_settings/host_content_settings_map.h" 46 #include "chrome/browser/content_settings/host_content_settings_map.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 new_tab_ui_load_observer_.reset(new NewTabUILoadObserver(this)); 124 new_tab_ui_load_observer_.reset(new NewTabUILoadObserver(this));
126 metric_event_duration_observer_.reset(new MetricEventDurationObserver()); 125 metric_event_duration_observer_.reset(new MetricEventDurationObserver());
127 extension_test_result_observer_.reset( 126 extension_test_result_observer_.reset(
128 new ExtensionTestResultNotificationObserver(this)); 127 new ExtensionTestResultNotificationObserver(this));
129 g_browser_process->AddRefModule(); 128 g_browser_process->AddRefModule();
130 129
131 TRACE_EVENT_END("AutomationProvider::AutomationProvider", 0, ""); 130 TRACE_EVENT_END("AutomationProvider::AutomationProvider", 0, "");
132 } 131 }
133 132
134 AutomationProvider::~AutomationProvider() { 133 AutomationProvider::~AutomationProvider() {
135 STLDeleteContainerPairSecondPointers(port_containers_.begin(),
136 port_containers_.end());
137 port_containers_.clear();
138
139 if (channel_.get()) 134 if (channel_.get())
140 channel_->Close(); 135 channel_->Close();
141 136
142 g_browser_process->ReleaseModule(); 137 g_browser_process->ReleaseModule();
143 } 138 }
144 139
145 bool AutomationProvider::InitializeChannel(const std::string& channel_id) { 140 bool AutomationProvider::InitializeChannel(const std::string& channel_id) {
146 TRACE_EVENT_BEGIN("AutomationProvider::InitializeChannel", 0, ""); 141 TRACE_EVENT_BEGIN("AutomationProvider::InitializeChannel", 0, "");
147 142
148 channel_id_ = channel_id; 143 channel_id_ = channel_id;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 void AutomationProvider::AddLoginHandler(NavigationController* tab, 210 void AutomationProvider::AddLoginHandler(NavigationController* tab,
216 LoginHandler* handler) { 211 LoginHandler* handler) {
217 login_handler_map_[tab] = handler; 212 login_handler_map_[tab] = handler;
218 } 213 }
219 214
220 void AutomationProvider::RemoveLoginHandler(NavigationController* tab) { 215 void AutomationProvider::RemoveLoginHandler(NavigationController* tab) {
221 DCHECK(login_handler_map_[tab]); 216 DCHECK(login_handler_map_[tab]);
222 login_handler_map_.erase(tab); 217 login_handler_map_.erase(tab);
223 } 218 }
224 219
225 void AutomationProvider::AddPortContainer(ExtensionPortContainer* port) {
226 int port_id = port->port_id();
227 DCHECK_NE(-1, port_id);
228 DCHECK(port_containers_.find(port_id) == port_containers_.end());
229
230 port_containers_[port_id] = port;
231 }
232
233 void AutomationProvider::RemovePortContainer(ExtensionPortContainer* port) {
234 int port_id = port->port_id();
235 DCHECK_NE(-1, port_id);
236
237 PortContainerMap::iterator it = port_containers_.find(port_id);
238 DCHECK(it != port_containers_.end());
239
240 if (it != port_containers_.end()) {
241 delete it->second;
242 port_containers_.erase(it);
243 }
244 }
245
246 ExtensionPortContainer* AutomationProvider::GetPortContainer(
247 int port_id) const {
248 PortContainerMap::const_iterator it = port_containers_.find(port_id);
249 if (it == port_containers_.end())
250 return NULL;
251
252 return it->second;
253 }
254
255 int AutomationProvider::GetIndexForNavigationController( 220 int AutomationProvider::GetIndexForNavigationController(
256 const NavigationController* controller, const Browser* parent) const { 221 const NavigationController* controller, const Browser* parent) const {
257 DCHECK(parent); 222 DCHECK(parent);
258 return parent->GetIndexOfController(controller); 223 return parent->GetIndexOfController(controller);
259 } 224 }
260 225
261 int AutomationProvider::AddExtension(const Extension* extension) { 226 int AutomationProvider::AddExtension(const Extension* extension) {
262 DCHECK(extension); 227 DCHECK(extension);
263 return extension_tracker_->Add(extension); 228 return extension_tracker_->Add(extension);
264 } 229 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 IPC_MESSAGE_HANDLER(AutomationMsg_OverrideEncoding, OverrideEncoding) 317 IPC_MESSAGE_HANDLER(AutomationMsg_OverrideEncoding, OverrideEncoding)
353 IPC_MESSAGE_HANDLER(AutomationMsg_SelectAll, SelectAll) 318 IPC_MESSAGE_HANDLER(AutomationMsg_SelectAll, SelectAll)
354 IPC_MESSAGE_HANDLER(AutomationMsg_Cut, Cut) 319 IPC_MESSAGE_HANDLER(AutomationMsg_Cut, Cut)
355 IPC_MESSAGE_HANDLER(AutomationMsg_Copy, Copy) 320 IPC_MESSAGE_HANDLER(AutomationMsg_Copy, Copy)
356 IPC_MESSAGE_HANDLER(AutomationMsg_Paste, Paste) 321 IPC_MESSAGE_HANDLER(AutomationMsg_Paste, Paste)
357 IPC_MESSAGE_HANDLER(AutomationMsg_ReloadAsync, ReloadAsync) 322 IPC_MESSAGE_HANDLER(AutomationMsg_ReloadAsync, ReloadAsync)
358 IPC_MESSAGE_HANDLER(AutomationMsg_StopAsync, StopAsync) 323 IPC_MESSAGE_HANDLER(AutomationMsg_StopAsync, StopAsync)
359 IPC_MESSAGE_HANDLER(AutomationMsg_SetPageFontSize, OnSetPageFontSize) 324 IPC_MESSAGE_HANDLER(AutomationMsg_SetPageFontSize, OnSetPageFontSize)
360 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_InstallExtension, 325 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_InstallExtension,
361 InstallExtension) 326 InstallExtension)
362 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_LoadExpandedExtension,
363 LoadExpandedExtension)
364 IPC_MESSAGE_HANDLER(AutomationMsg_GetEnabledExtensions,
365 GetEnabledExtensions)
366 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForExtensionTestResult, 327 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForExtensionTestResult,
367 WaitForExtensionTestResult) 328 WaitForExtensionTestResult)
368 IPC_MESSAGE_HANDLER_DELAY_REPLY( 329 IPC_MESSAGE_HANDLER_DELAY_REPLY(
369 AutomationMsg_InstallExtensionAndGetHandle, 330 AutomationMsg_InstallExtensionAndGetHandle,
370 InstallExtensionAndGetHandle) 331 InstallExtensionAndGetHandle)
371 IPC_MESSAGE_HANDLER(AutomationMsg_UninstallExtension, 332 IPC_MESSAGE_HANDLER(AutomationMsg_UninstallExtension,
372 UninstallExtension) 333 UninstallExtension)
373 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_EnableExtension, 334 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_EnableExtension,
374 EnableExtension) 335 EnableExtension)
375 IPC_MESSAGE_HANDLER(AutomationMsg_DisableExtension, 336 IPC_MESSAGE_HANDLER(AutomationMsg_DisableExtension,
(...skipping 16 matching lines...) Expand all
392 ProcessUnhandledAccelerator) 353 ProcessUnhandledAccelerator)
393 IPC_MESSAGE_HANDLER(AutomationMsg_SetInitialFocus, SetInitialFocus) 354 IPC_MESSAGE_HANDLER(AutomationMsg_SetInitialFocus, SetInitialFocus)
394 IPC_MESSAGE_HANDLER(AutomationMsg_TabReposition, OnTabReposition) 355 IPC_MESSAGE_HANDLER(AutomationMsg_TabReposition, OnTabReposition)
395 IPC_MESSAGE_HANDLER(AutomationMsg_ForwardContextMenuCommandToChrome, 356 IPC_MESSAGE_HANDLER(AutomationMsg_ForwardContextMenuCommandToChrome,
396 OnForwardContextMenuCommandToChrome) 357 OnForwardContextMenuCommandToChrome)
397 IPC_MESSAGE_HANDLER(AutomationMsg_NavigateInExternalTab, 358 IPC_MESSAGE_HANDLER(AutomationMsg_NavigateInExternalTab,
398 NavigateInExternalTab) 359 NavigateInExternalTab)
399 IPC_MESSAGE_HANDLER(AutomationMsg_NavigateExternalTabAtIndex, 360 IPC_MESSAGE_HANDLER(AutomationMsg_NavigateExternalTabAtIndex,
400 NavigateExternalTabAtIndex) 361 NavigateExternalTabAtIndex)
401 IPC_MESSAGE_HANDLER(AutomationMsg_ConnectExternalTab, ConnectExternalTab) 362 IPC_MESSAGE_HANDLER(AutomationMsg_ConnectExternalTab, ConnectExternalTab)
402 IPC_MESSAGE_HANDLER(AutomationMsg_SetEnableExtensionAutomation,
403 SetEnableExtensionAutomation)
404 IPC_MESSAGE_HANDLER(AutomationMsg_HandleMessageFromExternalHost, 363 IPC_MESSAGE_HANDLER(AutomationMsg_HandleMessageFromExternalHost,
405 OnMessageFromExternalHost) 364 OnMessageFromExternalHost)
406 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserMove, OnBrowserMoved) 365 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserMove, OnBrowserMoved)
407 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_RunUnloadHandlers, 366 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_RunUnloadHandlers,
408 OnRunUnloadHandlers) 367 OnRunUnloadHandlers)
409 IPC_MESSAGE_HANDLER(AutomationMsg_SetZoomLevel, OnSetZoomLevel) 368 IPC_MESSAGE_HANDLER(AutomationMsg_SetZoomLevel, OnSetZoomLevel)
410 #endif // defined(OS_WIN) 369 #endif // defined(OS_WIN)
411 IPC_MESSAGE_UNHANDLED(handled = false; OnUnhandledMessage()) 370 IPC_MESSAGE_UNHANDLED(handled = false; OnUnhandledMessage())
412 IPC_END_MESSAGE_MAP_EX() 371 IPC_END_MESSAGE_MAP_EX()
413 if (!deserialize_success) 372 if (!deserialize_success)
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 scoped_refptr<CrxInstaller> installer( 773 scoped_refptr<CrxInstaller> installer(
815 new CrxInstaller(service, NULL)); // silent install, no UI 774 new CrxInstaller(service, NULL)); // silent install, no UI
816 installer->InstallCrx(crx_path); 775 installer->InstallCrx(crx_path);
817 } else { 776 } else {
818 AutomationMsg_InstallExtension::WriteReplyParams( 777 AutomationMsg_InstallExtension::WriteReplyParams(
819 reply_message, AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); 778 reply_message, AUTOMATION_MSG_EXTENSION_INSTALL_FAILED);
820 Send(reply_message); 779 Send(reply_message);
821 } 780 }
822 } 781 }
823 782
824 void AutomationProvider::LoadExpandedExtension(
825 const FilePath& extension_dir,
826 IPC::Message* reply_message) {
827 if (profile_->GetExtensionService()) {
828 // The observer will delete itself when done.
829 new ExtensionInstallNotificationObserver(
830 this,
831 AutomationMsg_LoadExpandedExtension::ID,
832 reply_message);
833
834 profile_->GetExtensionService()->LoadExtension(extension_dir);
835 } else {
836 AutomationMsg_LoadExpandedExtension::WriteReplyParams(
837 reply_message, AUTOMATION_MSG_EXTENSION_INSTALL_FAILED);
838 Send(reply_message);
839 }
840 }
841
842 void AutomationProvider::GetEnabledExtensions(
843 std::vector<FilePath>* result) {
844 ExtensionService* service = profile_->GetExtensionService();
845 DCHECK(service);
846 if (service->extensions_enabled()) {
847 const ExtensionList* extensions = service->extensions();
848 DCHECK(extensions);
849 for (size_t i = 0; i < extensions->size(); ++i) {
850 const Extension* extension = (*extensions)[i];
851 DCHECK(extension);
852 // AutomationProvider only exposes non app internal/loaded extensions.
853 if (!extension->is_app() &&
854 (extension->location() == Extension::INTERNAL ||
855 extension->location() == Extension::LOAD)) {
856 result->push_back(extension->path());
857 }
858 }
859 }
860 }
861
862 void AutomationProvider::WaitForExtensionTestResult( 783 void AutomationProvider::WaitForExtensionTestResult(
863 IPC::Message* reply_message) { 784 IPC::Message* reply_message) {
864 DCHECK(!reply_message_); 785 DCHECK(!reply_message_);
865 reply_message_ = reply_message; 786 reply_message_ = reply_message;
866 // Call MaybeSendResult, because the result might have come in before 787 // Call MaybeSendResult, because the result might have come in before
867 // we were waiting on it. 788 // we were waiting on it.
868 extension_test_result_observer_->MaybeSendResult(); 789 extension_test_result_observer_->MaybeSendResult();
869 } 790 }
870 791
871 void AutomationProvider::InstallExtensionAndGetHandle( 792 void AutomationProvider::InstallExtensionAndGetHandle(
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 } 954 }
1034 } 955 }
1035 } 956 }
1036 957
1037 void AutomationProvider::SaveAsAsync(int tab_handle) { 958 void AutomationProvider::SaveAsAsync(int tab_handle) {
1038 NavigationController* tab = NULL; 959 NavigationController* tab = NULL;
1039 TabContents* tab_contents = GetTabContentsForHandle(tab_handle, &tab); 960 TabContents* tab_contents = GetTabContentsForHandle(tab_handle, &tab);
1040 if (tab_contents) 961 if (tab_contents)
1041 tab_contents->OnSavePage(); 962 tab_contents->OnSavePage();
1042 } 963 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698