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

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

Issue 9473001: Extract minimal RenderViewHost interface for embedders, leaving (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for initial review. Created 8 years, 9 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 | Annotate | Revision Log
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 2950 matching lines...) Expand 10 before | Expand all | Expand 10 after
2961 item->SetString("extension_id", ex_host->extension()->id()); 2961 item->SetString("extension_id", ex_host->extension()->id());
2962 item->SetInteger( 2962 item->SetInteger(
2963 "pid", 2963 "pid",
2964 base::GetProcId(ex_host->render_process_host()->GetHandle())); 2964 base::GetProcId(ex_host->render_process_host()->GetHandle()));
2965 DictionaryValue* view = new DictionaryValue; 2965 DictionaryValue* view = new DictionaryValue;
2966 view->SetInteger( 2966 view->SetInteger(
2967 "render_process_id", 2967 "render_process_id",
2968 ex_host->render_process_host()->GetID()); 2968 ex_host->render_process_host()->GetID());
2969 view->SetInteger( 2969 view->SetInteger(
2970 "render_view_id", 2970 "render_view_id",
2971 ex_host->render_view_host()->routing_id()); 2971 ex_host->render_view_host()->GetRoutingID());
2972 item->Set("view", view); 2972 item->Set("view", view);
2973 std::string type; 2973 std::string type;
2974 switch (ex_host->extension_host_type()) { 2974 switch (ex_host->extension_host_type()) {
2975 case chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE: 2975 case chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE:
2976 type = "EXTENSION_BACKGROUND_PAGE"; 2976 type = "EXTENSION_BACKGROUND_PAGE";
2977 break; 2977 break;
2978 case chrome::VIEW_TYPE_EXTENSION_POPUP: 2978 case chrome::VIEW_TYPE_EXTENSION_POPUP:
2979 type = "EXTENSION_POPUP"; 2979 type = "EXTENSION_POPUP";
2980 break; 2980 break;
2981 case chrome::VIEW_TYPE_EXTENSION_INFOBAR: 2981 case chrome::VIEW_TYPE_EXTENSION_INFOBAR:
(...skipping 3141 matching lines...) Expand 10 before | Expand all | Expand 10 after
6123 AutomationJSONReply(this, reply_message).SendError( 6123 AutomationJSONReply(this, reply_message).SendError(
6124 StringPrintf("Could not get WebContents at tab index %d", tab_index)); 6124 StringPrintf("Could not get WebContents at tab index %d", tab_index));
6125 return; 6125 return;
6126 } 6126 }
6127 6127
6128 RenderViewHost* render_view = web_contents->GetRenderViewHost(); 6128 RenderViewHost* render_view = web_contents->GetRenderViewHost();
6129 6129
6130 // This observer will delete itself. 6130 // This observer will delete itself.
6131 new V8HeapStatsObserver( 6131 new V8HeapStatsObserver(
6132 this, reply_message, 6132 this, reply_message,
6133 base::GetProcId(render_view->process()->GetHandle())); 6133 base::GetProcId(render_view->GetProcess()->GetHandle()));
6134 render_view->Send(new ChromeViewMsg_GetV8HeapStats); 6134 render_view->Send(new ChromeViewMsg_GetV8HeapStats);
6135 } 6135 }
6136 6136
6137 // Sample json input: { "command": "GetFPS", 6137 // Sample json input: { "command": "GetFPS",
6138 // "tab_index": 0 } 6138 // "tab_index": 0 }
6139 // Refer to GetFPS() in chrome/test/pyautolib/pyauto.py for 6139 // Refer to GetFPS() in chrome/test/pyautolib/pyauto.py for
6140 // sample json output. 6140 // sample json output.
6141 void TestingAutomationProvider::GetFPS( 6141 void TestingAutomationProvider::GetFPS(
6142 Browser* browser, 6142 Browser* browser,
6143 DictionaryValue* args, 6143 DictionaryValue* args,
6144 IPC::Message* reply_message) { 6144 IPC::Message* reply_message) {
6145 WebContents* web_contents; 6145 WebContents* web_contents;
6146 int tab_index; 6146 int tab_index;
6147 std::string error; 6147 std::string error;
6148 6148
6149 if (!args->GetInteger("tab_index", &tab_index)) { 6149 if (!args->GetInteger("tab_index", &tab_index)) {
6150 AutomationJSONReply(this, reply_message).SendError( 6150 AutomationJSONReply(this, reply_message).SendError(
6151 "Missing 'tab_index' argument."); 6151 "Missing 'tab_index' argument.");
6152 return; 6152 return;
6153 } 6153 }
6154 6154
6155 web_contents = browser->GetWebContentsAt(tab_index); 6155 web_contents = browser->GetWebContentsAt(tab_index);
6156 if (!web_contents) { 6156 if (!web_contents) {
6157 AutomationJSONReply(this, reply_message).SendError( 6157 AutomationJSONReply(this, reply_message).SendError(
6158 StringPrintf("Could not get WebContents at tab index %d", tab_index)); 6158 StringPrintf("Could not get WebContents at tab index %d", tab_index));
6159 return; 6159 return;
6160 } 6160 }
6161 6161
6162 RenderViewHost* render_view = web_contents->GetRenderViewHost(); 6162 RenderViewHost* render_view = web_contents->GetRenderViewHost();
6163 int routing_id = render_view->routing_id(); 6163 int routing_id = render_view->GetRoutingID();
6164 6164
6165 // This observer will delete itself. 6165 // This observer will delete itself.
6166 new FPSObserver( 6166 new FPSObserver(
6167 this, reply_message, 6167 this, reply_message,
6168 base::GetProcId(render_view->process()->GetHandle()), 6168 base::GetProcId(render_view->GetProcess()->GetHandle()),
6169 routing_id); 6169 routing_id);
6170 render_view->Send(new ChromeViewMsg_GetFPS(routing_id)); 6170 render_view->Send(new ChromeViewMsg_GetFPS(routing_id));
6171 } 6171 }
6172 6172
6173 void TestingAutomationProvider::WaitForAllViewsToStopLoading( 6173 void TestingAutomationProvider::WaitForAllViewsToStopLoading(
6174 DictionaryValue* args, 6174 DictionaryValue* args,
6175 IPC::Message* reply_message) { 6175 IPC::Message* reply_message) {
6176 if (AppModalDialogQueue::GetInstance()->HasActiveDialog()) { 6176 if (AppModalDialogQueue::GetInstance()->HasActiveDialog()) {
6177 AutomationJSONReply(this, reply_message).SendSuccess(NULL); 6177 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
6178 return; 6178 return;
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
6917 bool* success) { 6917 bool* success) {
6918 *success = false; 6918 *success = false;
6919 if (tab_tracker_->ContainsHandle(tab_handle)) { 6919 if (tab_tracker_->ContainsHandle(tab_handle)) {
6920 NavigationController* nav = tab_tracker_->GetResource(tab_handle); 6920 NavigationController* nav = tab_tracker_->GetResource(tab_handle);
6921 if (!nav) 6921 if (!nav)
6922 return; 6922 return;
6923 WebContents* contents = nav->GetWebContents(); 6923 WebContents* contents = nav->GetWebContents();
6924 if (!contents) 6924 if (!contents)
6925 return; 6925 return;
6926 RenderViewHost* host = contents->GetRenderViewHost(); 6926 RenderViewHost* host = contents->GetRenderViewHost();
6927 host->Send(new ChromeViewMsg_LoadBlockedPlugins(host->routing_id())); 6927 host->Send(new ChromeViewMsg_LoadBlockedPlugins(host->GetRoutingID()));
6928 *success = true; 6928 *success = true;
6929 } 6929 }
6930 } 6930 }
6931 6931
6932 void TestingAutomationProvider::ResetToDefaultTheme() { 6932 void TestingAutomationProvider::ResetToDefaultTheme() {
6933 ThemeServiceFactory::GetForProfile(profile_)->UseDefaultTheme(); 6933 ThemeServiceFactory::GetForProfile(profile_)->UseDefaultTheme();
6934 } 6934 }
6935 6935
6936 void TestingAutomationProvider::WaitForProcessLauncherThreadToGoIdle( 6936 void TestingAutomationProvider::WaitForProcessLauncherThreadToGoIdle(
6937 IPC::Message* reply_message) { 6937 IPC::Message* reply_message) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
6973 6973
6974 Send(reply_message_); 6974 Send(reply_message_);
6975 redirect_query_ = 0; 6975 redirect_query_ = 0;
6976 reply_message_ = NULL; 6976 reply_message_ = NULL;
6977 } 6977 }
6978 6978
6979 void TestingAutomationProvider::OnRemoveProvider() { 6979 void TestingAutomationProvider::OnRemoveProvider() {
6980 if (g_browser_process) 6980 if (g_browser_process)
6981 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 6981 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
6982 } 6982 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698