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

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: Comments addressed 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 #include "content/public/browser/browser_child_process_host_iterator.h" 126 #include "content/public/browser/browser_child_process_host_iterator.h"
127 #include "content/public/browser/child_process_data.h" 127 #include "content/public/browser/child_process_data.h"
128 #include "content/public/browser/favicon_status.h" 128 #include "content/public/browser/favicon_status.h"
129 #include "content/public/browser/interstitial_page.h" 129 #include "content/public/browser/interstitial_page.h"
130 #include "content/public/browser/interstitial_page_delegate.h" 130 #include "content/public/browser/interstitial_page_delegate.h"
131 #include "content/public/browser/navigation_entry.h" 131 #include "content/public/browser/navigation_entry.h"
132 #include "content/public/browser/notification_service.h" 132 #include "content/public/browser/notification_service.h"
133 #include "content/public/browser/plugin_service.h" 133 #include "content/public/browser/plugin_service.h"
134 #include "content/public/browser/render_process_host.h" 134 #include "content/public/browser/render_process_host.h"
135 #include "content/public/browser/render_view_host.h" 135 #include "content/public/browser/render_view_host.h"
136 #include "content/public/browser/render_view_host_delegate.h"
136 #include "content/public/browser/render_widget_host_view.h" 137 #include "content/public/browser/render_widget_host_view.h"
137 #include "content/public/browser/web_contents.h" 138 #include "content/public/browser/web_contents.h"
138 #include "content/public/common/child_process_host.h" 139 #include "content/public/common/child_process_host.h"
139 #include "content/public/common/common_param_traits.h" 140 #include "content/public/common/common_param_traits.h"
140 #include "content/public/common/ssl_status.h" 141 #include "content/public/common/ssl_status.h"
141 #include "net/cookies/cookie_store.h" 142 #include "net/cookies/cookie_store.h"
142 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 143 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
143 #include "ui/base/events.h" 144 #include "ui/base/events.h"
144 #include "ui/base/keycodes/keyboard_codes.h" 145 #include "ui/base/keycodes/keyboard_codes.h"
145 #include "ui/base/ui_base_types.h" 146 #include "ui/base/ui_base_types.h"
(...skipping 2729 matching lines...) Expand 10 before | Expand all | Expand 10 after
2875 // Add all extension processes in a list of dictionaries, one dictionary 2876 // Add all extension processes in a list of dictionaries, one dictionary
2876 // item per extension process. 2877 // item per extension process.
2877 ListValue* extension_views = new ListValue; 2878 ListValue* extension_views = new ListValue;
2878 ProfileManager* profile_manager = g_browser_process->profile_manager(); 2879 ProfileManager* profile_manager = g_browser_process->profile_manager();
2879 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); 2880 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles());
2880 for (size_t i = 0; i < profiles.size(); ++i) { 2881 for (size_t i = 0; i < profiles.size(); ++i) {
2881 ExtensionProcessManager* process_manager = 2882 ExtensionProcessManager* process_manager =
2882 profiles[i]->GetExtensionProcessManager(); 2883 profiles[i]->GetExtensionProcessManager();
2883 if (!process_manager) 2884 if (!process_manager)
2884 continue; 2885 continue;
2885 ExtensionProcessManager::const_iterator jt; 2886 const ExtensionProcessManager::ViewSet view_set =
2886 for (jt = process_manager->begin(); jt != process_manager->end(); ++jt) { 2887 process_manager->GetAllViews();
2887 ExtensionHost* ex_host = *jt; 2888 for (ExtensionProcessManager::ViewSet::const_iterator jt =
2889 view_set.begin();
2890 jt != view_set.end(); ++jt) {
2891 content::RenderViewHost* render_view_host = *jt;
2888 // Don't add dead extension processes. 2892 // Don't add dead extension processes.
2889 if (!ex_host->IsRenderViewLive()) 2893 if (!render_view_host->IsRenderViewLive())
2890 continue; 2894 continue;
2895 const Extension* extension =
2896 process_manager->GetExtensionForRenderViewHost(render_view_host);
2891 DictionaryValue* item = new DictionaryValue; 2897 DictionaryValue* item = new DictionaryValue;
2892 item->SetString("name", ex_host->extension()->name()); 2898 item->SetString("name", extension->name());
2893 item->SetString("extension_id", ex_host->extension()->id()); 2899 item->SetString("extension_id", extension->id());
2894 item->SetInteger( 2900 item->SetInteger(
2895 "pid", 2901 "pid",
2896 base::GetProcId(ex_host->render_process_host()->GetHandle())); 2902 base::GetProcId(render_view_host->GetProcess()->GetHandle()));
2897 DictionaryValue* view = new DictionaryValue; 2903 DictionaryValue* view = new DictionaryValue;
2898 view->SetInteger( 2904 view->SetInteger(
2899 "render_process_id", 2905 "render_process_id",
2900 ex_host->render_process_host()->GetID()); 2906 render_view_host->GetProcess()->GetID());
2901 view->SetInteger( 2907 view->SetInteger(
2902 "render_view_id", 2908 "render_view_id",
2903 ex_host->render_view_host()->GetRoutingID()); 2909 render_view_host->GetRoutingID());
2904 item->Set("view", view); 2910 item->Set("view", view);
2905 std::string type; 2911 std::string type;
2906 switch (ex_host->extension_host_type()) { 2912 switch (render_view_host->GetDelegate()->GetRenderViewType()) {
2907 case chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE: 2913 case chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE:
2908 type = "EXTENSION_BACKGROUND_PAGE"; 2914 type = "EXTENSION_BACKGROUND_PAGE";
2909 break; 2915 break;
2910 case chrome::VIEW_TYPE_EXTENSION_POPUP: 2916 case chrome::VIEW_TYPE_EXTENSION_POPUP:
2911 type = "EXTENSION_POPUP"; 2917 type = "EXTENSION_POPUP";
2912 break; 2918 break;
2913 case chrome::VIEW_TYPE_EXTENSION_INFOBAR: 2919 case chrome::VIEW_TYPE_EXTENSION_INFOBAR:
2914 type = "EXTENSION_INFOBAR"; 2920 type = "EXTENSION_INFOBAR";
2915 break; 2921 break;
2916 case chrome::VIEW_TYPE_EXTENSION_DIALOG: 2922 case chrome::VIEW_TYPE_EXTENSION_DIALOG:
2917 type = "EXTENSION_DIALOG"; 2923 type = "EXTENSION_DIALOG";
2918 break; 2924 break;
2919 case chrome::VIEW_TYPE_APP_SHELL: 2925 case chrome::VIEW_TYPE_APP_SHELL:
2920 type = "APP_SHELL"; 2926 type = "APP_SHELL";
2921 break; 2927 break;
2922 case chrome::VIEW_TYPE_PANEL: 2928 case chrome::VIEW_TYPE_PANEL:
2923 type = "PANEL"; 2929 type = "PANEL";
2924 break; 2930 break;
2925 default: 2931 default:
2926 type = "unknown"; 2932 type = "unknown";
2927 break; 2933 break;
2928 } 2934 }
2929 item->SetString("view_type", type); 2935 item->SetString("view_type", type);
2930 item->SetString("url", ex_host->GetURL().spec()); 2936 item->SetString("url", render_view_host->GetDelegate()->GetURL().spec());
2931 item->SetBoolean("loaded", ex_host->did_stop_loading()); 2937 item->SetBoolean("loaded", !render_view_host->IsLoading());
2932 extension_views->Append(item); 2938 extension_views->Append(item);
2933 } 2939 }
2934 } 2940 }
2935 return_value->Set("extension_views", extension_views); 2941 return_value->Set("extension_views", extension_views);
2936 2942
2937 return_value->SetString("child_process_path", 2943 return_value->SetString("child_process_path",
2938 ChildProcessHost::GetChildPath(flags).value()); 2944 ChildProcessHost::GetChildPath(flags).value());
2939 // Child processes are the processes for plugins and other workers. 2945 // Child processes are the processes for plugins and other workers.
2940 // Add all child processes in a list of dictionaries, one dictionary item 2946 // Add all child processes in a list of dictionaries, one dictionary item
2941 // per child process. 2947 // per child process.
(...skipping 3765 matching lines...) Expand 10 before | Expand all | Expand 10 after
6707 AutomationId id = automation_util::GetIdForTab(preview_tab); 6713 AutomationId id = automation_util::GetIdForTab(preview_tab);
6708 dict->Set("auto_id", id.ToValue()); 6714 dict->Set("auto_id", id.ToValue());
6709 view_list->Append(dict); 6715 view_list->Append(dict);
6710 } 6716 }
6711 } 6717 }
6712 } 6718 }
6713 } 6719 }
6714 6720
6715 ExtensionProcessManager* extension_mgr = 6721 ExtensionProcessManager* extension_mgr =
6716 profile()->GetExtensionProcessManager(); 6722 profile()->GetExtensionProcessManager();
6717 ExtensionProcessManager::const_iterator iter; 6723 const ExtensionProcessManager::ViewSet all_views =
6718 for (iter = extension_mgr->begin(); iter != extension_mgr->end(); 6724 extension_mgr->GetAllViews();
6719 ++iter) { 6725 ExtensionProcessManager::ViewSet::const_iterator iter;
6720 ExtensionHost* host = *iter; 6726 for (iter = all_views.begin(); iter != all_views.end(); ++iter) {
6727 content::RenderViewHost* host = (*iter);
6721 AutomationId id = automation_util::GetIdForExtensionView(host); 6728 AutomationId id = automation_util::GetIdForExtensionView(host);
6722 if (!id.is_valid()) 6729 if (!id.is_valid())
6723 continue; 6730 continue;
6731 const Extension* extension =
6732 extension_mgr->GetExtensionForRenderViewHost(host);
6724 DictionaryValue* dict = new DictionaryValue(); 6733 DictionaryValue* dict = new DictionaryValue();
6725 dict->Set("auto_id", id.ToValue()); 6734 dict->Set("auto_id", id.ToValue());
6726 dict->SetString("extension_id", host->extension_id()); 6735 dict->SetString("extension_id", extension->id());
6727 view_list->Append(dict); 6736 view_list->Append(dict);
6728 } 6737 }
6729 DictionaryValue dict; 6738 DictionaryValue dict;
6730 dict.Set("views", view_list); 6739 dict.Set("views", view_list);
6731 AutomationJSONReply(this, reply_message).SendSuccess(&dict); 6740 AutomationJSONReply(this, reply_message).SendSuccess(&dict);
6732 } 6741 }
6733 6742
6734 void TestingAutomationProvider::IsTabIdValid( 6743 void TestingAutomationProvider::IsTabIdValid(
6735 DictionaryValue* args, IPC::Message* reply_message) { 6744 DictionaryValue* args, IPC::Message* reply_message) {
6736 AutomationJSONReply reply(this, reply_message); 6745 AutomationJSONReply reply(this, reply_message);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
7038 *browser_handle = browser_tracker_->Add(browser); 7047 *browser_handle = browser_tracker_->Add(browser);
7039 *success = true; 7048 *success = true;
7040 } 7049 }
7041 } 7050 }
7042 } 7051 }
7043 7052
7044 void TestingAutomationProvider::OnRemoveProvider() { 7053 void TestingAutomationProvider::OnRemoveProvider() {
7045 if (g_browser_process) 7054 if (g_browser_process)
7046 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 7055 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
7047 } 7056 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698