Skip to content
Permalink
Browse files
2010-03-08 Stuart Morgan <stuartmorgan@chromium.org>
        Reviewed by Darin Adler.

        Added a new USE definition for secure text mode on the Mac.
        https://bugs.webkit.org/show_bug.cgi?id=31265

        * wtf/Platform.h:
2010-03-08  Stuart Morgan  <stuartmorgan@chromium.org>

        Reviewed by Darin Adler.

        Move the details of secure text mode into WebCore/platform.
        Move the higher-level logic for secure text mode from Frame
        to SelectionController.

        https://bugs.webkit.org/show_bug.cgi?id=31265

        No new tests: no functional changes.

        * WebCore.gypi:
        * WebCore.xcodeproj/project.pbxproj:
        * dom/Document.cpp:
        (WebCore::Document::setUseSecureKeyboardEntryWhenActive):
        * editing/SelectionController.cpp:
        (WebCore::SelectionController::focusedOrActiveStateChanged):
        (WebCore::SelectionController::updateSecureKeyboardEntryIfActive):
        (WebCore::SelectionController::setUseSecureKeyboardEntry):
        * editing/SelectionController.h:
        * page/Frame.cpp:
        (WebCore::Frame::setDocument):
        * page/Frame.h:
        * platform/SecureTextInput.cpp: Added.
        (WebCore::enableSecureTextInput):
        (WebCore::disableSecureTextInput):
        * platform/SecureTextInput.h: Added.
        (WebCore::enableSecureTextInput):
        (WebCore::disableSecureTextInput):

Canonical link: https://commits.webkit.org/46970@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@55673 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
eseidel committed Mar 8, 2010
1 parent a4835e5 commit 1ab530c8762169185e631763da5a975fc627e6e6
Showing 12 changed files with 199 additions and 49 deletions.
@@ -1,3 +1,12 @@
2010-03-08 Stuart Morgan <stuartmorgan@chromium.org>

Reviewed by Darin Adler.

Added a new USE definition for secure text mode on the Mac.
https://bugs.webkit.org/show_bug.cgi?id=31265

* wtf/Platform.h:

2010-03-08 Jian Li <jianli@chromium.org>

Reviewed by Dmitry Titov.
@@ -579,10 +579,15 @@
#define HAVE_RUNLOOP_TIMER 1
#endif /* PLATFORM(MAC) && !PLATFORM(IPHONE) */

#if PLATFORM(MAC)
#define WTF_USE_CARBON_SECURE_INPUT_MODE 1
#endif

#if PLATFORM(CHROMIUM) && OS(DARWIN)
#define WTF_PLATFORM_CF 1
#define WTF_USE_PTHREADS 1
#define HAVE_PTHREAD_RWLOCK 1
#define WTF_USE_CARBON_SECURE_INPUT_MODE 1
#endif

#if PLATFORM(QT) && OS(DARWIN)
@@ -1,3 +1,34 @@
2010-03-08 Stuart Morgan <stuartmorgan@chromium.org>

Reviewed by Darin Adler.

Move the details of secure text mode into WebCore/platform.
Move the higher-level logic for secure text mode from Frame
to SelectionController.

https://bugs.webkit.org/show_bug.cgi?id=31265

No new tests: no functional changes.

* WebCore.gypi:
* WebCore.xcodeproj/project.pbxproj:
* dom/Document.cpp:
(WebCore::Document::setUseSecureKeyboardEntryWhenActive):
* editing/SelectionController.cpp:
(WebCore::SelectionController::focusedOrActiveStateChanged):
(WebCore::SelectionController::updateSecureKeyboardEntryIfActive):
(WebCore::SelectionController::setUseSecureKeyboardEntry):
* editing/SelectionController.h:
* page/Frame.cpp:
(WebCore::Frame::setDocument):
* page/Frame.h:
* platform/SecureTextInput.cpp: Added.
(WebCore::enableSecureTextInput):
(WebCore::disableSecureTextInput):
* platform/SecureTextInput.h: Added.
(WebCore::enableSecureTextInput):
(WebCore::disableSecureTextInput):

2010-03-08 Brady Eidson <beidson@apple.com>

