OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 17 matching lines...) Expand all Loading... |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "public/web/WebDOMActivityLogger.h" | 31 #include "public/web/WebDOMActivityLogger.h" |
32 | 32 |
33 #include "bindings/core/v8/V8Binding.h" | 33 #include "bindings/core/v8/V8Binding.h" |
34 #include "bindings/core/v8/V8DOMActivityLogger.h" | 34 #include "bindings/core/v8/V8DOMActivityLogger.h" |
35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
36 #include "core/frame/LocalDOMWindow.h" | 36 #include "core/frame/LocalDOMWindow.h" |
37 #include "wtf/PassRefPtr.h" | 37 #include "wtf/PassRefPtr.h" |
| 38 #include "wtf/PtrUtil.h" |
38 #include "wtf/text/WTFString.h" | 39 #include "wtf/text/WTFString.h" |
| 40 #include <memory> |
39 | 41 |
40 namespace blink { | 42 namespace blink { |
41 | 43 |
42 class DOMActivityLoggerContainer : public V8DOMActivityLogger { | 44 class DOMActivityLoggerContainer : public V8DOMActivityLogger { |
43 public: | 45 public: |
44 explicit DOMActivityLoggerContainer(PassOwnPtr<WebDOMActivityLogger> logger) | 46 explicit DOMActivityLoggerContainer(std::unique_ptr<WebDOMActivityLogger> lo
gger) |
45 : m_domActivityLogger(std::move(logger)) | 47 : m_domActivityLogger(std::move(logger)) |
46 { | 48 { |
47 } | 49 } |
48 | 50 |
49 void logGetter(const String& apiName) override | 51 void logGetter(const String& apiName) override |
50 { | 52 { |
51 m_domActivityLogger->logGetter(WebString(apiName), getURL(), getTitle())
; | 53 m_domActivityLogger->logGetter(WebString(apiName), getURL(), getTitle())
; |
52 } | 54 } |
53 | 55 |
54 void logSetter(const String& apiName, const v8::Local<v8::Value>& newValue)
override | 56 void logSetter(const String& apiName, const v8::Local<v8::Value>& newValue)
override |
(...skipping 22 matching lines...) Expand all Loading... |
77 return WebURL(); | 79 return WebURL(); |
78 } | 80 } |
79 | 81 |
80 WebString getTitle() | 82 WebString getTitle() |
81 { | 83 { |
82 if (Document* document = currentDOMWindow(v8::Isolate::GetCurrent())->do
cument()) | 84 if (Document* document = currentDOMWindow(v8::Isolate::GetCurrent())->do
cument()) |
83 return WebString(document->title()); | 85 return WebString(document->title()); |
84 return WebString(); | 86 return WebString(); |
85 } | 87 } |
86 | 88 |
87 OwnPtr<WebDOMActivityLogger> m_domActivityLogger; | 89 std::unique_ptr<WebDOMActivityLogger> m_domActivityLogger; |
88 }; | 90 }; |
89 | 91 |
90 bool hasDOMActivityLogger(int worldId, const WebString& extensionId) | 92 bool hasDOMActivityLogger(int worldId, const WebString& extensionId) |
91 { | 93 { |
92 return V8DOMActivityLogger::activityLogger(worldId, extensionId); | 94 return V8DOMActivityLogger::activityLogger(worldId, extensionId); |
93 } | 95 } |
94 | 96 |
95 void setDOMActivityLogger(int worldId, const WebString& extensionId, WebDOMActiv
ityLogger* logger) | 97 void setDOMActivityLogger(int worldId, const WebString& extensionId, WebDOMActiv
ityLogger* logger) |
96 { | 98 { |
97 DCHECK(logger); | 99 DCHECK(logger); |
98 V8DOMActivityLogger::setActivityLogger(worldId, extensionId, adoptPtr(new DO
MActivityLoggerContainer(adoptPtr(logger)))); | 100 V8DOMActivityLogger::setActivityLogger(worldId, extensionId, wrapUnique(new
DOMActivityLoggerContainer(wrapUnique(logger)))); |
99 } | 101 } |
100 | 102 |
101 } // namespace blink | 103 } // namespace blink |
OLD | NEW |