| OLD | NEW | 
|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 121 #include "chrome/common/chrome_paths.h" | 121 #include "chrome/common/chrome_paths.h" | 
| 122 #include "chrome/common/chrome_switches.h" | 122 #include "chrome/common/chrome_switches.h" | 
| 123 #include "chrome/common/extensions/extension.h" | 123 #include "chrome/common/extensions/extension.h" | 
| 124 #include "chrome/common/extensions/permissions/permission_set.h" | 124 #include "chrome/common/extensions/permissions/permission_set.h" | 
| 125 #include "chrome/common/pref_names.h" | 125 #include "chrome/common/pref_names.h" | 
| 126 #include "chrome/common/render_messages.h" | 126 #include "chrome/common/render_messages.h" | 
| 127 #include "content/public/browser/browser_child_process_host_iterator.h" | 127 #include "content/public/browser/browser_child_process_host_iterator.h" | 
| 128 #include "content/public/browser/child_process_data.h" | 128 #include "content/public/browser/child_process_data.h" | 
| 129 #include "content/public/browser/favicon_status.h" | 129 #include "content/public/browser/favicon_status.h" | 
| 130 #include "content/public/browser/geolocation.h" | 130 #include "content/public/browser/geolocation.h" | 
|  | 131 #include "content/public/browser/gpu_data_manager.h" | 
|  | 132 #include "content/public/browser/gpu_data_manager_observer.h" | 
| 131 #include "content/public/browser/interstitial_page.h" | 133 #include "content/public/browser/interstitial_page.h" | 
| 132 #include "content/public/browser/interstitial_page_delegate.h" | 134 #include "content/public/browser/interstitial_page_delegate.h" | 
| 133 #include "content/public/browser/navigation_entry.h" | 135 #include "content/public/browser/navigation_entry.h" | 
| 134 #include "content/public/browser/notification_service.h" | 136 #include "content/public/browser/notification_service.h" | 
| 135 #include "content/public/browser/plugin_service.h" | 137 #include "content/public/browser/plugin_service.h" | 
| 136 #include "content/public/browser/render_process_host.h" | 138 #include "content/public/browser/render_process_host.h" | 
| 137 #include "content/public/browser/render_view_host.h" | 139 #include "content/public/browser/render_view_host.h" | 
| 138 #include "content/public/browser/render_widget_host_view.h" | 140 #include "content/public/browser/render_widget_host_view.h" | 
| 139 #include "content/public/browser/web_contents.h" | 141 #include "content/public/browser/web_contents.h" | 
| 140 #include "content/public/common/child_process_host.h" | 142 #include "content/public/common/child_process_host.h" | 
| (...skipping 1824 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1965       &TestingAutomationProvider::KillRendererProcess; | 1967       &TestingAutomationProvider::KillRendererProcess; | 
| 1966 | 1968 | 
| 1967   browser_handler_map_["LaunchApp"] = &TestingAutomationProvider::LaunchApp; | 1969   browser_handler_map_["LaunchApp"] = &TestingAutomationProvider::LaunchApp; | 
| 1968   browser_handler_map_["SetAppLaunchType"] = | 1970   browser_handler_map_["SetAppLaunchType"] = | 
| 1969       &TestingAutomationProvider::SetAppLaunchType; | 1971       &TestingAutomationProvider::SetAppLaunchType; | 
| 1970 | 1972 | 
| 1971   browser_handler_map_["GetV8HeapStats"] = | 1973   browser_handler_map_["GetV8HeapStats"] = | 
| 1972       &TestingAutomationProvider::GetV8HeapStats; | 1974       &TestingAutomationProvider::GetV8HeapStats; | 
| 1973   browser_handler_map_["GetFPS"] = | 1975   browser_handler_map_["GetFPS"] = | 
| 1974       &TestingAutomationProvider::GetFPS; | 1976       &TestingAutomationProvider::GetFPS; | 
|  | 1977   browser_handler_map_["GetGpuMemoryUsage"] = | 
|  | 1978       &TestingAutomationProvider::GetGpuMemoryUsage; | 
| 1975 | 1979 | 
| 1976   browser_handler_map_["IsFullscreenForBrowser"] = | 1980   browser_handler_map_["IsFullscreenForBrowser"] = | 
| 1977       &TestingAutomationProvider::IsFullscreenForBrowser; | 1981       &TestingAutomationProvider::IsFullscreenForBrowser; | 
| 1978   browser_handler_map_["IsFullscreenForTab"] = | 1982   browser_handler_map_["IsFullscreenForTab"] = | 
| 1979       &TestingAutomationProvider::IsFullscreenForTab; | 1983       &TestingAutomationProvider::IsFullscreenForTab; | 
| 1980   browser_handler_map_["IsMouseLocked"] = | 1984   browser_handler_map_["IsMouseLocked"] = | 
| 1981       &TestingAutomationProvider::IsMouseLocked; | 1985       &TestingAutomationProvider::IsMouseLocked; | 
| 1982   browser_handler_map_["IsMouseLockPermissionRequested"] = | 1986   browser_handler_map_["IsMouseLockPermissionRequested"] = | 
| 1983       &TestingAutomationProvider::IsMouseLockPermissionRequested; | 1987       &TestingAutomationProvider::IsMouseLockPermissionRequested; | 
| 1984   browser_handler_map_["IsFullscreenPermissionRequested"] = | 1988   browser_handler_map_["IsFullscreenPermissionRequested"] = | 
| (...skipping 3109 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5094   int routing_id = render_view->GetRoutingID(); | 5098   int routing_id = render_view->GetRoutingID(); | 
| 5095 | 5099 | 
| 5096   // This observer will delete itself. | 5100   // This observer will delete itself. | 
| 5097   new FPSObserver( | 5101   new FPSObserver( | 
| 5098       this, reply_message, | 5102       this, reply_message, | 
| 5099       base::GetProcId(render_view->GetProcess()->GetHandle()), | 5103       base::GetProcId(render_view->GetProcess()->GetHandle()), | 
| 5100       routing_id); | 5104       routing_id); | 
| 5101   render_view->Send(new ChromeViewMsg_GetFPS(routing_id)); | 5105   render_view->Send(new ChromeViewMsg_GetFPS(routing_id)); | 
| 5102 } | 5106 } | 
| 5103 | 5107 | 
|  | 5108 class TestingAutomationGpuDataManagerObserver | 
|  | 5109     : public content::GpuDataManagerObserver { | 
|  | 5110  public: | 
|  | 5111   TestingAutomationGpuDataManagerObserver( | 
|  | 5112       TestingAutomationProvider* provider, | 
|  | 5113       IPC::Message* reply_message) | 
|  | 5114       : provider_(provider), | 
|  | 5115         reply_message_(reply_message) { | 
|  | 5116     content::GpuDataManager::GetInstance()->AddObserver(this); | 
|  | 5117   } | 
|  | 5118 | 
|  | 5119   virtual ~TestingAutomationGpuDataManagerObserver() { | 
|  | 5120     content::GpuDataManager::GetInstance()->RemoveObserver(this); | 
|  | 5121   } | 
|  | 5122 | 
|  | 5123   virtual void OnGpuInfoUpdate() OVERRIDE {} | 
|  | 5124 | 
|  | 5125   virtual void OnVideoMemoryUsageStatsUpdate( | 
|  | 5126       const content::GPUVideoMemoryUsageStats& video_memory_usage_stats) | 
|  | 5127           OVERRIDE { | 
|  | 5128     DictionaryValue dict; | 
|  | 5129     dict.SetInteger("gpu_memory_mbytes_allocated", static_cast<int>( | 
|  | 5130         video_memory_usage_stats.bytes_allocated/1048576)); | 
|  | 5131     AutomationJSONReply(provider_, reply_message_).SendSuccess(&dict); | 
|  | 5132     delete this; | 
|  | 5133   } | 
|  | 5134 | 
|  | 5135  private: | 
|  | 5136   TestingAutomationProvider* provider_; | 
|  | 5137   IPC::Message* reply_message_; | 
|  | 5138 }; | 
|  | 5139 | 
|  | 5140 void TestingAutomationProvider::GetGpuMemoryUsage( | 
|  | 5141     Browser* browser, | 
|  | 5142     DictionaryValue* args, | 
|  | 5143     IPC::Message* reply_message) { | 
|  | 5144   if (!content::GpuDataManager::GetInstance()->GpuAccessAllowed()) { | 
|  | 5145     AutomationJSONReply(this, reply_message).SendError("Cannot access GPU"); | 
|  | 5146     return; | 
|  | 5147   } | 
|  | 5148   // This observer will delete itself. | 
|  | 5149   new TestingAutomationGpuDataManagerObserver(this, reply_message); | 
|  | 5150   content::GpuDataManager::GetInstance()->RequestVideoMemoryUsageStatsUpdate(); | 
|  | 5151 } | 
|  | 5152 | 
| 5104 void TestingAutomationProvider::IsFullscreenForBrowser(Browser* browser, | 5153 void TestingAutomationProvider::IsFullscreenForBrowser(Browser* browser, | 
| 5105     base::DictionaryValue* args, | 5154     base::DictionaryValue* args, | 
| 5106     IPC::Message* reply_message) { | 5155     IPC::Message* reply_message) { | 
| 5107   DictionaryValue dict; | 5156   DictionaryValue dict; | 
| 5108   dict.SetBoolean("result", | 5157   dict.SetBoolean("result", | 
| 5109                   browser->fullscreen_controller()->IsFullscreenForBrowser()); | 5158                   browser->fullscreen_controller()->IsFullscreenForBrowser()); | 
| 5110   AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 5159   AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 
| 5111 } | 5160 } | 
| 5112 | 5161 | 
| 5113 void TestingAutomationProvider::IsFullscreenForTab(Browser* browser, | 5162 void TestingAutomationProvider::IsFullscreenForTab(Browser* browser, | 
| (...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 6276   if (g_browser_process) | 6325   if (g_browser_process) | 
| 6277     g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6326     g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 
| 6278 } | 6327 } | 
| 6279 | 6328 | 
| 6280 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 6329 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 
| 6281                                                   WebContents* tab) { | 6330                                                   WebContents* tab) { | 
| 6282   TabStripModel* tab_strip = browser->tab_strip_model(); | 6331   TabStripModel* tab_strip = browser->tab_strip_model(); | 
| 6283   if (tab_strip->GetActiveWebContents() != tab) | 6332   if (tab_strip->GetActiveWebContents() != tab) | 
| 6284     tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); | 6333     tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); | 
| 6285 } | 6334 } | 
| OLD | NEW | 
|---|