blob: 81c9cad0b32bd3d91b7e15e28506a990da3b9cc1 [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
avi66a07722015-12-25 23:38:127#include <stddef.h>
8
[email protected]11a65b692012-03-30 11:29:169#include "base/auto_reset.h"
[email protected]efb5f572012-01-29 10:57:3310#include "base/command_line.h"
skyostil95082a62015-06-05 19:53:0711#include "base/location.h"
avi66a07722015-12-25 23:38:1212#include "base/macros.h"
skyostil95082a62015-06-05 19:53:0713#include "base/single_thread_task_runner.h"
[email protected]21aa99682013-06-11 07:17:0114#include "base/strings/string_number_conversions.h"
15#include "base/strings/string_util.h"
16#include "base/strings/stringprintf.h"
[email protected]74ebfb12013-06-07 20:48:0017#include "base/strings/utf_string_conversions.h"
skyostil95082a62015-06-05 19:53:0718#include "base/thread_task_runner_handle.h"
avi66a07722015-12-25 23:38:1219#include "build/build_config.h"
[email protected]b50452f2014-08-18 12:31:4420#include "content/public/browser/devtools_agent_host.h"
[email protected]0b659b32012-03-26 21:29:3221#include "content/public/browser/navigation_controller.h"
[email protected]b7c504c2013-05-07 14:42:1222#include "content/public/browser/navigation_entry.h"
[email protected]0b659b32012-03-26 21:29:3223#include "content/public/browser/render_view_host.h"
avif9ab5d942015-10-15 14:05:4424#include "content/public/browser/render_widget_host.h"
[email protected]0b659b32012-03-26 21:29:3225#include "content/public/browser/web_contents.h"
[email protected]7fff43e2013-05-21 20:21:1026#include "content/public/browser/web_contents_observer.h"
guoweis8efb6d892015-10-12 18:26:1727#include "content/public/common/content_switches.h"
[email protected]1596efb2013-01-17 22:13:0128#include "content/public/common/renderer_preferences.h"
guoweisc537ba22015-11-06 21:20:3129#include "content/public/common/webrtc_ip_handling_policy.h"
tfarinacde91252015-05-06 16:10:4930#include "content/shell/browser/blink_test_controller.h"
jyasskin8057c002015-09-10 19:09:5331#include "content/shell/browser/layout_test/layout_test_bluetooth_chooser_factory.h"
mkwst30d20d52014-10-09 13:33:1432#include "content/shell/browser/layout_test/layout_test_devtools_frontend.h"
mkwst6efe7f2e62014-10-08 15:09:0133#include "content/shell/browser/layout_test/layout_test_javascript_dialog_manager.h"
[email protected]de7d61ff2013-08-20 11:30:4134#include "content/shell/browser/notify_done_forwarder.h"
35#include "content/shell/browser/shell_browser_main_parts.h"
36#include "content/shell/browser/shell_content_browser_client.h"
37#include "content/shell/browser/shell_devtools_frontend.h"
38#include "content/shell/browser/shell_javascript_dialog_manager.h"
[email protected]b7c504c2013-05-07 14:42:1239#include "content/shell/common/shell_messages.h"
40#include "content/shell/common/shell_switches.h"
[email protected]9fbd3f862011-09-20 23:31:3441
[email protected]9fbd3f862011-09-20 23:31:3442namespace content {
43
pdrcab84ee2015-03-13 21:47:0444const int kDefaultTestWindowWidthDip = 800;
45const int kDefaultTestWindowHeightDip = 600;
[email protected]1e57cab2013-05-28 04:26:1146
[email protected]e99ca5112011-09-26 17:22:5447std::vector<Shell*> Shell::windows_;
[email protected]9e00e6352012-07-30 17:05:1848base::Callback<void(Shell*)> Shell::shell_created_callback_;
[email protected]9fbd3f862011-09-20 23:31:3449
[email protected]11a65b692012-03-30 11:29:1650bool Shell::quit_message_loop_ = true;
51
[email protected]7fff43e2013-05-21 20:21:1052class Shell::DevToolsWebContentsObserver : public WebContentsObserver {
53 public:
54 DevToolsWebContentsObserver(Shell* shell, WebContents* web_contents)
55 : WebContentsObserver(web_contents),
56 shell_(shell) {
57 }
58
59 // WebContentsObserver
dchenge933b3e2014-10-21 11:44:0960 void WebContentsDestroyed() override {
[email protected]7fff43e2013-05-21 20:21:1061 shell_->OnDevToolsWebContentsDestroyed();
62 }
63
64 private:
65 Shell* shell_;
66
67 DISALLOW_COPY_AND_ASSIGN(DevToolsWebContentsObserver);
68};
69
[email protected]0b659b32012-03-26 21:29:3270Shell::Shell(WebContents* web_contents)
[email protected]1ef02d242013-10-07 16:18:5371 : WebContentsObserver(web_contents),
72 devtools_frontend_(NULL),
[email protected]001841c92012-12-11 17:00:1373 is_fullscreen_(false),
[email protected]99c014c2012-11-27 12:03:4274 window_(NULL),
sadrul8b11d262015-11-12 18:41:3375#if defined(OS_MACOSX)
[email protected]86b36e672012-12-21 00:09:5176 url_edit_view_(NULL),
sadrul8b11d262015-11-12 18:41:3377#endif
[email protected]86b36e672012-12-21 00:09:5178 headless_(false) {
avi83883c82014-12-23 00:08:4979 const base::CommandLine& command_line =
80 *base::CommandLine::ForCurrentProcess();
paulmeyerbcc6ad22015-02-11 21:51:5981 if (command_line.HasSwitch(switches::kRunLayoutTest))
[email protected]86b36e672012-12-21 00:09:5182 headless_ = true;
[email protected]9e00e6352012-07-30 17:05:1883 windows_.push_back(this);
84
85 if (!shell_created_callback_.is_null()) {
86 shell_created_callback_.Run(this);
87 shell_created_callback_.Reset();
88 }
[email protected]9fbd3f862011-09-20 23:31:3489}
90
91Shell::~Shell() {
92 PlatformCleanUp();
[email protected]e99ca5112011-09-26 17:22:5493
94 for (size_t i = 0; i < windows_.size(); ++i) {
95 if (windows_[i] == this) {
96 windows_.erase(windows_.begin() + i);
97 break;
98 }
99 }
[email protected]11a65b692012-03-30 11:29:16100
[email protected]b53adf452014-02-07 12:55:08101 if (windows_.empty() && quit_message_loop_) {
102 if (headless_)
103 PlatformExit();
skyostil95082a62015-06-05 19:53:07104 base::ThreadTaskRunnerHandle::Get()->PostTask(
ki.stfu800779242015-10-12 22:46:26105 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
[email protected]b53adf452014-02-07 12:55:08106 }
[email protected]9fbd3f862011-09-20 23:31:34107}
108
[email protected]c0d036d2013-05-07 12:50:50109Shell* Shell::CreateShell(WebContents* web_contents,
110 const gfx::Size& initial_size) {
[email protected]0b659b32012-03-26 21:29:32111 Shell* shell = new Shell(web_contents);
[email protected]c0d036d2013-05-07 12:50:50112 shell->PlatformCreateWindow(initial_size.width(), initial_size.height());
[email protected]3fd84032012-01-12 18:20:17113
[email protected]0b659b32012-03-26 21:29:32114 shell->web_contents_.reset(web_contents);
115 web_contents->SetDelegate(shell);
[email protected]3fd84032012-01-12 18:20:17116
[email protected]5cba3bf2012-01-14 02:40:35117 shell->PlatformSetContents();
[email protected]3fd84032012-01-12 18:20:17118
119 shell->PlatformResizeSubViews();
[email protected]1596efb2013-01-17 22:13:01120
guoweis4ee48592015-12-02 06:37:07121 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
122 if (command_line->HasSwitch(switches::kRunLayoutTest)) {
[email protected]1596efb2013-01-17 22:13:01123 web_contents->GetMutableRendererPrefs()->use_custom_colors = false;
124 web_contents->GetRenderViewHost()->SyncRendererPrefs();
125 }
126
guoweis8efb6d892015-10-12 18:26:17127#if defined(ENABLE_WEBRTC)
guoweis4ee48592015-12-02 06:37:07128 if (command_line->HasSwitch(switches::kForceWebRtcIPHandlingPolicy)) {
guoweisc537ba22015-11-06 21:20:31129 web_contents->GetMutableRendererPrefs()->webrtc_ip_handling_policy =
guoweis4ee48592015-12-02 06:37:07130 command_line->GetSwitchValueASCII(
131 switches::kForceWebRtcIPHandlingPolicy);
guoweis8efb6d892015-10-12 18:26:17132 }
133#endif
134
[email protected]3fd84032012-01-12 18:20:17135 return shell;
136}
137
[email protected]11a65b692012-03-30 11:29:16138void Shell::CloseAllWindows() {
[email protected]997ec9f2012-11-21 04:44:14139 base::AutoReset<bool> auto_reset(&quit_message_loop_, false);
[email protected]b50452f2014-08-18 12:31:44140 DevToolsAgentHost::DetachAllClients();
[email protected]11a65b692012-03-30 11:29:16141 std::vector<Shell*> open_windows(windows_);
142 for (size_t i = 0; i < open_windows.size(); ++i)
143 open_windows[i]->Close();
[email protected]dd32b1272013-05-04 14:17:11144 base::MessageLoop::current()->RunUntilIdle();
dmazzoni948fbc72015-05-17 07:57:33145 PlatformExit();
[email protected]11a65b692012-03-30 11:29:16146}
147
[email protected]9e00e6352012-07-30 17:05:18148void Shell::SetShellCreatedCallback(
149 base::Callback<void(Shell*)> shell_created_callback) {
150 DCHECK(shell_created_callback_.is_null());
151 shell_created_callback_ = shell_created_callback;
152}
153
[email protected]74830f02012-01-30 22:27:04154Shell* Shell::FromRenderViewHost(RenderViewHost* rvh) {
155 for (size_t i = 0; i < windows_.size(); ++i) {
[email protected]0b659b32012-03-26 21:29:32156 if (windows_[i]->web_contents() &&
157 windows_[i]->web_contents()->GetRenderViewHost() == rvh) {
[email protected]74830f02012-01-30 22:27:04158 return windows_[i];
159 }
160 }
161 return NULL;
162}
163
[email protected]6153b272013-01-25 22:29:23164// static
165void Shell::Initialize() {
pdrcab84ee2015-03-13 21:47:04166 PlatformInitialize(GetShellDefaultSize());
[email protected]6153b272013-01-25 22:29:23167}
168
[email protected]a2904092013-10-15 04:53:59169gfx::Size Shell::AdjustWindowSize(const gfx::Size& initial_size) {
170 if (!initial_size.IsEmpty())
171 return initial_size;
pdrcab84ee2015-03-13 21:47:04172 return GetShellDefaultSize();
[email protected]a2904092013-10-15 04:53:59173}
174
[email protected]bdcf9152012-07-19 17:43:21175Shell* Shell::CreateNewWindow(BrowserContext* browser_context,
[email protected]e99ca5112011-09-26 17:22:54176 const GURL& url,
177 SiteInstance* site_instance,
[email protected]cdb806722013-01-10 14:18:23178 const gfx::Size& initial_size) {
[email protected]54944cde2012-12-09 09:24:59179 WebContents::CreateParams create_params(browser_context, site_instance);
[email protected]a2904092013-10-15 04:53:59180 create_params.initial_size = AdjustWindowSize(initial_size);
[email protected]54944cde2012-12-09 09:24:59181 WebContents* web_contents = WebContents::Create(create_params);
[email protected]c0d036d2013-05-07 12:50:50182 Shell* shell = CreateShell(web_contents, create_params.initial_size);
[email protected]e99ca5112011-09-26 17:22:54183 if (!url.is_empty())
184 shell->LoadURL(url);
[email protected]9fbd3f862011-09-20 23:31:34185 return shell;
186}
187
188void Shell::LoadURL(const GURL& url) {
[email protected]d2494ff2013-02-20 08:22:37189 LoadURLForFrame(url, std::string());
190}
191
192void Shell::LoadURLForFrame(const GURL& url, const std::string& frame_name) {
193 NavigationController::LoadURLParams params(url);
Sylvain Defresnec6ccc77d2014-09-19 10:19:35194 params.transition_type = ui::PageTransitionFromInt(
195 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
[email protected]d2494ff2013-02-20 08:22:37196 params.frame_name = frame_name;
197 web_contents_->GetController().LoadURLWithParams(params);
[email protected]fc2b46b2014-05-03 16:33:45198 web_contents_->Focus();
[email protected]9fbd3f862011-09-20 23:31:34199}
200
[email protected]76bdecb2014-04-16 17:58:08201void Shell::LoadDataWithBaseURL(const GURL& url, const std::string& data,
202 const GURL& base_url) {
203 const GURL data_url = GURL("data:text/html;charset=utf-8," + data);
204 NavigationController::LoadURLParams params(data_url);
205 params.load_type = NavigationController::LOAD_TYPE_DATA;
206 params.base_url_for_data_url = base_url;
207 params.virtual_url_for_data_url = url;
208 params.override_user_agent = NavigationController::UA_OVERRIDE_FALSE;
209 web_contents_->GetController().LoadURLWithParams(params);
[email protected]fc2b46b2014-05-03 16:33:45210 web_contents_->Focus();
[email protected]76bdecb2014-04-16 17:58:08211}
212
[email protected]a2904092013-10-15 04:53:59213void Shell::AddNewContents(WebContents* source,
214 WebContents* new_contents,
215 WindowOpenDisposition disposition,
bokan107a47f2015-02-03 23:23:39216 const gfx::Rect& initial_rect,
[email protected]a2904092013-10-15 04:53:59217 bool user_gesture,
218 bool* was_blocked) {
bokan107a47f2015-02-03 23:23:39219 CreateShell(new_contents, AdjustWindowSize(initial_rect.size()));
avi83883c82014-12-23 00:08:49220 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
paulmeyerbcc6ad22015-02-11 21:51:59221 switches::kRunLayoutTest))
[email protected]a2904092013-10-15 04:53:59222 NotifyDoneForwarder::CreateForWebContents(new_contents);
223}
224
[email protected]9fbd3f862011-09-20 23:31:34225void Shell::GoBackOrForward(int offset) {
[email protected]0b659b32012-03-26 21:29:32226 web_contents_->GetController().GoToOffset(offset);
[email protected]fc2b46b2014-05-03 16:33:45227 web_contents_->Focus();
[email protected]9fbd3f862011-09-20 23:31:34228}
229
230void Shell::Reload() {
[email protected]0b659b32012-03-26 21:29:32231 web_contents_->GetController().Reload(false);
[email protected]fc2b46b2014-05-03 16:33:45232 web_contents_->Focus();
[email protected]9fbd3f862011-09-20 23:31:34233}
234
235void Shell::Stop() {
[email protected]0b659b32012-03-26 21:29:32236 web_contents_->Stop();
[email protected]fc2b46b2014-05-03 16:33:45237 web_contents_->Focus();
[email protected]9fbd3f862011-09-20 23:31:34238}
239
[email protected]e3b10d12014-03-28 16:06:09240void Shell::UpdateNavigationControls(bool to_different_document) {
[email protected]0b659b32012-03-26 21:29:32241 int current_index = web_contents_->GetController().GetCurrentEntryIndex();
242 int max_index = web_contents_->GetController().GetEntryCount() - 1;
[email protected]9fbd3f862011-09-20 23:31:34243
244 PlatformEnableUIControl(BACK_BUTTON, current_index > 0);
245 PlatformEnableUIControl(FORWARD_BUTTON, current_index < max_index);
[email protected]e3b10d12014-03-28 16:06:09246 PlatformEnableUIControl(STOP_BUTTON,
247 to_different_document && web_contents_->IsLoading());
[email protected]9fbd3f862011-09-20 23:31:34248}
249
[email protected]7c17b6992012-08-09 16:16:30250void Shell::ShowDevTools() {
pfeldman552756452015-02-03 17:33:06251 InnerShowDevTools();
[email protected]3142e5d2014-02-07 00:54:46252}
253
254void Shell::ShowDevToolsForElementAt(int x, int y) {
pfeldman552756452015-02-03 17:33:06255 InnerShowDevTools();
[email protected]2317fcd2014-02-10 14:36:48256 devtools_frontend_->InspectElementAt(x, y);
[email protected]7c17b6992012-08-09 16:16:30257}
258
[email protected]001841c92012-12-11 17:00:13259void Shell::CloseDevTools() {
[email protected]0773e0c2013-01-25 15:57:57260 if (!devtools_frontend_)
[email protected]001841c92012-12-11 17:00:13261 return;
[email protected]7fff43e2013-05-21 20:21:10262 devtools_observer_.reset();
[email protected]0773e0c2013-01-25 15:57:57263 devtools_frontend_->Close();
264 devtools_frontend_ = NULL;
[email protected]001841c92012-12-11 17:00:13265}
266
[email protected]9fbd3f862011-09-20 23:31:34267gfx::NativeView Shell::GetContentView() {
[email protected]59383c782013-04-17 16:43:27268 if (!web_contents_)
[email protected]9fbd3f862011-09-20 23:31:34269 return NULL;
[email protected]fc2b46b2014-05-03 16:33:45270 return web_contents_->GetNativeView();
[email protected]9fbd3f862011-09-20 23:31:34271}
272
[email protected]e3b10d12014-03-28 16:06:09273void Shell::LoadingStateChanged(WebContents* source,
274 bool to_different_document) {
275 UpdateNavigationControls(to_different_document);
[email protected]15aea412012-01-19 03:18:50276 PlatformSetIsLoading(source->IsLoading());
[email protected]e99ca5112011-09-26 17:22:54277}
278
mlamouri7a78d6fd2015-01-17 13:23:53279void Shell::EnterFullscreenModeForTab(WebContents* web_contents,
280 const GURL& origin) {
281 ToggleFullscreenModeForTab(web_contents, true);
282}
283
284void Shell::ExitFullscreenModeForTab(WebContents* web_contents) {
285 ToggleFullscreenModeForTab(web_contents, false);
286}
287
[email protected]99c014c2012-11-27 12:03:42288void Shell::ToggleFullscreenModeForTab(WebContents* web_contents,
289 bool enter_fullscreen) {
290#if defined(OS_ANDROID)
291 PlatformToggleFullscreenModeForTab(web_contents, enter_fullscreen);
292#endif
avi83883c82014-12-23 00:08:49293 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
paulmeyerbcc6ad22015-02-11 21:51:59294 switches::kRunLayoutTest))
[email protected]99c014c2012-11-27 12:03:42295 return;
296 if (is_fullscreen_ != enter_fullscreen) {
297 is_fullscreen_ = enter_fullscreen;
avif9ab5d942015-10-15 14:05:44298 web_contents->GetRenderViewHost()->GetWidget()->WasResized();
[email protected]99c014c2012-11-27 12:03:42299 }
300}
301
302bool Shell::IsFullscreenForTabOrPending(const WebContents* web_contents) const {
303#if defined(OS_ANDROID)
304 return PlatformIsFullscreenForTabOrPending(web_contents);
305#else
306 return is_fullscreen_;
307#endif
308}
309
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12310blink::WebDisplayMode Shell::GetDisplayMode(
311 const WebContents* web_contents) const {
312 // TODO : should return blink::WebDisplayModeFullscreen wherever user puts
313 // a browser window into fullscreen (not only in case of renderer-initiated
314 // fullscreen mode): crbug.com/476874.
315 return IsFullscreenForTabOrPending(web_contents) ?
316 blink::WebDisplayModeFullscreen : blink::WebDisplayModeBrowser;
317}
318
[email protected]f78439002012-11-28 14:45:59319void Shell::RequestToLockMouse(WebContents* web_contents,
320 bool user_gesture,
321 bool last_unlocked_by_target) {
322 web_contents->GotResponseToLockMouseRequest(true);
323}
324
[email protected]9e00e6352012-07-30 17:05:18325void Shell::CloseContents(WebContents* source) {
326 Close();
327}
328
[email protected]067310262012-11-22 14:30:41329bool Shell::CanOverscrollContent() const {
330#if defined(USE_AURA)
331 return true;
332#else
333 return false;
334#endif
335}
336
[email protected]3bbacc5b2012-04-17 17:46:15337void Shell::DidNavigateMainFramePostCommit(WebContents* web_contents) {
[email protected]4e3c7522013-08-13 11:53:18338 PlatformSetAddressBarURL(web_contents->GetLastCommittedURL());
[email protected]e99ca5112011-09-26 17:22:54339}
340
mathiash72a5e462014-11-19 08:18:50341JavaScriptDialogManager* Shell::GetJavaScriptDialogManager(
342 WebContents* source) {
mkwst6efe7f2e62014-10-08 15:09:01343 if (!dialog_manager_) {
avi83883c82014-12-23 00:08:49344 const base::CommandLine& command_line =
345 *base::CommandLine::ForCurrentProcess();
paulmeyerbcc6ad22015-02-11 21:51:59346 dialog_manager_.reset(command_line.HasSwitch(switches::kRunLayoutTest)
mkwst6efe7f2e62014-10-08 15:09:01347 ? new LayoutTestJavaScriptDialogManager
348 : new ShellJavaScriptDialogManager);
349 }
[email protected]71a88bb2013-02-01 22:05:15350 return dialog_manager_.get();
[email protected]f2210022012-03-29 00:36:08351}
352
jyasskin8057c002015-09-10 19:09:53353scoped_ptr<BluetoothChooser> Shell::RunBluetoothChooser(
354 WebContents* web_contents,
355 const BluetoothChooser::EventHandler& event_handler,
356 const GURL& origin) {
357 const base::CommandLine& command_line =
358 *base::CommandLine::ForCurrentProcess();
359 if (command_line.HasSwitch(switches::kRunLayoutTest)) {
360 return BlinkTestController::Get()->RunBluetoothChooser(
361 web_contents, event_handler, origin);
362 }
363 return nullptr;
364}
365
[email protected]c272c5b2012-06-06 09:01:06366bool Shell::AddMessageToConsole(WebContents* source,
avi66a07722015-12-25 23:38:12367 int32_t level,
[email protected]fcf75d42013-12-03 20:11:26368 const base::string16& message,
avi66a07722015-12-25 23:38:12369 int32_t line_no,
[email protected]fcf75d42013-12-03 20:11:26370 const base::string16& source_id) {
avi83883c82014-12-23 00:08:49371 return base::CommandLine::ForCurrentProcess()->HasSwitch(
paulmeyerbcc6ad22015-02-11 21:51:59372 switches::kRunLayoutTest);
[email protected]efb5f572012-01-29 10:57:33373}
374
[email protected]5bf68f22012-08-31 07:38:10375void Shell::RendererUnresponsive(WebContents* source) {
avi83883c82014-12-23 00:08:49376 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
paulmeyerbcc6ad22015-02-11 21:51:59377 switches::kRunLayoutTest))
[email protected]5bf68f22012-08-31 07:38:10378 return;
tfarinacde91252015-05-06 16:10:49379 BlinkTestController::Get()->RendererUnresponsive();
[email protected]5bf68f22012-08-31 07:38:10380}
381
[email protected]233567d2013-02-27 20:22:02382void Shell::ActivateContents(WebContents* contents) {
avif9ab5d942015-10-15 14:05:44383 contents->GetRenderViewHost()->GetWidget()->Focus();
[email protected]233567d2013-02-27 20:22:02384}
385
[email protected]3142e5d2014-02-07 00:54:46386bool Shell::HandleContextMenu(const content::ContextMenuParams& params) {
387 return PlatformHandleContextMenu(params);
388}
389
pdrcab84ee2015-03-13 21:47:04390gfx::Size Shell::GetShellDefaultSize() {
391 static gfx::Size default_shell_size;
392 if (!default_shell_size.IsEmpty())
393 return default_shell_size;
394 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
395 if (command_line->HasSwitch(switches::kContentShellHostWindowSize)) {
396 const std::string size_str = command_line->GetSwitchValueASCII(
397 switches::kContentShellHostWindowSize);
398 int width, height;
399 CHECK_EQ(2, sscanf(size_str.c_str(), "%dx%d", &width, &height));
400 default_shell_size = gfx::Size(width, height);
401 } else {
402 default_shell_size = gfx::Size(
403 kDefaultTestWindowWidthDip, kDefaultTestWindowHeightDip);
404 }
405 return default_shell_size;
406}
407
[email protected]1ef02d242013-10-07 16:18:53408void Shell::TitleWasSet(NavigationEntry* entry, bool explicit_set) {
409 if (entry)
410 PlatformSetTitle(entry->GetTitle());
[email protected]aecc085b2012-06-01 18:15:53411}
412
pfeldman552756452015-02-03 17:33:06413void Shell::InnerShowDevTools() {
[email protected]fee9eca02014-02-14 19:24:40414 if (!devtools_frontend_) {
pfeldman552756452015-02-03 17:33:06415 devtools_frontend_ = ShellDevToolsFrontend::Show(web_contents());
[email protected]fee9eca02014-02-14 19:24:40416 devtools_observer_.reset(new DevToolsWebContentsObserver(
417 this, devtools_frontend_->frontend_shell()->web_contents()));
418 }
419
420 devtools_frontend_->Activate();
421 devtools_frontend_->Focus();
422}
423
[email protected]7fff43e2013-05-21 20:21:10424void Shell::OnDevToolsWebContentsDestroyed() {
425 devtools_observer_.reset();
426 devtools_frontend_ = NULL;
427}
428
[email protected]9fbd3f862011-09-20 23:31:34429} // namespace content