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

Side by Side Diff: chrome/browser/notifications/sync_notifier/synced_notification_app_info.cc

Issue 193773003: Turn on and use the AppInfo data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Turn on app info: another windows fix Created 6 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/sync_notifier/synced_notification_app_inf o.h" 5 #include "chrome/browser/notifications/sync_notifier/synced_notification_app_inf o.h"
6 6
7 #include "chrome/browser/notifications/sync_notifier/image_holder.h"
8 #include "chrome/browser/notifications/sync_notifier/synced_notification_app_inf o_service.h"
9 #include "chrome/browser/profiles/profile.h"
7 #include "sync/api/sync_data.h" 10 #include "sync/api/sync_data.h"
8 #include "sync/protocol/synced_notification_app_info_specifics.pb.h" 11 #include "sync/protocol/synced_notification_app_info_specifics.pb.h"
9 12
10 namespace notifier { 13 namespace notifier {
11 14
12 SyncedNotificationAppInfo::SyncedNotificationAppInfo( 15 SyncedNotificationAppInfo::SyncedNotificationAppInfo(
13 const std::string& settings_display_name) 16 Profile* const profile,
14 : settings_display_name_(settings_display_name) {} 17 const std::string& settings_display_name,
18 SyncedNotificationAppInfoService* synced_notification_app_info_service)
19 : profile_(profile),
20 settings_display_name_(settings_display_name),
21 synced_notification_app_info_service_(
22 synced_notification_app_info_service) {}
15 23
16 SyncedNotificationAppInfo::~SyncedNotificationAppInfo() {} 24 SyncedNotificationAppInfo::~SyncedNotificationAppInfo() {}
17 25
26
27 void SyncedNotificationAppInfo::SetSettingsURLs(
dewittj 2014/03/25 22:31:14 nit: declaration order and definition order should
Pete Williamson 2014/03/26 18:12:55 I'll do that in the next changelist so you can mor
28 const GURL& settings_low_dpi, const GURL& settings_high_dpi) {
29 settings_holder_.reset(new ImageHolder(settings_low_dpi,
30 settings_high_dpi,
31 profile_,
32 this));
33 }
34
35 void SyncedNotificationAppInfo::SetMonochromeURLs(
36 const GURL& monochrome_low_dpi, const GURL& monochrome_high_dpi) {
37 monochrome_holder_.reset(new ImageHolder(monochrome_low_dpi,
38 monochrome_high_dpi,
39 profile_,
40 this));
41 }
42
43 void SyncedNotificationAppInfo::SetWelcomeURLs(
44 const GURL& welcome_low_dpi, const GURL& welcome_high_dpi) {
45 welcome_holder_.reset(new ImageHolder(welcome_low_dpi,
46 welcome_high_dpi,
47 profile_,
48 this));
49 }
50
51 GURL SyncedNotificationAppInfo::settings_icon_url() {
52 if (settings_holder_ != NULL)
53 return settings_holder_->low_dpi_url();
54 else
55 return GURL();
56 }
57
18 bool SyncedNotificationAppInfo::HasAppId(const std::string& app_id) { 58 bool SyncedNotificationAppInfo::HasAppId(const std::string& app_id) {
19 std::vector<std::string>::iterator it; 59 std::vector<std::string>::iterator it;
20 60
21 for (it = app_ids_.begin(); it != app_ids_.end(); ++it) { 61 for (it = app_ids_.begin(); it != app_ids_.end(); ++it) {
22 if (app_id == *it) 62 if (app_id == *it)
23 return true; 63 return true;
24 } 64 }
25 65
26 return false; 66 return false;
27 } 67 }
28 68
29 void SyncedNotificationAppInfo::AddAppId(const std::string& app_id) { 69 void SyncedNotificationAppInfo::AddAppId(const std::string& app_id) {
30 if (HasAppId(app_id)) 70 if (HasAppId(app_id))
31 return; 71 return;
32 72
33 app_ids_.push_back(app_id); 73 app_ids_.push_back(app_id);
34 } 74 }
35 75
36 void SyncedNotificationAppInfo::RemoveAppId(const std::string& app_id) { 76 void SyncedNotificationAppInfo::RemoveAppId(const std::string& app_id) {
37 std::vector<std::string>::iterator it; 77 std::vector<std::string>::iterator it;
38 78
39 for (it = app_ids_.begin(); it != app_ids_.end(); ++it) { 79 for (it = app_ids_.begin(); it != app_ids_.end(); ++it) {
40 if (app_id == *it) { 80 if (app_id == *it) {
41 app_ids_.erase(it); 81 app_ids_.erase(it);
42 return; 82 return;
43 } 83 }
44 } 84 }
45 } 85 }
46 86
47 void SyncedNotificationAppInfo::GetAppIdList( 87 std::vector<std::string> SyncedNotificationAppInfo::GetAppIdList() {
48 std::vector<std::string>* app_id_list) { 88 std::vector<std::string> app_id_list;
49 if (app_id_list == NULL)
50 return;
51
52 std::vector<std::string>::iterator it; 89 std::vector<std::string>::iterator it;
53 for (it = app_ids_.begin(); it != app_ids_.end(); ++it) { 90 for (it = app_ids_.begin(); it != app_ids_.end(); ++it) {
54 app_id_list->push_back(*it); 91 app_id_list.push_back(*it);
92 }
93
94 return app_id_list;
95 }
96
97 // TODO: rename, queing now happens elsewhere.
98 // Fill up the queue of bitmaps to fetch.
99 void SyncedNotificationAppInfo::QueueBitmapFetchJobs() {
100 // If there are no bitmaps to fetch, call OnBitmapFetchesDone.
101 if (AreAllBitmapsFetched()) {
102 synced_notification_app_info_service_->OnBitmapFetchesDone(
103 added_app_ids_, removed_app_ids_);
104 DVLOG(2) << "AppInfo object with no bitmaps, we should add some. "
105 << this->settings_display_name_;
106 return;
55 } 107 }
56 } 108 }
57 109
110 // Start the bitmap fetching. When it is complete, the callback
111 // will notify the ChromeNotifierService of the new app info availablity.
112 void SyncedNotificationAppInfo::StartBitmapFetch() {
113 if (settings_holder_.get() != NULL)
114 settings_holder_->StartFetch();
115 if (monochrome_holder_.get() != NULL)
116 monochrome_holder_->StartFetch();
117 if (welcome_holder_.get() != NULL)
118 welcome_holder_->StartFetch();
119 }
120
121 // Method inherited from ImageHolderDelegate
122 void SyncedNotificationAppInfo::OnFetchComplete() {
123 if (AreAllBitmapsFetched()) {
124 if (synced_notification_app_info_service_ != NULL) {
125 synced_notification_app_info_service_->OnBitmapFetchesDone(
126 added_app_ids_, removed_app_ids_);
127 }
128 }
129 }
130
131 // Check to see if we have responses for all the bitmaps we got a URL for.
132 bool SyncedNotificationAppInfo::AreAllBitmapsFetched() {
133 bool done =
134 (settings_holder_.get() == NULL || settings_holder_->IsFetchingDone()) &&
135 (monochrome_holder_.get() == NULL ||
136 monochrome_holder_->IsFetchingDone()) &&
137 (welcome_holder_.get() == NULL || welcome_holder_->IsFetchingDone());
138
139 return done;
140 }
141
142 message_center::NotifierId SyncedNotificationAppInfo::GetNotifierId() {
143 return message_center::NotifierId(
144 message_center::NotifierId::SYNCED_NOTIFICATION_SERVICE,
145 settings_display_name_);
146 }
147
58 } // namespace notifier 148 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698