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 #include "chrome/browser/history/history_extension_api.h" | 5 #include "chrome/browser/history/history_extension_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 void HistoryExtensionEventRouter::HistoryUrlVisited( | 128 void HistoryExtensionEventRouter::HistoryUrlVisited( |
129 Profile* profile, | 129 Profile* profile, |
130 const history::URLVisitedDetails* details) { | 130 const history::URLVisitedDetails* details) { |
131 ListValue args; | 131 ListValue args; |
132 DictionaryValue* dict = new DictionaryValue(); | 132 DictionaryValue* dict = new DictionaryValue(); |
133 GetHistoryItemDictionary(details->row, dict); | 133 GetHistoryItemDictionary(details->row, dict); |
134 args.Append(dict); | 134 args.Append(dict); |
135 | 135 |
136 std::string json_args; | 136 std::string json_args; |
137 base::JSONWriter::Write(&args, false, &json_args); | 137 base::JSONWriter::Write(&args, &json_args); |
138 DispatchEvent(profile, kOnVisited, json_args); | 138 DispatchEvent(profile, kOnVisited, json_args); |
139 } | 139 } |
140 | 140 |
141 void HistoryExtensionEventRouter::HistoryUrlsRemoved( | 141 void HistoryExtensionEventRouter::HistoryUrlsRemoved( |
142 Profile* profile, | 142 Profile* profile, |
143 const history::URLsDeletedDetails* details) { | 143 const history::URLsDeletedDetails* details) { |
144 ListValue args; | 144 ListValue args; |
145 DictionaryValue* dict = new DictionaryValue(); | 145 DictionaryValue* dict = new DictionaryValue(); |
146 dict->SetBoolean(kAllHistoryKey, details->all_history); | 146 dict->SetBoolean(kAllHistoryKey, details->all_history); |
147 ListValue* urls = new ListValue(); | 147 ListValue* urls = new ListValue(); |
148 for (std::set<GURL>::const_iterator iterator = details->urls.begin(); | 148 for (std::set<GURL>::const_iterator iterator = details->urls.begin(); |
149 iterator != details->urls.end(); | 149 iterator != details->urls.end(); |
150 ++iterator) { | 150 ++iterator) { |
151 urls->Append(new StringValue(iterator->spec())); | 151 urls->Append(new StringValue(iterator->spec())); |
152 } | 152 } |
153 dict->Set(kUrlsKey, urls); | 153 dict->Set(kUrlsKey, urls); |
154 args.Append(dict); | 154 args.Append(dict); |
155 | 155 |
156 std::string json_args; | 156 std::string json_args; |
157 base::JSONWriter::Write(&args, false, &json_args); | 157 base::JSONWriter::Write(&args, &json_args); |
158 DispatchEvent(profile, kOnVisitRemoved, json_args); | 158 DispatchEvent(profile, kOnVisitRemoved, json_args); |
159 } | 159 } |
160 | 160 |
161 void HistoryExtensionEventRouter::DispatchEvent(Profile* profile, | 161 void HistoryExtensionEventRouter::DispatchEvent(Profile* profile, |
162 const char* event_name, | 162 const char* event_name, |
163 const std::string& json_args) { | 163 const std::string& json_args) { |
164 if (profile && profile->GetExtensionEventRouter()) { | 164 if (profile && profile->GetExtensionEventRouter()) { |
165 profile->GetExtensionEventRouter()->DispatchEventToRenderers( | 165 profile->GetExtensionEventRouter()->DispatchEventToRenderers( |
166 event_name, json_args, profile, GURL()); | 166 event_name, json_args, profile, GURL()); |
167 } | 167 } |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 &cancelable_consumer_, | 393 &cancelable_consumer_, |
394 base::Bind(&DeleteAllHistoryFunction::DeleteComplete, | 394 base::Bind(&DeleteAllHistoryFunction::DeleteComplete, |
395 base::Unretained(this))); | 395 base::Unretained(this))); |
396 | 396 |
397 return true; | 397 return true; |
398 } | 398 } |
399 | 399 |
400 void DeleteAllHistoryFunction::DeleteComplete() { | 400 void DeleteAllHistoryFunction::DeleteComplete() { |
401 SendAsyncResponse(); | 401 SendAsyncResponse(); |
402 } | 402 } |
OLD | NEW |