| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/loadtimes_extension_bindings.h" | 5 #include "chrome/renderer/loadtimes_extension_bindings.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "content/public/renderer/document_state.h" | 10 #include "content/public/renderer/document_state.h" |
| 11 #include "net/http/http_response_info.h" | 11 #include "net/http/http_response_info.h" |
| 12 #include "third_party/WebKit/public/web/WebFrame.h" | 12 #include "third_party/WebKit/public/web/WebFrame.h" |
| 13 #include "v8/include/v8.h" | 13 #include "v8/include/v8.h" |
| 14 | 14 |
| 15 using WebKit::WebDataSource; | 15 using blink::WebDataSource; |
| 16 using WebKit::WebFrame; | 16 using blink::WebFrame; |
| 17 using WebKit::WebNavigationType; | 17 using blink::WebNavigationType; |
| 18 using content::DocumentState; | 18 using content::DocumentState; |
| 19 | 19 |
| 20 // Values for CSI "tran" property | 20 // Values for CSI "tran" property |
| 21 const int kTransitionLink = 0; | 21 const int kTransitionLink = 0; |
| 22 const int kTransitionForwardBack = 6; | 22 const int kTransitionForwardBack = 6; |
| 23 const int kTransitionOther = 15; | 23 const int kTransitionOther = 15; |
| 24 const int kTransitionReload = 16; | 24 const int kTransitionReload = 16; |
| 25 | 25 |
| 26 namespace extensions_v8 { | 26 namespace extensions_v8 { |
| 27 | 27 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 57 if (name->Equals(v8::String::New("GetLoadTimes"))) { | 57 if (name->Equals(v8::String::New("GetLoadTimes"))) { |
| 58 return v8::FunctionTemplate::New(GetLoadTimes); | 58 return v8::FunctionTemplate::New(GetLoadTimes); |
| 59 } else if (name->Equals(v8::String::New("GetCSI"))) { | 59 } else if (name->Equals(v8::String::New("GetCSI"))) { |
| 60 return v8::FunctionTemplate::New(GetCSI); | 60 return v8::FunctionTemplate::New(GetCSI); |
| 61 } | 61 } |
| 62 return v8::Handle<v8::FunctionTemplate>(); | 62 return v8::Handle<v8::FunctionTemplate>(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 static const char* GetNavigationType(WebNavigationType nav_type) { | 65 static const char* GetNavigationType(WebNavigationType nav_type) { |
| 66 switch (nav_type) { | 66 switch (nav_type) { |
| 67 case WebKit::WebNavigationTypeLinkClicked: | 67 case blink::WebNavigationTypeLinkClicked: |
| 68 return "LinkClicked"; | 68 return "LinkClicked"; |
| 69 case WebKit::WebNavigationTypeFormSubmitted: | 69 case blink::WebNavigationTypeFormSubmitted: |
| 70 return "FormSubmitted"; | 70 return "FormSubmitted"; |
| 71 case WebKit::WebNavigationTypeBackForward: | 71 case blink::WebNavigationTypeBackForward: |
| 72 return "BackForward"; | 72 return "BackForward"; |
| 73 case WebKit::WebNavigationTypeReload: | 73 case blink::WebNavigationTypeReload: |
| 74 return "Reload"; | 74 return "Reload"; |
| 75 case WebKit::WebNavigationTypeFormResubmitted: | 75 case blink::WebNavigationTypeFormResubmitted: |
| 76 return "Resubmitted"; | 76 return "Resubmitted"; |
| 77 case WebKit::WebNavigationTypeOther: | 77 case blink::WebNavigationTypeOther: |
| 78 return "Other"; | 78 return "Other"; |
| 79 } | 79 } |
| 80 return ""; | 80 return ""; |
| 81 } | 81 } |
| 82 | 82 |
| 83 static int GetCSITransitionType(WebNavigationType nav_type) { | 83 static int GetCSITransitionType(WebNavigationType nav_type) { |
| 84 switch (nav_type) { | 84 switch (nav_type) { |
| 85 case WebKit::WebNavigationTypeLinkClicked: | 85 case blink::WebNavigationTypeLinkClicked: |
| 86 case WebKit::WebNavigationTypeFormSubmitted: | 86 case blink::WebNavigationTypeFormSubmitted: |
| 87 case WebKit::WebNavigationTypeFormResubmitted: | 87 case blink::WebNavigationTypeFormResubmitted: |
| 88 return kTransitionLink; | 88 return kTransitionLink; |
| 89 case WebKit::WebNavigationTypeBackForward: | 89 case blink::WebNavigationTypeBackForward: |
| 90 return kTransitionForwardBack; | 90 return kTransitionForwardBack; |
| 91 case WebKit::WebNavigationTypeReload: | 91 case blink::WebNavigationTypeReload: |
| 92 return kTransitionReload; | 92 return kTransitionReload; |
| 93 case WebKit::WebNavigationTypeOther: | 93 case blink::WebNavigationTypeOther: |
| 94 return kTransitionOther; | 94 return kTransitionOther; |
| 95 } | 95 } |
| 96 return kTransitionOther; | 96 return kTransitionOther; |
| 97 } | 97 } |
| 98 | 98 |
| 99 static void GetLoadTimes(const v8::FunctionCallbackInfo<v8::Value>& args) { | 99 static void GetLoadTimes(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 100 WebFrame* frame = WebFrame::frameForCurrentContext(); | 100 WebFrame* frame = WebFrame::frameForCurrentContext(); |
| 101 if (frame) { | 101 if (frame) { |
| 102 WebDataSource* data_source = frame->dataSource(); | 102 WebDataSource* data_source = frame->dataSource(); |
| 103 if (data_source) { | 103 if (data_source) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 args.GetReturnValue().SetNull(); | 190 args.GetReturnValue().SetNull(); |
| 191 return; | 191 return; |
| 192 } | 192 } |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 v8::Extension* LoadTimesExtension::Get() { | 195 v8::Extension* LoadTimesExtension::Get() { |
| 196 return new LoadTimesExtensionWrapper(); | 196 return new LoadTimesExtensionWrapper(); |
| 197 } | 197 } |
| 198 | 198 |
| 199 } // namespace extensions_v8 | 199 } // namespace extensions_v8 |
| OLD | NEW |