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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 #include "content/public/browser/browser_child_process_host_iterator.h" | 125 #include "content/public/browser/browser_child_process_host_iterator.h" |
126 #include "content/public/browser/child_process_data.h" | 126 #include "content/public/browser/child_process_data.h" |
127 #include "content/public/browser/favicon_status.h" | 127 #include "content/public/browser/favicon_status.h" |
128 #include "content/public/browser/interstitial_page.h" | 128 #include "content/public/browser/interstitial_page.h" |
129 #include "content/public/browser/interstitial_page_delegate.h" | 129 #include "content/public/browser/interstitial_page_delegate.h" |
130 #include "content/public/browser/navigation_entry.h" | 130 #include "content/public/browser/navigation_entry.h" |
131 #include "content/public/browser/notification_service.h" | 131 #include "content/public/browser/notification_service.h" |
132 #include "content/public/browser/plugin_service.h" | 132 #include "content/public/browser/plugin_service.h" |
133 #include "content/public/browser/render_process_host.h" | 133 #include "content/public/browser/render_process_host.h" |
134 #include "content/public/browser/render_view_host.h" | 134 #include "content/public/browser/render_view_host.h" |
135 #include "content/public/browser/render_view_host_delegate.h" | |
135 #include "content/public/browser/render_widget_host_view.h" | 136 #include "content/public/browser/render_widget_host_view.h" |
136 #include "content/public/browser/web_contents.h" | 137 #include "content/public/browser/web_contents.h" |
137 #include "content/public/common/child_process_host.h" | 138 #include "content/public/common/child_process_host.h" |
138 #include "content/public/common/common_param_traits.h" | 139 #include "content/public/common/common_param_traits.h" |
139 #include "content/public/common/ssl_status.h" | 140 #include "content/public/common/ssl_status.h" |
140 #include "net/cookies/cookie_store.h" | 141 #include "net/cookies/cookie_store.h" |
141 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 142 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
142 #include "ui/base/events.h" | 143 #include "ui/base/events.h" |
143 #include "ui/base/keycodes/keyboard_codes.h" | 144 #include "ui/base/keycodes/keyboard_codes.h" |
144 #include "ui/base/ui_base_types.h" | 145 #include "ui/base/ui_base_types.h" |
(...skipping 2701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2846 // Add all extension processes in a list of dictionaries, one dictionary | 2847 // Add all extension processes in a list of dictionaries, one dictionary |
2847 // item per extension process. | 2848 // item per extension process. |
2848 ListValue* extension_views = new ListValue; | 2849 ListValue* extension_views = new ListValue; |
2849 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 2850 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
2850 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); | 2851 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); |
2851 for (size_t i = 0; i < profiles.size(); ++i) { | 2852 for (size_t i = 0; i < profiles.size(); ++i) { |
2852 ExtensionProcessManager* process_manager = | 2853 ExtensionProcessManager* process_manager = |
2853 profiles[i]->GetExtensionProcessManager(); | 2854 profiles[i]->GetExtensionProcessManager(); |
2854 if (!process_manager) | 2855 if (!process_manager) |
2855 continue; | 2856 continue; |
2856 ExtensionProcessManager::const_iterator jt; | 2857 const ExtensionProcessManager::ViewSet view_set = |
2857 for (jt = process_manager->begin(); jt != process_manager->end(); ++jt) { | 2858 process_manager->GetAllViews(); |
2858 ExtensionHost* ex_host = *jt; | 2859 for (ExtensionProcessManager::ViewSet::const_iterator jt = |
2860 view_set.begin(); jt != view_set.end(); ++jt) { | |
2861 content::RenderViewHost* render_view_host = *jt; | |
2859 // Don't add dead extension processes. | 2862 // Don't add dead extension processes. |
2860 if (!ex_host->IsRenderViewLive()) | 2863 if (!render_view_host->IsRenderViewLive()) |
2861 continue; | 2864 continue; |
2865 const Extension* extension = | |
2866 process_manager->GetExtensionForRenderViewHost(render_view_host); | |
2862 DictionaryValue* item = new DictionaryValue; | 2867 DictionaryValue* item = new DictionaryValue; |
2863 item->SetString("name", ex_host->extension()->name()); | 2868 item->SetString("name", extension->name()); |
2864 item->SetString("extension_id", ex_host->extension()->id()); | 2869 item->SetString("extension_id", extension->id()); |
2865 item->SetInteger( | 2870 item->SetInteger( |
2866 "pid", | 2871 "pid", |
2867 base::GetProcId(ex_host->render_process_host()->GetHandle())); | 2872 base::GetProcId(render_view_host->GetProcess()->GetHandle())); |
2868 DictionaryValue* view = new DictionaryValue; | 2873 DictionaryValue* view = new DictionaryValue; |
2869 view->SetInteger( | 2874 view->SetInteger( |
2870 "render_process_id", | 2875 "render_process_id", |
2871 ex_host->render_process_host()->GetID()); | 2876 render_view_host->GetProcess()->GetID()); |
2872 view->SetInteger( | 2877 view->SetInteger( |
2873 "render_view_id", | 2878 "render_view_id", |
2874 ex_host->render_view_host()->GetRoutingID()); | 2879 render_view_host->GetRoutingID()); |
2875 item->Set("view", view); | 2880 item->Set("view", view); |
2876 std::string type; | 2881 std::string type; |
2877 switch (ex_host->extension_host_type()) { | 2882 switch (render_view_host->GetDelegate()->GetRenderViewType()) { |
2878 case chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE: | 2883 case chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE: |
2879 type = "EXTENSION_BACKGROUND_PAGE"; | 2884 type = "EXTENSION_BACKGROUND_PAGE"; |
2880 break; | 2885 break; |
2881 case chrome::VIEW_TYPE_EXTENSION_POPUP: | 2886 case chrome::VIEW_TYPE_EXTENSION_POPUP: |
2882 type = "EXTENSION_POPUP"; | 2887 type = "EXTENSION_POPUP"; |
2883 break; | 2888 break; |
2884 case chrome::VIEW_TYPE_EXTENSION_INFOBAR: | 2889 case chrome::VIEW_TYPE_EXTENSION_INFOBAR: |
2885 type = "EXTENSION_INFOBAR"; | 2890 type = "EXTENSION_INFOBAR"; |
2886 break; | 2891 break; |
2887 case chrome::VIEW_TYPE_EXTENSION_DIALOG: | 2892 case chrome::VIEW_TYPE_EXTENSION_DIALOG: |
2888 type = "EXTENSION_DIALOG"; | 2893 type = "EXTENSION_DIALOG"; |
2889 break; | 2894 break; |
2890 case chrome::VIEW_TYPE_APP_SHELL: | 2895 case chrome::VIEW_TYPE_APP_SHELL: |
2891 type = "APP_SHELL"; | 2896 type = "APP_SHELL"; |
2892 break; | 2897 break; |
2893 case chrome::VIEW_TYPE_PANEL: | 2898 case chrome::VIEW_TYPE_PANEL: |
2894 type = "PANEL"; | 2899 type = "PANEL"; |
2895 break; | 2900 break; |
2896 default: | 2901 default: |
2897 type = "unknown"; | 2902 type = "unknown"; |
2898 break; | 2903 break; |
2899 } | 2904 } |
2900 item->SetString("view_type", type); | 2905 item->SetString("view_type", type); |
2901 item->SetString("url", ex_host->GetURL().spec()); | 2906 item->SetString("url", render_view_host->GetDelegate()->GetURL().spec()); |
2902 item->SetBoolean("loaded", ex_host->did_stop_loading()); | 2907 |
2908 /* | |
2909 TODO(aa): Hmmmm... | |
2910 item->SetBoolean( | |
2911 "loaded", | |
2912 static_cast<ExtensionHost*>( | |
2913 render_view_host->GetDelegate())->did_stop_loading()); | |
Aaron Boodman
2012/04/19 06:25:40
Sure would be nice to be able to get render_view_h
| |
2914 */ | |
2903 extension_views->Append(item); | 2915 extension_views->Append(item); |
2904 } | 2916 } |
2905 } | 2917 } |
2906 return_value->Set("extension_views", extension_views); | 2918 return_value->Set("extension_views", extension_views); |
2907 | 2919 |
2908 return_value->SetString("child_process_path", | 2920 return_value->SetString("child_process_path", |
2909 ChildProcessHost::GetChildPath(flags).value()); | 2921 ChildProcessHost::GetChildPath(flags).value()); |
2910 // Child processes are the processes for plugins and other workers. | 2922 // Child processes are the processes for plugins and other workers. |
2911 // Add all child processes in a list of dictionaries, one dictionary item | 2923 // Add all child processes in a list of dictionaries, one dictionary item |
2912 // per child process. | 2924 // per child process. |
(...skipping 3734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6647 AutomationId id = automation_util::GetIdForTab(preview_tab); | 6659 AutomationId id = automation_util::GetIdForTab(preview_tab); |
6648 dict->Set("auto_id", id.ToValue()); | 6660 dict->Set("auto_id", id.ToValue()); |
6649 view_list->Append(dict); | 6661 view_list->Append(dict); |
6650 } | 6662 } |
6651 } | 6663 } |
6652 } | 6664 } |
6653 } | 6665 } |
6654 | 6666 |
6655 ExtensionProcessManager* extension_mgr = | 6667 ExtensionProcessManager* extension_mgr = |
6656 profile()->GetExtensionProcessManager(); | 6668 profile()->GetExtensionProcessManager(); |
6657 ExtensionProcessManager::const_iterator iter; | 6669 const ExtensionProcessManager::ViewSet all_views = |
6658 for (iter = extension_mgr->begin(); iter != extension_mgr->end(); | 6670 extension_mgr->GetAllViews(); |
6659 ++iter) { | 6671 ExtensionProcessManager::ViewSet::const_iterator iter; |
6660 ExtensionHost* host = *iter; | 6672 for (iter = all_views.begin(); iter != all_views.end(); ++iter) { |
6673 content::RenderViewHost* host = *iter; | |
6661 AutomationId id = automation_util::GetIdForExtensionView(host); | 6674 AutomationId id = automation_util::GetIdForExtensionView(host); |
6662 if (!id.is_valid()) | 6675 if (!id.is_valid()) |
6663 continue; | 6676 continue; |
6677 const Extension* extension = | |
6678 extension_mgr->GetExtensionForRenderViewHost(host); | |
6664 DictionaryValue* dict = new DictionaryValue(); | 6679 DictionaryValue* dict = new DictionaryValue(); |
6665 dict->Set("auto_id", id.ToValue()); | 6680 dict->Set("auto_id", id.ToValue()); |
6666 dict->SetString("extension_id", host->extension_id()); | 6681 dict->SetString("extension_id", extension->id()); |
6667 view_list->Append(dict); | 6682 view_list->Append(dict); |
6668 } | 6683 } |
6669 DictionaryValue dict; | 6684 DictionaryValue dict; |
6670 dict.Set("views", view_list); | 6685 dict.Set("views", view_list); |
6671 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 6686 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
6672 } | 6687 } |
6673 | 6688 |
6674 void TestingAutomationProvider::IsTabIdValid( | 6689 void TestingAutomationProvider::IsTabIdValid( |
6675 DictionaryValue* args, IPC::Message* reply_message) { | 6690 DictionaryValue* args, IPC::Message* reply_message) { |
6676 AutomationJSONReply reply(this, reply_message); | 6691 AutomationJSONReply reply(this, reply_message); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6978 *browser_handle = browser_tracker_->Add(browser); | 6993 *browser_handle = browser_tracker_->Add(browser); |
6979 *success = true; | 6994 *success = true; |
6980 } | 6995 } |
6981 } | 6996 } |
6982 } | 6997 } |
6983 | 6998 |
6984 void TestingAutomationProvider::OnRemoveProvider() { | 6999 void TestingAutomationProvider::OnRemoveProvider() { |
6985 if (g_browser_process) | 7000 if (g_browser_process) |
6986 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 7001 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
6987 } | 7002 } |
OLD | NEW |