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/browser/extensions/api/history/history_api.h" | 5 #include "chrome/browser/extensions/api/history/history_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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 break; | 161 break; |
162 default: | 162 default: |
163 NOTREACHED(); | 163 NOTREACHED(); |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 void HistoryEventRouter::HistoryUrlVisited( | 167 void HistoryEventRouter::HistoryUrlVisited( |
168 Profile* profile, | 168 Profile* profile, |
169 const history::URLVisitedDetails* details) { | 169 const history::URLVisitedDetails* details) { |
170 scoped_ptr<HistoryItem> history_item = GetHistoryItem(details->row); | 170 scoped_ptr<HistoryItem> history_item = GetHistoryItem(details->row); |
171 scoped_ptr<ListValue> args = OnVisited::Create(*history_item); | 171 scoped_ptr<base::ListValue> args = OnVisited::Create(*history_item); |
172 | 172 |
173 DispatchEvent(profile, kOnVisited, args.Pass()); | 173 DispatchEvent(profile, kOnVisited, args.Pass()); |
174 } | 174 } |
175 | 175 |
176 void HistoryEventRouter::HistoryUrlsRemoved( | 176 void HistoryEventRouter::HistoryUrlsRemoved( |
177 Profile* profile, | 177 Profile* profile, |
178 const history::URLsDeletedDetails* details) { | 178 const history::URLsDeletedDetails* details) { |
179 OnVisitRemoved::Removed removed; | 179 OnVisitRemoved::Removed removed; |
180 removed.all_history = details->all_history; | 180 removed.all_history = details->all_history; |
181 | 181 |
182 std::vector<std::string>* urls = new std::vector<std::string>(); | 182 std::vector<std::string>* urls = new std::vector<std::string>(); |
183 for (history::URLRows::const_iterator iterator = details->rows.begin(); | 183 for (history::URLRows::const_iterator iterator = details->rows.begin(); |
184 iterator != details->rows.end(); ++iterator) { | 184 iterator != details->rows.end(); ++iterator) { |
185 urls->push_back(iterator->url().spec()); | 185 urls->push_back(iterator->url().spec()); |
186 } | 186 } |
187 removed.urls.reset(urls); | 187 removed.urls.reset(urls); |
188 | 188 |
189 scoped_ptr<ListValue> args = OnVisitRemoved::Create(removed); | 189 scoped_ptr<base::ListValue> args = OnVisitRemoved::Create(removed); |
190 DispatchEvent(profile, kOnVisitRemoved, args.Pass()); | 190 DispatchEvent(profile, kOnVisitRemoved, args.Pass()); |
191 } | 191 } |
192 | 192 |
193 void HistoryEventRouter::DispatchEvent( | 193 void HistoryEventRouter::DispatchEvent( |
194 Profile* profile, | 194 Profile* profile, |
195 const char* event_name, | 195 const char* event_name, |
196 scoped_ptr<ListValue> event_args) { | 196 scoped_ptr<base::ListValue> event_args) { |
197 if (profile && extensions::ExtensionSystem::Get(profile)->event_router()) { | 197 if (profile && extensions::ExtensionSystem::Get(profile)->event_router()) { |
198 scoped_ptr<extensions::Event> event(new extensions::Event( | 198 scoped_ptr<extensions::Event> event(new extensions::Event( |
199 event_name, event_args.Pass())); | 199 event_name, event_args.Pass())); |
200 event->restrict_to_profile = profile; | 200 event->restrict_to_profile = profile; |
201 extensions::ExtensionSystem::Get(profile)->event_router()-> | 201 extensions::ExtensionSystem::Get(profile)->event_router()-> |
202 BroadcastEvent(event.Pass()); | 202 BroadcastEvent(event.Pass()); |
203 } | 203 } |
204 } | 204 } |
205 | 205 |
206 HistoryAPI::HistoryAPI(Profile* profile) : profile_(profile) { | 206 HistoryAPI::HistoryAPI(Profile* profile) : profile_(profile) { |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 &task_tracker_); | 496 &task_tracker_); |
497 | 497 |
498 return true; | 498 return true; |
499 } | 499 } |
500 | 500 |
501 void HistoryDeleteAllFunction::DeleteComplete() { | 501 void HistoryDeleteAllFunction::DeleteComplete() { |
502 SendAsyncResponse(); | 502 SendAsyncResponse(); |
503 } | 503 } |
504 | 504 |
505 } // namespace extensions | 505 } // namespace extensions |
OLD | NEW |