Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_webnavigation_api.h" | 7 #include "chrome/browser/extensions/extension_webnavigation_api.h" |
| 8 | 8 |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 dict->SetInteger(keys::kFrameIdKey, GetFrameId(is_main_frame, frame_id)); | 101 dict->SetInteger(keys::kFrameIdKey, GetFrameId(is_main_frame, frame_id)); |
| 102 dict->SetString(keys::kTransitionTypeKey, | 102 dict->SetString(keys::kTransitionTypeKey, |
| 103 PageTransition::CoreTransitionString(transition_type)); | 103 PageTransition::CoreTransitionString(transition_type)); |
| 104 ListValue* qualifiers = new ListValue(); | 104 ListValue* qualifiers = new ListValue(); |
| 105 if (transition_type & PageTransition::CLIENT_REDIRECT) | 105 if (transition_type & PageTransition::CLIENT_REDIRECT) |
| 106 qualifiers->Append(Value::CreateStringValue("client_redirect")); | 106 qualifiers->Append(Value::CreateStringValue("client_redirect")); |
| 107 if (transition_type & PageTransition::SERVER_REDIRECT) | 107 if (transition_type & PageTransition::SERVER_REDIRECT) |
| 108 qualifiers->Append(Value::CreateStringValue("server_redirect")); | 108 qualifiers->Append(Value::CreateStringValue("server_redirect")); |
| 109 if (transition_type & PageTransition::FORWARD_BACK) | 109 if (transition_type & PageTransition::FORWARD_BACK) |
| 110 qualifiers->Append(Value::CreateStringValue("forward_back")); | 110 qualifiers->Append(Value::CreateStringValue("forward_back")); |
| 111 if (transition_type & PageTransition::FROM_ADDRESS_BAR) | |
| 112 qualifiers->Append(Value::CreateStringValue("from_address_bar")); | |
|
Matt Perry
2011/08/18 00:22:40
This changes the API. It seems like a reasonable c
Peter Kasting
2011/08/18 00:53:39
Sure, will be in next revision.
| |
| 111 dict->Set(keys::kTransitionQualifiersKey, qualifiers); | 113 dict->Set(keys::kTransitionQualifiersKey, qualifiers); |
| 112 dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); | 114 dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); |
| 113 args.Append(dict); | 115 args.Append(dict); |
| 114 | 116 |
| 115 std::string json_args; | 117 std::string json_args; |
| 116 base::JSONWriter::Write(&args, false, &json_args); | 118 base::JSONWriter::Write(&args, false, &json_args); |
| 117 DispatchEvent(tab_contents->browser_context(), keys::kOnCommitted, json_args); | 119 DispatchEvent(tab_contents->browser_context(), keys::kOnCommitted, json_args); |
| 118 } | 120 } |
| 119 | 121 |
| 120 // Constructs and dispatches an onDOMContentLoaded event. | 122 // Constructs and dispatches an onDOMContentLoaded event. |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 624 DictionaryValue* resultDict = new DictionaryValue(); | 626 DictionaryValue* resultDict = new DictionaryValue(); |
| 625 resultDict->SetString( | 627 resultDict->SetString( |
| 626 keys::kUrlKey, | 628 keys::kUrlKey, |
| 627 frame_navigation_state.GetUrl(frame_id).spec()); | 629 frame_navigation_state.GetUrl(frame_id).spec()); |
| 628 resultDict->SetBoolean( | 630 resultDict->SetBoolean( |
| 629 keys::kErrorOccurredKey, | 631 keys::kErrorOccurredKey, |
| 630 frame_navigation_state.GetErrorOccurredInFrame(frame_id)); | 632 frame_navigation_state.GetErrorOccurredInFrame(frame_id)); |
| 631 result_.reset(resultDict); | 633 result_.reset(resultDict); |
| 632 return true; | 634 return true; |
| 633 } | 635 } |
| OLD | NEW |