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

Side by Side Diff: Source/core/dom/ExecutionContext.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
« no previous file with comments | « Source/core/dom/ExecutionContext.h ('k') | Source/core/dom/ScopedWindowFocusAllowedIndicator.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 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2012 Google Inc. All Rights Reserved. 3 * Copyright (C) 2012 Google Inc. All Rights Reserved.
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 18 matching lines...) Expand all
29 #include "core/dom/ExecutionContext.h" 29 #include "core/dom/ExecutionContext.h"
30 30
31 #include "core/dom/AddConsoleMessageTask.h" 31 #include "core/dom/AddConsoleMessageTask.h"
32 #include "core/dom/ContextLifecycleNotifier.h" 32 #include "core/dom/ContextLifecycleNotifier.h"
33 #include "core/dom/ExecutionContextTask.h" 33 #include "core/dom/ExecutionContextTask.h"
34 #include "core/events/ErrorEvent.h" 34 #include "core/events/ErrorEvent.h"
35 #include "core/events/EventTarget.h" 35 #include "core/events/EventTarget.h"
36 #include "core/html/PublicURLManager.h" 36 #include "core/html/PublicURLManager.h"
37 #include "core/inspector/InspectorInstrumentation.h" 37 #include "core/inspector/InspectorInstrumentation.h"
38 #include "core/inspector/ScriptCallStack.h" 38 #include "core/inspector/ScriptCallStack.h"
39 #include "core/page/WindowFocusAllowedIndicator.h"
39 #include "core/workers/WorkerGlobalScope.h" 40 #include "core/workers/WorkerGlobalScope.h"
40 #include "core/workers/WorkerThread.h" 41 #include "core/workers/WorkerThread.h"
41 #include "wtf/MainThread.h" 42 #include "wtf/MainThread.h"
42 43
43 namespace blink { 44 namespace blink {
44 45
45 class ExecutionContext::PendingException : public NoBaseWillBeGarbageCollectedFi nalized<ExecutionContext::PendingException> { 46 class ExecutionContext::PendingException : public NoBaseWillBeGarbageCollectedFi nalized<ExecutionContext::PendingException> {
46 WTF_MAKE_NONCOPYABLE(PendingException); 47 WTF_MAKE_NONCOPYABLE(PendingException);
47 public: 48 public:
48 PendingException(const String& errorMessage, int lineNumber, int columnNumbe r, int scriptId, const String& sourceURL, PassRefPtrWillBeRawPtr<ScriptCallStack > callStack) 49 PendingException(const String& errorMessage, int lineNumber, int columnNumbe r, int scriptId, const String& sourceURL, PassRefPtrWillBeRawPtr<ScriptCallStack > callStack)
(...skipping 18 matching lines...) Expand all
67 }; 68 };
68 69
69 ExecutionContext::ExecutionContext() 70 ExecutionContext::ExecutionContext()
70 : m_sandboxFlags(SandboxNone) 71 : m_sandboxFlags(SandboxNone)
71 , m_circularSequentialID(0) 72 , m_circularSequentialID(0)
72 , m_timerNestingLevel(0) 73 , m_timerNestingLevel(0)
73 , m_inDispatchErrorEvent(false) 74 , m_inDispatchErrorEvent(false)
74 , m_activeDOMObjectsAreSuspended(false) 75 , m_activeDOMObjectsAreSuspended(false)
75 , m_activeDOMObjectsAreStopped(false) 76 , m_activeDOMObjectsAreStopped(false)
76 , m_strictMixedContentCheckingEnforced(false) 77 , m_strictMixedContentCheckingEnforced(false)
78 , m_windowFocusTokens(0)
77 { 79 {
78 } 80 }
79 81
80 ExecutionContext::~ExecutionContext() 82 ExecutionContext::~ExecutionContext()
81 { 83 {
82 } 84 }
83 85
84 bool ExecutionContext::hasPendingActivity() 86 bool ExecutionContext::hasPendingActivity()
85 { 87 {
86 return lifecycleNotifier().hasPendingActivity(); 88 return lifecycleNotifier().hasPendingActivity();
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 { 267 {
266 m_sandboxFlags |= mask; 268 m_sandboxFlags |= mask;
267 269
268 // The SandboxOrigin is stored redundantly in the security origin. 270 // The SandboxOrigin is stored redundantly in the security origin.
269 if (isSandboxed(SandboxOrigin) && securityContext().securityOrigin() && !sec urityContext().securityOrigin()->isUnique()) { 271 if (isSandboxed(SandboxOrigin) && securityContext().securityOrigin() && !sec urityContext().securityOrigin()->isUnique()) {
270 securityContext().setSecurityOrigin(SecurityOrigin::createUnique()); 272 securityContext().setSecurityOrigin(SecurityOrigin::createUnique());
271 didUpdateSecurityOrigin(); 273 didUpdateSecurityOrigin();
272 } 274 }
273 } 275 }
274 276
277 void ExecutionContext::allowWindowFocus()
278 {
279 ++m_windowFocusTokens;
280 }
281
282 void ExecutionContext::consumeWindowFocus()
283 {
284 if (m_windowFocusTokens == 0)
285 return;
286 --m_windowFocusTokens;
287 }
288
289 bool ExecutionContext::isWindowFocusAllowed() const
290 {
291 // FIXME: WindowFocusAllowedIndicator::windowFocusAllowed() is temporary,
292 // it will be removed as soon as WebScopedWindowFocusAllowedIndicator will
293 // be updated to not use WindowFocusAllowedIndicator.
294 return m_windowFocusTokens > 0 || WindowFocusAllowedIndicator::windowFocusAl lowed();
295 }
296
275 void ExecutionContext::trace(Visitor* visitor) 297 void ExecutionContext::trace(Visitor* visitor)
276 { 298 {
277 #if ENABLE(OILPAN) 299 #if ENABLE(OILPAN)
278 visitor->trace(m_pendingExceptions); 300 visitor->trace(m_pendingExceptions);
279 visitor->trace(m_publicURLManager); 301 visitor->trace(m_publicURLManager);
280 visitor->trace(m_timeouts); 302 visitor->trace(m_timeouts);
281 HeapSupplementable<ExecutionContext>::trace(visitor); 303 HeapSupplementable<ExecutionContext>::trace(visitor);
282 #endif 304 #endif
283 LifecycleContext<ExecutionContext>::trace(visitor); 305 LifecycleContext<ExecutionContext>::trace(visitor);
284 } 306 }
285 307
286 } // namespace blink 308 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/ExecutionContext.h ('k') | Source/core/dom/ScopedWindowFocusAllowedIndicator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698