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

Side by Side Diff: headless/lib/browser/headless_browser_impl_aura.cc

Issue 2709433002: Add HeadlessFocusClient to fix document.hasFocus() issues. (Closed)
Patch Set: Remove unnecessary imports Created 3 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "headless/lib/browser/headless_browser_impl.h" 5 #include "headless/lib/browser/headless_browser_impl.h"
6 6
7 #include "content/public/browser/render_widget_host_view.h" 7 #include "content/public/browser/render_widget_host_view.h"
8 #include "content/public/browser/web_contents.h" 8 #include "content/public/browser/web_contents.h"
9 #include "headless/lib/browser/headless_focus_client.h"
9 #include "headless/lib/browser/headless_screen.h" 10 #include "headless/lib/browser/headless_screen.h"
11 #include "ui/aura/client/focus_client.h"
10 #include "ui/aura/env.h" 12 #include "ui/aura/env.h"
11 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
12 #include "ui/display/screen.h" 14 #include "ui/display/screen.h"
13 #include "ui/events/devices/device_data_manager.h" 15 #include "ui/events/devices/device_data_manager.h"
14 #include "ui/gfx/geometry/size.h" 16 #include "ui/gfx/geometry/size.h"
15 17
16 namespace headless { 18 namespace headless {
17 19
18 void HeadlessBrowserImpl::PlatformInitialize() { 20 void HeadlessBrowserImpl::PlatformInitialize() {
19 HeadlessScreen* screen = HeadlessScreen::Create(options()->window_size); 21 HeadlessScreen* screen = HeadlessScreen::Create(options()->window_size);
20 display::Screen::SetScreenInstance(screen); 22 display::Screen::SetScreenInstance(screen);
21 } 23 }
22 24
23 void HeadlessBrowserImpl::PlatformCreateWindow() { 25 void HeadlessBrowserImpl::PlatformCreateWindow() {
24 DCHECK(aura::Env::GetInstance()); 26 DCHECK(aura::Env::GetInstance());
25 ui::DeviceDataManager::CreateInstance(); 27 ui::DeviceDataManager::CreateInstance();
26 28
27 window_tree_host_.reset( 29 window_tree_host_.reset(
28 new HeadlessWindowTreeHost(gfx::Rect(options()->window_size))); 30 new HeadlessWindowTreeHost(gfx::Rect(options()->window_size)));
29 window_tree_host_->InitHost(); 31 window_tree_host_->InitHost();
30 window_tree_host_->window()->Show(); 32 window_tree_host_->window()->Show();
31 window_tree_host_->SetParentWindow(window_tree_host_->window()); 33 window_tree_host_->SetParentWindow(window_tree_host_->window());
34
35 focus_client_.reset(new HeadlessFocusClient());
36 aura::client::SetFocusClient(window_tree_host_->window(),
37 focus_client_.get());
32 } 38 }
33 39
34 void HeadlessBrowserImpl::PlatformInitializeWebContents( 40 void HeadlessBrowserImpl::PlatformInitializeWebContents(
35 const gfx::Size& initial_size, 41 const gfx::Size& initial_size,
36 content::WebContents* web_contents) { 42 content::WebContents* web_contents) {
37 gfx::NativeView contents = web_contents->GetNativeView(); 43 gfx::NativeView contents = web_contents->GetNativeView();
38 gfx::NativeWindow parent_window = window_tree_host_->window(); 44 gfx::NativeWindow parent_window = window_tree_host_->window();
39 DCHECK(!parent_window->Contains(contents)); 45 DCHECK(!parent_window->Contains(contents));
40 parent_window->AddChild(contents); 46 parent_window->AddChild(contents);
41 contents->Show(); 47 contents->Show();
42 contents->SetBounds(gfx::Rect(initial_size)); 48 contents->SetBounds(gfx::Rect(initial_size));
43 49
44 content::RenderWidgetHostView* host_view = 50 content::RenderWidgetHostView* host_view =
45 web_contents->GetRenderWidgetHostView(); 51 web_contents->GetRenderWidgetHostView();
46 if (host_view) 52 if (host_view)
47 host_view->SetSize(initial_size); 53 host_view->SetSize(initial_size);
48 } 54 }
49 55
50 } // namespace headless 56 } // namespace headless
OLDNEW
« no previous file with comments | « headless/lib/browser/headless_browser_impl.cc ('k') | headless/lib/browser/headless_focus_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698