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

Side by Side Diff: chrome/browser/sync/glue/extension_change_processor.cc

Issue 5968009: Change extension unload notification to indicate updates.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/sync/glue/extension_change_processor.h" 5 #include "chrome/browser/sync/glue/extension_change_processor.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 void ExtensionChangeProcessor::Observe(NotificationType type, 42 void ExtensionChangeProcessor::Observe(NotificationType type,
43 const NotificationSource& source, 43 const NotificationSource& source,
44 const NotificationDetails& details) { 44 const NotificationDetails& details) {
45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
46 DCHECK(running()); 46 DCHECK(running());
47 DCHECK(profile_); 47 DCHECK(profile_);
48 if ((type != NotificationType::EXTENSION_INSTALLED) && 48 if ((type != NotificationType::EXTENSION_INSTALLED) &&
49 (type != NotificationType::EXTENSION_UNINSTALLED) && 49 (type != NotificationType::EXTENSION_UNINSTALLED) &&
50 (type != NotificationType::EXTENSION_LOADED) && 50 (type != NotificationType::EXTENSION_LOADED) &&
51 (type != NotificationType::EXTENSION_UPDATE_DISABLED) && 51 (type != NotificationType::EXTENSION_UPDATE_DISABLED) &&
52 (type != NotificationType::EXTENSION_UNLOADED) && 52 (type != NotificationType::EXTENSION_UNLOADED)) {
53 (type != NotificationType::EXTENSION_UNLOADED_DISABLED)) {
54 LOG(DFATAL) << "Received unexpected notification of type " 53 LOG(DFATAL) << "Received unexpected notification of type "
55 << type.value; 54 << type.value;
56 return; 55 return;
57 } 56 }
58 57
59 DCHECK_EQ(Source<Profile>(source).ptr(), profile_); 58 DCHECK_EQ(Source<Profile>(source).ptr(), profile_);
60 if (type == NotificationType::EXTENSION_UNINSTALLED) { 59 if (type == NotificationType::EXTENSION_UNINSTALLED) {
61 const UninstalledExtensionInfo* uninstalled_extension_info = 60 const UninstalledExtensionInfo* uninstalled_extension_info =
62 Details<UninstalledExtensionInfo>(details).ptr(); 61 Details<UninstalledExtensionInfo>(details).ptr();
63 CHECK(uninstalled_extension_info); 62 CHECK(uninstalled_extension_info);
64 if (traits_.should_handle_extension_uninstall( 63 if (traits_.should_handle_extension_uninstall(
65 *uninstalled_extension_info)) { 64 *uninstalled_extension_info)) {
66 const std::string& id = uninstalled_extension_info->extension_id; 65 const std::string& id = uninstalled_extension_info->extension_id;
67 VLOG(1) << "Removing server data for uninstalled extension " << id 66 VLOG(1) << "Removing server data for uninstalled extension " << id
68 << " of type " << uninstalled_extension_info->extension_type; 67 << " of type " << uninstalled_extension_info->extension_type;
69 RemoveServerData(traits_, id, profile_->GetProfileSyncService()); 68 RemoveServerData(traits_, id, profile_->GetProfileSyncService());
70 } 69 }
71 } else { 70 } else {
72 const Extension* extension = Details<const Extension>(details).ptr(); 71 const Extension* extension = NULL;
72 if (type == NotificationType::EXTENSION_UNLOADED) {
73 extension = Details<UnloadedExtensionInfo>(details)->extension;
74 } else {
75 extension = Details<const Extension>(details).ptr();
76 }
73 CHECK(extension); 77 CHECK(extension);
74 VLOG(1) << "Updating server data for extension " << extension->id() 78 VLOG(1) << "Updating server data for extension " << extension->id()
75 << " (notification type = " << type.value << ")"; 79 << " (notification type = " << type.value << ")";
76 if (!traits_.is_valid_and_syncable(*extension)) { 80 if (!traits_.is_valid_and_syncable(*extension)) {
77 return; 81 return;
78 } 82 }
79 std::string error; 83 std::string error;
80 if (!UpdateServerData(traits_, *extension, 84 if (!UpdateServerData(traits_, *extension,
81 profile_->GetProfileSyncService(), &error)) { 85 profile_->GetProfileSyncService(), &error)) {
82 error_handler()->OnUnrecoverableError(FROM_HERE, error); 86 error_handler()->OnUnrecoverableError(FROM_HERE, error);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 Source<Profile>(profile_)); 174 Source<Profile>(profile_));
171 // Despite the name, this notification is exactly like 175 // Despite the name, this notification is exactly like
172 // EXTENSION_LOADED but with an initial state of DISABLED. 176 // EXTENSION_LOADED but with an initial state of DISABLED.
173 notification_registrar_.Add( 177 notification_registrar_.Add(
174 this, NotificationType::EXTENSION_UPDATE_DISABLED, 178 this, NotificationType::EXTENSION_UPDATE_DISABLED,
175 Source<Profile>(profile_)); 179 Source<Profile>(profile_));
176 180
177 notification_registrar_.Add( 181 notification_registrar_.Add(
178 this, NotificationType::EXTENSION_UNLOADED, 182 this, NotificationType::EXTENSION_UNLOADED,
179 Source<Profile>(profile_)); 183 Source<Profile>(profile_));
180 notification_registrar_.Add(
181 this, NotificationType::EXTENSION_UNLOADED_DISABLED,
182 Source<Profile>(profile_));
183 } 184 }
184 185
185 void ExtensionChangeProcessor::StopObserving() { 186 void ExtensionChangeProcessor::StopObserving() {
186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 187 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
187 DCHECK(profile_); 188 DCHECK(profile_);
188 VLOG(1) << "Unobserving all notifications"; 189 VLOG(1) << "Unobserving all notifications";
189 notification_registrar_.RemoveAll(); 190 notification_registrar_.RemoveAll();
190 } 191 }
191 192
192 } // namespace browser_sync 193 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698