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

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

Issue 777483004: Bind Window focus ability to the ExecutionContext instead of the process. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@sw_client_focus
Patch Set: rebase 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
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 bool allowFocus = WindowFocusAllowedIndicator::windowFocusAllowed(); 979 ASSERT(context);
980 if (context) { 980
981 bool allowFocus = context->isWindowFocusAllowed();
982 if (allowFocus) {
983 context->consumeWindowFocus();
984 } else {
981 ASSERT(isMainThread()); 985 ASSERT(isMainThread());
982 Document* activeDocument = toDocument(context); 986 allowFocus = opener() && (opener() != this) && (toDocument(context)->dom Window() == opener());
983 if (opener() && opener() != this && activeDocument->domWindow() == opene r())
984 allowFocus = true;
985 } 987 }
986 988
987 // If we're a top level window, bring the window to the front. 989 // If we're a top level window, bring the window to the front.
988 if (frame()->isMainFrame() && allowFocus) 990 if (frame()->isMainFrame() && allowFocus)
989 host->chrome().focus(); 991 host->chrome().focus();
990 992
991 if (!frame())
992 return;
993
994 frame()->eventHandler().focusDocumentView(); 993 frame()->eventHandler().focusDocumentView();
995 } 994 }
996 995
997 void LocalDOMWindow::blur() 996 void LocalDOMWindow::blur()
998 { 997 {
999 } 998 }
1000 999
1001 void LocalDOMWindow::close(ExecutionContext* context) 1000 void LocalDOMWindow::close(ExecutionContext* context)
1002 { 1001 {
1003 if (!frame() || !frame()->isMainFrame()) 1002 if (!frame() || !frame()->isMainFrame())
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 return m_frameObserver->frame(); 1980 return m_frameObserver->frame();
1982 } 1981 }
1983 1982
1984 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate) 1983 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate)
1985 { 1984 {
1986 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. 1985 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8].
1987 return v8::Handle<v8::Object>(); 1986 return v8::Handle<v8::Object>();
1988 } 1987 }
1989 1988
1990 } // namespace blink 1989 } // 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