| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 #include "chrome/browser/printing/print_preview_tab_controller.h" | 76 #include "chrome/browser/printing/print_preview_tab_controller.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_service.h" | 80 #include "chrome/browser/protector/protector_service.h" |
| 81 #include "chrome/browser/protector/protector_service_factory.h" | 81 #include "chrome/browser/protector/protector_service_factory.h" |
| 82 #include "chrome/browser/protector/protector_utils.h" | 82 #include "chrome/browser/protector/protector_utils.h" |
| 83 #include "chrome/browser/search_engines/template_url.h" | 83 #include "chrome/browser/search_engines/template_url.h" |
| 84 #include "chrome/browser/search_engines/template_url_service.h" | 84 #include "chrome/browser/search_engines/template_url_service.h" |
| 85 #include "chrome/browser/search_engines/template_url_service_factory.h" | 85 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 86 #include "chrome/browser/sessions/restore_tab_helper.h" | |
| 87 #include "chrome/browser/sessions/session_service_factory.h" | 86 #include "chrome/browser/sessions/session_service_factory.h" |
| 87 #include "chrome/browser/sessions/session_tab_helper.h" |
| 88 #include "chrome/browser/sync/profile_sync_service.h" | 88 #include "chrome/browser/sync/profile_sync_service.h" |
| 89 #include "chrome/browser/sync/profile_sync_service_factory.h" | 89 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 90 #include "chrome/browser/themes/theme_service.h" | 90 #include "chrome/browser/themes/theme_service.h" |
| 91 #include "chrome/browser/themes/theme_service_factory.h" | 91 #include "chrome/browser/themes/theme_service_factory.h" |
| 92 #include "chrome/browser/translate/translate_infobar_delegate.h" | 92 #include "chrome/browser/translate/translate_infobar_delegate.h" |
| 93 #include "chrome/browser/translate/translate_tab_helper.h" | 93 #include "chrome/browser/translate/translate_tab_helper.h" |
| 94 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | 94 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
| 95 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 95 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
| 96 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" | 96 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" |
| 97 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" | 97 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" |
| (...skipping 5642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5740 } | 5740 } |
| 5741 if (has_handle && (!args->GetInteger("tab_handle", &id_or_handle) || | 5741 if (has_handle && (!args->GetInteger("tab_handle", &id_or_handle) || |
| 5742 !tab_tracker_->ContainsHandle(id_or_handle))) { | 5742 !tab_tracker_->ContainsHandle(id_or_handle))) { |
| 5743 reply.SendError("'tab_handle' is invalid"); | 5743 reply.SendError("'tab_handle' is invalid"); |
| 5744 return; | 5744 return; |
| 5745 } | 5745 } |
| 5746 int id = id_or_handle; | 5746 int id = id_or_handle; |
| 5747 if (has_handle) { | 5747 if (has_handle) { |
| 5748 TabContents* tab = TabContents::FromWebContents( | 5748 TabContents* tab = TabContents::FromWebContents( |
| 5749 tab_tracker_->GetResource(id_or_handle)->GetWebContents()); | 5749 tab_tracker_->GetResource(id_or_handle)->GetWebContents()); |
| 5750 id = tab->restore_tab_helper()->session_id().id(); | 5750 id = tab->session_tab_helper()->session_id().id(); |
| 5751 } | 5751 } |
| 5752 BrowserList::const_iterator iter = BrowserList::begin(); | 5752 BrowserList::const_iterator iter = BrowserList::begin(); |
| 5753 int browser_index = 0; | 5753 int browser_index = 0; |
| 5754 for (; iter != BrowserList::end(); ++iter, ++browser_index) { | 5754 for (; iter != BrowserList::end(); ++iter, ++browser_index) { |
| 5755 Browser* browser = *iter; | 5755 Browser* browser = *iter; |
| 5756 for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) { | 5756 for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) { |
| 5757 TabContents* tab = chrome::GetTabContentsAt(browser, tab_index); | 5757 TabContents* tab = chrome::GetTabContentsAt(browser, tab_index); |
| 5758 if (tab->restore_tab_helper()->session_id().id() == id) { | 5758 if (tab->session_tab_helper()->session_id().id() == id) { |
| 5759 DictionaryValue dict; | 5759 DictionaryValue dict; |
| 5760 dict.SetInteger("windex", browser_index); | 5760 dict.SetInteger("windex", browser_index); |
| 5761 dict.SetInteger("tab_index", tab_index); | 5761 dict.SetInteger("tab_index", tab_index); |
| 5762 reply.SendSuccess(&dict); | 5762 reply.SendSuccess(&dict); |
| 5763 return; | 5763 return; |
| 5764 } | 5764 } |
| 5765 } | 5765 } |
| 5766 } | 5766 } |
| 5767 reply.SendError("Could not find tab among current browser windows"); | 5767 reply.SendError("Could not find tab among current browser windows"); |
| 5768 } | 5768 } |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6391 reply.SendSuccess(NULL); | 6391 reply.SendSuccess(NULL); |
| 6392 } | 6392 } |
| 6393 | 6393 |
| 6394 void TestingAutomationProvider::GetTabIds( | 6394 void TestingAutomationProvider::GetTabIds( |
| 6395 DictionaryValue* args, IPC::Message* reply_message) { | 6395 DictionaryValue* args, IPC::Message* reply_message) { |
| 6396 ListValue* id_list = new ListValue(); | 6396 ListValue* id_list = new ListValue(); |
| 6397 BrowserList::const_iterator iter = BrowserList::begin(); | 6397 BrowserList::const_iterator iter = BrowserList::begin(); |
| 6398 for (; iter != BrowserList::end(); ++iter) { | 6398 for (; iter != BrowserList::end(); ++iter) { |
| 6399 Browser* browser = *iter; | 6399 Browser* browser = *iter; |
| 6400 for (int i = 0; i < browser->tab_count(); ++i) { | 6400 for (int i = 0; i < browser->tab_count(); ++i) { |
| 6401 int id = chrome::GetTabContentsAt(browser, i)->restore_tab_helper()-> | 6401 int id = chrome::GetTabContentsAt(browser, i)->session_tab_helper()-> |
| 6402 session_id().id(); | 6402 session_id().id(); |
| 6403 id_list->Append(Value::CreateIntegerValue(id)); | 6403 id_list->Append(Value::CreateIntegerValue(id)); |
| 6404 } | 6404 } |
| 6405 } | 6405 } |
| 6406 DictionaryValue dict; | 6406 DictionaryValue dict; |
| 6407 dict.Set("ids", id_list); | 6407 dict.Set("ids", id_list); |
| 6408 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 6408 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 6409 } | 6409 } |
| 6410 | 6410 |
| 6411 void TestingAutomationProvider::GetViews( | 6411 void TestingAutomationProvider::GetViews( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6464 if (!args->GetInteger("id", &id)) { | 6464 if (!args->GetInteger("id", &id)) { |
| 6465 reply.SendError("'id' missing or invalid"); | 6465 reply.SendError("'id' missing or invalid"); |
| 6466 return; | 6466 return; |
| 6467 } | 6467 } |
| 6468 bool is_valid = false; | 6468 bool is_valid = false; |
| 6469 BrowserList::const_iterator iter = BrowserList::begin(); | 6469 BrowserList::const_iterator iter = BrowserList::begin(); |
| 6470 for (; iter != BrowserList::end(); ++iter) { | 6470 for (; iter != BrowserList::end(); ++iter) { |
| 6471 Browser* browser = *iter; | 6471 Browser* browser = *iter; |
| 6472 for (int i = 0; i < browser->tab_count(); ++i) { | 6472 for (int i = 0; i < browser->tab_count(); ++i) { |
| 6473 TabContents* tab = chrome::GetTabContentsAt(browser, i); | 6473 TabContents* tab = chrome::GetTabContentsAt(browser, i); |
| 6474 if (tab->restore_tab_helper()->session_id().id() == id) { | 6474 if (tab->session_tab_helper()->session_id().id() == id) { |
| 6475 is_valid = true; | 6475 is_valid = true; |
| 6476 break; | 6476 break; |
| 6477 } | 6477 } |
| 6478 } | 6478 } |
| 6479 } | 6479 } |
| 6480 DictionaryValue dict; | 6480 DictionaryValue dict; |
| 6481 dict.SetBoolean("is_valid", is_valid); | 6481 dict.SetBoolean("is_valid", is_valid); |
| 6482 reply.SendSuccess(&dict); | 6482 reply.SendSuccess(&dict); |
| 6483 } | 6483 } |
| 6484 | 6484 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6736 void TestingAutomationProvider::OnRemoveProvider() { | 6736 void TestingAutomationProvider::OnRemoveProvider() { |
| 6737 if (g_browser_process) | 6737 if (g_browser_process) |
| 6738 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6738 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 6739 } | 6739 } |
| 6740 | 6740 |
| 6741 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 6741 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
| 6742 WebContents* tab) { | 6742 WebContents* tab) { |
| 6743 if (chrome::GetActiveWebContents(browser) != tab) | 6743 if (chrome::GetActiveWebContents(browser) != tab) |
| 6744 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); | 6744 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); |
| 6745 } | 6745 } |
| OLD | NEW |