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

Unified Diff: Source/WebKit/chromium/src/InbandTextTrackPrivateImpl.cpp

Issue 13968007: Create WebInbandTextTrack and WebInbandTextTrackClient (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: Source/WebKit/chromium/src/InbandTextTrackPrivateImpl.cpp
diff --git a/Source/WebKit/chromium/src/InbandTextTrackPrivateImpl.cpp b/Source/WebKit/chromium/src/InbandTextTrackPrivateImpl.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a451dc722150b74734152c2d48283a62a9d80b8d
--- /dev/null
+++ b/Source/WebKit/chromium/src/InbandTextTrackPrivateImpl.cpp
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#define WEBKIT_IMPLEMENTATION 1
+#include <wtf/ExportMacros.h>
+#include "InbandTextTrackPrivateImpl.h"
+#include "WebInbandTextTrack.h"
+#define WEBKIT_IMPLEMENTATION 1
+#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
+
+namespace WebKit {
+
+InbandTextTrackPrivateImpl::InbandTextTrackPrivateImpl(
+ WebInbandTextTrack* track)
acolwell GONE FROM CHROMIUM 2013/04/17 00:13:56 nit: Blink style doesn't require 80-col wrap for s
Matthew Heaney (Chromium) 2013/04/18 23:15:42 Done.
+ : m_track(track)
+{
acolwell GONE FROM CHROMIUM 2013/04/17 00:13:56 nit: Add ASSERT(!m_track); here and remove all m_t
Matthew Heaney (Chromium) 2013/04/18 23:15:42 Done.
+}
+
+InbandTextTrackPrivateImpl::~InbandTextTrackPrivateImpl()
+{
+}
+
+void InbandTextTrackPrivateImpl::setClient(
+ WebCore::InbandTextTrackPrivateClient* client)
+{
+ if (!m_track)
+ return;
+
+ // TODO(matthewjheaney): not sure what to do here yet
acolwell GONE FROM CHROMIUM 2013/04/17 00:13:56 At a minimum you need to store the pointer so clie
Matthew Heaney (Chromium) 2013/04/18 23:15:42 Done.
Matthew Heaney (Chromium) 2013/04/18 23:15:42 Done.
+ //m_track->setClient(client);
+ // For now:
+ m_track->setClient(NULL);
+}
+
+WebCore::InbandTextTrackPrivateClient* InbandTextTrackPrivateImpl::client()
+{
+ if (!m_track)
+ return NULL; // TODO(matthewjheaney): is this really correct?
+
+ // TODO(matthewjheaney): not sure how to handle this yet
+ //return m_track->client();
+ // For now:
+ return NULL;
acolwell GONE FROM CHROMIUM 2013/04/17 00:13:56 Update to return m_client.
Matthew Heaney (Chromium) 2013/04/18 23:15:42 Done.
+}
+
+void InbandTextTrackPrivateImpl::setMode(Mode mode)
+{
+ if (!m_track)
+ return;
+
+ const WebInbandTextTrack::Mode mode_map[] =
+ {
+ WebInbandTextTrack::Disabled,
+ WebInbandTextTrack::Hidden,
+ WebInbandTextTrack::Showing
+ };
+
+ const WebInbandTextTrack::Mode m = mode_map[mode];
acolwell GONE FROM CHROMIUM 2013/04/17 00:13:56 nit: Use a static_cast and there is no need for a
Matthew Heaney (Chromium) 2013/04/18 23:15:42 Done.
Matthew Heaney (Chromium) 2013/04/18 23:15:42 Done.
+
+ m_track->setMode(m);
+}
+
+WebCore::InbandTextTrackPrivate::Mode InbandTextTrackPrivateImpl::mode() const
+{
+ typedef WebCore::InbandTextTrackPrivate T;
+
+ if (!m_track)
+ // TODO(matthewjheaney): correct?
+ return T::Disabled;
+
+ const T::Mode mode_map[] =
+ {
+ T::Disabled,
+ T::Hidden,
+ T::Showing
+ };
+
+ const T::Mode result = mode_map[m_track->mode()];
acolwell GONE FROM CHROMIUM 2013/04/17 00:13:56 ditto
Matthew Heaney (Chromium) 2013/04/18 23:15:42 Done.
+ return result;
+}
+
+WebCore::InbandTextTrackPrivate::Kind InbandTextTrackPrivateImpl::kind() const
+{
+ typedef WebCore::InbandTextTrackPrivate T;
+
+ if (!m_track)
+ // TODO(matthewjheaney): correct?
+ return T::None;
+
+ const T::Kind kind_map[] =
+ {
+ T::Subtitles,
+ T::Captions,
+ T::Descriptions,
+ T::Chapters,
+ T::Metadata,
+ T::None
+ };
+
+ const T::Kind result = kind_map[m_track->kind()];
acolwell GONE FROM CHROMIUM 2013/04/17 00:13:56 ditto
Matthew Heaney (Chromium) 2013/04/18 23:15:42 Done.
+ return result;
+}
+
+bool InbandTextTrackPrivateImpl::isClosedCaptions()
+{
+ if (!m_track)
+ return false; // TODO(matthewjheaney): correct value?
+
+ return m_track->isClosedCaptions();
+}
+
+AtomicString InbandTextTrackPrivateImpl::label() const
+{
+ if (!m_track)
+ return AtomicString(); // TODO(matthewjheaney): correct?
+
+ return m_track->label();
+}
+
+AtomicString InbandTextTrackPrivateImpl::language() const
+{
+ if (!m_track)
+ return AtomicString(); // TODO(matthewjheaney): "eng" perhaps?
+
+ return m_track->language();
+}
+
+bool InbandTextTrackPrivateImpl::isDefault() const
+{
+ if (!m_track)
+ return false; // TODO(matthewjheaney): correct?
+
+ return m_track->isDefault();
+}
+
+int InbandTextTrackPrivateImpl::textTrackIndex() const
+{
+ if (!m_track)
+ return 0; // TODO(matthewjheaney): correct?
+
+ return m_track->textTrackIndex();
+}
+
+} // namespace WebKit

Powered by Google App Engine
This is Rietveld 408576698