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

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: Merge to LKGR. 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 3143 matching lines...) Expand 10 before | Expand all | Expand 10 after
6125 AutomationJSONReply(this, reply_message).SendError( 6125 AutomationJSONReply(this, reply_message).SendError(
6126 StringPrintf("Could not get WebContents at tab index %d", tab_index)); 6126 StringPrintf("Could not get WebContents at tab index %d", tab_index));
6127 return; 6127 return;
6128 } 6128 }
6129 6129
6130 RenderViewHost* render_view = web_contents->GetRenderViewHost(); 6130 RenderViewHost* render_view = web_contents->GetRenderViewHost();
6131 6131
6132 // This observer will delete itself. 6132 // This observer will delete itself.
6133 new V8HeapStatsObserver( 6133 new V8HeapStatsObserver(
6134 this, reply_message, 6134 this, reply_message,
6135 base::GetProcId(render_view->process()->GetHandle())); 6135 base::GetProcId(render_view->GetProcess()->GetHandle()));
6136 render_view->Send(new ChromeViewMsg_GetV8HeapStats); 6136 render_view->Send(new ChromeViewMsg_GetV8HeapStats);
6137 } 6137 }
6138 6138
6139 // Sample json input: { "command": "GetFPS", 6139 // Sample json input: { "command": "GetFPS",
6140 // "tab_index": 0 } 6140 // "tab_index": 0 }
6141 // Refer to GetFPS() in chrome/test/pyautolib/pyauto.py for 6141 // Refer to GetFPS() in chrome/test/pyautolib/pyauto.py for
6142 // sample json output. 6142 // sample json output.
6143 void TestingAutomationProvider::GetFPS( 6143 void TestingAutomationProvider::GetFPS(
6144 Browser* browser, 6144 Browser* browser,
6145 DictionaryValue* args, 6145 DictionaryValue* args,
6146 IPC::Message* reply_message) { 6146 IPC::Message* reply_message) {
6147 WebContents* web_contents; 6147 WebContents* web_contents;
6148 int tab_index; 6148 int tab_index;
6149 std::string error; 6149 std::string error;
6150 6150
6151 if (!args->GetInteger("tab_index", &tab_index)) { 6151 if (!args->GetInteger("tab_index", &tab_index)) {
6152 AutomationJSONReply(this, reply_message).SendError( 6152 AutomationJSONReply(this, reply_message).SendError(
6153 "Missing 'tab_index' argument."); 6153 "Missing 'tab_index' argument.");
6154 return; 6154 return;
6155 } 6155 }
6156 6156
6157 web_contents = browser->GetWebContentsAt(tab_index); 6157 web_contents = browser->GetWebContentsAt(tab_index);
6158 if (!web_contents) { 6158 if (!web_contents) {
6159 AutomationJSONReply(this, reply_message).SendError( 6159 AutomationJSONReply(this, reply_message).SendError(
6160 StringPrintf("Could not get WebContents at tab index %d", tab_index)); 6160 StringPrintf("Could not get WebContents at tab index %d", tab_index));
6161 return; 6161 return;
6162 } 6162 }
6163 6163
6164 RenderViewHost* render_view = web_contents->GetRenderViewHost(); 6164 RenderViewHost* render_view = web_contents->GetRenderViewHost();
6165 int routing_id = render_view->routing_id(); 6165 int routing_id = render_view->GetRoutingID();
6166 6166
6167 // This observer will delete itself. 6167 // This observer will delete itself.
6168 new FPSObserver( 6168 new FPSObserver(
6169 this, reply_message, 6169 this, reply_message,
6170 base::GetProcId(render_view->process()->GetHandle()), 6170 base::GetProcId(render_view->GetProcess()->GetHandle()),
6171 routing_id); 6171 routing_id);
6172 render_view->Send(new ChromeViewMsg_GetFPS(routing_id)); 6172 render_view->Send(new ChromeViewMsg_GetFPS(routing_id));
6173 } 6173 }
6174 6174
6175 void TestingAutomationProvider::WaitForAllViewsToStopLoading( 6175 void TestingAutomationProvider::WaitForAllViewsToStopLoading(
6176 DictionaryValue* args, 6176 DictionaryValue* args,
6177 IPC::Message* reply_message) { 6177 IPC::Message* reply_message) {
6178 if (AppModalDialogQueue::GetInstance()->HasActiveDialog()) { 6178 if (AppModalDialogQueue::GetInstance()->HasActiveDialog()) {
6179 AutomationJSONReply(this, reply_message).SendSuccess(NULL); 6179 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
6180 return; 6180 return;
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
6919 bool* success) { 6919 bool* success) {
6920 *success = false; 6920 *success = false;
6921 if (tab_tracker_->ContainsHandle(tab_handle)) { 6921 if (tab_tracker_->ContainsHandle(tab_handle)) {
6922 NavigationController* nav = tab_tracker_->GetResource(tab_handle); 6922 NavigationController* nav = tab_tracker_->GetResource(tab_handle);
6923 if (!nav) 6923 if (!nav)
6924 return; 6924 return;
6925 WebContents* contents = nav->GetWebContents(); 6925 WebContents* contents = nav->GetWebContents();
6926 if (!contents) 6926 if (!contents)
6927 return; 6927 return;
6928 RenderViewHost* host = contents->GetRenderViewHost(); 6928 RenderViewHost* host = contents->GetRenderViewHost();
6929 host->Send(new ChromeViewMsg_LoadBlockedPlugins(host->routing_id())); 6929 host->Send(new ChromeViewMsg_LoadBlockedPlugins(host->GetRoutingID()));
6930 *success = true; 6930 *success = true;
6931 } 6931 }
6932 } 6932 }
6933 6933
6934 void TestingAutomationProvider::ResetToDefaultTheme() { 6934 void TestingAutomationProvider::ResetToDefaultTheme() {
6935 ThemeServiceFactory::GetForProfile(profile_)->UseDefaultTheme(); 6935 ThemeServiceFactory::GetForProfile(profile_)->UseDefaultTheme();
6936 } 6936 }
6937 6937
6938 void TestingAutomationProvider::WaitForProcessLauncherThreadToGoIdle( 6938 void TestingAutomationProvider::WaitForProcessLauncherThreadToGoIdle(
6939 IPC::Message* reply_message) { 6939 IPC::Message* reply_message) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
6975 6975
6976 Send(reply_message_); 6976 Send(reply_message_);
6977 redirect_query_ = 0; 6977 redirect_query_ = 0;
6978 reply_message_ = NULL; 6978 reply_message_ = NULL;
6979 } 6979 }
6980 6980
6981 void TestingAutomationProvider::OnRemoveProvider() { 6981 void TestingAutomationProvider::OnRemoveProvider() {
6982 if (g_browser_process) 6982 if (g_browser_process)
6983 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 6983 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
6984 } 6984 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_util.cc ('k') | chrome/browser/bookmarks/bookmark_manager_extension_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698