Commit 65853274 authored by tengs@chromium.org's avatar tengs@chromium.org

Add flow to enable Google Drive offline mode automatically on first run.

How this works is that we create a WebContents in the background to a Drive
endpoint that will take care of all the offline initialization for the app.
We succeed if a background page is opened; otherwise, we fail if the page does
not load or after a timeout.

BUG=307302
TEST=manual

Review URL: https://codereview.chromium.org/55423004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233501 0039d316-1c4b-4281-b951-d872f2087c98
parent bbce7be6
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_FIRST_RUN_DRIVE_FIRST_RUN_CONTROLLER_H_
#define CHROME_BROWSER_CHROMEOS_FIRST_RUN_DRIVE_FIRST_RUN_CONTROLLER_H_
#include "base/basictypes.h"
#include "base/timer/timer.h"
#include "chrome/browser/profiles/profile.h"
namespace chromeos {
class DriveWebContentsManager;
// This class is responsible for kicking off the Google Drive offline
// initialization process. There is an initial delay to avoid contention when
// the session starts. DriveFirstRunController will manage its own lifetime and
// destroy itself when the initialization succeeds or fails.
class DriveFirstRunController {
public:
DriveFirstRunController();
~DriveFirstRunController();
// Starts the process to enable offline mode for the user's Drive account.
void EnableOfflineMode();
private:
// Used as a callback to indicate whether the offline initialization
// succeeds or fails.
void OnOfflineInit(bool success);
// Called when timed out waiting for offline initialization to complete.
void OnWebContentsTimedOut();
// Cleans up internal state and schedules self for deletion.
void CleanUp();
Profile* profile_;
scoped_ptr<DriveWebContentsManager> web_contents_manager_;
base::OneShotTimer<DriveFirstRunController> web_contents_timer_;
base::OneShotTimer<DriveFirstRunController> initial_delay_timer_;
bool started_;
DISALLOW_COPY_AND_ASSIGN(DriveFirstRunController);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_FIRST_RUN_DRIVE_FIRST_RUN_CONTROLLER_H_
......@@ -26,6 +26,7 @@
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
#include "chrome/browser/chromeos/customization_document.h"
#include "chrome/browser/chromeos/first_run/drive_first_run_controller.h"
#include "chrome/browser/chromeos/first_run/first_run_controller.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h"
#include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
......@@ -318,6 +319,16 @@ LoginDisplayHostImpl::~LoginDisplayHostImpl() {
// completion.
(new FirstRunController())->Start();
}
// TODO(tengs): This should be refactored together with the first run UI.
// See crbug.com/314934.
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableDriveOfflineFirstRun)) {
if (UserManager::Get()->IsCurrentUserNew()) {
// DriveOptInController will delete itself when finished.
(new DriveFirstRunController())->EnableOfflineMode();
}
}
}
////////////////////////////////////////////////////////////////////////////////
......
......@@ -366,6 +366,8 @@
'browser/chromeos/fileapi/file_system_backend.cc',
'browser/chromeos/fileapi/file_system_backend.h',
'browser/chromeos/fileapi/file_system_backend_delegate.h',
'browser/chromeos/first_run/drive_first_run_controller.cc',
'browser/chromeos/first_run/drive_first_run_controller.h',
'browser/chromeos/first_run/first_run_controller.cc',
'browser/chromeos/first_run/first_run_controller.h',
'browser/chromeos/first_run/first_run_view.cc',
......
......@@ -82,6 +82,9 @@ const char kEnableCarrierSwitching[] = "enable-carrier-switching";
const char kEnableChromeCaptivePortalDetector[] =
"enable-chrome-captive-portal-detector";
// Enables automatically initializing Google Drive offline mode on first run.
const char kEnableDriveOfflineFirstRun[] = "enable-drive-offline-first-run";
// Enables reporting recently logged in users for enterprise-managed devices.
const char kEnableEnterpriseUserReporting[] =
"enable-enterprise-user-reporting";
......
......@@ -41,6 +41,7 @@ CHROMEOS_EXPORT extern const char kEchoExtensionPath[];
CHROMEOS_EXPORT extern const char kEnableBackgroundLoader[];
CHROMEOS_EXPORT extern const char kEnableCarrierSwitching[];
CHROMEOS_EXPORT extern const char kEnableChromeCaptivePortalDetector[];
CHROMEOS_EXPORT extern const char kEnableDriveOfflineFirstRun[];
CHROMEOS_EXPORT extern const char kEnableEnterpriseUserReporting[];
CHROMEOS_EXPORT extern const char kEnableIMEModeIndicator[];
CHROMEOS_EXPORT extern const char kEnableKioskMode[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment