| OLD | NEW |
| 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 // The SyncedNotificationAppInfoService brings down read only metadata from the | 5 // The SyncedNotificationAppInfoService brings down read only metadata from the |
| 6 // sync server with information about the services sending synced notifications. | 6 // sync server with information about the services sending synced notifications. |
| 7 | 7 |
| 8 #include "chrome/browser/notifications/sync_notifier/synced_notification_app_inf
o_service.h" | 8 #include "chrome/browser/notifications/sync_notifier/synced_notification_app_inf
o_service.h" |
| 9 | 9 |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 // Static Method. Convert from a server protobuf to our internal format. | 238 // Static Method. Convert from a server protobuf to our internal format. |
| 239 scoped_ptr<SyncedNotificationAppInfo> | 239 scoped_ptr<SyncedNotificationAppInfo> |
| 240 SyncedNotificationAppInfoService::CreateSyncedNotificationAppInfoFromProtobuf( | 240 SyncedNotificationAppInfoService::CreateSyncedNotificationAppInfoFromProtobuf( |
| 241 const sync_pb::SyncedNotificationAppInfo& server_app_info) { | 241 const sync_pb::SyncedNotificationAppInfo& server_app_info) { |
| 242 | 242 |
| 243 // Check for mandatory fields in the sync_data object. | 243 // Check for mandatory fields in the sync_data object. |
| 244 std::string display_name; | 244 std::string display_name; |
| 245 if (server_app_info.has_settings_display_name()) { | 245 if (server_app_info.has_settings_display_name()) { |
| 246 display_name = server_app_info.settings_display_name(); | 246 display_name = server_app_info.settings_display_name(); |
| 247 } | 247 } |
| 248 |
| 248 scoped_ptr<SyncedNotificationAppInfo> app_info; | 249 scoped_ptr<SyncedNotificationAppInfo> app_info; |
| 249 if (display_name.length() == 0) | 250 if (display_name.length() == 0) |
| 250 return app_info.Pass(); | 251 return app_info.Pass(); |
| 251 | 252 |
| 252 // Create a new app info object based on the supplied protobuf. | 253 // Create a new app info object based on the supplied protobuf. |
| 253 app_info.reset(new SyncedNotificationAppInfo(profile_, display_name, this)); | 254 app_info.reset(new SyncedNotificationAppInfo(profile_, display_name, this)); |
| 254 | 255 |
| 256 // This URL is used whenever the user clicks on the body of the app's welcome |
| 257 // notification. |
| 258 if (server_app_info.has_info_url()) { |
| 259 app_info->SetWelcomeLinkUrl(GURL(server_app_info.info_url())); |
| 260 } |
| 261 |
| 255 // TODO(petewil): Eventually we will add the monochrome icon here, and we may | 262 // TODO(petewil): Eventually we will add the monochrome icon here, and we may |
| 256 // need to fetch the correct url for the current DPI. | 263 // need to fetch the correct url for the current DPI. |
| 257 // Add the icon URL, if any. | 264 // Add the icon URL, if any. |
| 258 if (server_app_info.has_icon()) { | 265 if (server_app_info.has_icon()) { |
| 259 std::string icon_url = server_app_info.icon().url(); | 266 std::string icon_url = server_app_info.icon().url(); |
| 260 // Set the URLs for the low and high DPI images. | 267 // Set the URLs for the low and high DPI images. |
| 261 // TODO(petewil): Since the high DPI image is not available yet, we just | 268 // TODO(petewil): Since the high DPI image is not available yet, we just |
| 262 // pass an empty URL for now. Fix this once the high DPI URL is available. | 269 // pass an empty URL for now. Fix this once the high DPI URL is available. |
| 263 app_info->SetSettingsURLs(GURL(icon_url), GURL()); | 270 app_info->SetSettingsURLs(GURL(icon_url), GURL()); |
| 264 } | 271 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 } | 359 } |
| 353 | 360 |
| 354 // Add a new app info to our data structure. This takes ownership | 361 // Add a new app info to our data structure. This takes ownership |
| 355 // of the passed in pointer. | 362 // of the passed in pointer. |
| 356 void SyncedNotificationAppInfoService::Add( | 363 void SyncedNotificationAppInfoService::Add( |
| 357 scoped_ptr<SyncedNotificationAppInfo> app_info) { | 364 scoped_ptr<SyncedNotificationAppInfo> app_info) { |
| 358 sending_service_infos_.push_back(app_info.release()); | 365 sending_service_infos_.push_back(app_info.release()); |
| 359 } | 366 } |
| 360 | 367 |
| 361 } // namespace notifier | 368 } // namespace notifier |
| OLD | NEW |