diff options
author | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-24 07:43:07 +0000 |
---|---|---|
committer | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-24 07:43:07 +0000 |
commit | ff6c86ff44d49f340328fedcb87bb4eba9bda29a (patch) | |
tree | e3760199edf367efceb471f6038b871e3cf9d08d /chrome/browser/automation/automation_util.cc | |
parent | b7392003761efc72983dae8f279f62eb93ddf752 (diff) | |
download | chromium_src-ff6c86ff44d49f340328fedcb87bb4eba9bda29a.zip chromium_src-ff6c86ff44d49f340328fedcb87bb4eba9bda29a.tar.gz chromium_src-ff6c86ff44d49f340328fedcb87bb4eba9bda29a.tar.bz2 |
Delete automation code needed by old (and deleted) ChromeDriver.
BUG=none
Review URL: https://chromiumcodereview.appspot.com/24396002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224949 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/automation/automation_util.cc')
-rw-r--r-- | chrome/browser/automation/automation_util.cc | 182 |
1 files changed, 2 insertions, 180 deletions
diff --git a/chrome/browser/automation/automation_util.cc b/chrome/browser/automation/automation_util.cc index 3313186..7b42e6c 100644 --- a/chrome/browser/automation/automation_util.cc +++ b/chrome/browser/automation/automation_util.cc @@ -29,7 +29,6 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/host_desktop.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" -#include "chrome/common/automation_id.h" #include "chrome/common/extensions/extension.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_process_host.h" @@ -51,10 +50,6 @@ #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" #endif -#if defined(ENABLE_FULL_PRINTING) -#include "chrome/browser/printing/print_preview_dialog_controller.h" -#endif - using content::BrowserThread; using content::RenderViewHost; using content::WebContents; @@ -469,182 +464,9 @@ void SetCookieJSON(AutomationProvider* provider, bool SendErrorIfModalDialogActive(AutomationProvider* provider, IPC::Message* message) { bool active = AppModalDialogQueue::GetInstance()->HasActiveDialog(); - if (active) { - AutomationJSONReply(provider, message).SendErrorCode( - automation::kBlockedByModalDialog); - } + if (active) + AutomationJSONReply(provider, message).SendError("Blocked by modal dialog"); return active; } -AutomationId GetIdForTab(const WebContents* tab) { - const SessionTabHelper* session_tab_helper = - SessionTabHelper::FromWebContents(tab); - return AutomationId(AutomationId::kTypeTab, - base::IntToString(session_tab_helper->session_id().id())); -} - -AutomationId GetIdForExtensionView( - const content::RenderViewHost* render_view_host) { - AutomationId::Type type; - WebContents* web_contents = WebContents::FromRenderViewHost(render_view_host); - switch (extensions::GetViewType(web_contents)) { - case extensions::VIEW_TYPE_EXTENSION_POPUP: - type = AutomationId::kTypeExtensionPopup; - break; - case extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE: - type = AutomationId::kTypeExtensionBgPage; - break; - case extensions::VIEW_TYPE_EXTENSION_INFOBAR: - type = AutomationId::kTypeExtensionInfobar; - break; - case extensions::VIEW_TYPE_APP_SHELL: - type = AutomationId::kTypeAppShell; - break; - default: - type = AutomationId::kTypeInvalid; - break; - } - // Since these extension views do not permit navigation, using the - // renderer process and view ID should suffice. - std::string id = base::StringPrintf("%d|%d", - render_view_host->GetRoutingID(), - render_view_host->GetProcess()->GetID()); - return AutomationId(type, id); -} - -AutomationId GetIdForExtension(const extensions::Extension* extension) { - return AutomationId(AutomationId::kTypeExtension, extension->id()); -} - -bool GetTabForId(const AutomationId& id, WebContents** tab) { - if (id.type() != AutomationId::kTypeTab) - return false; - -#if defined(ENABLE_FULL_PRINTING) - printing::PrintPreviewDialogController* preview_controller = - printing::PrintPreviewDialogController::GetInstance(); -#endif - for (chrome::BrowserIterator it; !it.done(); it.Next()) { - Browser* browser = *it; - for (int tab_index = 0; - tab_index < browser->tab_strip_model()->count(); - ++tab_index) { - WebContents* web_contents = - browser->tab_strip_model()->GetWebContentsAt(tab_index); - SessionTabHelper* session_tab_helper = - SessionTabHelper::FromWebContents(web_contents); - if (base::IntToString( - session_tab_helper->session_id().id()) == id.id()) { - *tab = web_contents; - return true; - } - -#if defined(ENABLE_FULL_PRINTING) - if (preview_controller) { - WebContents* print_preview_contents = - preview_controller->GetPrintPreviewForContents(web_contents); - if (print_preview_contents) { - SessionTabHelper* preview_session_tab_helper = - SessionTabHelper::FromWebContents(print_preview_contents); - std::string preview_id = base::IntToString( - preview_session_tab_helper->session_id().id()); - if (preview_id == id.id()) { - *tab = print_preview_contents; - return true; - } - } - } -#endif - } - } - return false; -} - -namespace { - -bool GetExtensionRenderViewForId( - const AutomationId& id, - Profile* profile, - RenderViewHost** rvh) { - ExtensionProcessManager* extension_mgr = - extensions::ExtensionSystem::Get(profile)->process_manager(); - const ExtensionProcessManager::ViewSet view_set = - extension_mgr->GetAllViews(); - for (ExtensionProcessManager::ViewSet::const_iterator iter = view_set.begin(); - iter != view_set.end(); ++iter) { - content::RenderViewHost* host = *iter; - AutomationId this_id = GetIdForExtensionView(host); - if (id == this_id) { - *rvh = host; - return true; - } - } - return false; -} - -} // namespace - -bool GetRenderViewForId( - const AutomationId& id, - Profile* profile, - RenderViewHost** rvh) { - switch (id.type()) { - case AutomationId::kTypeTab: { - WebContents* tab; - if (!GetTabForId(id, &tab)) - return false; - *rvh = tab->GetRenderViewHost(); - break; - } - case AutomationId::kTypeExtensionPopup: - case AutomationId::kTypeExtensionBgPage: - case AutomationId::kTypeExtensionInfobar: - case AutomationId::kTypeAppShell: - if (!GetExtensionRenderViewForId(id, profile, rvh)) - return false; - break; - default: - return false; - } - return true; -} - -bool GetExtensionForId( - const AutomationId& id, - Profile* profile, - const extensions::Extension** extension) { - if (id.type() != AutomationId::kTypeExtension) - return false; - ExtensionService* service = extensions::ExtensionSystem::Get(profile)-> - extension_service(); - const extensions::Extension* installed_extension = - service->GetInstalledExtension(id.id()); - if (installed_extension) - *extension = installed_extension; - return !!installed_extension; -} - -bool DoesObjectWithIdExist(const AutomationId& id, Profile* profile) { - switch (id.type()) { - case AutomationId::kTypeTab: { - WebContents* tab; - return GetTabForId(id, &tab); - } - case AutomationId::kTypeExtensionPopup: - case AutomationId::kTypeExtensionBgPage: - case AutomationId::kTypeExtensionInfobar: - case AutomationId::kTypeAppShell: { - RenderViewHost* rvh; - return GetExtensionRenderViewForId(id, profile, &rvh); - } - case AutomationId::kTypeExtension: { - const extensions::Extension* extension; - return GetExtensionForId(id, profile, &extension); - } - default: - break; - } - return false; -} - } // namespace automation_util |