Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: chrome/browser/extensions/activity_log/activity_log.cc

Issue 2326613003: [Extensions] Validate Profile extistence in ActivityLog reporting (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/activity_log.h" 5 #include "chrome/browser/extensions/activity_log/activity_log.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/json/json_string_value_serializer.h" 13 #include "base/json/json_string_value_serializer.h"
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
20 #include "base/threading/thread_checker.h" 20 #include "base/threading/thread_checker.h"
21 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/chrome_notification_types.h" 22 #include "chrome/browser/chrome_notification_types.h"
22 #include "chrome/browser/extensions/activity_log/activity_action_constants.h" 23 #include "chrome/browser/extensions/activity_log/activity_action_constants.h"
23 #include "chrome/browser/extensions/activity_log/counting_policy.h" 24 #include "chrome/browser/extensions/activity_log/counting_policy.h"
24 #include "chrome/browser/extensions/activity_log/fullstream_ui_policy.h" 25 #include "chrome/browser/extensions/activity_log/fullstream_ui_policy.h"
25 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat e_api.h" 26 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat e_api.h"
26 #include "chrome/browser/extensions/extension_tab_util.h" 27 #include "chrome/browser/extensions/extension_tab_util.h"
27 #include "chrome/browser/prerender/prerender_manager.h" 28 #include "chrome/browser/prerender/prerender_manager.h"
28 #include "chrome/browser/prerender/prerender_manager_factory.h" 29 #include "chrome/browser/prerender/prerender_manager_factory.h"
29 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/browser/profiles/profile_manager.h"
30 #include "chrome/browser/ui/browser.h" 32 #include "chrome/browser/ui/browser.h"
31 #include "chrome/common/chrome_constants.h" 33 #include "chrome/common/chrome_constants.h"
32 #include "chrome/common/chrome_switches.h" 34 #include "chrome/common/chrome_switches.h"
33 #include "chrome/common/pref_names.h" 35 #include "chrome/common/pref_names.h"
34 #include "components/syncable_prefs/pref_service_syncable.h" 36 #include "components/syncable_prefs/pref_service_syncable.h"
35 #include "content/public/browser/browser_thread.h" 37 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
37 #include "content/public/browser/notification_source.h" 39 #include "content/public/browser/notification_source.h"
38 #include "content/public/browser/render_process_host.h" 40 #include "content/public/browser/render_process_host.h"
39 #include "content/public/browser/web_contents.h" 41 #include "content/public/browser/web_contents.h"
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 LAZY_INSTANCE_INITIALIZER; 392 LAZY_INSTANCE_INITIALIZER;
391 393
392 // Calls into the ActivityLog to log an api event or function call. 394 // Calls into the ActivityLog to log an api event or function call.
393 // Must be called on the UI thread. 395 // Must be called on the UI thread.
394 void LogApiActivityOnUI(content::BrowserContext* browser_context, 396 void LogApiActivityOnUI(content::BrowserContext* browser_context,
395 const std::string& extension_id, 397 const std::string& extension_id,
396 const std::string& activity_name, 398 const std::string& activity_name,
397 std::unique_ptr<base::ListValue> args, 399 std::unique_ptr<base::ListValue> args,
398 Action::ActionType type) { 400 Action::ActionType type) {
399 DCHECK_CURRENTLY_ON(BrowserThread::UI); 401 DCHECK_CURRENTLY_ON(BrowserThread::UI);
402 // There's a chance that the |browser_context| was deleted some time during
403 // the thread hops.
404 // TODO(devlin): We should probably be doing this more extensively throughout
405 // extensions code.
406 if (g_browser_process->IsShuttingDown() ||
407 !g_browser_process->profile_manager()->IsValidProfile(browser_context)) {
408 return;
409 }
400 ActivityLog* activity_log = ActivityLog::GetInstance(browser_context); 410 ActivityLog* activity_log = ActivityLog::GetInstance(browser_context);
401 if (!activity_log || !activity_log->ShouldLog(extension_id)) 411 if (!activity_log || !activity_log->ShouldLog(extension_id))
402 return; 412 return;
403 scoped_refptr<Action> action = 413 scoped_refptr<Action> action =
404 new Action(extension_id, base::Time::Now(), type, activity_name); 414 new Action(extension_id, base::Time::Now(), type, activity_name);
405 action->set_args(std::move(args)); 415 action->set_args(std::move(args));
406 activity_log->LogAction(action); 416 activity_log->LogAction(action);
407 } 417 }
408 418
409 // Generic thread-safe handler for API calls and events. 419 // Generic thread-safe handler for API calls and events.
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 } 907 }
898 } 908 }
899 909
900 template <> 910 template <>
901 void BrowserContextKeyedAPIFactory<ActivityLog>::DeclareFactoryDependencies() { 911 void BrowserContextKeyedAPIFactory<ActivityLog>::DeclareFactoryDependencies() {
902 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); 912 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
903 DependsOn(ExtensionRegistryFactory::GetInstance()); 913 DependsOn(ExtensionRegistryFactory::GetInstance());
904 } 914 }
905 915
906 } // namespace extensions 916 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698