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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 10963045: Makes closing a fullscreen window refocus the window it came from. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | ui/aura/window_tracker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 19 matching lines...) Expand all
30 #include "ui/aura/client/aura_constants.h" 30 #include "ui/aura/client/aura_constants.h"
31 #include "ui/aura/client/cursor_client.h" 31 #include "ui/aura/client/cursor_client.h"
32 #include "ui/aura/client/screen_position_client.h" 32 #include "ui/aura/client/screen_position_client.h"
33 #include "ui/aura/client/stacking_client.h" 33 #include "ui/aura/client/stacking_client.h"
34 #include "ui/aura/client/tooltip_client.h" 34 #include "ui/aura/client/tooltip_client.h"
35 #include "ui/aura/client/window_types.h" 35 #include "ui/aura/client/window_types.h"
36 #include "ui/aura/env.h" 36 #include "ui/aura/env.h"
37 #include "ui/aura/root_window.h" 37 #include "ui/aura/root_window.h"
38 #include "ui/aura/window.h" 38 #include "ui/aura/window.h"
39 #include "ui/aura/window_observer.h" 39 #include "ui/aura/window_observer.h"
40 #include "ui/aura/window_tracker.h"
40 #include "ui/base/clipboard/scoped_clipboard_writer.h" 41 #include "ui/base/clipboard/scoped_clipboard_writer.h"
41 #include "ui/base/events/event.h" 42 #include "ui/base/events/event.h"
42 #include "ui/base/gestures/gesture_recognizer.h" 43 #include "ui/base/gestures/gesture_recognizer.h"
43 #include "ui/base/hit_test.h" 44 #include "ui/base/hit_test.h"
44 #include "ui/base/ime/input_method.h" 45 #include "ui/base/ime/input_method.h"
45 #include "ui/base/ui_base_types.h" 46 #include "ui/base/ui_base_types.h"
46 #include "ui/compositor/compositor.h" 47 #include "ui/compositor/compositor.h"
47 #include "ui/compositor/layer.h" 48 #include "ui/compositor/layer.h"
48 #include "ui/gfx/canvas.h" 49 #include "ui/gfx/canvas.h"
49 #include "ui/gfx/display.h" 50 #include "ui/gfx/display.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 147
147 // We have to implement the WindowObserver interface on a separate object 148 // We have to implement the WindowObserver interface on a separate object
148 // because clang doesn't like implementing multiple interfaces that have 149 // because clang doesn't like implementing multiple interfaces that have
149 // methods with the same name. This object is owned by the 150 // methods with the same name. This object is owned by the
150 // RenderWidgetHostViewAura. 151 // RenderWidgetHostViewAura.
151 class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver { 152 class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver {
152 public: 153 public:
153 explicit WindowObserver(RenderWidgetHostViewAura* view) : view_(view) {} 154 explicit WindowObserver(RenderWidgetHostViewAura* view) : view_(view) {}
154 virtual ~WindowObserver() {} 155 virtual ~WindowObserver() {}
155 156
156 // Overridden from aura::WindowObserver: 157 // Overridden from aura::WindowObserver:
157 virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE { 158 virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE {
158 view_->RemovingFromRootWindow(); 159 view_->RemovingFromRootWindow();
159 } 160 }
160 161
161 private: 162 private:
162 RenderWidgetHostViewAura* view_; 163 RenderWidgetHostViewAura* view_;
163 164
164 DISALLOW_COPY_AND_ASSIGN(WindowObserver); 165 DISALLOW_COPY_AND_ASSIGN(WindowObserver);
165 }; 166 };
166 167
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 RenderWidgetHostView* reference_host_view) { 277 RenderWidgetHostView* reference_host_view) {
277 is_fullscreen_ = true; 278 is_fullscreen_ = true;
278 window_->SetType(aura::client::WINDOW_TYPE_NORMAL); 279 window_->SetType(aura::client::WINDOW_TYPE_NORMAL);
279 window_->Init(ui::LAYER_TEXTURED); 280 window_->Init(ui::LAYER_TEXTURED);
280 window_->SetName("RenderWidgetHostViewAura"); 281 window_->SetName("RenderWidgetHostViewAura");
281 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 282 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
282 aura::Window* parent = NULL; 283 aura::Window* parent = NULL;
283 if (reference_host_view) { 284 if (reference_host_view) {
284 aura::Window* reference_window = 285 aura::Window* reference_window =
285 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; 286 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_;
287 if (reference_window) {
288 host_tracker_.reset(new aura::WindowTracker);
289 host_tracker_->Add(reference_window);
290 }
286 gfx::Display display = 291 gfx::Display display =
287 gfx::Screen::GetDisplayNearestWindow(reference_window); 292 gfx::Screen::GetDisplayNearestWindow(reference_window);
288 aura::client::StackingClient* stacking_client = 293 aura::client::StackingClient* stacking_client =
289 aura::client::GetStackingClient(); 294 aura::client::GetStackingClient();
290 if (stacking_client) 295 if (stacking_client)
291 parent = stacking_client->GetDefaultParent(window_, display.bounds()); 296 parent = stacking_client->GetDefaultParent(window_, display.bounds());
292 } 297 }
293 window_->SetParent(parent); 298 window_->SetParent(parent);
294 Show(); 299 Show();
295 Focus(); 300 Focus();
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 // RenderWidgetHostViewAura, ui::EventHandler implementation: 1353 // RenderWidgetHostViewAura, ui::EventHandler implementation:
1349 1354
1350 ui::EventResult RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { 1355 ui::EventResult RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) {
1351 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnKeyEvent"); 1356 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnKeyEvent");
1352 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab() && 1357 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab() &&
1353 popup_child_host_view_->OnKeyEvent(event)) 1358 popup_child_host_view_->OnKeyEvent(event))
1354 return ui::ER_HANDLED; 1359 return ui::ER_HANDLED;
1355 1360
1356 // We need to handle the Escape key for Pepper Flash. 1361 // We need to handle the Escape key for Pepper Flash.
1357 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { 1362 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) {
1363 // Focus the window we were created from.
1364 if (host_tracker_.get() && !host_tracker_->windows().empty()) {
1365 aura::Window* host = *(host_tracker_->windows().begin());
1366 if (host->GetFocusManager())
1367 host->Focus();
1368 }
1358 if (!in_shutdown_) { 1369 if (!in_shutdown_) {
1359 in_shutdown_ = true; 1370 in_shutdown_ = true;
1360 host_->Shutdown(); 1371 host_->Shutdown();
1361 } 1372 }
1362 } else { 1373 } else {
1363 // We don't have to communicate with an input method here. 1374 // We don't have to communicate with an input method here.
1364 if (!event->HasNativeEvent()) { 1375 if (!event->HasNativeEvent()) {
1365 // Send a fabricated event, which is usually a VKEY_PROCESSKEY IME event. 1376 // Send a fabricated event, which is usually a VKEY_PROCESSKEY IME event.
1366 NativeWebKeyboardEvent webkit_event(event->type(), 1377 NativeWebKeyboardEvent webkit_event(event->type(),
1367 false /* is_char */, 1378 false /* is_char */,
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1791 RenderWidgetHost* widget) { 1802 RenderWidgetHost* widget) {
1792 return new RenderWidgetHostViewAura(widget); 1803 return new RenderWidgetHostViewAura(widget);
1793 } 1804 }
1794 1805
1795 // static 1806 // static
1796 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 1807 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
1797 GetScreenInfoForWindow(results, NULL); 1808 GetScreenInfoForWindow(results, NULL);
1798 } 1809 }
1799 1810
1800 } // namespace content 1811 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | ui/aura/window_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698