| 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 // Implements the Chrome Extensions WebNavigation API. | 5 // Implements the Chrome Extensions WebNavigation API. |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_helper
s.h" | 7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_helper
s.h" |
| 8 | 8 |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 dict->SetInteger(keys::kTabIdKey, ExtensionTabUtil::GetTabId(web_contents)); | 95 dict->SetInteger(keys::kTabIdKey, ExtensionTabUtil::GetTabId(web_contents)); |
| 96 dict->SetString(keys::kUrlKey, url.spec()); | 96 dict->SetString(keys::kUrlKey, url.spec()); |
| 97 dict->SetInteger(keys::kProcessIdKey, | 97 dict->SetInteger(keys::kProcessIdKey, |
| 98 web_contents->GetRenderViewHost()->GetProcess()->GetID()); | 98 web_contents->GetRenderViewHost()->GetProcess()->GetID()); |
| 99 dict->SetInteger(keys::kFrameIdKey, GetFrameId(is_main_frame, frame_id)); | 99 dict->SetInteger(keys::kFrameIdKey, GetFrameId(is_main_frame, frame_id)); |
| 100 dict->SetString( | 100 dict->SetString( |
| 101 keys::kTransitionTypeKey, | 101 keys::kTransitionTypeKey, |
| 102 content::PageTransitionGetCoreTransitionString(transition_type)); | 102 content::PageTransitionGetCoreTransitionString(transition_type)); |
| 103 base::ListValue* qualifiers = new base::ListValue(); | 103 base::ListValue* qualifiers = new base::ListValue(); |
| 104 if (transition_type & content::PAGE_TRANSITION_CLIENT_REDIRECT) | 104 if (transition_type & content::PAGE_TRANSITION_CLIENT_REDIRECT) |
| 105 qualifiers->Append(Value::CreateStringValue("client_redirect")); | 105 qualifiers->Append(new base::StringValue("client_redirect")); |
| 106 if (transition_type & content::PAGE_TRANSITION_SERVER_REDIRECT) | 106 if (transition_type & content::PAGE_TRANSITION_SERVER_REDIRECT) |
| 107 qualifiers->Append(Value::CreateStringValue("server_redirect")); | 107 qualifiers->Append(new base::StringValue("server_redirect")); |
| 108 if (transition_type & content::PAGE_TRANSITION_FORWARD_BACK) | 108 if (transition_type & content::PAGE_TRANSITION_FORWARD_BACK) |
| 109 qualifiers->Append(Value::CreateStringValue("forward_back")); | 109 qualifiers->Append(new base::StringValue("forward_back")); |
| 110 if (transition_type & content::PAGE_TRANSITION_FROM_ADDRESS_BAR) | 110 if (transition_type & content::PAGE_TRANSITION_FROM_ADDRESS_BAR) |
| 111 qualifiers->Append(Value::CreateStringValue("from_address_bar")); | 111 qualifiers->Append(new base::StringValue("from_address_bar")); |
| 112 dict->Set(keys::kTransitionQualifiersKey, qualifiers); | 112 dict->Set(keys::kTransitionQualifiersKey, qualifiers); |
| 113 dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); | 113 dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); |
| 114 args->Append(dict); | 114 args->Append(dict); |
| 115 | 115 |
| 116 DispatchEvent(web_contents->GetBrowserContext(), event_name, args.Pass(), | 116 DispatchEvent(web_contents->GetBrowserContext(), event_name, args.Pass(), |
| 117 url); | 117 url); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // Constructs and dispatches an onDOMContentLoaded event. | 120 // Constructs and dispatches an onDOMContentLoaded event. |
| 121 void DispatchOnDOMContentLoaded(content::WebContents* web_contents, | 121 void DispatchOnDOMContentLoaded(content::WebContents* web_contents, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 ExtensionTabUtil::GetTabId(new_web_contents)); | 226 ExtensionTabUtil::GetTabId(new_web_contents)); |
| 227 dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); | 227 dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); |
| 228 args->Append(dict); | 228 args->Append(dict); |
| 229 | 229 |
| 230 DispatchEvent(browser_context, keys::kOnTabReplaced, args.Pass(), GURL()); | 230 DispatchEvent(browser_context, keys::kOnTabReplaced, args.Pass(), GURL()); |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace web_navigation_api_helpers | 233 } // namespace web_navigation_api_helpers |
| 234 | 234 |
| 235 } // namespace extensions | 235 } // namespace extensions |
| OLD | NEW |