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

Side by Side Diff: Source/bindings/v8/Dictionary.cpp

Issue 340353006: [webcrypto] Replace KeyAlgorithm interfaces with an Object. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase onto master Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "modules/speech/SpeechRecognitionResultList.h" 57 #include "modules/speech/SpeechRecognitionResultList.h"
58 #include "wtf/MathExtras.h" 58 #include "wtf/MathExtras.h"
59 59
60 namespace WebCore { 60 namespace WebCore {
61 61
62 Dictionary::Dictionary() 62 Dictionary::Dictionary()
63 : m_isolate(0) 63 : m_isolate(0)
64 { 64 {
65 } 65 }
66 66
67 Dictionary::Dictionary(v8::Isolate* isolate)
68 : m_options(v8::Object::New(isolate))
69 , m_isolate(isolate)
70 {
71 }
72
67 Dictionary::Dictionary(const v8::Handle<v8::Value>& options, v8::Isolate* isolat e) 73 Dictionary::Dictionary(const v8::Handle<v8::Value>& options, v8::Isolate* isolat e)
68 : m_options(options) 74 : m_options(options)
69 , m_isolate(isolate) 75 , m_isolate(isolate)
70 { 76 {
71 ASSERT(m_isolate); 77 ASSERT(m_isolate);
72 } 78 }
73 79
74 Dictionary::~Dictionary() 80 Dictionary::~Dictionary()
75 { 81 {
76 } 82 }
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 bool Dictionary::get(const String& key, RefPtr<Headers>& value) const 588 bool Dictionary::get(const String& key, RefPtr<Headers>& value) const
583 { 589 {
584 v8::Local<v8::Value> v8Value; 590 v8::Local<v8::Value> v8Value;
585 if (!getKey(key, v8Value)) 591 if (!getKey(key, v8Value))
586 return false; 592 return false;
587 593
588 value = V8Headers::toNativeWithTypeCheck(m_isolate, v8Value); 594 value = V8Headers::toNativeWithTypeCheck(m_isolate, v8Value);
589 return true; 595 return true;
590 } 596 }
591 597
598 bool Dictionary::set(const String& key, const v8::Handle<v8::Value>& value)
599 {
600 if (isUndefinedOrNull())
601 return false;
602 v8::Local<v8::Object> options = m_options->ToObject();
603 ASSERT(!options.IsEmpty());
604
605 return options->Set(v8String(m_isolate, key), value);
606 }
607
608 bool Dictionary::set(const String& key, const String& value)
609 {
610 return set(key, v8String(m_isolate, value));
611 }
612
613 bool Dictionary::set(const String& key, unsigned value)
614 {
615 return set(key, v8::Integer::NewFromUnsigned(m_isolate, value));
616 }
617
618 bool Dictionary::set(const String& key, const Dictionary& value)
619 {
620 return set(key, value.v8Value());
621 }
622
592 bool Dictionary::convert(ConversionContext& context, const String& key, Dictiona ry& value) const 623 bool Dictionary::convert(ConversionContext& context, const String& key, Dictiona ry& value) const
593 { 624 {
594 ConversionContextScope scope(context); 625 ConversionContextScope scope(context);
595 626
596 v8::Local<v8::Value> v8Value; 627 v8::Local<v8::Value> v8Value;
597 if (!getKey(key, v8Value)) 628 if (!getKey(key, v8Value))
598 return true; 629 return true;
599 630
600 if (v8Value->IsObject()) 631 if (v8Value->IsObject())
601 return get(key, value); 632 return get(key, value);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 788
758 return *this; 789 return *this;
759 } 790 }
760 791
761 void Dictionary::ConversionContext::throwTypeError(const String& detail) 792 void Dictionary::ConversionContext::throwTypeError(const String& detail)
762 { 793 {
763 exceptionState().throwTypeError(detail); 794 exceptionState().throwTypeError(detail);
764 } 795 }
765 796
766 } // namespace WebCore 797 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698