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

Side by Side Diff: chrome/browser/chromeos/app_mode/kiosk_app_manager.cc

Issue 1869483002: kiosk: Defer app update until platform matches (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
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/chromeos/app_mode/kiosk_app_manager.h" 5 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/barrier_closure.h" 11 #include "base/barrier_closure.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #include "base/stl_util.h" 18 #include "base/strings/stringprintf.h"
19 #include "base/sys_info.h" 19 #include "base/sys_info.h"
20 #include "base/version.h"
20 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/chromeos/app_mode/app_session.h" 22 #include "chrome/browser/chromeos/app_mode/app_session.h"
22 #include "chrome/browser/chromeos/app_mode/kiosk_app_data.h" 23 #include "chrome/browser/chromeos/app_mode/kiosk_app_data.h"
23 #include "chrome/browser/chromeos/app_mode/kiosk_app_external_loader.h" 24 #include "chrome/browser/chromeos/app_mode/kiosk_app_external_loader.h"
24 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h" 25 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h"
25 #include "chrome/browser/chromeos/app_mode/kiosk_external_updater.h" 26 #include "chrome/browser/chromeos/app_mode/kiosk_external_updater.h"
26 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" 27 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
27 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h" 28 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h"
28 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 29 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
29 #include "chrome/browser/chromeos/policy/device_local_account.h" 30 #include "chrome/browser/chromeos/policy/device_local_account.h"
(...skipping 11 matching lines...) Expand all
41 #include "chromeos/settings/cros_settings_names.h" 42 #include "chromeos/settings/cros_settings_names.h"
42 #include "components/ownership/owner_key_util.h" 43 #include "components/ownership/owner_key_util.h"
43 #include "components/prefs/pref_registry_simple.h" 44 #include "components/prefs/pref_registry_simple.h"
44 #include "components/prefs/pref_service.h" 45 #include "components/prefs/pref_service.h"
45 #include "components/prefs/scoped_user_pref_update.h" 46 #include "components/prefs/scoped_user_pref_update.h"
46 #include "components/signin/core/account_id/account_id.h" 47 #include "components/signin/core/account_id/account_id.h"
47 #include "components/user_manager/known_user.h" 48 #include "components/user_manager/known_user.h"
48 #include "components/user_manager/user_manager.h" 49 #include "components/user_manager/user_manager.h"
49 #include "content/public/browser/browser_thread.h" 50 #include "content/public/browser/browser_thread.h"
50 #include "extensions/common/extension_urls.h" 51 #include "extensions/common/extension_urls.h"
52 #include "extensions/common/manifest_handlers/kiosk_mode_info.h"
51 53
52 namespace chromeos { 54 namespace chromeos {
53 55
54 namespace { 56 namespace {
55 57
56 // Domain that is used for kiosk-app account IDs. 58 // Domain that is used for kiosk-app account IDs.
57 const char kKioskAppAccountDomain[] = "kiosk-apps"; 59 const char kKioskAppAccountDomain[] = "kiosk-apps";
58 60
59 // Preference for the dictionary of user ids for which cryptohomes have to be 61 // Preference for the dictionary of user ids for which cryptohomes have to be
60 // removed upon browser restart. 62 // removed upon browser restart.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 *present = util.get() && util->IsPublicKeyPresent(); 129 *present = util.get() && util->IsPublicKeyPresent();
128 } 130 }
129 131
130 scoped_refptr<base::SequencedTaskRunner> GetBackgroundTaskRunner() { 132 scoped_refptr<base::SequencedTaskRunner> GetBackgroundTaskRunner() {
131 base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool(); 133 base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool();
132 CHECK(pool); 134 CHECK(pool);
133 return pool->GetSequencedTaskRunnerWithShutdownBehavior( 135 return pool->GetSequencedTaskRunnerWithShutdownBehavior(
134 pool->GetSequenceToken(), base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); 136 pool->GetSequenceToken(), base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
135 } 137 }
136 138
139 base::Version GetPlatformVersion() {
140 int32_t major_version;
141 int32_t minor_version;
142 int32_t bugfix_version;
143 base::SysInfo::OperatingSystemVersionNumbers(&major_version, &minor_version,
144 &bugfix_version);
145 return base::Version(base::StringPrintf("%d.%d.%d", major_version,
146 minor_version, bugfix_version));
147 }
148
137 } // namespace 149 } // namespace
138 150
139 // static 151 // static
140 const char KioskAppManager::kKioskDictionaryName[] = "kiosk"; 152 const char KioskAppManager::kKioskDictionaryName[] = "kiosk";
141 const char KioskAppManager::kKeyApps[] = "apps"; 153 const char KioskAppManager::kKeyApps[] = "apps";
142 const char KioskAppManager::kKeyAutoLoginState[] = "auto_login_state"; 154 const char KioskAppManager::kKeyAutoLoginState[] = "auto_login_state";
143 const char KioskAppManager::kIconCacheDir[] = "kiosk/icon"; 155 const char KioskAppManager::kIconCacheDir[] = "kiosk/icon";
144 const char KioskAppManager::kCrxCacheDir[] = "kiosk/crx"; 156 const char KioskAppManager::kCrxCacheDir[] = "kiosk/crx";
145 const char KioskAppManager::kCrxUnpackDir[] = "kiosk_unpack"; 157 const char KioskAppManager::kCrxUnpackDir[] = "kiosk_unpack";
146 158
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 } 573 }
562 574
563 void KioskAppManager::PutValidatedExternalExtension( 575 void KioskAppManager::PutValidatedExternalExtension(
564 const std::string& app_id, 576 const std::string& app_id,
565 const base::FilePath& crx_path, 577 const base::FilePath& crx_path,
566 const std::string& version, 578 const std::string& version,
567 const ExternalCache::PutExternalExtensionCallback& callback) { 579 const ExternalCache::PutExternalExtensionCallback& callback) {
568 external_cache_->PutExternalExtension(app_id, crx_path, version, callback); 580 external_cache_->PutExternalExtension(app_id, crx_path, version, callback);
569 } 581 }
570 582
583 bool KioskAppManager::IsPlatformCompliant(
584 const std::string& required_platform_version) const {
585 // Empty required version are compliant with any platform version.
jennyz 2016/04/19 21:54:28 nit: are->is?
xiyuan 2016/04/19 22:28:45 Done.
586 if (required_platform_version.empty())
587 return true;
588
589 // Not compliant for bad formatted required versions.
590 const base::Version required_version(required_platform_version);
591 if (!required_version.IsValid() || required_version.components().size() > 3u)
jennyz 2016/04/19 21:54:28 Will it be helpful to add some log for such case?
xiyuan 2016/04/19 22:28:45 Done.
592 return false;
593
594 // Not compliant if the platform version components do not match.
595 const size_t count = required_version.components().size();
596 const base::Version platform_version = GetPlatformVersion();
597 const auto& platform_version_components = platform_version.components();
598 const auto& required_version_components = required_version.components();
599 for (size_t i = 0; i < count; ++i) {
600 if (platform_version_components[i] != required_version_components[i])
601 return false;
602 }
603
604 return true;
605 }
606
607 bool KioskAppManager::IsPlatformCompliantWithApp(
608 const extensions::Extension* app) const {
609 // Compliant if the app is not the auto launched with zero delay app.
610 if (currently_auto_launched_with_zero_delay_app_ != app->id())
611 return true;
612
613 // Compliant if the app does not specify required platform version.
614 const extensions::KioskModeInfo* info = extensions::KioskModeInfo::Get(app);
615 if (info == nullptr)
616 return true;
617
618 return IsPlatformCompliant(info->required_platform_version);
619 }
620
571 KioskAppManager::KioskAppManager() 621 KioskAppManager::KioskAppManager()
572 : ownership_established_(false), 622 : ownership_established_(false),
573 external_loader_created_(false), 623 external_loader_created_(false),
574 secondary_app_external_loader_created_(false) { 624 secondary_app_external_loader_created_(false) {
575 base::FilePath cache_dir; 625 base::FilePath cache_dir;
576 GetCrxCacheDir(&cache_dir); 626 GetCrxCacheDir(&cache_dir);
577 external_cache_.reset( 627 external_cache_.reset(
578 new ExternalCache(cache_dir, 628 new ExternalCache(cache_dir,
579 g_browser_process->system_request_context(), 629 g_browser_process->system_request_context(),
580 GetBackgroundTaskRunner(), 630 GetBackgroundTaskRunner(),
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 base::TimeDelta KioskAppManager::GetAutoLaunchDelay() const { 861 base::TimeDelta KioskAppManager::GetAutoLaunchDelay() const {
812 int delay; 862 int delay;
813 if (!CrosSettings::Get()->GetInteger( 863 if (!CrosSettings::Get()->GetInteger(
814 kAccountsPrefDeviceLocalAccountAutoLoginDelay, &delay)) { 864 kAccountsPrefDeviceLocalAccountAutoLoginDelay, &delay)) {
815 return base::TimeDelta(); // Default delay is 0ms. 865 return base::TimeDelta(); // Default delay is 0ms.
816 } 866 }
817 return base::TimeDelta::FromMilliseconds(delay); 867 return base::TimeDelta::FromMilliseconds(delay);
818 } 868 }
819 869
820 } // namespace chromeos 870 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698