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

Side by Side Diff: Source/core/frame/LocalDOMWindow.cpp

Issue 804163002: Revert 186849 "Bind Window focus ability to the ExecutionContext..." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/2250/
Patch Set: Created 6 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 969
970 void LocalDOMWindow::focus(ExecutionContext* context) 970 void LocalDOMWindow::focus(ExecutionContext* context)
971 { 971 {
972 if (!frame()) 972 if (!frame())
973 return; 973 return;
974 974
975 FrameHost* host = frame()->host(); 975 FrameHost* host = frame()->host();
976 if (!host) 976 if (!host)
977 return; 977 return;
978 978
979 ASSERT(context); 979 bool allowFocus = WindowFocusAllowedIndicator::windowFocusAllowed();
980 980 if (context) {
981 bool allowFocus = context->isWindowFocusAllowed();
982 if (allowFocus) {
983 context->consumeWindowFocus();
984 } else {
985 ASSERT(isMainThread()); 981 ASSERT(isMainThread());
986 allowFocus = opener() && (opener() != this) && (toDocument(context)->dom Window() == opener()); 982 Document* activeDocument = toDocument(context);
983 if (opener() && opener() != this && activeDocument->domWindow() == opene r())
984 allowFocus = true;
987 } 985 }
988 986
989 // If we're a top level window, bring the window to the front. 987 // If we're a top level window, bring the window to the front.
990 if (frame()->isMainFrame() && allowFocus) 988 if (frame()->isMainFrame() && allowFocus)
991 host->chrome().focus(); 989 host->chrome().focus();
992 990
991 if (!frame())
992 return;
993
993 frame()->eventHandler().focusDocumentView(); 994 frame()->eventHandler().focusDocumentView();
994 } 995 }
995 996
996 void LocalDOMWindow::blur() 997 void LocalDOMWindow::blur()
997 { 998 {
998 } 999 }
999 1000
1000 void LocalDOMWindow::close(ExecutionContext* context) 1001 void LocalDOMWindow::close(ExecutionContext* context)
1001 { 1002 {
1002 if (!frame() || !frame()->isMainFrame()) 1003 if (!frame() || !frame()->isMainFrame())
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
1980 return m_frameObserver->frame(); 1981 return m_frameObserver->frame();
1981 } 1982 }
1982 1983
1983 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate) 1984 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate)
1984 { 1985 {
1985 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. 1986 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8].
1986 return v8::Handle<v8::Object>(); 1987 return v8::Handle<v8::Object>();
1987 } 1988 }
1988 1989
1989 } // namespace blink 1990 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/ScopedWindowFocusAllowedIndicator.cpp ('k') | Source/modules/notifications/Notification.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698