| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "core/frame/DOMWindow.h" | 5 #include "core/frame/DOMWindow.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "bindings/core/v8/WindowProxyManager.h" | 9 #include "bindings/core/v8/WindowProxyManager.h" |
| 10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 void DOMWindow::close(ExecutionContext* context) { | 361 void DOMWindow::close(ExecutionContext* context) { |
| 362 if (!GetFrame() || !GetFrame()->IsMainFrame()) | 362 if (!GetFrame() || !GetFrame()->IsMainFrame()) |
| 363 return; | 363 return; |
| 364 | 364 |
| 365 Page* page = GetFrame()->GetPage(); | 365 Page* page = GetFrame()->GetPage(); |
| 366 if (!page) | 366 if (!page) |
| 367 return; | 367 return; |
| 368 | 368 |
| 369 Document* active_document = nullptr; | 369 Document* active_document = nullptr; |
| 370 if (context) { | 370 if (context) { |
| 371 ASSERT(IsMainThread()); | 371 DCHECK(IsMainThread()); |
| 372 active_document = ToDocument(context); | 372 active_document = ToDocument(context); |
| 373 if (!active_document) | 373 if (!active_document) |
| 374 return; | 374 return; |
| 375 | 375 |
| 376 if (!active_document->GetFrame() || | 376 if (!active_document->GetFrame() || |
| 377 !active_document->GetFrame()->CanNavigate(*GetFrame())) | 377 !active_document->GetFrame()->CanNavigate(*GetFrame())) |
| 378 return; | 378 return; |
| 379 } | 379 } |
| 380 | 380 |
| 381 Settings* settings = GetFrame()->GetSettings(); | 381 Settings* settings = GetFrame()->GetSettings(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 408 } | 408 } |
| 409 | 409 |
| 410 void DOMWindow::focus(ExecutionContext* context) { | 410 void DOMWindow::focus(ExecutionContext* context) { |
| 411 if (!GetFrame()) | 411 if (!GetFrame()) |
| 412 return; | 412 return; |
| 413 | 413 |
| 414 Page* page = GetFrame()->GetPage(); | 414 Page* page = GetFrame()->GetPage(); |
| 415 if (!page) | 415 if (!page) |
| 416 return; | 416 return; |
| 417 | 417 |
| 418 ASSERT(context); | 418 DCHECK(context); |
| 419 | 419 |
| 420 bool allow_focus = context->IsWindowInteractionAllowed(); | 420 bool allow_focus = context->IsWindowInteractionAllowed(); |
| 421 if (allow_focus) { | 421 if (allow_focus) { |
| 422 context->ConsumeWindowInteraction(); | 422 context->ConsumeWindowInteraction(); |
| 423 } else { | 423 } else { |
| 424 ASSERT(IsMainThread()); | 424 DCHECK(IsMainThread()); |
| 425 allow_focus = opener() && (opener() != this) && | 425 allow_focus = opener() && (opener() != this) && |
| 426 (ToDocument(context)->domWindow() == opener()); | 426 (ToDocument(context)->domWindow() == opener()); |
| 427 } | 427 } |
| 428 | 428 |
| 429 // If we're a top level window, bring the window to the front. | 429 // If we're a top level window, bring the window to the front. |
| 430 if (GetFrame()->IsMainFrame() && allow_focus) | 430 if (GetFrame()->IsMainFrame() && allow_focus) |
| 431 page->GetChromeClient().Focus(); | 431 page->GetChromeClient().Focus(); |
| 432 | 432 |
| 433 page->GetFocusController().FocusDocumentView(GetFrame(), | 433 page->GetFocusController().FocusDocumentView(GetFrame(), |
| 434 true /* notifyEmbedder */); | 434 true /* notifyEmbedder */); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 447 visitor->Trace(location_); | 447 visitor->Trace(location_); |
| 448 EventTargetWithInlineData::Trace(visitor); | 448 EventTargetWithInlineData::Trace(visitor); |
| 449 } | 449 } |
| 450 | 450 |
| 451 DEFINE_TRACE_WRAPPERS(DOMWindow) { | 451 DEFINE_TRACE_WRAPPERS(DOMWindow) { |
| 452 visitor->TraceWrappers(location_); | 452 visitor->TraceWrappers(location_); |
| 453 EventTargetWithInlineData::TraceWrappers(visitor); | 453 EventTargetWithInlineData::TraceWrappers(visitor); |
| 454 } | 454 } |
| 455 | 455 |
| 456 } // namespace blink | 456 } // namespace blink |
| OLD | NEW |