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

Side by Side Diff: chrome/browser/extensions/extension_sync_service.cc

Issue 782693002: Ensure there are always nice icons for bookmark apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac compile Created 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/extensions/extension_sync_service.h" 5 #include "chrome/browser/extensions/extension_sync_service.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 14 matching lines...) Expand all
25 #include "chrome/common/web_application_info.h" 25 #include "chrome/common/web_application_info.h"
26 #include "components/sync_driver/sync_prefs.h" 26 #include "components/sync_driver/sync_prefs.h"
27 #include "extensions/browser/app_sorting.h" 27 #include "extensions/browser/app_sorting.h"
28 #include "extensions/browser/extension_prefs.h" 28 #include "extensions/browser/extension_prefs.h"
29 #include "extensions/browser/extension_registry.h" 29 #include "extensions/browser/extension_registry.h"
30 #include "extensions/browser/extension_util.h" 30 #include "extensions/browser/extension_util.h"
31 #include "extensions/browser/uninstall_reason.h" 31 #include "extensions/browser/uninstall_reason.h"
32 #include "extensions/common/extension.h" 32 #include "extensions/common/extension.h"
33 #include "extensions/common/extension_icon_set.h" 33 #include "extensions/common/extension_icon_set.h"
34 #include "extensions/common/feature_switch.h" 34 #include "extensions/common/feature_switch.h"
35 #include "extensions/common/image_util.h"
35 #include "extensions/common/manifest_constants.h" 36 #include "extensions/common/manifest_constants.h"
36 #include "extensions/common/manifest_handlers/icons_handler.h" 37 #include "extensions/common/manifest_handlers/icons_handler.h"
37 #include "sync/api/sync_change.h" 38 #include "sync/api/sync_change.h"
38 #include "sync/api/sync_error_factory.h" 39 #include "sync/api/sync_error_factory.h"
39 #include "ui/gfx/image/image_family.h" 40 #include "ui/gfx/image/image_family.h"
40 41
41 using extensions::Extension; 42 using extensions::Extension;
42 using extensions::ExtensionPrefs; 43 using extensions::ExtensionPrefs;
43 using extensions::ExtensionRegistry; 44 using extensions::ExtensionRegistry;
44 using extensions::FeatureSwitch; 45 using extensions::FeatureSwitch;
45 46
46 namespace { 47 namespace {
47 48
48 void OnWebApplicationInfoLoaded( 49 void OnWebApplicationInfoLoaded(
49 WebApplicationInfo synced_info, 50 WebApplicationInfo synced_info,
50 base::WeakPtr<ExtensionService> extension_service, 51 base::WeakPtr<ExtensionService> extension_service,
51 const WebApplicationInfo& loaded_info) { 52 const WebApplicationInfo& loaded_info) {
52 DCHECK_EQ(synced_info.app_url, loaded_info.app_url); 53 DCHECK_EQ(synced_info.app_url, loaded_info.app_url);
53 54
54 if (!extension_service) 55 if (!extension_service)
55 return; 56 return;
56 57
57 // Use the old icons if they exist. 58 // Use the old icons if they exist.
58 synced_info.icons = loaded_info.icons; 59 synced_info.icons = loaded_info.icons;
59 CreateOrUpdateBookmarkApp(extension_service.get(), synced_info); 60 CreateOrUpdateBookmarkApp(extension_service.get(), &synced_info);
60 } 61 }
61 62
62 } // namespace 63 } // namespace
63 64
64 ExtensionSyncService::ExtensionSyncService(Profile* profile, 65 ExtensionSyncService::ExtensionSyncService(Profile* profile,
65 ExtensionPrefs* extension_prefs, 66 ExtensionPrefs* extension_prefs,
66 ExtensionService* extension_service) 67 ExtensionService* extension_service)
67 : profile_(profile), 68 : profile_(profile),
68 extension_prefs_(extension_prefs), 69 extension_prefs_(extension_prefs),
69 extension_service_(extension_service), 70 extension_service_(extension_service),
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 extension->description() == app_sync_data.bookmark_app_description()) { 382 extension->description() == app_sync_data.bookmark_app_description()) {
382 return; 383 return;
383 } 384 }
384 385
385 WebApplicationInfo web_app_info; 386 WebApplicationInfo web_app_info;
386 web_app_info.app_url = bookmark_app_url; 387 web_app_info.app_url = bookmark_app_url;
387 web_app_info.title = 388 web_app_info.title =
388 base::UTF8ToUTF16(app_sync_data.extension_sync_data().name()); 389 base::UTF8ToUTF16(app_sync_data.extension_sync_data().name());
389 web_app_info.description = 390 web_app_info.description =
390 base::UTF8ToUTF16(app_sync_data.bookmark_app_description()); 391 base::UTF8ToUTF16(app_sync_data.bookmark_app_description());
392 if (!app_sync_data.bookmark_app_icon_color().empty()) {
393 extensions::image_util::ParseCSSColorString(
394 app_sync_data.bookmark_app_icon_color(),
395 &web_app_info.generated_icon_color);
396 }
391 397
392 // If the bookmark app already exists, keep the old icons. 398 // If the bookmark app already exists, keep the old icons.
393 if (!extension) { 399 if (!extension) {
394 CreateOrUpdateBookmarkApp(extension_service_, web_app_info); 400 CreateOrUpdateBookmarkApp(extension_service_, &web_app_info);
395 } else { 401 } else {
396 app_sync_data.extension_sync_data().name(); 402 app_sync_data.extension_sync_data().name();
397 GetWebApplicationInfoFromApp(profile_, 403 GetWebApplicationInfoFromApp(profile_,
398 extension, 404 extension,
399 base::Bind(&OnWebApplicationInfoLoaded, 405 base::Bind(&OnWebApplicationInfoLoaded,
400 web_app_info, 406 web_app_info,
401 extension_service_->AsWeakPtr())); 407 extension_service_->AsWeakPtr()));
402 } 408 }
403 } 409 }
404 410
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 app_sync_bundle_.SyncChangeIfNeeded(extension); 550 app_sync_bundle_.SyncChangeIfNeeded(extension);
545 else if (extension_service_->is_ready() && !flare_.is_null()) 551 else if (extension_service_->is_ready() && !flare_.is_null())
546 flare_.Run(syncer::APPS); 552 flare_.Run(syncer::APPS);
547 } else if (extensions::util::ShouldSyncExtension(&extension, profile_)) { 553 } else if (extensions::util::ShouldSyncExtension(&extension, profile_)) {
548 if (extension_sync_bundle_.IsSyncing()) 554 if (extension_sync_bundle_.IsSyncing())
549 extension_sync_bundle_.SyncChangeIfNeeded(extension); 555 extension_sync_bundle_.SyncChangeIfNeeded(extension);
550 else if (extension_service_->is_ready() && !flare_.is_null()) 556 else if (extension_service_->is_ready() && !flare_.is_null())
551 flare_.Run(syncer::EXTENSIONS); 557 flare_.Run(syncer::EXTENSIONS);
552 } 558 }
553 } 559 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/convert_web_app.cc ('k') | chrome/browser/sync/test/integration/two_client_apps_sync_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698