OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ui/app_list/arc/arc_app_list_prefs.h" | 5 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/task_runner_util.h" | 14 #include "base/task_runner_util.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/app_list/app_list_service.h" | 16 #include "chrome/browser/ui/app_list/app_list_service.h" |
17 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" | 17 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" |
18 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 18 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
19 #include "chrome/browser/ui/app_list/arc/arc_package_syncable_service.h" | 19 #include "chrome/browser/ui/app_list/arc/arc_package_syncable_service.h" |
20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
21 #include "chrome/grit/generated_resources.h" | |
21 #include "components/arc/arc_bridge_service.h" | 22 #include "components/arc/arc_bridge_service.h" |
22 #include "components/crx_file/id_util.h" | 23 #include "components/crx_file/id_util.h" |
23 #include "components/pref_registry/pref_registry_syncable.h" | 24 #include "components/pref_registry/pref_registry_syncable.h" |
24 #include "components/prefs/scoped_user_pref_update.h" | 25 #include "components/prefs/scoped_user_pref_update.h" |
25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
27 #include "ui/base/l10n/l10n_util.h" | |
26 | 28 |
27 namespace { | 29 namespace { |
28 | 30 |
29 const char kActivity[] = "activity"; | 31 const char kActivity[] = "activity"; |
30 const char kIconResourceId[] = "icon_resource_id"; | 32 const char kIconResourceId[] = "icon_resource_id"; |
31 const char kInstallTime[] = "install_time"; | 33 const char kInstallTime[] = "install_time"; |
32 const char kIntentUri[] = "intent_uri"; | 34 const char kIntentUri[] = "intent_uri"; |
33 const char kLastBackupAndroidId[] = "last_backup_android_id"; | 35 const char kLastBackupAndroidId[] = "last_backup_android_id"; |
34 const char kLastBackupTime[] = "last_backup_time"; | 36 const char kLastBackupTime[] = "last_backup_time"; |
35 const char kLastLaunchTime[] = "lastlaunchtime"; | 37 const char kLastLaunchTime[] = "lastlaunchtime"; |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
688 const std::string& activity, | 690 const std::string& activity, |
689 const std::string& intent_uri, | 691 const std::string& intent_uri, |
690 const std::string& icon_resource_id, | 692 const std::string& icon_resource_id, |
691 const bool sticky, | 693 const bool sticky, |
692 const bool notifications_enabled, | 694 const bool notifications_enabled, |
693 const bool shortcut, | 695 const bool shortcut, |
694 const bool launchable, | 696 const bool launchable, |
695 const arc::mojom::OrientationLock orientation_lock) { | 697 const arc::mojom::OrientationLock orientation_lock) { |
696 const std::string app_id = shortcut ? GetAppId(package_name, intent_uri) | 698 const std::string app_id = shortcut ? GetAppId(package_name, intent_uri) |
697 : GetAppId(package_name, activity); | 699 : GetAppId(package_name, activity); |
700 | |
701 // |name_beta| will be only used on M53 and will be reverted on later version. | |
702 std::string name_beta = name; | |
703 if (app_id == arc::kPlayStoreAppId) { | |
704 name_beta = name + " (" + | |
xiyuan
2016/09/07 22:56:36
Don't like the concatenation but don't have a bett
xdai1
2016/09/07 23:25:01
Renamed it.
| |
705 l10n_util::GetStringUTF8(IDS_ABOUT_PAGE_CURRENT_CHANNEL_BETA) + | |
706 ")"; | |
707 } | |
708 | |
698 const bool was_registered = IsRegistered(app_id); | 709 const bool was_registered = IsRegistered(app_id); |
699 if (was_registered) { | 710 if (was_registered) { |
700 std::unique_ptr<ArcAppListPrefs::AppInfo> app_old_info = GetApp(app_id); | 711 std::unique_ptr<ArcAppListPrefs::AppInfo> app_old_info = GetApp(app_id); |
701 DCHECK(app_old_info); | 712 DCHECK(app_old_info); |
702 DCHECK(launchable); | 713 DCHECK(launchable); |
703 if (name != app_old_info->name) { | 714 if (name_beta != app_old_info->name) { |
704 FOR_EACH_OBSERVER(Observer, observer_list_, | 715 FOR_EACH_OBSERVER(Observer, observer_list_, |
705 OnAppNameUpdated(app_id, name)); | 716 OnAppNameUpdated(app_id, name_beta)); |
706 } | 717 } |
707 } | 718 } |
708 | 719 |
709 ScopedArcPrefUpdate update(prefs_, app_id, prefs::kArcApps); | 720 ScopedArcPrefUpdate update(prefs_, app_id, prefs::kArcApps); |
710 base::DictionaryValue* app_dict = update.Get(); | 721 base::DictionaryValue* app_dict = update.Get(); |
711 app_dict->SetString(kName, name); | 722 app_dict->SetString(kName, name_beta); |
712 app_dict->SetString(kPackageName, package_name); | 723 app_dict->SetString(kPackageName, package_name); |
713 app_dict->SetString(kActivity, activity); | 724 app_dict->SetString(kActivity, activity); |
714 app_dict->SetString(kIntentUri, intent_uri); | 725 app_dict->SetString(kIntentUri, intent_uri); |
715 app_dict->SetString(kIconResourceId, icon_resource_id); | 726 app_dict->SetString(kIconResourceId, icon_resource_id); |
716 app_dict->SetBoolean(kSticky, sticky); | 727 app_dict->SetBoolean(kSticky, sticky); |
717 app_dict->SetBoolean(kNotificationsEnabled, notifications_enabled); | 728 app_dict->SetBoolean(kNotificationsEnabled, notifications_enabled); |
718 app_dict->SetBoolean(kShortcut, shortcut); | 729 app_dict->SetBoolean(kShortcut, shortcut); |
719 app_dict->SetBoolean(kLaunchable, launchable); | 730 app_dict->SetBoolean(kLaunchable, launchable); |
720 app_dict->SetInteger(kOrientationLock, static_cast<int>(orientation_lock)); | 731 app_dict->SetInteger(kOrientationLock, static_cast<int>(orientation_lock)); |
721 | 732 |
722 // Note the install time is the first time the Chrome OS sees the app, not the | 733 // Note the install time is the first time the Chrome OS sees the app, not the |
723 // actual install time in Android side. | 734 // actual install time in Android side. |
724 if (GetInstallTime(app_id).is_null()) { | 735 if (GetInstallTime(app_id).is_null()) { |
725 std::string install_time_str = | 736 std::string install_time_str = |
726 base::Int64ToString(base::Time::Now().ToInternalValue()); | 737 base::Int64ToString(base::Time::Now().ToInternalValue()); |
727 app_dict->SetString(kInstallTime, install_time_str); | 738 app_dict->SetString(kInstallTime, install_time_str); |
728 } | 739 } |
729 | 740 |
730 // From now, app is available. | 741 // From now, app is available. |
731 const bool was_disabled = ready_apps_.count(app_id) == 0; | 742 const bool was_disabled = ready_apps_.count(app_id) == 0; |
732 if (was_disabled) | 743 if (was_disabled) |
733 ready_apps_.insert(app_id); | 744 ready_apps_.insert(app_id); |
734 | 745 |
735 if (was_registered) { | 746 if (was_registered) { |
736 if (was_disabled) { | 747 if (was_disabled) { |
737 FOR_EACH_OBSERVER(Observer, observer_list_, | 748 FOR_EACH_OBSERVER(Observer, observer_list_, |
738 OnAppReadyChanged(app_id, true)); | 749 OnAppReadyChanged(app_id, true)); |
739 } | 750 } |
740 } else { | 751 } else { |
741 AppInfo app_info(name, package_name, activity, intent_uri, icon_resource_id, | 752 AppInfo app_info(name_beta, package_name, activity, intent_uri, |
742 base::Time(), GetInstallTime(app_id), sticky, | 753 icon_resource_id, base::Time(), GetInstallTime(app_id), |
743 notifications_enabled, true, | 754 sticky, notifications_enabled, true, |
744 launchable && arc::ShouldShowInLauncher(app_id), shortcut, | 755 launchable && arc::ShouldShowInLauncher(app_id), shortcut, |
745 launchable, orientation_lock); | 756 launchable, orientation_lock); |
746 FOR_EACH_OBSERVER(Observer, | 757 FOR_EACH_OBSERVER(Observer, |
747 observer_list_, | 758 observer_list_, |
748 OnAppRegistered(app_id, app_info)); | 759 OnAppRegistered(app_id, app_info)); |
749 } | 760 } |
750 | 761 |
751 auto deferred_icons = request_icon_deferred_.find(app_id); | 762 auto deferred_icons = request_icon_deferred_.find(app_id); |
752 if (deferred_icons != request_icon_deferred_.end()) { | 763 if (deferred_icons != request_icon_deferred_.end()) { |
753 for (uint32_t i = ui::SCALE_FACTOR_100P; i < ui::NUM_SCALE_FACTORS; ++i) { | 764 for (uint32_t i = ui::SCALE_FACTOR_100P; i < ui::NUM_SCALE_FACTORS; ++i) { |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1211 int64_t last_backup_android_id, | 1222 int64_t last_backup_android_id, |
1212 int64_t last_backup_time, | 1223 int64_t last_backup_time, |
1213 bool should_sync, | 1224 bool should_sync, |
1214 bool system) | 1225 bool system) |
1215 : package_name(package_name), | 1226 : package_name(package_name), |
1216 package_version(package_version), | 1227 package_version(package_version), |
1217 last_backup_android_id(last_backup_android_id), | 1228 last_backup_android_id(last_backup_android_id), |
1218 last_backup_time(last_backup_time), | 1229 last_backup_time(last_backup_time), |
1219 should_sync(should_sync), | 1230 should_sync(should_sync), |
1220 system(system) {} | 1231 system(system) {} |
OLD | NEW |