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

Unified Diff: chrome/browser/chromeos/login/wizard_controller.cc

Issue 2878056: Put back 53641 - Landing OEM customization CL for Denis... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/wizard_controller.cc
===================================================================
--- chrome/browser/chromeos/login/wizard_controller.cc (revision 53758)
+++ chrome/browser/chromeos/login/wizard_controller.cc (working copy)
@@ -12,8 +12,10 @@
#include <vector>
#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
#include "base/command_line.h"
#include "base/logging.h"
+#include "base/file_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/login_library.h"
@@ -51,6 +53,19 @@
// A boolean pref of the OOBE complete flag.
const wchar_t kOobeComplete[] = L"OobeComplete";
+// Path to OEM partner startup customization manifest.
+const char kStartupCustomizationManifestPath[] =
+ "/mnt/partner_partition/etc/chromeos/startup_manifest.json";
+
+// URL where to fetch OEM services customization manifest from.
+// TODO(denisromanov): Change this to real URL when it becomes available.
+const char kServicesCustomizationManifestUrl[] =
+ "file:///mnt/partner_partition/etc/chromeos/services_manifest.json";
+
+// Path to flag file indicating that OOBE was completed successfully.
+const char kOobeCompleteFlagFilePath[] =
+ "/home/chronos/.oobe_completed";
+
// Default size of the OOBE screen.
const int kWizardScreenWidth = 700;
const int kWizardScreenHeight = 416;
@@ -162,6 +177,11 @@
ProfileManager::GetDefaultProfile()));
}
+void DeleteWizardControllerAndApplyCustomization(WizardController* controller) {
+ controller->ApplyPartnerServicesCustomizations();
+ delete controller;
+}
+
} // namespace
const char WizardController::kNetworkScreenName[] = "network";
@@ -237,7 +257,7 @@
NULL);
window->SetContentsView(contents_);
- bool oobe_complete = IsOobeComplete();
+ bool oobe_complete = IsOobeCompleted();
if (!oobe_complete || first_screen_name == kOutOfBoxScreenName) {
is_out_of_box_ = true;
@@ -340,7 +360,18 @@
controller->Init();
background_widget_ = NULL;
background_view_ = NULL;
- MessageLoop::current()->DeleteSoon(FROM_HERE, this);
+
+ FilePath startup_manifest_path(kStartupCustomizationManifestPath);
+ if (file_util::PathExists(startup_manifest_path)) {
+ services_manifest_fetcher_.reset(new StringFetcher(
+ kServicesCustomizationManifestUrl));
+ }
+ ChromeThread::PostTask(
+ ChromeThread::UI,
+ FROM_HERE,
+ NewRunnableFunction(&DeleteWizardControllerAndApplyCustomization,
+ this));
+
return;
}
@@ -450,7 +481,7 @@
if (!password_.empty()) {
login->view()->SetPassword(password_);
// TODO(dpolukhin): clear password memory for real. Now it is not
- // a problem becuase we can't extract password from the form.
+ // a problem because we can't extract password from the form.
password_.clear();
login->view()->Login();
}
@@ -506,6 +537,7 @@
}
void WizardController::OnRegistrationSuccess() {
+ MarkDeviceRegistered();
// TODO(nkostylev): Registration screen should be shown on first sign in.
ShowLoginScreen();
}
@@ -571,6 +603,42 @@
prefs->SavePersistentPrefs();
}
+void WizardController::MarkDeviceRegistered() {
+ // Create flag file for boot-time init scripts.
+ FilePath oobe_complete_path(kOobeCompleteFlagFilePath);
+ FILE* oobe_flag_file = file_util::OpenFile(oobe_complete_path, "w+b");
+ DCHECK(oobe_flag_file != NULL) << kOobeCompleteFlagFilePath;
+ if (oobe_flag_file != NULL)
+ file_util::CloseFile(oobe_flag_file);
+}
+
+void WizardController::ApplyPartnerServicesCustomizations() {
+ if (services_manifest_fetcher_.get() == NULL ||
+ services_manifest_fetcher_->result().empty()) {
+ return;
+ }
+ scoped_ptr<chromeos::ServicesCustomizationDocument> customization;
+ bool manifest_loaded;
+ customization.reset(new chromeos::ServicesCustomizationDocument());
+ manifest_loaded = customization->LoadManifestFromString(
+ services_manifest_fetcher_->result());
+ DCHECK(manifest_loaded) << "Customization manifest fetch error: "
+ << services_manifest_fetcher_->result();
+ if (!manifest_loaded)
+ return;
+ LOG(INFO) << "partner services customizations manifest loaded successfully";
+ if (!customization->initial_start_page_url().empty()) {
+ // Append partner's start page url to command line so it gets opened
+ // on browser startup.
+ CommandLine::ForCurrentProcess()->AppendLooseValue(
+ UTF8ToWide(customization->initial_start_page_url()));
+ LOG(INFO) << "initial_start_page_url: "
+ << customization->initial_start_page_url();
+ }
+ // TODO(dpolukhin): apply customized apps, exts and support page.
+ MarkDeviceRegistered();
+}
+
///////////////////////////////////////////////////////////////////////////////
// WizardController, chromeos::ScreenObserver overrides:
void WizardController::OnExit(ExitCodes exit_code) {
@@ -639,10 +707,15 @@
return observer_ ? observer_ : this;
}
-bool WizardController::IsOobeComplete() {
+bool WizardController::IsOobeCompleted() {
return g_browser_process->local_state()->GetBoolean(kOobeComplete);
}
+bool WizardController::IsDeviceRegistered() {
+ FilePath oobe_complete_flag_file_path(kOobeCompleteFlagFilePath);
+ return file_util::PathExists(oobe_complete_flag_file_path);
+}
+
namespace browser {
// Declared in browser_dialogs.h so that others don't need to depend on our .h.
@@ -668,7 +741,7 @@
gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(size));
// Check whether we need to execute OOBE process.
- bool oobe_complete = WizardController::IsOobeComplete();
+ bool oobe_complete = WizardController::IsOobeCompleted();
if (first_screen_name.empty() &&
oobe_complete &&
@@ -682,47 +755,61 @@
return;
}
- scoped_ptr<chromeos::StartupCustomizationDocument> customization;
+ // Create and show the wizard.
+ WizardController* controller = new WizardController();
- if (!oobe_complete) {
- // Load partner customization startup manifest if needed.
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kStartupManifest)) {
- customization.reset(new chromeos::StartupCustomizationDocument());
- FilePath manifest_path =
- CommandLine::ForCurrentProcess()->GetSwitchValuePath(
- switches::kStartupManifest);
- bool manifest_loaded = customization->LoadManifestFromFile(manifest_path);
- DCHECK(manifest_loaded) << manifest_path.value();
- }
-
- // Do UX customizations if needed.
- if (customization != NULL) {
- // Switch to initial locale if specified by customization.
- const std::string locale = customization->initial_locale();
- if (!locale.empty()) {
- chromeos::LanguageSwitchMenu::SwitchLanguage(locale);
+ // Load partner customization startup manifest if it is available.
+ FilePath startup_manifest_path(kStartupCustomizationManifestPath);
+ std::string locale;
+ if (file_util::PathExists(startup_manifest_path)) {
+ scoped_ptr<chromeos::StartupCustomizationDocument> customization(
+ new chromeos::StartupCustomizationDocument());
+ bool manifest_loaded = customization->LoadManifestFromFile(
+ FilePath(kStartupCustomizationManifestPath));
+ DCHECK(manifest_loaded) << kStartupCustomizationManifestPath;
+ if (manifest_loaded) {
+ LOG(INFO) << "startup manifest loaded successfully";
+ // Switch to initial locale if specified by customization
+ // and has not been set yet. We cannot call
+ // chromeos::LanguageSwitchMenu::SwitchLanguage here before
+ // EmitLoginPromptReady.
+ const std::string current_locale =
+ g_browser_process->local_state()->GetString(
+ prefs::kApplicationLocale);
+ LOG(INFO) << "current locale: " << current_locale;
+ if (current_locale.empty()) {
+ locale = customization->initial_locale();
+ LOG(INFO) << "initial locale: " << locale;
+ if (!locale.empty()) {
+ ResourceBundle::ReloadSharedInstance(UTF8ToWide(locale));
+ }
}
- // Set initial timezone if specified by customization.
- const std::string timezone_name = customization->initial_timezone();
- if (!timezone_name.empty()) {
- icu::TimeZone* timezone = icu::TimeZone::createTimeZone(
- icu::UnicodeString::fromUTF8(timezone_name));
- chromeos::CrosLibrary::Get()->GetSystemLibrary()->SetTimezone(timezone);
- }
+ controller->SetCustomization(customization.release());
}
}
- // Create and show the wizard.
- WizardController* controller = new WizardController();
- if (!oobe_complete)
- controller->SetCustomization(customization.release());
controller->ShowBackground(screen_bounds);
controller->Init(first_screen_name, screen_bounds);
controller->Show();
+
if (chromeos::CrosLibrary::Get()->EnsureLoaded())
chromeos::CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady();
+
+ if (controller->GetCustomization() != NULL) {
+ if (!locale.empty())
+ chromeos::LanguageSwitchMenu::SwitchLanguage(locale);
+
+ // Set initial timezone if specified by customization.
+ const std::string timezone_name =
+ controller->GetCustomization()->initial_timezone();
+ LOG(INFO) << "initial time zone: " << timezone_name;
+ if (!timezone_name.empty()) {
+ icu::TimeZone* timezone = icu::TimeZone::createTimeZone(
+ icu::UnicodeString::fromUTF8(timezone_name));
+ chromeos::CrosLibrary::Get()->GetSystemLibrary()->SetTimezone(timezone);
+ }
+ }
}
} // namespace browser
« no previous file with comments | « chrome/browser/chromeos/login/wizard_controller.h ('k') | chrome/browser/chromeos/testdata/services_manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698