Reviewed by Anders Carlsson.
@@ -2860,6 +2860,8 @@
'platform/ScrollbarThemeComposite.cpp',
'platform/ScrollbarThemeComposite.h',
'platform/SearchPopupMenu.h',
'platform/SecureTextInput.cpp',
'platform/SecureTextInput.h',
'platform/SharedBuffer.cpp',
'platform/SharedBuffer.h',
'platform/SharedTimer.h',
@@ -680,6 +680,8 @@
3390CA550FFC157B00921962 /* NotificationCenter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3390CA510FFC157B00921962 /* NotificationCenter.cpp */; };
3390CA560FFC157B00921962 /* NotificationCenter.h in Headers */ = {isa = PBXBuildFile; fileRef = 3390CA520FFC157B00921962 /* NotificationCenter.h */; };
3390CA580FFC157B00921962 /* NotificationContents.h in Headers */ = {isa = PBXBuildFile; fileRef = 3390CA540FFC157B00921962 /* NotificationContents.h */; };
33C0CCD4112C5E6200CE057D /* SecureTextInput.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33C0CCD2112C5E6200CE057D /* SecureTextInput.cpp */; };
33C0CCD5112C5E6200CE057D /* SecureTextInput.h in Headers */ = {isa = PBXBuildFile; fileRef = 33C0CCD3112C5E6200CE057D /* SecureTextInput.h */; };
371F4F400D25B9AF00ECE0D5 /* FontData.h in Headers */ = {isa = PBXBuildFile; fileRef = 371F4F3E0D25B9AF00ECE0D5 /* FontData.h */; settings = {ATTRIBUTES = (Private, ); }; };
371F4F410D25B9AF00ECE0D5 /* FontData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 371F4F3F0D25B9AF00ECE0D5 /* FontData.cpp */; };
371F4FFC0D25E7F300ECE0D5 /* SegmentedFontData.h in Headers */ = {isa = PBXBuildFile; fileRef = 371F4FFA0D25E7F300ECE0D5 /* SegmentedFontData.h */; };
@@ -6051,6 +6053,8 @@
3390CA520FFC157B00921962 /* NotificationCenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NotificationCenter.h; path = notifications/NotificationCenter.h; sourceTree = "<group>"; };
3390CA530FFC157B00921962 /* NotificationCenter.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = NotificationCenter.idl; path = notifications/NotificationCenter.idl; sourceTree = "<group>"; };
3390CA540FFC157B00921962 /* NotificationContents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NotificationContents.h; path = notifications/NotificationContents.h; sourceTree = "<group>"; };
33C0CCD2112C5E6200CE057D /* SecureTextInput.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SecureTextInput.cpp; sourceTree = "<group>"; };
33C0CCD3112C5E6200CE057D /* SecureTextInput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecureTextInput.h; sourceTree = "<group>"; };
371F4F3E0D25B9AF00ECE0D5 /* FontData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontData.h; sourceTree = "<group>"; };
371F4F3F0D25B9AF00ECE0D5 /* FontData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontData.cpp; sourceTree = "<group>"; };
371F4FFA0D25E7F300ECE0D5 /* SegmentedFontData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SegmentedFontData.h; sourceTree = "<group>"; };
@@ -15319,6 +15323,8 @@
BC2441C30E8B65D00055320F /* ScrollView.cpp */,
BC6D6E2509AF943500F59759 /* ScrollView.h */,
AB7170880B3118080017123E /* SearchPopupMenu.h */,
33C0CCD2112C5E6200CE057D /* SecureTextInput.cpp */,
33C0CCD3112C5E6200CE057D /* SecureTextInput.h */,
1A4A954B0B4EDCCB002D8C3C /* SharedBuffer.cpp */,
1A4A954C0B4EDCCB002D8C3C /* SharedBuffer.h */,
93309EA0099EB78C0056E581 /* SharedTimer.h */,
@@ -18645,6 +18651,7 @@
931BCC611124DFCB00BE70DD /* MediaCanStartListener.h in Headers */,
9F2A322C1125A0A2003C3056 /* JavaScriptProfile.h in Headers */,
9F2A322E1125A0A2003C3056 /* JavaScriptProfileNode.h in Headers */,
33C0CCD5112C5E6200CE057D /* SecureTextInput.h in Headers */,
7AFD4A8B1131C2760035B883 /* ScriptBreakpoint.h in Headers */,
7AFD4FF4113277B60035B883 /* ScriptDebugListener.h in Headers */,
E169803D1133542D00894115 /* CRuntimeObject.h in Headers */,
@@ -20846,6 +20853,7 @@
76FF17E311235673001D61B5 /* PluginViewNone.cpp in Sources */,
9F2A322B1125A0A2003C3056 /* JavaScriptProfile.cpp in Sources */,
9F2A322D1125A0A2003C3056 /* JavaScriptProfileNode.cpp in Sources */,
33C0CCD4112C5E6200CE057D /* SecureTextInput.cpp in Sources */,
6E21C6C01126338500A7BE02 /* GraphicsContext3D.cpp in Sources */,
6E21C6C21126339900A7BE02 /* GraphicsContext3DCG.cpp in Sources */,
E16980491133644700894115 /* CRuntimeObject.cpp in Sources */,
@@ -4380,7 +4380,7 @@ void Document::setUseSecureKeyboardEntryWhenActive(bool usesSecureKeyboard)
return;

