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

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

Issue 10113005: Remove EPM:all_hosts_ and use all_extension_views_ instead. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: interactive_ui_tests Created 8 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
OLDNEW
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
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
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::ContentsSet content_set =
2857 for (jt = process_manager->begin(); jt != process_manager->end(); ++jt) { 2858 process_manager->GetAllContents();
2858 ExtensionHost* ex_host = *jt; 2859 for (ExtensionProcessManager::ContentsSet::const_iterator jt =
2860 content_set.begin(); jt != content_set.end(); ++jt) {
2861 content::WebContents* contents = *jt;
2862 content::RenderViewHost* render_view_host = contents->GetRenderViewHost();
2859 // Don't add dead extension processes. 2863 // Don't add dead extension processes.
2860 if (!ex_host->IsRenderViewLive()) 2864 if (!render_view_host->IsRenderViewLive())
2861 continue; 2865 continue;
2866 const Extension* extension =
2867 process_manager->GetExtensionForRenderViewHost(render_view_host);
2862 DictionaryValue* item = new DictionaryValue; 2868 DictionaryValue* item = new DictionaryValue;
2863 item->SetString("name", ex_host->extension()->name()); 2869 item->SetString("name", extension->name());
2864 item->SetString("extension_id", ex_host->extension()->id()); 2870 item->SetString("extension_id", extension->id());
2865 item->SetInteger( 2871 item->SetInteger(
2866 "pid", 2872 "pid",
2867 base::GetProcId(ex_host->render_process_host()->GetHandle())); 2873 base::GetProcId(render_view_host->GetProcess()->GetHandle()));
2868 DictionaryValue* view = new DictionaryValue; 2874 DictionaryValue* view = new DictionaryValue;
2869 view->SetInteger( 2875 view->SetInteger(
2870 "render_process_id", 2876 "render_process_id",
2871 ex_host->render_process_host()->GetID()); 2877 render_view_host->GetProcess()->GetID());
2872 view->SetInteger( 2878 view->SetInteger(
2873 "render_view_id", 2879 "render_view_id",
2874 ex_host->render_view_host()->GetRoutingID()); 2880 render_view_host->GetRoutingID());
2875 item->Set("view", view); 2881 item->Set("view", view);
2876 std::string type; 2882 std::string type;
2877 switch (ex_host->extension_host_type()) { 2883 switch (render_view_host->GetDelegate()->GetRenderViewType()) {
2878 case chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE: 2884 case chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE:
2879 type = "EXTENSION_BACKGROUND_PAGE"; 2885 type = "EXTENSION_BACKGROUND_PAGE";
2880 break; 2886 break;
2881 case chrome::VIEW_TYPE_EXTENSION_POPUP: 2887 case chrome::VIEW_TYPE_EXTENSION_POPUP:
2882 type = "EXTENSION_POPUP"; 2888 type = "EXTENSION_POPUP";
2883 break; 2889 break;
2884 case chrome::VIEW_TYPE_EXTENSION_INFOBAR: 2890 case chrome::VIEW_TYPE_EXTENSION_INFOBAR:
2885 type = "EXTENSION_INFOBAR"; 2891 type = "EXTENSION_INFOBAR";
2886 break; 2892 break;
2887 case chrome::VIEW_TYPE_EXTENSION_DIALOG: 2893 case chrome::VIEW_TYPE_EXTENSION_DIALOG:
2888 type = "EXTENSION_DIALOG"; 2894 type = "EXTENSION_DIALOG";
2889 break; 2895 break;
2890 case chrome::VIEW_TYPE_APP_SHELL: 2896 case chrome::VIEW_TYPE_APP_SHELL:
2891 type = "APP_SHELL"; 2897 type = "APP_SHELL";
2892 break; 2898 break;
2893 case chrome::VIEW_TYPE_PANEL: 2899 case chrome::VIEW_TYPE_PANEL:
2894 type = "PANEL"; 2900 type = "PANEL";
2895 break; 2901 break;
2896 default: 2902 default:
2897 type = "unknown"; 2903 type = "unknown";
2898 break; 2904 break;
2899 } 2905 }
2900 item->SetString("view_type", type); 2906 item->SetString("view_type", type);
2901 item->SetString("url", ex_host->GetURL().spec()); 2907 item->SetString("url", render_view_host->GetDelegate()->GetURL().spec());
2902 item->SetBoolean("loaded", ex_host->did_stop_loading()); 2908
2909 item->SetBoolean("loaded", !contents->IsLoading());
2903 extension_views->Append(item); 2910 extension_views->Append(item);
2904 } 2911 }
2905 } 2912 }
2906 return_value->Set("extension_views", extension_views); 2913 return_value->Set("extension_views", extension_views);
2907 2914
2908 return_value->SetString("child_process_path", 2915 return_value->SetString("child_process_path",
2909 ChildProcessHost::GetChildPath(flags).value()); 2916 ChildProcessHost::GetChildPath(flags).value());
2910 // Child processes are the processes for plugins and other workers. 2917 // Child processes are the processes for plugins and other workers.
2911 // Add all child processes in a list of dictionaries, one dictionary item 2918 // Add all child processes in a list of dictionaries, one dictionary item
2912 // per child process. 2919 // per child process.
(...skipping 3734 matching lines...) Expand 10 before | Expand all | Expand 10 after
6647 AutomationId id = automation_util::GetIdForTab(preview_tab); 6654 AutomationId id = automation_util::GetIdForTab(preview_tab);
6648 dict->Set("auto_id", id.ToValue()); 6655 dict->Set("auto_id", id.ToValue());
6649 view_list->Append(dict); 6656 view_list->Append(dict);
6650 } 6657 }
6651 } 6658 }
6652 } 6659 }
6653 } 6660 }
6654 6661
6655 ExtensionProcessManager* extension_mgr = 6662 ExtensionProcessManager* extension_mgr =
6656 profile()->GetExtensionProcessManager(); 6663 profile()->GetExtensionProcessManager();
6657 ExtensionProcessManager::const_iterator iter; 6664 const ExtensionProcessManager::ContentsSet all_contents =
6658 for (iter = extension_mgr->begin(); iter != extension_mgr->end(); 6665 extension_mgr->GetAllContents();
6659 ++iter) { 6666 ExtensionProcessManager::ContentsSet::const_iterator iter;
6660 ExtensionHost* host = *iter; 6667 for (iter = all_contents.begin(); iter != all_contents.end(); ++iter) {
6668 content::RenderViewHost* host = (*iter)->GetRenderViewHost();
6661 AutomationId id = automation_util::GetIdForExtensionView(host); 6669 AutomationId id = automation_util::GetIdForExtensionView(host);
6662 if (!id.is_valid()) 6670 if (!id.is_valid())
6663 continue; 6671 continue;
6672 const Extension* extension =
6673 extension_mgr->GetExtensionForRenderViewHost(host);
6664 DictionaryValue* dict = new DictionaryValue(); 6674 DictionaryValue* dict = new DictionaryValue();
6665 dict->Set("auto_id", id.ToValue()); 6675 dict->Set("auto_id", id.ToValue());
6666 dict->SetString("extension_id", host->extension_id()); 6676 dict->SetString("extension_id", extension->id());
6667 view_list->Append(dict); 6677 view_list->Append(dict);
6668 } 6678 }
6669 DictionaryValue dict; 6679 DictionaryValue dict;
6670 dict.Set("views", view_list); 6680 dict.Set("views", view_list);
6671 AutomationJSONReply(this, reply_message).SendSuccess(&dict); 6681 AutomationJSONReply(this, reply_message).SendSuccess(&dict);
6672 } 6682 }
6673 6683
6674 void TestingAutomationProvider::IsTabIdValid( 6684 void TestingAutomationProvider::IsTabIdValid(
6675 DictionaryValue* args, IPC::Message* reply_message) { 6685 DictionaryValue* args, IPC::Message* reply_message) {
6676 AutomationJSONReply reply(this, reply_message); 6686 AutomationJSONReply reply(this, reply_message);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
6978 *browser_handle = browser_tracker_->Add(browser); 6988 *browser_handle = browser_tracker_->Add(browser);
6979 *success = true; 6989 *success = true;
6980 } 6990 }
6981 } 6991 }
6982 } 6992 }
6983 6993
6984 void TestingAutomationProvider::OnRemoveProvider() { 6994 void TestingAutomationProvider::OnRemoveProvider() {
6985 if (g_browser_process) 6995 if (g_browser_process)
6986 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 6996 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
6987 } 6997 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698