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/extensions/activity_log.h" | 5 #include "chrome/browser/extensions/activity_log.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
350 if (!IsLogEnabled()) return; | 350 if (!IsLogEnabled()) return; |
351 LogDOMActionInternal(extension, | 351 LogDOMActionInternal(extension, |
352 url, | 352 url, |
353 url_title, | 353 url_title, |
354 api_call, | 354 api_call, |
355 args, | 355 args, |
356 extra, | 356 extra, |
357 DOMAction::MODIFIED); | 357 DOMAction::MODIFIED); |
358 } | 358 } |
359 | 359 |
360 void ActivityLog::LogWebRequestAction(const Extension* extension, | |
361 const GURL& url, | |
362 const std::string& api_call, | |
363 scoped_ptr<DictionaryValue> details, | |
364 const std::string& extra) { | |
365 string16 null_title; | |
366 if (!IsLogEnabled()) return; | |
367 | |
368 if (!log_arguments_) { | |
felt
2013/04/11 21:13:37
just a heads up: if issue 13726026 lands first thi
mvrable
2013/04/11 21:41:26
Thanks for the advance notice; I'll fix this befor
| |
369 DictionaryValue::Iterator details_iterator(*details); | |
370 while (!details_iterator.IsAtEnd()) { | |
371 details->SetBoolean(details_iterator.key(), true); | |
372 details_iterator.Advance(); | |
373 } | |
374 } | |
375 std::string details_string; | |
376 JSONStringValueSerializer serializer(&details_string); | |
377 serializer.SerializeAndOmitBinaryValues(*details); | |
378 | |
379 scoped_refptr<DOMAction> action = new DOMAction( | |
380 extension->id(), | |
381 base::Time::Now(), | |
382 DOMAction::WEBREQUEST, | |
383 url, | |
384 null_title, | |
385 api_call, | |
386 details_string, | |
387 extra); | |
388 ScheduleAndForget(&ActivityDatabase::RecordAction, action); | |
389 | |
390 // Display the action. | |
391 ObserverMap::const_iterator iter = observers_.find(extension); | |
392 if (iter != observers_.end()) { | |
393 iter->second->Notify(&Observer::OnExtensionActivity, | |
394 extension, | |
395 ActivityLog::ACTIVITY_CONTENT_SCRIPT, | |
396 action->PrettyPrintForDebug()); | |
397 } | |
398 if (log_activity_to_stdout_) | |
399 LOG(INFO) << action->PrettyPrintForDebug(); | |
400 } | |
401 | |
360 void ActivityLog::GetActions( | 402 void ActivityLog::GetActions( |
361 const std::string& extension_id, | 403 const std::string& extension_id, |
362 const int day, | 404 const int day, |
363 const base::Callback | 405 const base::Callback |
364 <void(scoped_ptr<std::vector<scoped_refptr<Action> > >)>& callback) { | 406 <void(scoped_ptr<std::vector<scoped_refptr<Action> > >)>& callback) { |
365 if (!db_.get()) return; | 407 if (!db_.get()) return; |
366 BrowserThread::PostTaskAndReplyWithResult( | 408 BrowserThread::PostTaskAndReplyWithResult( |
367 BrowserThread::DB, | 409 BrowserThread::DB, |
368 FROM_HERE, | 410 FROM_HERE, |
369 base::Bind(&ActivityDatabase::GetActions, | 411 base::Bind(&ActivityDatabase::GetActions, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 return "content_script"; | 474 return "content_script"; |
433 case ActivityLog::ACTIVITY_EVENT_DISPATCH: | 475 case ActivityLog::ACTIVITY_EVENT_DISPATCH: |
434 return "event_dispatch"; | 476 return "event_dispatch"; |
435 default: | 477 default: |
436 NOTREACHED(); | 478 NOTREACHED(); |
437 return ""; | 479 return ""; |
438 } | 480 } |
439 } | 481 } |
440 | 482 |
441 } // namespace extensions | 483 } // namespace extensions |
OLD | NEW |