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

Side by Side Diff: chrome/browser/background/background_application_list_model.cc

Issue 425303002: Move extension notifications to extensions/browser/notification_types.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (extension-notifications) rebase Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
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/background/background_application_list_model.h" 5 #include "chrome/browser/background/background_application_list_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/sha1.h" 10 #include "base/sha1.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/background/background_contents_service.h" 15 #include "chrome/browser/background/background_contents_service.h"
16 #include "chrome/browser/background/background_contents_service_factory.h" 16 #include "chrome/browser/background/background_contents_service_factory.h"
17 #include "chrome/browser/background/background_mode_manager.h" 17 #include "chrome/browser/background/background_mode_manager.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/chrome_notification_types.h" 19 #include "chrome/browser/chrome_notification_types.h"
20 #include "chrome/browser/extensions/extension_service.h" 20 #include "chrome/browser/extensions/extension_service.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/common/extensions/extension_constants.h" 22 #include "chrome/common/extensions/extension_constants.h"
23 #include "content/public/browser/notification_details.h" 23 #include "content/public/browser/notification_details.h"
24 #include "content/public/browser/notification_source.h" 24 #include "content/public/browser/notification_source.h"
25 #include "extensions/browser/extension_prefs.h" 25 #include "extensions/browser/extension_prefs.h"
26 #include "extensions/browser/extension_registry.h" 26 #include "extensions/browser/extension_registry.h"
27 #include "extensions/browser/extension_system.h" 27 #include "extensions/browser/extension_system.h"
28 #include "extensions/browser/extension_util.h" 28 #include "extensions/browser/extension_util.h"
29 #include "extensions/browser/image_loader.h" 29 #include "extensions/browser/image_loader.h"
30 #include "extensions/browser/notification_types.h"
30 #include "extensions/common/extension.h" 31 #include "extensions/common/extension.h"
31 #include "extensions/common/extension_icon_set.h" 32 #include "extensions/common/extension_icon_set.h"
32 #include "extensions/common/extension_resource.h" 33 #include "extensions/common/extension_resource.h"
33 #include "extensions/common/extension_set.h" 34 #include "extensions/common/extension_set.h"
34 #include "extensions/common/manifest_handlers/background_info.h" 35 #include "extensions/common/manifest_handlers/background_info.h"
35 #include "extensions/common/manifest_handlers/icons_handler.h" 36 #include "extensions/common/manifest_handlers/icons_handler.h"
36 #include "extensions/common/permissions/permission_set.h" 37 #include "extensions/common/permissions/permission_set.h"
37 #include "extensions/common/permissions/permissions_data.h" 38 #include "extensions/common/permissions/permissions_data.h"
38 #include "ui/base/l10n/l10n_util_collator.h" 39 #include "ui/base/l10n/l10n_util_collator.h"
39 #include "ui/gfx/image/image.h" 40 #include "ui/gfx/image/image.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 BackgroundApplicationListModel::~BackgroundApplicationListModel() { 173 BackgroundApplicationListModel::~BackgroundApplicationListModel() {
173 STLDeleteContainerPairSecondPointers(applications_.begin(), 174 STLDeleteContainerPairSecondPointers(applications_.begin(),
174 applications_.end()); 175 applications_.end());
175 } 176 }
176 177
177 BackgroundApplicationListModel::BackgroundApplicationListModel(Profile* profile) 178 BackgroundApplicationListModel::BackgroundApplicationListModel(Profile* profile)
178 : profile_(profile), 179 : profile_(profile),
179 ready_(false) { 180 ready_(false) {
180 DCHECK(profile_); 181 DCHECK(profile_);
181 registrar_.Add(this, 182 registrar_.Add(this,
182 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, 183 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
183 content::Source<Profile>(profile)); 184 content::Source<Profile>(profile));
184 registrar_.Add(this, 185 registrar_.Add(this,
185 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, 186 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
186 content::Source<Profile>(profile)); 187 content::Source<Profile>(profile));
187 registrar_.Add(this, 188 registrar_.Add(this,
188 chrome::NOTIFICATION_EXTENSIONS_READY, 189 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
189 content::Source<Profile>(profile)); 190 content::Source<Profile>(profile));
190 registrar_.Add(this, 191 registrar_.Add(this,
191 chrome::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED, 192 extensions::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED,
192 content::Source<Profile>(profile)); 193 content::Source<Profile>(profile));
193 registrar_.Add(this, 194 registrar_.Add(this,
194 chrome::NOTIFICATION_BACKGROUND_CONTENTS_SERVICE_CHANGED, 195 chrome::NOTIFICATION_BACKGROUND_CONTENTS_SERVICE_CHANGED,
195 content::Source<Profile>(profile)); 196 content::Source<Profile>(profile));
196 ExtensionService* service = extensions::ExtensionSystem::Get(profile)-> 197 ExtensionService* service = extensions::ExtensionSystem::Get(profile)->
197 extension_service(); 198 extension_service();
198 if (service && service->is_ready()) { 199 if (service && service->is_ready()) {
199 Update(); 200 Update();
200 ready_ = true; 201 ready_ = true;
201 } 202 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 } 347 }
347 348
348 // Doesn't meet our criteria, so it's not a background app. 349 // Doesn't meet our criteria, so it's not a background app.
349 return false; 350 return false;
350 } 351 }
351 352
352 void BackgroundApplicationListModel::Observe( 353 void BackgroundApplicationListModel::Observe(
353 int type, 354 int type,
354 const content::NotificationSource& source, 355 const content::NotificationSource& source,
355 const content::NotificationDetails& details) { 356 const content::NotificationDetails& details) {
356 if (type == chrome::NOTIFICATION_EXTENSIONS_READY) { 357 if (type == extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED) {
357 Update(); 358 Update();
358 ready_ = true; 359 ready_ = true;
359 return; 360 return;
360 } 361 }
361 ExtensionService* service = extensions::ExtensionSystem::Get(profile_)-> 362 ExtensionService* service = extensions::ExtensionSystem::Get(profile_)->
362 extension_service(); 363 extension_service();
363 if (!service || !service->is_ready()) 364 if (!service || !service->is_ready())
364 return; 365 return;
365 366
366 switch (type) { 367 switch (type) {
367 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: 368 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED:
368 OnExtensionLoaded(content::Details<Extension>(details).ptr()); 369 OnExtensionLoaded(content::Details<Extension>(details).ptr());
369 break; 370 break;
370 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: 371 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED:
371 OnExtensionUnloaded( 372 OnExtensionUnloaded(
372 content::Details<UnloadedExtensionInfo>(details)->extension); 373 content::Details<UnloadedExtensionInfo>(details)->extension);
373 break; 374 break;
374 case chrome::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED: 375 case extensions::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED:
375 OnExtensionPermissionsUpdated( 376 OnExtensionPermissionsUpdated(
376 content::Details<UpdatedExtensionPermissionsInfo>(details)->extension, 377 content::Details<UpdatedExtensionPermissionsInfo>(details)->extension,
377 content::Details<UpdatedExtensionPermissionsInfo>(details)->reason, 378 content::Details<UpdatedExtensionPermissionsInfo>(details)->reason,
378 content::Details<UpdatedExtensionPermissionsInfo>(details)-> 379 content::Details<UpdatedExtensionPermissionsInfo>(details)->
379 permissions); 380 permissions);
380 break; 381 break;
381 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_SERVICE_CHANGED: 382 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_SERVICE_CHANGED:
382 Update(); 383 Update();
383 break; 384 break;
384 default: 385 default:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 (*old_cursor)->name() == (*new_cursor)->name() && 453 (*old_cursor)->name() == (*new_cursor)->name() &&
453 (*old_cursor)->id() == (*new_cursor)->id()) { 454 (*old_cursor)->id() == (*new_cursor)->id()) {
454 ++old_cursor; 455 ++old_cursor;
455 ++new_cursor; 456 ++new_cursor;
456 } 457 }
457 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { 458 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) {
458 extensions_ = extensions; 459 extensions_ = extensions;
459 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_)); 460 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_));
460 } 461 }
461 } 462 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/shortcuts_provider_unittest.cc ('k') | chrome/browser/background/background_contents_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698