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

Side by Side Diff: Source/core/frame/Location.h

Issue 879423003: Move Location to DOMWindow (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase, #include cleanup Created 5 years, 10 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
« no previous file with comments | « Source/core/frame/LocalDOMWindow.cpp ('k') | Source/core/frame/Location.cpp » ('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, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2010 Apple 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 22 matching lines...) Expand all
33 #include "core/dom/DOMStringList.h" 33 #include "core/dom/DOMStringList.h"
34 #include "core/frame/DOMWindowProperty.h" 34 #include "core/frame/DOMWindowProperty.h"
35 #include "wtf/PassRefPtr.h" 35 #include "wtf/PassRefPtr.h"
36 #include "wtf/RefCounted.h" 36 #include "wtf/RefCounted.h"
37 #include "wtf/text/WTFString.h" 37 #include "wtf/text/WTFString.h"
38 38
39 namespace blink { 39 namespace blink {
40 40
41 class LocalDOMWindow; 41 class LocalDOMWindow;
42 class ExceptionState; 42 class ExceptionState;
43 class LocalFrame; 43 class Frame;
44 class KURL; 44 class KURL;
45 45
46 class Location final : public RefCountedWillBeGarbageCollected<Location>, public ScriptWrappable, public DOMWindowProperty { 46 // This class corresponds to the JS Location API, which is the only DOM API besi des Window that is operable
47 // in a RemoteFrame. Rather than making DOMWindowProperty support RemoteFrames a nd generating a lot
48 // code churn, Location is implemented as a one-off with some custom lifetime ma nagement code. Namely,
49 // it needs a manual call to reset() from DOMWindow::reset() to ensure it doesn' t retain a stale Frame pointer.
50 class Location final : public RefCountedWillBeGarbageCollected<Location>, public ScriptWrappable {
47 DEFINE_WRAPPERTYPEINFO(); 51 DEFINE_WRAPPERTYPEINFO();
48 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Location);
49 public: 52 public:
50 static PassRefPtrWillBeRawPtr<Location> create(LocalFrame* frame) 53 static PassRefPtrWillBeRawPtr<Location> create(Frame* frame)
51 { 54 {
52 return adoptRefWillBeNoop(new Location(frame)); 55 return adoptRefWillBeNoop(new Location(frame));
53 } 56 }
54 57
58 Frame* frame() const { return m_frame.get(); }
59 void reset() { m_frame = nullptr; }
60
55 void setHref(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&); 61 void setHref(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&);
56 String href() const; 62 String href() const;
57 63
58 void assign(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, co nst String&); 64 void assign(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, co nst String&);
59 void replace(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&); 65 void replace(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&);
60 void reload(LocalDOMWindow* callingWindow); 66 void reload(LocalDOMWindow* callingWindow);
61 67
62 void setProtocol(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindo w, const String&, ExceptionState&); 68 void setProtocol(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindo w, const String&, ExceptionState&);
63 String protocol() const; 69 String protocol() const;
64 void setHost(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&); 70 void setHost(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&);
65 String host() const; 71 String host() const;
66 void setHostname(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindo w, const String&); 72 void setHostname(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindo w, const String&);
67 String hostname() const; 73 String hostname() const;
68 void setPort(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&); 74 void setPort(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&);
69 String port() const; 75 String port() const;
70 void setPathname(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindo w, const String&); 76 void setPathname(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindo w, const String&);
71 String pathname() const; 77 String pathname() const;
72 void setSearch(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, const String&); 78 void setSearch(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, const String&);
73 String search() const; 79 String search() const;
74 void setHash(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&); 80 void setHash(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&);
75 String hash() const; 81 String hash() const;
76 String origin() const; 82 String origin() const;
77 83
78 PassRefPtrWillBeRawPtr<DOMStringList> ancestorOrigins() const; 84 PassRefPtrWillBeRawPtr<DOMStringList> ancestorOrigins() const;
79 85
80 virtual void trace(Visitor*) override; 86 virtual void trace(Visitor*);
81 87
82 private: 88 private:
83 explicit Location(LocalFrame*); 89 explicit Location(Frame*);
84 90
85 enum class SetLocation { Normal, ReplaceThisFrame }; 91 enum class SetLocation { Normal, ReplaceThisFrame };
86 void setLocation(const String&, LocalDOMWindow* callingWindow, LocalDOMWindo w* enteredWindow, SetLocation = SetLocation::Normal); 92 void setLocation(const String&, LocalDOMWindow* callingWindow, LocalDOMWindo w* enteredWindow, SetLocation = SetLocation::Normal);
87 93
88 const KURL& url() const; 94 const KURL& url() const;
95
96 RawPtrWillBeMember<Frame> m_frame;
89 }; 97 };
90 98
91 } // namespace blink 99 } // namespace blink
92 100
93 #endif // Location_h 101 #endif // Location_h
OLDNEW
« no previous file with comments | « Source/core/frame/LocalDOMWindow.cpp ('k') | Source/core/frame/Location.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698