blob: b50eb090c7ce0c14292cbbc24858120ea3a3f113 [file] [log] [blame]
[email protected]de7d61ff2013-08-20 11:30:411// Copyright 2013 The Chromium Authors. All rights reserved.
[email protected]9fbd3f862011-09-20 23:31:342// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]de7d61ff2013-08-20 11:30:415#include "content/shell/browser/shell.h"
[email protected]9fbd3f862011-09-20 23:31:346
[email protected]11a65b692012-03-30 11:29:167#include "base/auto_reset.h"
[email protected]efb5f572012-01-29 10:57:338#include "base/command_line.h"
skyostil95082a62015-06-05 19:53:079#include "base/location.h"
10#include "base/single_thread_task_runner.h"
[email protected]21aa99682013-06-11 07:17:0111#include "base/strings/string_number_conversions.h"
12#include "base/strings/string_util.h"
13#include "base/strings/stringprintf.h"
[email protected]74ebfb12013-06-07 20:48:0014#include "base/strings/utf_string_conversions.h"
skyostil95082a62015-06-05 19:53:0715#include "base/thread_task_runner_handle.h"
[email protected]b50452f2014-08-18 12:31:4416#include "content/public/browser/devtools_agent_host.h"
[email protected]0b659b32012-03-26 21:29:3217#include "content/public/browser/navigation_controller.h"
[email protected]b7c504c2013-05-07 14:42:1218#include "content/public/browser/navigation_entry.h"
[email protected]0b659b32012-03-26 21:29:3219#include "content/public/browser/render_view_host.h"
avif9ab5d942015-10-15 14:05:4420#include "content/public/browser/render_widget_host.h"
[email protected]0b659b32012-03-26 21:29:3221#include "content/public/browser/web_contents.h"
[email protected]7fff43e2013-05-21 20:21:1022#include "content/public/browser/web_contents_observer.h"
guoweis8efb6d892015-10-12 18:26:1723#include "content/public/common/content_switches.h"
[email protected]1596efb2013-01-17 22:13:0124#include "content/public/common/renderer_preferences.h"
guoweisc537ba22015-11-06 21:20:3125#include "content/public/common/webrtc_ip_handling_policy.h"
tfarinacde91252015-05-06 16:10:4926#include "content/shell/browser/blink_test_controller.h"
jyasskin8057c002015-09-10 19:09:5327#include "content/shell/browser/layout_test/layout_test_bluetooth_chooser_factory.h"
mkwst30d20d52014-10-09 13:33:1428#include "content/shell/browser/layout_test/layout_test_devtools_frontend.h"
mkwst6efe7f2e62014-10-08 15:09:0129#include "content/shell/browser/layout_test/layout_test_javascript_dialog_manager.h"
[email protected]de7d61ff2013-08-20 11:30:4130#include "content/shell/browser/notify_done_forwarder.h"
31#include "content/shell/browser/shell_browser_main_parts.h"
32#include "content/shell/browser/shell_content_browser_client.h"
33#include "content/shell/browser/shell_devtools_frontend.h"
34#include "content/shell/browser/shell_javascript_dialog_manager.h"
[email protected]b7c504c2013-05-07 14:42:1235#include "content/shell/common/shell_messages.h"
36#include "content/shell/common/shell_switches.h"
[email protected]9fbd3f862011-09-20 23:31:3437
[email protected]9fbd3f862011-09-20 23:31:3438namespace content {
39
pdrcab84ee2015-03-13 21:47:0440const int kDefaultTestWindowWidthDip = 800;
41const int kDefaultTestWindowHeightDip = 600;
[email protected]1e57cab2013-05-28 04:26:1142
[email protected]e99ca5112011-09-26 17:22:5443std::vector<Shell*> Shell::windows_;
[email protected]9e00e6352012-07-30 17:05:1844base::Callback<void(Shell*)> Shell::shell_created_callback_;
[email protected]9fbd3f862011-09-20 23:31:3445
[email protected]11a65b692012-03-30 11:29:1646bool Shell::quit_message_loop_ = true;
47
[email protected]7fff43e2013-05-21 20:21:1048class Shell::DevToolsWebContentsObserver : public WebContentsObserver {
49 public:
50 DevToolsWebContentsObserver(Shell* shell, WebContents* web_contents)
51 : WebContentsObserver(web_contents),
52 shell_(shell) {
53 }
54
55 // WebContentsObserver
dchenge933b3e2014-10-21 11:44:0956 void WebContentsDestroyed() override {
[email protected]7fff43e2013-05-21 20:21:1057 shell_->OnDevToolsWebContentsDestroyed();
58 }
59
60 private:
61 Shell* shell_;
62
63 DISALLOW_COPY_AND_ASSIGN(DevToolsWebContentsObserver);
64};
65
[email protected]0b659b32012-03-26 21:29:3266Shell::Shell(WebContents* web_contents)
[email protected]1ef02d242013-10-07 16:18:5367 : WebContentsObserver(web_contents),
68 devtools_frontend_(NULL),
[email protected]001841c92012-12-11 17:00:1369 is_fullscreen_(false),
[email protected]99c014c2012-11-27 12:03:4270 window_(NULL),
sadrul8b11d262015-11-12 18:41:3371#if defined(OS_MACOSX)
[email protected]86b36e672012-12-21 00:09:5172 url_edit_view_(NULL),
sadrul8b11d262015-11-12 18:41:3373#endif
[email protected]86b36e672012-12-21 00:09:5174 headless_(false) {
avi83883c82014-12-23 00:08:4975 const base::CommandLine& command_line =
76 *base::CommandLine::ForCurrentProcess();
paulmeyerbcc6ad22015-02-11 21:51:5977 if (command_line.HasSwitch(switches::kRunLayoutTest))
[email protected]86b36e672012-12-21 00:09:5178 headless_ = true;
[email protected]9e00e6352012-07-30 17:05:1879 windows_.push_back(this);
80
81 if (!shell_created_callback_.is_null()) {
82 shell_created_callback_.Run(this);
83 shell_created_callback_.Reset();
84 }
[email protected]9fbd3f862011-09-20 23:31:3485}
86
87Shell::~Shell() {
88 PlatformCleanUp();
[email protected]e99ca5112011-09-26 17:22:5489
90 for (size_t i = 0; i < windows_.size(); ++i) {
91 if (windows_[i] == this) {
92 windows_.erase(windows_.begin() + i);
93 break;
94 }
95 }
[email protected]11a65b692012-03-30 11:29:1696
[email protected]b53adf452014-02-07 12:55:0897 if (windows_.empty() && quit_message_loop_) {
98 if (headless_)
99 PlatformExit();
skyostil95082a62015-06-05 19:53:07100 base::ThreadTaskRunnerHandle::Get()->PostTask(
ki.stfu800779242015-10-12 22:46:26101 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
[email protected]b53adf452014-02-07 12:55:08102 }
[email protected]9fbd3f862011-09-20 23:31:34103}
104
[email protected]c0d036d2013-05-07 12:50:50105Shell* Shell::CreateShell(WebContents* web_contents,
106 const gfx::Size& initial_size) {
[email protected]0b659b32012-03-26 21:29:32107 Shell* shell = new Shell(web_contents);
[email protected]c0d036d2013-05-07 12:50:50108 shell->PlatformCreateWindow(initial_size.width(), initial_size.height());
[email protected]3fd84032012-01-12 18:20:17109
[email protected]0b659b32012-03-26 21:29:32110 shell->web_contents_.reset(web_contents);
111 web_contents->SetDelegate(shell);
[email protected]3fd84032012-01-12 18:20:17112
[email protected]5cba3bf2012-01-14 02:40:35113 shell->PlatformSetContents();
[email protected]3fd84032012-01-12 18:20:17114
115 shell->PlatformResizeSubViews();
[email protected]1596efb2013-01-17 22:13:01116
avi83883c82014-12-23 00:08:49117 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
paulmeyerbcc6ad22015-02-11 21:51:59118 switches::kRunLayoutTest)) {
[email protected]1596efb2013-01-17 22:13:01119 web_contents->GetMutableRendererPrefs()->use_custom_colors = false;
120 web_contents->GetRenderViewHost()->SyncRendererPrefs();
121 }
122
guoweis8efb6d892015-10-12 18:26:17123#if defined(ENABLE_WEBRTC)
124 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
125 switches::kDisableWebRtcMultipleRoutes)) {
guoweisc537ba22015-11-06 21:20:31126 web_contents->GetMutableRendererPrefs()->webrtc_ip_handling_policy =
127 kWebRTCIPHandlingDefaultPublicInterfaceOnly;
guoweis8efb6d892015-10-12 18:26:17128 }
129#endif
130
[email protected]3fd84032012-01-12 18:20:17131 return shell;
132}
133
[email protected]11a65b692012-03-30 11:29:16134void Shell::CloseAllWindows() {
[email protected]997ec9f2012-11-21 04:44:14135 base::AutoReset<bool> auto_reset(&quit_message_loop_, false);
[email protected]b50452f2014-08-18 12:31:44136 DevToolsAgentHost::DetachAllClients();
[email protected]11a65b692012-03-30 11:29:16137 std::vector<Shell*> open_windows(windows_);
138 for (size_t i = 0; i < open_windows.size(); ++i)
139 open_windows[i]->Close();
[email protected]dd32b1272013-05-04 14:17:11140 base::MessageLoop::current()->RunUntilIdle();
dmazzoni948fbc72015-05-17 07:57:33141 PlatformExit();
[email protected]11a65b692012-03-30 11:29:16142}
143
[email protected]9e00e6352012-07-30 17:05:18144void Shell::SetShellCreatedCallback(
145 base::Callback<void(Shell*)> shell_created_callback) {
146 DCHECK(shell_created_callback_.is_null());
147 shell_created_callback_ = shell_created_callback;
148}
149
[email protected]74830f02012-01-30 22:27:04150Shell* Shell::FromRenderViewHost(RenderViewHost* rvh) {
151 for (size_t i = 0; i < windows_.size(); ++i) {
[email protected]0b659b32012-03-26 21:29:32152 if (windows_[i]->web_contents() &&
153 windows_[i]->web_contents()->GetRenderViewHost() == rvh) {
[email protected]74830f02012-01-30 22:27:04154 return windows_[i];
155 }
156 }
157 return NULL;
158}
159
[email protected]6153b272013-01-25 22:29:23160// static
161void Shell::Initialize() {
pdrcab84ee2015-03-13 21:47:04162 PlatformInitialize(GetShellDefaultSize());
[email protected]6153b272013-01-25 22:29:23163}
164
[email protected]a2904092013-10-15 04:53:59165gfx::Size Shell::AdjustWindowSize(const gfx::Size& initial_size) {
166 if (!initial_size.IsEmpty())
167 return initial_size;
pdrcab84ee2015-03-13 21:47:04168 return GetShellDefaultSize();
[email protected]a2904092013-10-15 04:53:59169}
170
[email protected]bdcf9152012-07-19 17:43:21171Shell* Shell::CreateNewWindow(BrowserContext* browser_context,
[email protected]e99ca5112011-09-26 17:22:54172 const GURL& url,
173 SiteInstance* site_instance,
[email protected]cdb806722013-01-10 14:18:23174 const gfx::Size& initial_size) {
[email protected]54944cde2012-12-09 09:24:59175 WebContents::CreateParams create_params(browser_context, site_instance);
[email protected]a2904092013-10-15 04:53:59176 create_params.initial_size = AdjustWindowSize(initial_size);
[email protected]54944cde2012-12-09 09:24:59177 WebContents* web_contents = WebContents::Create(create_params);
[email protected]c0d036d2013-05-07 12:50:50178 Shell* shell = CreateShell(web_contents, create_params.initial_size);
[email protected]e99ca5112011-09-26 17:22:54179 if (!url.is_empty())
180 shell->LoadURL(url);
[email protected]9fbd3f862011-09-20 23:31:34181 return shell;
182}
183
184void Shell::LoadURL(const GURL& url) {
[email protected]d2494ff2013-02-20 08:22:37185 LoadURLForFrame(url, std::string());
186}
187
188void Shell::LoadURLForFrame(const GURL& url, const std::string& frame_name) {
189 NavigationController::LoadURLParams params(url);
Sylvain Defresnec6ccc77d2014-09-19 10:19:35190 params.transition_type = ui::PageTransitionFromInt(
191 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
[email protected]d2494ff2013-02-20 08:22:37192 params.frame_name = frame_name;
193 web_contents_->GetController().LoadURLWithParams(params);
[email protected]fc2b46b2014-05-03 16:33:45194 web_contents_->Focus();
[email protected]9fbd3f862011-09-20 23:31:34195}
196
[email protected]76bdecb2014-04-16 17:58:08197void Shell::LoadDataWithBaseURL(const GURL& url, const std::string& data,
198 const GURL& base_url) {
199 const GURL data_url = GURL("data:text/html;charset=utf-8," + data);
200 NavigationController::LoadURLParams params(data_url);
201 params.load_type = NavigationController::LOAD_TYPE_DATA;
202 params.base_url_for_data_url = base_url;
203 params.virtual_url_for_data_url = url;
204 params.override_user_agent = NavigationController::UA_OVERRIDE_FALSE;
205 web_contents_->GetController().LoadURLWithParams(params);
[email protected]fc2b46b2014-05-03 16:33:45206 web_contents_->Focus();
[email protected]76bdecb2014-04-16 17:58:08207}
208
[email protected]a2904092013-10-15 04:53:59209void Shell::AddNewContents(WebContents* source,
210 WebContents* new_contents,
211 WindowOpenDisposition disposition,
bokan107a47f2015-02-03 23:23:39212 const gfx::Rect& initial_rect,
[email protected]a2904092013-10-15 04:53:59213 bool user_gesture,
214 bool* was_blocked) {
bokan107a47f2015-02-03 23:23:39215 CreateShell(new_contents, AdjustWindowSize(initial_rect.size()));
avi83883c82014-12-23 00:08:49216 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
paulmeyerbcc6ad22015-02-11 21:51:59217 switches::kRunLayoutTest))
[email protected]a2904092013-10-15 04:53:59218 NotifyDoneForwarder::CreateForWebContents(new_contents);
219}
220
[email protected]9fbd3f862011-09-20 23:31:34221void Shell::GoBackOrForward(int offset) {
[email protected]0b659b32012-03-26 21:29:32222 web_contents_->GetController().GoToOffset(offset);
[email protected]fc2b46b2014-05-03 16:33:45223 web_contents_->Focus();
[email protected]9fbd3f862011-09-20 23:31:34224}
225
226void Shell::Reload() {
[email protected]0b659b32012-03-26 21:29:32227 web_contents_->GetController().Reload(false);
[email protected]fc2b46b2014-05-03 16:33:45228 web_contents_->Focus();
[email protected]9fbd3f862011-09-20 23:31:34229}
230
231void Shell::Stop() {
[email protected]0b659b32012-03-26 21:29:32232 web_contents_->Stop();
[email protected]fc2b46b2014-05-03 16:33:45233 web_contents_->Focus();
[email protected]9fbd3f862011-09-20 23:31:34234}
235
[email protected]e3b10d12014-03-28 16:06:09236void Shell::UpdateNavigationControls(bool to_different_document) {
[email protected]0b659b32012-03-26 21:29:32237 int current_index = web_contents_->GetController().GetCurrentEntryIndex();
238 int max_index = web_contents_->GetController().GetEntryCount() - 1;
[email protected]9fbd3f862011-09-20 23:31:34239
240 PlatformEnableUIControl(BACK_BUTTON, current_index > 0);
241 PlatformEnableUIControl(FORWARD_BUTTON, current_index < max_index);
[email protected]e3b10d12014-03-28 16:06:09242 PlatformEnableUIControl(STOP_BUTTON,
243 to_different_document && web_contents_->IsLoading());
[email protected]9fbd3f862011-09-20 23:31:34244}
245
[email protected]7c17b6992012-08-09 16:16:30246void Shell::ShowDevTools() {
pfeldman552756452015-02-03 17:33:06247 InnerShowDevTools();
[email protected]3142e5d2014-02-07 00:54:46248}
249
250void Shell::ShowDevToolsForElementAt(int x, int y) {
pfeldman552756452015-02-03 17:33:06251 InnerShowDevTools();
[email protected]2317fcd2014-02-10 14:36:48252 devtools_frontend_->InspectElementAt(x, y);
[email protected]7c17b6992012-08-09 16:16:30253}
254
[email protected]001841c92012-12-11 17:00:13255void Shell::CloseDevTools() {
[email protected]0773e0c2013-01-25 15:57:57256 if (!devtools_frontend_)
[email protected]001841c92012-12-11 17:00:13257 return;
[email protected]7fff43e2013-05-21 20:21:10258 devtools_observer_.reset();
[email protected]0773e0c2013-01-25 15:57:57259 devtools_frontend_->Close();
260 devtools_frontend_ = NULL;
[email protected]001841c92012-12-11 17:00:13261}
262
[email protected]9fbd3f862011-09-20 23:31:34263gfx::NativeView Shell::GetContentView() {
[email protected]59383c782013-04-17 16:43:27264 if (!web_contents_)
[email protected]9fbd3f862011-09-20 23:31:34265 return NULL;
[email protected]fc2b46b2014-05-03 16:33:45266 return web_contents_->GetNativeView();
[email protected]9fbd3f862011-09-20 23:31:34267}
268
[email protected]9e00e6352012-07-30 17:05:18269WebContents* Shell::OpenURLFromTab(WebContents* source,
270 const OpenURLParams& params) {
[email protected]7cf38302013-08-29 12:23:46271 // CURRENT_TAB is the only one we implement for now.
272 if (params.disposition != CURRENT_TAB)
273 return NULL;
[email protected]fbaccee2013-08-12 23:24:02274 NavigationController::LoadURLParams load_url_params(params.url);
lfg9ef7d2d2014-12-15 22:32:30275 load_url_params.source_site_instance = params.source_site_instance;
[email protected]fbaccee2013-08-12 23:24:02276 load_url_params.referrer = params.referrer;
[email protected]c80297782013-11-21 07:10:16277 load_url_params.frame_tree_node_id = params.frame_tree_node_id;
[email protected]fbaccee2013-08-12 23:24:02278 load_url_params.transition_type = params.transition;
279 load_url_params.extra_headers = params.extra_headers;
280 load_url_params.should_replace_current_entry =
281 params.should_replace_current_entry;
282
283 if (params.transferred_global_request_id != GlobalRequestID()) {
284 load_url_params.is_renderer_initiated = params.is_renderer_initiated;
285 load_url_params.transferred_global_request_id =
286 params.transferred_global_request_id;
287 } else if (params.is_renderer_initiated) {
288 load_url_params.is_renderer_initiated = true;
289 }
290
291 source->GetController().LoadURLWithParams(load_url_params);
[email protected]9e00e6352012-07-30 17:05:18292 return source;
293}
294
[email protected]e3b10d12014-03-28 16:06:09295void Shell::LoadingStateChanged(WebContents* source,
296 bool to_different_document) {
297 UpdateNavigationControls(to_different_document);
[email protected]15aea412012-01-19 03:18:50298 PlatformSetIsLoading(source->IsLoading());
[email protected]e99ca5112011-09-26 17:22:54299}
300
mlamouri7a78d6fd2015-01-17 13:23:53301void Shell::EnterFullscreenModeForTab(WebContents* web_contents,
302 const GURL& origin) {
303 ToggleFullscreenModeForTab(web_contents, true);
304}
305
306void Shell::ExitFullscreenModeForTab(WebContents* web_contents) {
307 ToggleFullscreenModeForTab(web_contents, false);
308}
309
[email protected]99c014c2012-11-27 12:03:42310void Shell::ToggleFullscreenModeForTab(WebContents* web_contents,
311 bool enter_fullscreen) {
312#if defined(OS_ANDROID)
313 PlatformToggleFullscreenModeForTab(web_contents, enter_fullscreen);
314#endif
avi83883c82014-12-23 00:08:49315 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
paulmeyerbcc6ad22015-02-11 21:51:59316 switches::kRunLayoutTest))
[email protected]99c014c2012-11-27 12:03:42317 return;
318 if (is_fullscreen_ != enter_fullscreen) {
319 is_fullscreen_ = enter_fullscreen;
avif9ab5d942015-10-15 14:05:44320 web_contents->GetRenderViewHost()->GetWidget()->WasResized();
[email protected]99c014c2012-11-27 12:03:42321 }
322}
323
324bool Shell::IsFullscreenForTabOrPending(const WebContents* web_contents) const {
325#if defined(OS_ANDROID)
326 return PlatformIsFullscreenForTabOrPending(web_contents);
327#else
328 return is_fullscreen_;
329#endif
330}
331
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12332blink::WebDisplayMode Shell::GetDisplayMode(
333 const WebContents* web_contents) const {
334 // TODO : should return blink::WebDisplayModeFullscreen wherever user puts
335 // a browser window into fullscreen (not only in case of renderer-initiated
336 // fullscreen mode): crbug.com/476874.
337 return IsFullscreenForTabOrPending(web_contents) ?
338 blink::WebDisplayModeFullscreen : blink::WebDisplayModeBrowser;
339}
340
[email protected]f78439002012-11-28 14:45:59341void Shell::RequestToLockMouse(WebContents* web_contents,
342 bool user_gesture,
343 bool last_unlocked_by_target) {
344 web_contents->GotResponseToLockMouseRequest(true);
345}
346
[email protected]9e00e6352012-07-30 17:05:18347void Shell::CloseContents(WebContents* source) {
348 Close();
349}
350
[email protected]067310262012-11-22 14:30:41351bool Shell::CanOverscrollContent() const {
352#if defined(USE_AURA)
353 return true;
354#else
355 return false;
356#endif
357}
358
[email protected]3bbacc5b2012-04-17 17:46:15359void Shell::DidNavigateMainFramePostCommit(WebContents* web_contents) {
[email protected]4e3c7522013-08-13 11:53:18360 PlatformSetAddressBarURL(web_contents->GetLastCommittedURL());
[email protected]e99ca5112011-09-26 17:22:54361}
362
mathiash72a5e462014-11-19 08:18:50363JavaScriptDialogManager* Shell::GetJavaScriptDialogManager(
364 WebContents* source) {
mkwst6efe7f2e62014-10-08 15:09:01365 if (!dialog_manager_) {
avi83883c82014-12-23 00:08:49366 const base::CommandLine& command_line =
367 *base::CommandLine::ForCurrentProcess();
paulmeyerbcc6ad22015-02-11 21:51:59368 dialog_manager_.reset(command_line.HasSwitch(switches::kRunLayoutTest)
mkwst6efe7f2e62014-10-08 15:09:01369 ? new LayoutTestJavaScriptDialogManager
370 : new ShellJavaScriptDialogManager);
371 }
[email protected]71a88bb2013-02-01 22:05:15372 return dialog_manager_.get();
[email protected]f2210022012-03-29 00:36:08373}
374
jyasskin8057c002015-09-10 19:09:53375scoped_ptr<BluetoothChooser> Shell::RunBluetoothChooser(
376 WebContents* web_contents,
377 const BluetoothChooser::EventHandler& event_handler,
378 const GURL& origin) {
379 const base::CommandLine& command_line =
380 *base::CommandLine::ForCurrentProcess();
381 if (command_line.HasSwitch(switches::kRunLayoutTest)) {
382 return BlinkTestController::Get()->RunBluetoothChooser(
383 web_contents, event_handler, origin);
384 }
385 return nullptr;
386}
387
[email protected]c272c5b2012-06-06 09:01:06388bool Shell::AddMessageToConsole(WebContents* source,
389 int32 level,
[email protected]fcf75d42013-12-03 20:11:26390 const base::string16& message,
[email protected]c272c5b2012-06-06 09:01:06391 int32 line_no,
[email protected]fcf75d42013-12-03 20:11:26392 const base::string16& source_id) {
avi83883c82014-12-23 00:08:49393 return base::CommandLine::ForCurrentProcess()->HasSwitch(
paulmeyerbcc6ad22015-02-11 21:51:59394 switches::kRunLayoutTest);
[email protected]efb5f572012-01-29 10:57:33395}
396
[email protected]5bf68f22012-08-31 07:38:10397void Shell::RendererUnresponsive(WebContents* source) {
avi83883c82014-12-23 00:08:49398 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
paulmeyerbcc6ad22015-02-11 21:51:59399 switches::kRunLayoutTest))
[email protected]5bf68f22012-08-31 07:38:10400 return;
tfarinacde91252015-05-06 16:10:49401 BlinkTestController::Get()->RendererUnresponsive();
[email protected]5bf68f22012-08-31 07:38:10402}
403
[email protected]233567d2013-02-27 20:22:02404void Shell::ActivateContents(WebContents* contents) {
avif9ab5d942015-10-15 14:05:44405 contents->GetRenderViewHost()->GetWidget()->Focus();
[email protected]233567d2013-02-27 20:22:02406}
407
[email protected]3142e5d2014-02-07 00:54:46408bool Shell::HandleContextMenu(const content::ContextMenuParams& params) {
409 return PlatformHandleContextMenu(params);
410}
411
pdrcab84ee2015-03-13 21:47:04412gfx::Size Shell::GetShellDefaultSize() {
413 static gfx::Size default_shell_size;
414 if (!default_shell_size.IsEmpty())
415 return default_shell_size;
416 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
417 if (command_line->HasSwitch(switches::kContentShellHostWindowSize)) {
418 const std::string size_str = command_line->GetSwitchValueASCII(
419 switches::kContentShellHostWindowSize);
420 int width, height;
421 CHECK_EQ(2, sscanf(size_str.c_str(), "%dx%d", &width, &height));
422 default_shell_size = gfx::Size(width, height);
423 } else {
424 default_shell_size = gfx::Size(
425 kDefaultTestWindowWidthDip, kDefaultTestWindowHeightDip);
426 }
427 return default_shell_size;
428}
429
[email protected]1ef02d242013-10-07 16:18:53430void Shell::TitleWasSet(NavigationEntry* entry, bool explicit_set) {
431 if (entry)
432 PlatformSetTitle(entry->GetTitle());
[email protected]aecc085b2012-06-01 18:15:53433}
434
pfeldman552756452015-02-03 17:33:06435void Shell::InnerShowDevTools() {
[email protected]fee9eca02014-02-14 19:24:40436 if (!devtools_frontend_) {
pfeldman552756452015-02-03 17:33:06437 devtools_frontend_ = ShellDevToolsFrontend::Show(web_contents());
[email protected]fee9eca02014-02-14 19:24:40438 devtools_observer_.reset(new DevToolsWebContentsObserver(
439 this, devtools_frontend_->frontend_shell()->web_contents()));
440 }
441
442 devtools_frontend_->Activate();
443 devtools_frontend_->Focus();
444}
445
[email protected]7fff43e2013-05-21 20:21:10446void Shell::OnDevToolsWebContentsDestroyed() {
447 devtools_observer_.reset();
448 devtools_frontend_ = NULL;
449}
450
[email protected]9fbd3f862011-09-20 23:31:34451} // namespace content