m_useSecureKeyboardEntryWhenActive = usesSecureKeyboard;
m_frame->updateSecureKeyboardEntryIfActive();
m_frame->selection()->updateSecureKeyboardEntryIfActive();
}

bool Document::useSecureKeyboardEntryWhenActive() const
@@ -47,6 +47,7 @@
#include "Range.h"
#include "RenderTheme.h"
#include "RenderView.h"
#include "SecureTextInput.h"
#include "Settings.h"
#include "TextIterator.h"
#include "TypingCommand.h"
@@ -1321,14 +1322,28 @@ void SelectionController::focusedOrActiveStateChanged()

// Secure keyboard entry is set by the active frame.
if (m_frame->document()->useSecureKeyboardEntryWhenActive())
m_frame->setUseSecureKeyboardEntry(activeAndFocused);
setUseSecureKeyboardEntry(activeAndFocused);
}

void SelectionController::pageActivationChanged()
{
focusedOrActiveStateChanged();
}

void SelectionController::updateSecureKeyboardEntryIfActive()
{
if (m_frame->document() && isFocusedAndActive())
setUseSecureKeyboardEntry(m_frame->document()->useSecureKeyboardEntryWhenActive());
}

void SelectionController::setUseSecureKeyboardEntry(bool enable)
{
if (enable)
enableSecureTextInput();
else
disableSecureTextInput();
}

