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

Side by Side Diff: chrome/browser/notifications/message_center_settings_controller.cc

Issue 2383893002: Optimize startup time of notification code by removing unused code. (Closed)
Patch Set: Created 4 years, 2 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 | ui/message_center/cocoa/settings_controller_unittest.mm » ('j') | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/notifications/message_center_settings_controller.h" 5 #include "chrome/browser/notifications/message_center_settings_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 22 matching lines...) Expand all
33 #include "chrome/browser/notifications/system_component_notifier_source_chromeos .h" 33 #include "chrome/browser/notifications/system_component_notifier_source_chromeos .h"
34 #endif 34 #endif
35 35
36 using message_center::Notifier; 36 using message_center::Notifier;
37 using message_center::NotifierId; 37 using message_center::NotifierId;
38 38
39 namespace message_center { 39 namespace message_center {
40 40
41 class ProfileNotifierGroup : public message_center::NotifierGroup { 41 class ProfileNotifierGroup : public message_center::NotifierGroup {
42 public: 42 public:
43 ProfileNotifierGroup(const gfx::Image& icon, 43 ProfileNotifierGroup(const base::string16& display_name,
44 const base::string16& display_name,
45 const base::string16& login_info, 44 const base::string16& login_info,
46 const base::FilePath& profile_path); 45 const base::FilePath& profile_path);
47 ProfileNotifierGroup(const gfx::Image& icon, 46 ProfileNotifierGroup(const base::string16& display_name,
48 const base::string16& display_name,
49 const base::string16& login_info, 47 const base::string16& login_info,
50 Profile* profile); 48 Profile* profile);
51 virtual ~ProfileNotifierGroup() {} 49 virtual ~ProfileNotifierGroup() {}
52 50
53 Profile* profile() const { return profile_; } 51 Profile* profile() const { return profile_; }
54 52
55 private: 53 private:
56 Profile* profile_; 54 Profile* profile_;
57 }; 55 };
58 56
59 ProfileNotifierGroup::ProfileNotifierGroup(const gfx::Image& icon, 57 ProfileNotifierGroup::ProfileNotifierGroup(const base::string16& display_name,
60 const base::string16& display_name,
61 const base::string16& login_info, 58 const base::string16& login_info,
62 const base::FilePath& profile_path) 59 const base::FilePath& profile_path)
63 : message_center::NotifierGroup(icon, display_name, login_info), 60 : message_center::NotifierGroup(display_name, login_info), profile_(NULL) {
64 profile_(NULL) {
65 // Try to get the profile 61 // Try to get the profile
66 profile_ = 62 profile_ =
67 g_browser_process->profile_manager()->GetProfileByPath(profile_path); 63 g_browser_process->profile_manager()->GetProfileByPath(profile_path);
68 } 64 }
69 65
70 ProfileNotifierGroup::ProfileNotifierGroup(const gfx::Image& icon, 66 ProfileNotifierGroup::ProfileNotifierGroup(const base::string16& display_name,
71 const base::string16& display_name,
72 const base::string16& login_info, 67 const base::string16& login_info,
73 Profile* profile) 68 Profile* profile)
74 : message_center::NotifierGroup(icon, display_name, login_info), 69 : message_center::NotifierGroup(display_name, login_info),
75 profile_(profile) { 70 profile_(profile) {}
76 }
77 71
78 } // namespace message_center 72 } // namespace message_center
79 73
80 namespace { 74 namespace {
81 75
82 class NotifierComparator { 76 class NotifierComparator {
83 public: 77 public:
84 explicit NotifierComparator(icu::Collator* collator) : collator_(collator) {} 78 explicit NotifierComparator(icu::Collator* collator) : collator_(collator) {}
85 79
86 bool operator() (Notifier* n1, Notifier* n2) { 80 bool operator() (Notifier* n1, Notifier* n2) {
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 if (!user_manager->IsLoggedInAsGuest()) 344 if (!user_manager->IsLoggedInAsGuest())
351 return; 345 return;
352 346
353 user_manager::User* user = user_manager->GetActiveUser(); 347 user_manager::User* user = user_manager->GetActiveUser();
354 Profile* profile = 348 Profile* profile =
355 chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe(user); 349 chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe(user);
356 DCHECK(profile); 350 DCHECK(profile);
357 351
358 std::unique_ptr<message_center::ProfileNotifierGroup> group( 352 std::unique_ptr<message_center::ProfileNotifierGroup> group(
359 new message_center::ProfileNotifierGroup( 353 new message_center::ProfileNotifierGroup(
360 gfx::Image(user->GetImage()), user->GetDisplayName(), 354 user->GetDisplayName(), user->GetDisplayName(), profile));
361 user->GetDisplayName(), profile));
362 355
363 notifier_groups_.push_back(std::move(group)); 356 notifier_groups_.push_back(std::move(group));
364 DispatchNotifierGroupChanged(); 357 DispatchNotifierGroupChanged();
365 } 358 }
366 #endif 359 #endif
367 360
368 void MessageCenterSettingsController::RebuildNotifierGroups(bool notify) { 361 void MessageCenterSettingsController::RebuildNotifierGroups(bool notify) {
369 notifier_groups_.clear(); 362 notifier_groups_.clear();
370 current_notifier_group_ = 0; 363 current_notifier_group_ = 0;
371 364
372 std::vector<ProfileAttributesEntry*> entries = 365 std::vector<ProfileAttributesEntry*> entries =
373 profile_attributes_storage_.GetAllProfilesAttributes(); 366 profile_attributes_storage_.GetAllProfilesAttributes();
374 for (auto* entry : entries) { 367 for (auto* entry : entries) {
375 std::unique_ptr<message_center::ProfileNotifierGroup> group( 368 std::unique_ptr<message_center::ProfileNotifierGroup> group(
376 new message_center::ProfileNotifierGroup( 369 new message_center::ProfileNotifierGroup(
377 entry->GetAvatarIcon(), entry->GetName(), entry->GetUserName(), 370 entry->GetName(), entry->GetUserName(), entry->GetPath()));
378 entry->GetPath()));
379 if (group->profile() == NULL) 371 if (group->profile() == NULL)
380 continue; 372 continue;
381 373
382 #if defined(OS_CHROMEOS) 374 #if defined(OS_CHROMEOS)
383 // Allows the active user only. 375 // Allows the active user only.
384 // UserManager may not exist in some tests. 376 // UserManager may not exist in some tests.
385 if (user_manager::UserManager::IsInitialized()) { 377 if (user_manager::UserManager::IsInitialized()) {
386 user_manager::UserManager* user_manager = 378 user_manager::UserManager* user_manager =
387 user_manager::UserManager::Get(); 379 user_manager::UserManager::Get();
388 if (chromeos::ProfileHelper::Get()->GetUserByProfile(group->profile()) != 380 if (chromeos::ProfileHelper::Get()->GetUserByProfile(group->profile()) !=
(...skipping 28 matching lines...) Expand all
417 FROM_HERE, 409 FROM_HERE,
418 base::Bind( 410 base::Bind(
419 &MessageCenterSettingsController::CreateNotifierGroupForGuestLogin, 411 &MessageCenterSettingsController::CreateNotifierGroupForGuestLogin,
420 weak_factory_.GetWeakPtr())); 412 weak_factory_.GetWeakPtr()));
421 } 413 }
422 #endif 414 #endif
423 415
424 if (notify) 416 if (notify)
425 DispatchNotifierGroupChanged(); 417 DispatchNotifierGroupChanged();
426 } 418 }
OLDNEW
« no previous file with comments | « no previous file | ui/message_center/cocoa/settings_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698