BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / sync / glue / extensions_activity_monitor.cc
blob9ee6235e589ff19210583beedd64d5d4b5c5c8da
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/sync/glue/extensions_activity_monitor.h"
7 #include "content/public/browser/browser_thread.h"
8 #include "sync/util/extensions_activity.h"
10 #if defined(ENABLE_EXTENSIONS)
11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h"
13 #include "content/public/browser/notification_service.h"
14 #include "extensions/common/extension.h"
15 #endif
17 using content::BrowserThread;
19 namespace browser_sync {
21 ExtensionsActivityMonitor::ExtensionsActivityMonitor()
22 : extensions_activity_(new syncer::ExtensionsActivity()) {
23 DCHECK_CURRENTLY_ON(BrowserThread::UI);
24 // It would be nice if we could specify a Source for each specific function
25 // we wanted to observe, but the actual function objects are allocated on
26 // the fly so there is no reliable object to point to (same problem if we
27 // wanted to use the string name). Thus, we use all sources and filter in
28 // Observe.
29 #if defined(ENABLE_EXTENSIONS)
30 registrar_.Add(this,
31 extensions::NOTIFICATION_EXTENSION_BOOKMARKS_API_INVOKED,
32 content::NotificationService::AllSources());
33 #endif
36 ExtensionsActivityMonitor::~ExtensionsActivityMonitor() {
37 DCHECK_CURRENTLY_ON(BrowserThread::UI);
40 void ExtensionsActivityMonitor::Observe(
41 int type,
42 const content::NotificationSource& source,
43 const content::NotificationDetails& details) {
44 #if defined(ENABLE_EXTENSIONS)
45 DCHECK_CURRENTLY_ON(BrowserThread::UI);
46 DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_BOOKMARKS_API_INVOKED, type);
47 const extensions::Extension* extension =
48 content::Source<const extensions::Extension>(source).ptr();
49 const extensions::BookmarksFunction* f =
50 content::Details<const extensions::BookmarksFunction>(details).ptr();
51 switch (f->histogram_value()) {
52 case extensions::functions::BOOKMARKS_UPDATE:
53 case extensions::functions::BOOKMARKS_MOVE:
54 case extensions::functions::BOOKMARKS_CREATE:
55 case extensions::functions::BOOKMARKS_REMOVETREE:
56 case extensions::functions::BOOKMARKS_REMOVE:
57 extensions_activity_->UpdateRecord(extension->id());
58 break;
59 default:
60 break;
62 #endif
65 const scoped_refptr<syncer::ExtensionsActivity>&
66 ExtensionsActivityMonitor::GetExtensionsActivity() {
67 return extensions_activity_;
70 } // namespace browser_sync