void SelectionController::setFocused(bool flag)
{
if (m_focused == flag)
@@ -131,6 +131,8 @@ class SelectionController : public Noncopyable {
// Painting.
void updateAppearance();

void updateSecureKeyboardEntryIfActive();

#ifndef NDEBUG
void formatForDebugger(char* buffer, unsigned length) const;
void showTreeForThis() const;
@@ -169,6 +171,8 @@ class SelectionController : public Noncopyable {

void caretBlinkTimerFired(Timer<SelectionController>*);

void setUseSecureKeyboardEntry(bool);

Frame* m_frame;

int m_xPosForVerticalArrowNavigation;
@@ -84,10 +84,6 @@
#include <wtf/RefCountedLeakCounter.h>
#include <wtf/StdLibExtras.h>

#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
#import <Carbon/Carbon.h>
#endif

#if USE(JSC)
#include "JSDOMWindowShell.h"
#include "runtime_root.h"
@@ -281,8 +277,7 @@ void Frame::setDocument(PassRefPtr<Document> newDoc)
}

m_doc = newDoc;
if (m_doc && selection()->isFocusedAndActive())
setUseSecureKeyboardEntry(m_doc->useSecureKeyboardEntryWhenActive());
selection()->updateSecureKeyboardEntryIfActive();

if (m_doc && !m_doc->attached())
m_doc->attach();
@@ -842,43 +837,6 @@ bool Frame::isContentEditable() const
return m_doc->inDesignMode();
}

#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
const short enableRomanKeyboardsOnly = -23;
#endif
void Frame::setUseSecureKeyboardEntry(bool enable)
{
#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
if (enable == IsSecureEventInputEnabled())
return;
if (enable) {
EnableSecureEventInput();
#ifdef BUILDING_ON_TIGER
KeyScript(enableRomanKeyboardsOnly);
#else
// WebKit substitutes nil for input context when in password field, which corresponds to null TSMDocument. So, there is
// no need to call TSMGetActiveDocument(), which may return an incorrect result when selection hasn't been yet updated
// after focusing a node.
CFArrayRef inputSources = TISCreateASCIICapableInputSourceList();
TSMSetDocumentProperty(0, kTSMDocumentEnabledInputSourcesPropertyTag, sizeof(CFArrayRef), &inputSources);
CFRelease(inputSources);
#endif
} else {
DisableSecureEventInput();
#ifdef BUILDING_ON_TIGER
KeyScript(smKeyEnableKybds);
#else
TSMRemoveDocumentProperty(0, kTSMDocumentEnabledInputSourcesPropertyTag);
#endif
}
#endif
}

void Frame::updateSecureKeyboardEntryIfActive()
{
if (selection()->isFocusedAndActive())
setUseSecureKeyboardEntry(m_doc->useSecureKeyboardEntryWhenActive());
}

CSSMutableStyleDeclaration *Frame::typingStyle() const
{
return m_typingStyle.get();
@@ -244,8 +244,6 @@ namespace WebCore {

bool isContentEditable() const; // if true, everything in frame is editable

void updateSecureKeyboardEntryIfActive();

CSSMutableStyleDeclaration* typingStyle() const;
void setTypingStyle(CSSMutableStyleDeclaration*);
void clearTypingStyle();
@@ -259,8 +257,6 @@ namespace WebCore {
void revealSelection(const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, bool revealExtent = false);
void setSelectionFromNone();

void setUseSecureKeyboardEntry(bool);

SelectionController* dragCaretController() const;

String searchForLabelsAboveCell(RegularExpression*, HTMLTableCellElement*, size_t* resultDistanceFromStartOfCell);
@@ -0,0 +1,72 @@
/*
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "config.h"
#include "SecureTextInput.h"

#if USE(CARBON_SECURE_INPUT_MODE)
#import <Carbon/Carbon.h>
#endif

namespace WebCore {

#if USE(CARBON_SECURE_INPUT_MODE)

#ifdef BUILDING_ON_TIGER
const short enableRomanKeyboardsOnly = -23;
#endif

void enableSecureTextInput()
{
if (IsSecureEventInputEnabled())
return;
EnableSecureEventInput();
#ifdef BUILDING_ON_TIGER
KeyScript(enableRomanKeyboardsOnly);
#else
// WebKit substitutes nil for input context when in password field, which corresponds to null TSMDocument. So, there is
// no need to call TSMGetActiveDocument(), which may return an incorrect result when selection hasn't been yet updated
// after focusing a node.
CFArrayRef inputSources = TISCreateASCIICapableInputSourceList();
TSMSetDocumentProperty(0, kTSMDocumentEnabledInputSourcesPropertyTag, sizeof(CFArrayRef), &inputSources);
CFRelease(inputSources);
#endif
}

void disableSecureTextInput()
{
if (!IsSecureEventInputEnabled())
return;
DisableSecureEventInput();
#ifdef BUILDING_ON_TIGER
KeyScript(smKeyEnableKybds);
#else
TSMRemoveDocumentProperty(0, kTSMDocumentEnabledInputSourcesPropertyTag);
#endif
}

#endif // USE(CARBON_SECURE_INPUT_MODE)

} // namespace WebCore
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2009, Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef SecureTextInput_h
#define SecureTextInput_h

#include <wtf/Platform.h>

namespace WebCore {

// Once enableSecureTextInput is called, secure text input mode is set until
// disableSecureTextInput has been called.
void enableSecureTextInput();
void disableSecureTextInput();

#if !USE(CARBON_SECURE_INPUT_MODE)
inline void enableSecureTextInput() { }
inline void disableSecureTextInput() { }
#endif

} // namespace WebCore

#endif // SecureTextInput_h

0 comments on commit 1ab530c

Please sign in to comment.