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

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

Powered by Google App Engine
This is Rietveld 408576698