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

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

Issue 2704133002: Associate Location with DOMWindow instead of Frame. (Closed)
Patch Set: Created 3 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
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 15 matching lines...) Expand all
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #ifndef Location_h 29 #ifndef Location_h
30 #define Location_h 30 #define Location_h
31 31
32 #include "bindings/core/v8/ScriptValue.h" 32 #include "bindings/core/v8/ScriptValue.h"
33 #include "bindings/core/v8/ScriptWrappable.h" 33 #include "bindings/core/v8/ScriptWrappable.h"
34 #include "core/CoreExport.h" 34 #include "core/CoreExport.h"
35 #include "core/dom/DOMStringList.h" 35 #include "core/dom/DOMStringList.h"
36 #include "core/frame/DOMWindow.h"
36 #include "wtf/text/WTFString.h" 37 #include "wtf/text/WTFString.h"
37 38
38 namespace blink { 39 namespace blink {
39 40
41 class Document;
40 class LocalDOMWindow; 42 class LocalDOMWindow;
41 class ExceptionState; 43 class ExceptionState;
42 class Frame;
43 class KURL; 44 class KURL;
44 45
45 // This class corresponds to the JS Location API, which is the only DOM API 46 // This class corresponds to the Location interface. Location is the only
46 // besides Window that is operable in a RemoteFrame. Location needs to be 47 // interface besides Window that is accessible cross-origin and must handle
47 // manually updated in DOMWindow::reset() to ensure it doesn't retain a stale 48 // remote frames.
48 // Frame pointer. 49 //
50 // HTML standard: https://whatwg.org/C/browsers.html#the-location-interface
49 class CORE_EXPORT Location final : public GarbageCollected<Location>, 51 class CORE_EXPORT Location final : public GarbageCollected<Location>,
50 public ScriptWrappable { 52 public ScriptWrappable {
51 DEFINE_WRAPPERTYPEINFO(); 53 DEFINE_WRAPPERTYPEINFO();
52 54
53 public: 55 public:
54 static Location* create(Frame* frame) { return new Location(frame); } 56 static Location* create(DOMWindow* domWindow) {
57 return new Location(domWindow);
58 }
55 59
56 Frame* frame() const { return m_frame.get(); } 60 DOMWindow* window() const { return m_domWindow.get(); }
Yuki 2017/02/20 08:57:46 nit: Document, Frame, ScriptState and ContextLifec
dcheng 2017/02/20 09:22:56 Good point, done.
57 void reset() { m_frame = nullptr; } 61 // TODO(dcheng): Deprecated and will be removed. Do not use in new code!
62 Frame* frame() const { return m_domWindow->frame(); }
58 63
59 void setHref(LocalDOMWindow* currentWindow, 64 void setHref(LocalDOMWindow* currentWindow,
60 LocalDOMWindow* enteredWindow, 65 LocalDOMWindow* enteredWindow,
61 const String&, 66 const String&,
62 ExceptionState&); 67 ExceptionState&);
63 String href() const; 68 String href() const;
64 69
65 void assign(LocalDOMWindow* currentWindow, 70 void assign(LocalDOMWindow* currentWindow,
66 LocalDOMWindow* enteredWindow, 71 LocalDOMWindow* enteredWindow,
67 const String&, 72 const String&,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 118
114 // Just return the |this| object the way the normal valueOf function on the 119 // Just return the |this| object the way the normal valueOf function on the
115 // Object prototype would. The valueOf function is only added to make sure 120 // Object prototype would. The valueOf function is only added to make sure
116 // that it cannot be overwritten on location objects, since that would provide 121 // that it cannot be overwritten on location objects, since that would provide
117 // a hook to change the string conversion behavior of location objects. 122 // a hook to change the string conversion behavior of location objects.
118 ScriptValue valueOf(const ScriptValue& thisObject) { return thisObject; } 123 ScriptValue valueOf(const ScriptValue& thisObject) { return thisObject; }
119 124
120 DECLARE_VIRTUAL_TRACE(); 125 DECLARE_VIRTUAL_TRACE();
121 126
122 private: 127 private:
123 explicit Location(Frame*); 128 explicit Location(DOMWindow*);
129
130 // Note: it is only valid to call this when this is a Location object is for a
Yuki 2017/02/20 08:57:47 maybe typo?: s/is for/for/
dcheng 2017/02/20 09:22:56 Done.
131 // LocalDOMWindow.
132 Document* document() const;
133
134 // Returns true if:
135 // (1) the associated Window is the active Window in the frame
136 // (2) and the frame is attached.
137 bool isAttached() const;
124 138
125 enum class SetLocationPolicy { Normal, ReplaceThisFrame }; 139 enum class SetLocationPolicy { Normal, ReplaceThisFrame };
126 void setLocation(const String&, 140 void setLocation(const String&,
127 LocalDOMWindow* currentWindow, 141 LocalDOMWindow* currentWindow,
128 LocalDOMWindow* enteredWindow, 142 LocalDOMWindow* enteredWindow,
129 ExceptionState* = nullptr, 143 ExceptionState* = nullptr,
130 SetLocationPolicy = SetLocationPolicy::Normal); 144 SetLocationPolicy = SetLocationPolicy::Normal);
131 145
132 const KURL& url() const; 146 const KURL& url() const;
133 147
134 Member<Frame> m_frame; 148 const Member<DOMWindow> m_domWindow;
135 }; 149 };
136 150
137 } // namespace blink 151 } // namespace blink
138 152
139 #endif // Location_h 153 #endif // Location_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698