9a7685110689091b857d14f5956672a3517be5b1
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / events / HashChangeEvent.h
1 /*
2  * Copyright (C) 2010 Apple Inc. All rights reserved.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  *
19  */
20
21 #ifndef HashChangeEvent_h
22 #define HashChangeEvent_h
23
24 #include "core/events/Event.h"
25
26 namespace blink {
27
28 struct HashChangeEventInit : public EventInit {
29     HashChangeEventInit()
30     {
31     };
32
33     String oldURL;
34     String newURL;
35 };
36
37 class HashChangeEvent FINAL : public Event {
38 public:
39     static PassRefPtrWillBeRawPtr<HashChangeEvent> create()
40     {
41         return adoptRefWillBeNoop(new HashChangeEvent);
42     }
43
44     static PassRefPtrWillBeRawPtr<HashChangeEvent> create(const String& oldURL, const String& newURL)
45     {
46         return adoptRefWillBeNoop(new HashChangeEvent(oldURL, newURL));
47     }
48
49     static PassRefPtrWillBeRawPtr<HashChangeEvent> create(const AtomicString& type, const HashChangeEventInit& initializer)
50     {
51         return adoptRefWillBeNoop(new HashChangeEvent(type, initializer));
52     }
53
54     void initHashChangeEvent(const AtomicString& eventType, bool canBubble, bool cancelable, const String& oldURL, const String& newURL)
55     {
56         if (dispatched())
57             return;
58
59         initEvent(eventType, canBubble, cancelable);
60
61         m_oldURL = oldURL;
62         m_newURL = newURL;
63     }
64
65     const String& oldURL() const { return m_oldURL; }
66     const String& newURL() const { return m_newURL; }
67
68     virtual const AtomicString& interfaceName() const OVERRIDE { return EventNames::HashChangeEvent; }
69
70     virtual void trace(Visitor* visitor) OVERRIDE { Event::trace(visitor); }
71
72 private:
73     HashChangeEvent()
74     {
75         ScriptWrappable::init(this);
76     }
77
78     HashChangeEvent(const String& oldURL, const String& newURL)
79         : Event(EventTypeNames::hashchange, false, false)
80         , m_oldURL(oldURL)
81         , m_newURL(newURL)
82     {
83         ScriptWrappable::init(this);
84     }
85
86     HashChangeEvent(const AtomicString& type, const HashChangeEventInit& initializer)
87         : Event(type, initializer)
88         , m_oldURL(initializer.oldURL)
89         , m_newURL(initializer.newURL)
90     {
91         ScriptWrappable::init(this);
92     }
93
94     String m_oldURL;
95     String m_newURL;
96 };
97
98 } // namespace blink
99
100 #endif // HashChangeEvent_h