Commit 6ef2a8be authored by satorux's avatar satorux Committed by Commit bot

chromeos: Remove legacy code for chrome://imageburner

chrome://imageburner was replaced by the new recovery tool
http://google.com/chromeos/recovery.

With this change, chrome://imageburner just redirects to
the new recovery tool page.

Note that the D-Bus client code (ImageBurnerClient) is not removed
because it's used in imageWriterPrivate API, used in the new
recovery tool.

BUG=344279
TEST=open chrome://imageburner and you are redirected to http://google.com/chromeos/recovery

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

Cr-Commit-Position: refs/heads/master@{#302042}
parent c3aa8cf5
...@@ -380,9 +380,6 @@ ...@@ -380,9 +380,6 @@
'filepath': 'base/i18n/|base/string|l10n|icu|'\ 'filepath': 'base/i18n/|base/string|l10n|icu|'\
'locale_settings|encoding', 'locale_settings|encoding',
}, },
'imageburner': {
'filepath': 'imageburner'
},
'importer': { 'importer': {
'filepath': 'import', 'filepath': 'import',
}, },
...@@ -883,7 +880,6 @@ ...@@ -883,7 +880,6 @@
'history_ui': ['dubroy@chromium.org', 'pam+watch@chromium.org'], 'history_ui': ['dubroy@chromium.org', 'pam+watch@chromium.org'],
'hotword': ['rlp+watch@chromium.org'], 'hotword': ['rlp+watch@chromium.org'],
'i18n': ['jshin+watch@chromium.org'], 'i18n': ['jshin+watch@chromium.org'],
'imageburner': ['tbarzic+watch@chromium.org'],
'importer': ['tfarina@chromium.org'], 'importer': ['tfarina@chromium.org'],
'indexed_db': ['cmumford@chromium.org', 'indexed_db': ['cmumford@chromium.org',
'dgrogan@chromium.org', 'jsbell+idb@chromium.org'], 'dgrogan@chromium.org', 'jsbell+idb@chromium.org'],
......
...@@ -325,7 +325,6 @@ ...@@ -325,7 +325,6 @@
<include name="IDR_PROVIDED_FILE_SYSTEMS_JS" file="resources\chromeos\provided_file_systems.js" flattenhtml="true" type="BINDATA" /> <include name="IDR_PROVIDED_FILE_SYSTEMS_JS" file="resources\chromeos\provided_file_systems.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_GUEST_SESSION_TAB_HTML" file="resources\chromeos\guest_session_tab.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_GUEST_SESSION_TAB_HTML" file="resources\chromeos\guest_session_tab.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_IMAGEBURNER_HTML" file="resources\chromeos\image_burner.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_IMAGEBURNER_HTML" file="resources\chromeos\image_burner.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_IMAGEBURNER_JS" file="resources\chromeos\image_burner.js" type="BINDATA" />
<include name="IDR_KEYBOARD_OVERLAY_CSS" file="resources\chromeos\keyboard_overlay.css" flattenhtml="true" type="BINDATA" /> <include name="IDR_KEYBOARD_OVERLAY_CSS" file="resources\chromeos\keyboard_overlay.css" flattenhtml="true" type="BINDATA" />
<include name="IDR_KEYBOARD_OVERLAY_HTML" file="resources\chromeos\keyboard_overlay.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_KEYBOARD_OVERLAY_HTML" file="resources\chromeos\keyboard_overlay.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_KEYBOARD_OVERLAY_JS" file="resources\chromeos\keyboard_overlay.js" flattenhtml="true" type="BINDATA" /> <include name="IDR_KEYBOARD_OVERLAY_JS" file="resources\chromeos\keyboard_overlay.js" flattenhtml="true" type="BINDATA" />
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include "chrome/browser/chromeos/extensions/default_app_order.h" #include "chrome/browser/chromeos/extensions/default_app_order.h"
#include "chrome/browser/chromeos/extensions/extension_system_event_observer.h" #include "chrome/browser/chromeos/extensions/extension_system_event_observer.h"
#include "chrome/browser/chromeos/external_metrics.h" #include "chrome/browser/chromeos/external_metrics.h"
#include "chrome/browser/chromeos/imageburner/burn_manager.h"
#include "chrome/browser/chromeos/input_method/input_method_configuration.h" #include "chrome/browser/chromeos/input_method/input_method_configuration.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h" #include "chrome/browser/chromeos/input_method/input_method_util.h"
#include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
...@@ -336,8 +335,6 @@ void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { ...@@ -336,8 +335,6 @@ void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() {
base::FilePath downloads_directory; base::FilePath downloads_directory;
CHECK(PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &downloads_directory)); CHECK(PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &downloads_directory));
imageburner::BurnManager::Initialize(
downloads_directory, g_browser_process->system_request_context());
DeviceOAuth2TokenServiceFactory::Initialize(); DeviceOAuth2TokenServiceFactory::Initialize();
...@@ -723,7 +720,6 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { ...@@ -723,7 +720,6 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() {
SystemKeyEventListener::Shutdown(); SystemKeyEventListener::Shutdown();
#endif #endif
imageburner::BurnManager::Shutdown();
CrasAudioHandler::Shutdown(); CrasAudioHandler::Shutdown();
// Detach D-Bus clients before DBusThreadManager is shut down. // Detach D-Bus clients before DBusThreadManager is shut down.
......
// Copyright (c) 2012 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.
#include "chrome/browser/chromeos/imageburner/burn_controller.h"
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/imageburner/burn_manager.h"
#include "chromeos/network/network_state_handler.h"
#include "url/gurl.h"
namespace chromeos {
namespace imageburner {
namespace {
// 3.9GB. It is less than 4GB because true device size ussually varies a little.
const uint64 kMinDeviceSize = static_cast<uint64>(3.9 * 1000 * 1000 * 1000);
class BurnControllerImpl
: public BurnController,
public StateMachine::Observer,
public BurnManager::Observer {
public:
explicit BurnControllerImpl(BurnController::Delegate* delegate)
: burn_manager_(NULL),
state_machine_(NULL),
working_(false),
delegate_(delegate) {
burn_manager_ = BurnManager::GetInstance();
burn_manager_->AddObserver(this);
state_machine_ = burn_manager_->state_machine();
state_machine_->AddObserver(this);
}
virtual ~BurnControllerImpl() {
state_machine_->RemoveObserver(this);
burn_manager_->RemoveObserver(this);
}
// BurnManager::Observer override.
virtual void OnDeviceAdded(
const disks::DiskMountManager::Disk& disk) override {
delegate_->OnDeviceAdded(disk);
}
// BurnManager::Observer override.
virtual void OnDeviceRemoved(
const disks::DiskMountManager::Disk& disk) override {
delegate_->OnDeviceRemoved(disk);
}
// BurnManager::Observer override.
virtual void OnNetworkDetected() override {
delegate_->OnNetworkDetected();
}
// BurnManager::Observer override.
virtual void OnSuccess() override {
delegate_->OnSuccess();
// TODO(hidehiko): Remove |working_| flag.
working_ = false;
}
// BurnManager::Observer override.
virtual void OnProgressWithRemainingTime(
ProgressType progress_type,
int64 received_bytes,
int64 total_bytes,
const base::TimeDelta& estimated_remaining_time) override {
delegate_->OnProgressWithRemainingTime(
progress_type, received_bytes, total_bytes, estimated_remaining_time);
}
// BurnManager::Observer override.
virtual void OnProgress(ProgressType progress_type,
int64 received_bytes,
int64 total_bytes) override {
delegate_->OnProgress(progress_type, received_bytes, total_bytes);
}
// StateMachine::Observer interface.
virtual void OnBurnStateChanged(StateMachine::State state) override {
if (state != StateMachine::INITIAL && !working_) {
// User has started burn process, so let's start observing.
StartBurnImage(base::FilePath(), base::FilePath());
}
}
virtual void OnError(int error_message_id) override {
delegate_->OnFail(error_message_id);
working_ = false;
}
// BurnController override.
virtual void Init() override {
if (state_machine_->state() == StateMachine::BURNING) {
// There is nothing else left to do but observe burn progress.
burn_manager_->DoBurn();
} else if (state_machine_->state() != StateMachine::INITIAL) {
// User has started burn process, so let's start observing.
StartBurnImage(base::FilePath(), base::FilePath());
}
}
// BurnController override.
virtual std::vector<disks::DiskMountManager::Disk> GetBurnableDevices()
override {
// Now this is just a proxy to the BurnManager.
// TODO(hidehiko): Remove this method.
return burn_manager_->GetBurnableDevices();
}
// BurnController override.
virtual void CancelBurnImage() override {
burn_manager_->Cancel();
}
// BurnController override.
// May be called with empty values if there is a handler that has started
// burning, and thus set the target paths.
virtual void StartBurnImage(const base::FilePath& target_device_path,
const base::FilePath& target_file_path) override {
if (!target_device_path.empty() && !target_file_path.empty() &&
state_machine_->new_burn_posible()) {
if (!NetworkHandler::Get()->network_state_handler()->DefaultNetwork()) {
delegate_->OnNoNetwork();
return;
}
burn_manager_->set_target_device_path(target_device_path);
burn_manager_->set_target_file_path(target_file_path);
uint64 device_size = GetDeviceSize(
burn_manager_->target_device_path().value());
if (device_size < kMinDeviceSize) {
delegate_->OnDeviceTooSmall(device_size);
return;
}
}
if (working_)
return;
working_ = true;
// Send progress signal now so ui doesn't hang in intial state until we get
// config file
delegate_->OnProgress(DOWNLOADING, 0, 0);
if (burn_manager_->GetImageDir().empty()) {
burn_manager_->CreateImageDir();
} else {
burn_manager_->FetchConfigFile();
}
}
private:
int64 GetDeviceSize(const std::string& device_path) {
disks::DiskMountManager* disk_mount_manager =
disks::DiskMountManager::GetInstance();
const disks::DiskMountManager::Disk* disk =
disk_mount_manager->FindDiskBySourcePath(device_path);
return disk ? disk->total_size_in_bytes() : 0;
}
BurnManager* burn_manager_;
StateMachine* state_machine_;
bool working_;
BurnController::Delegate* delegate_;
DISALLOW_COPY_AND_ASSIGN(BurnControllerImpl);
};
} // namespace
// static
BurnController* BurnController::CreateBurnController(
content::WebContents* web_contents,
Delegate* delegate) {
return new BurnControllerImpl(delegate);
}
} // namespace imageburner
} // namespace chromeos
// Copyright (c) 2012 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_IMAGEBURNER_BURN_CONTROLLER_H_
#define CHROME_BROWSER_CHROMEOS_IMAGEBURNER_BURN_CONTROLLER_H_
#include <vector>
#include "base/basictypes.h"
#include "chrome/browser/chromeos/imageburner/burn_manager.h"
#include "chromeos/disks/disk_mount_manager.h"
namespace base {
class FilePath;
class TimeDelta;
}
namespace content {
class WebContents;
}
namespace chromeos {
namespace imageburner {
// A class to control recovery media creating process.
class BurnController {
public:
class Delegate {
public:
// Called when recovery image is successfully burnt.
virtual void OnSuccess() = 0;
// Called when something goes wrong.
virtual void OnFail(int error_message_id) = 0;
// Called when a burnable device is added.
virtual void OnDeviceAdded(const disks::DiskMountManager::Disk& disk) = 0;
// Called when a burnable device is removed.
virtual void OnDeviceRemoved(const disks::DiskMountManager::Disk& disk) = 0;
// Called when device is too small.
virtual void OnDeviceTooSmall(int64 device_size) = 0;
// Called when some progress is made.
virtual void OnProgress(ProgressType progress_type,
int64 amount_finished,
int64 amount_total) = 0;
// Called when some progress is made and remaining time estimation is
// available.
virtual void OnProgressWithRemainingTime(
ProgressType progress_type,
int64 amount_finished,
int64 amount_total,
const base::TimeDelta& time_remaining) = 0;
// Called when network is connected.
virtual void OnNetworkDetected() = 0;
// Called when an error occurs because there is no network connection.
virtual void OnNoNetwork() = 0;
};
virtual ~BurnController() {}
// Initializes the instance.
virtual void Init() = 0;
// Returns devices on which we can burn recovery image.
virtual std::vector<disks::DiskMountManager::Disk> GetBurnableDevices() = 0;
// Starts burning process.
virtual void StartBurnImage(const base::FilePath& target_device_path,
const base::FilePath& target_file_path) = 0;
// Cancels burning process.
virtual void CancelBurnImage() = 0;
// Creates a new instance of BurnController.
static BurnController* CreateBurnController(
content::WebContents* web_contents, Delegate* delegate);
protected:
BurnController() {}
private:
DISALLOW_COPY_AND_ASSIGN(BurnController);
};
} // namespace imageburner
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_IMAGEBURNER_BURN_CONTROLLER_H_
// Copyright (c) 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.
#include "chrome/browser/chromeos/imageburner/burn_device_handler.h"
#include <string>
#include <vector>
#include "base/logging.h"
#include "chromeos/dbus/cros_disks_client.h"
#include "chromeos/disks/disk_mount_manager.h"
namespace chromeos {
namespace imageburner {
using disks::DiskMountManager;
namespace {
// Returns true when |disk| is a device on which we can burn recovery image.
bool IsBurnableDevice(const DiskMountManager::Disk& disk) {
return disk.is_parent() && !disk.on_boot_device() && disk.has_media() &&
(disk.device_type() == DEVICE_TYPE_USB ||
disk.device_type() == DEVICE_TYPE_SD);
}
} // namespace
BurnDeviceHandler::BurnDeviceHandler(DiskMountManager* disk_mount_manager)
: disk_mount_manager_(disk_mount_manager) {
DCHECK(disk_mount_manager_);
disk_mount_manager_->AddObserver(this);
}
BurnDeviceHandler::~BurnDeviceHandler() {
disk_mount_manager_->RemoveObserver(this);
}
void BurnDeviceHandler::SetCallbacks(const DiskCallback& add_callback,
const DiskCallback& remove_callback) {
add_callback_ = add_callback;
remove_callback_ = remove_callback;
}
std::vector<DiskMountManager::Disk> BurnDeviceHandler::GetBurnableDevices() {
const DiskMountManager::DiskMap& disks = disk_mount_manager_->disks();
std::vector<DiskMountManager::Disk> result;
for (DiskMountManager::DiskMap::const_iterator iter = disks.begin();
iter != disks.end();
++iter) {
const DiskMountManager::Disk& disk = *iter->second;
if (IsBurnableDevice(disk))
result.push_back(disk);
}
return result;
}
void BurnDeviceHandler::OnDiskEvent(DiskMountManager::DiskEvent event,
const DiskMountManager::Disk* disk) {
// We are only interested in burnable devices.
if (!IsBurnableDevice(*disk))
return;
switch (event) {
case DiskMountManager::DISK_ADDED:
add_callback_.Run(*disk);
break;
case DiskMountManager::DISK_REMOVED:
remove_callback_.Run(*disk);
break;
default: {
// Do nothing.
}
}
}
void BurnDeviceHandler::OnDeviceEvent(DiskMountManager::DeviceEvent event,
const std::string& device_path) {
// Do nothing.
}
void BurnDeviceHandler::OnMountEvent(
DiskMountManager::MountEvent event,
MountError error_code,
const DiskMountManager::MountPointInfo& mount_info) {
// Do nothing.
}
void BurnDeviceHandler::OnFormatEvent(DiskMountManager::FormatEvent event,
FormatError error_code,
const std::string& device_path) {
// Do nothing.
}
} // namespace imageburner
} // namespace chromeos
// Copyright (c) 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_IMAGEBURNER_BURN_DEVICE_HANDLER_H_
#define CHROME_BROWSER_CHROMEOS_IMAGEBURNER_BURN_DEVICE_HANDLER_H_
#include <string>
#include <vector>
#include "base/callback.h"
#include "chromeos/dbus/cros_disks_client.h"
#include "chromeos/disks/disk_mount_manager.h"
namespace chromeos {
namespace imageburner {
// This is the implementation for the communication between BurnManager
// and DiskMountManager.
// The main reason this is NOT merged into BurnManager is to improve
// testability, since both BurnManager and DiskMountManager are singleton
// in real usage.
class BurnDeviceHandler : public disks::DiskMountManager::Observer {
public:
// Triggered when a burnable device is added or removed.
typedef base::Callback<void(const disks::DiskMountManager::Disk& disk)>
DiskCallback;
// This class takes the pointer of DiskMountManager to improve testability,
// although it is singleton in the real usage.
explicit BurnDeviceHandler(disks::DiskMountManager* disk_mount_manager);
virtual ~BurnDeviceHandler();
// |add_callback| will be called when a new burnable device is added with
// the device's information.
// |remove_callback| will be called when a burnable device is removed.
// Note: This class is designed to connect to only one BurnManager,
// so it supports only single callback for each add and remove intentionally
// (rather than ObserverList).
void SetCallbacks(const DiskCallback& add_callback,
const DiskCallback& remove_callback);
// Returns devices on which we can burn recovery image.
std::vector<disks::DiskMountManager::Disk> GetBurnableDevices();
// DiskMountManager::Observer overrides.
virtual void OnDiskEvent(
disks::DiskMountManager::DiskEvent event,
const disks::DiskMountManager::Disk* disk) override;
virtual void OnDeviceEvent(
disks::DiskMountManager::DeviceEvent event,
const std::string& device_path) override;
virtual void OnMountEvent(
disks::DiskMountManager::MountEvent event,
MountError error_code,
const disks::DiskMountManager::MountPointInfo& mount_info) override;
virtual void OnFormatEvent(
disks::DiskMountManager::FormatEvent event,
FormatError error_code,
const std::string& device_path) override;
private:
disks::DiskMountManager* disk_mount_manager_; // Not owned by this class.
DiskCallback add_callback_;
DiskCallback remove_callback_;
DISALLOW_COPY_AND_ASSIGN(BurnDeviceHandler);
};
} // namespace imageburner
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_IMAGEBURNER_BURN_DEVICE_HANDLER_H_
// Copyright (c) 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.
#include "chrome/browser/chromeos/imageburner/burn_device_handler.h"
#include <string>
#include <utility>
#include <vector>
#include "base/bind.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "base/stl_util.h"
#include "chromeos/dbus/cros_disks_client.h"
#include "chromeos/disks/disk_mount_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
namespace imageburner {
namespace {
const bool kIsParent = true;
const bool kIsBootDevice = true;
const bool kHasMedia = true;
class FakeDiskMountManager : public disks::DiskMountManager {
public:
FakeDiskMountManager() {}
virtual ~FakeDiskMountManager() {
STLDeleteValues(&disks_);
}
// Emulates to add new disk physically (e.g., connecting a
// new USB flash to a Chrome OS).
void EmulateAddDisk(scoped_ptr<Disk> in_disk) {
DCHECK(in_disk.get());
// Keep the reference for the callback, before passing the ownership to
// InsertDisk. It should be safe, because it won't be deleted in
// InsertDisk.
Disk* disk = in_disk.get();
bool new_disk = InsertDisk(disk->device_path(), in_disk.Pass());
FOR_EACH_OBSERVER(
Observer, observers_,
OnDiskEvent(new_disk ? DISK_ADDED : DISK_CHANGED, disk));
}
// Emulates to remove a disk phyically (e.g., removing a USB flash from
// a Chrome OS).
void EmulateRemoveDisk(const std::string& source_path) {
scoped_ptr<Disk> disk(RemoveDisk(source_path));
if (disk.get()) {
FOR_EACH_OBSERVER(
Observer, observers_, OnDiskEvent(DISK_REMOVED, disk.get()));
}
}
// DiskMountManager overrides.
virtual void AddObserver(Observer* observer) override {
observers_.AddObserver(observer);
}
virtual void RemoveObserver(Observer* observer) override {
observers_.RemoveObserver(observer);
}
virtual const DiskMap& disks() const override {
return disks_;
}
// Following methods are not implemented.
virtual const Disk* FindDiskBySourcePath(
const std::string& source_path) const override {
return NULL;
}
virtual const MountPointMap& mount_points() const override {
// Note: mount_points_ will always be empty, now.
return mount_points_;
}
virtual void EnsureMountInfoRefreshed(
const EnsureMountInfoRefreshedCallback& callback) override {}
virtual void MountPath(const std::string& source_path,
const std::string& source_format,
const std::string& mount_label,
MountType type) override {}
virtual void UnmountPath(const std::string& mount_path,
UnmountOptions options,
const UnmountPathCallback& callback) override {}
virtual void FormatMountedDevice(const std::string& mount_path) override {}
virtual void UnmountDeviceRecursively(
const std::string& device_path,
const UnmountDeviceRecursivelyCallbackType& callback) override {}
virtual bool AddDiskForTest(Disk* disk) override { return false; }
virtual bool AddMountPointForTest(
const MountPointInfo& mount_point) override {
return false;
}
private:
bool InsertDisk(const std::string& path, scoped_ptr<Disk> disk) {
std::pair<DiskMap::iterator, bool> insert_result =
disks_.insert(std::pair<std::string, Disk*>(path, NULL));
if (!insert_result.second) {
// There is already an entry. Delete it before replacing.
delete insert_result.first->second;
}
insert_result.first->second = disk.release(); // Moves ownership.
return insert_result.second;
}
scoped_ptr<Disk> RemoveDisk(const std::string& path) {
DiskMap::iterator iter = disks_.find(path);
if (iter == disks_.end()) {
// Not found.
return scoped_ptr<Disk>();
}
scoped_ptr<Disk> result(iter->second);
disks_.erase(iter);
return result.Pass();
}
ObserverList<Observer> observers_;
DiskMap disks_;
MountPointMap mount_points_;
DISALLOW_COPY_AND_ASSIGN(FakeDiskMountManager);
};
void CopyDevicePathCallback(
std::string* out_path, const disks::DiskMountManager::Disk& disk) {
*out_path = disk.device_path();
}
} // namespace
class BurnDeviceHandlerTest : public testing::Test {
protected:
virtual void SetUp() override {
disk_mount_manager_.reset(new FakeDiskMountManager);
}
virtual void TearDown() override {
disk_mount_manager_.reset();
}
static scoped_ptr<disks::DiskMountManager::Disk> CreateMockDisk(
const std::string& device_path,
bool is_parent,
bool on_boot_device,
bool has_media,
DeviceType device_type) {
return scoped_ptr<disks::DiskMountManager::Disk>(
new disks::DiskMountManager::Disk(
device_path,
"", // mount path
"", // system_path
"", // file_path
"", // device label
"", // drive label
"", // vendor id
"", // vendor name
"", // product id
"", // product name
"", // fs uuid
"", // system path prefix
device_type,
0, // total size in bytes
is_parent,
false, // is read only
has_media,
on_boot_device,
true, // on_removable_device
false)); // is hidden
}
scoped_ptr<FakeDiskMountManager> disk_mount_manager_;
};
TEST_F(BurnDeviceHandlerTest, GetBurnableDevices) {
// The devices which should be retrieved as burnable.
disk_mount_manager_->EmulateAddDisk(
CreateMockDisk("/dev/burnable_usb",
kIsParent, !kIsBootDevice, kHasMedia, DEVICE_TYPE_USB));
disk_mount_manager_->EmulateAddDisk(
CreateMockDisk("/dev/burnable_sd",
kIsParent, !kIsBootDevice, kHasMedia, DEVICE_TYPE_SD));
// If the device type is neither USB nor SD, it shouldn't be burnable.
disk_mount_manager_->EmulateAddDisk(
CreateMockDisk(
"/dev/non_burnable_unknown",
kIsParent, !kIsBootDevice, kHasMedia, DEVICE_TYPE_UNKNOWN));
disk_mount_manager_->EmulateAddDisk(
CreateMockDisk("/dev/non_burnable_dvd",
kIsParent, !kIsBootDevice, kHasMedia, DEVICE_TYPE_DVD));
// If not parent, it shouldn't be burnable.
disk_mount_manager_->EmulateAddDisk(
CreateMockDisk("/dev/non_burnable_not_parent",
!kIsParent, !kIsBootDevice, kHasMedia, DEVICE_TYPE_USB));
// If on_boot_device, it shouldn't be burnable.
disk_mount_manager_->EmulateAddDisk(
CreateMockDisk("/dev/non_burnable_boot_device",
kIsParent, kIsBootDevice, kHasMedia, DEVICE_TYPE_USB));
// If no media, it shouldn't be burnable.
disk_mount_manager_->EmulateAddDisk(
CreateMockDisk("/dev/non_burnable_no_media",
kIsParent, !kIsBootDevice, !kHasMedia, DEVICE_TYPE_USB));
BurnDeviceHandler handler(disk_mount_manager_.get());
const std::vector<disks::DiskMountManager::Disk>& burnable_devices =
handler.GetBurnableDevices();
ASSERT_EQ(2u, burnable_devices.size());
bool burnable_usb_found = false;
bool burnable_sd_found = false;
for (size_t i = 0; i < burnable_devices.size(); ++i) {
const std::string& device_path = burnable_devices[i].device_path();
burnable_usb_found |= (device_path == "/dev/burnable_usb");
burnable_sd_found |= (device_path == "/dev/burnable_sd");
}
EXPECT_TRUE(burnable_usb_found);
EXPECT_TRUE(burnable_sd_found);
}
TEST_F(BurnDeviceHandlerTest, Callback) {
std::string added_device;
std::string removed_device;
BurnDeviceHandler handler(disk_mount_manager_.get());
handler.SetCallbacks(
base::Bind(CopyDevicePathCallback, &added_device),
base::Bind(CopyDevicePathCallback, &removed_device));
// Emulate to connect a burnable device.
// |add_callback| should be invoked.
disk_mount_manager_->EmulateAddDisk(
CreateMockDisk("/dev/burnable",
kIsParent, !kIsBootDevice, kHasMedia, DEVICE_TYPE_USB));
EXPECT_EQ("/dev/burnable", added_device);
EXPECT_TRUE(removed_device.empty());
// Emulate to change the currently connected burnable device.
// Neither |add_callback| nor |remove_callback| should be called.
added_device.clear();
removed_device.clear();
disk_mount_manager_->EmulateAddDisk(
CreateMockDisk("/dev/burnable",
kIsParent, !kIsBootDevice, kHasMedia, DEVICE_TYPE_USB));
EXPECT_TRUE(added_device.empty());
EXPECT_TRUE(removed_device.empty());
// Emulate to disconnect the burnable device.
// |remove_callback| should be called.
added_device.clear();
removed_device.clear();
disk_mount_manager_->EmulateRemoveDisk("/dev/burnable");
EXPECT_TRUE(added_device.empty());
EXPECT_EQ("/dev/burnable", removed_device);
// Emulate to connect and unconnect an unburnable device.
// For each case, neither |add_callback| nor |remove_callback| should be
// called.
added_device.clear();
removed_device.clear();
disk_mount_manager_->EmulateAddDisk(
CreateMockDisk("/dev/unburnable",
!kIsParent, !kIsBootDevice, kHasMedia, DEVICE_TYPE_USB));
EXPECT_TRUE(added_device.empty());
EXPECT_TRUE(removed_device.empty());
added_device.clear();
removed_device.clear();
disk_mount_manager_->EmulateRemoveDisk("/dev/unburnable");
EXPECT_TRUE(added_device.empty());
EXPECT_TRUE(removed_device.empty());
}
} // namespace imageburner
} // namespace chromeos
This diff is collapsed.
This diff is collapsed.
// Copyright (c) 2012 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.
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/chromeos/imageburner/burn_manager.h"
namespace chromeos {
namespace imageburner {
using ::testing::_;
using ::testing::AnyNumber;
using ::testing::InSequence;
const std::string kConfigFileWithNoHwidProperty =
"name=some_name\n"
"version=version\n"
"filesize=1000\n"
"url=http://image.bin.zip\n";
const std::string kConfigFileWithNoNameProperty =
"version=version\n"
"filesize=2000\n"
"url=http://some_image.bin.zip\n";
const std::string kConfigFileWithNoNewLineAtEnd =
"name=some_name\n"
"version=version\n"
"filesize=1000\n"
"hwid=some_hwid\n"
"url=http://image.bin.zip";
const std::string kSampleConfigFile =
"version=aaa\n"
"hwid=block_no_name\n"
"url=aaa\n"
"\n"
"name=some_name1\n"
"version=version1\n"
"hwid=hwid11\n"
"hwid=hwid12\n"
"hwid=hwid13\n"
"\n"
"filesize=1000\n"
"url=http://image1.bin.zip\n"
"file=url\n"
"name=some_name2\n"
"version=version2\n"
"hwid=hwid21\n"
"hwid=hwid22\n"
"hwid=hwid23\n"
"\n"
"filesize=1200\n"
"url=http://image2.bin.zip\n"
"file=file2"
"\n"
"name=some_name3\n"
"version=version3\n"
"hwid=hwid31\n"
"\n"
"filesize=3\n"
"url=http://image3.bin.zip\n"
"file=file3"
"\n"
"name=some_block_with_no_hwid\n"
"url=some_url\n"
"\n"
"name=some_name_invalid_block\n" // Good line.
"version=version \n" // Trailing whitespace.
"hwid=hwid41=q\n" // Extra =.
"hwid=hwid42\n"
"hwid= \n" // Blank property value.
"=\n"
"filesize=\n" // Empty property value.
"url\n" // No =.
" =something\n"
"name=another_block_with_no_hwid\n"
"version=version\n";
TEST(BurnManagerTest, ConfigFileTest) {
scoped_ptr<ConfigFile> cf(new ConfigFile());
EXPECT_TRUE(cf->empty());
cf.reset(new ConfigFile(""));
EXPECT_TRUE(cf->empty());
cf.reset(new ConfigFile(kConfigFileWithNoNameProperty));
EXPECT_TRUE(cf->empty());
cf.reset(new ConfigFile(kConfigFileWithNoHwidProperty));
EXPECT_TRUE(cf->empty());
cf.reset(new ConfigFile(kConfigFileWithNoNewLineAtEnd));
EXPECT_FALSE(cf->empty());
EXPECT_EQ(1u, cf->size());
EXPECT_EQ("http://image.bin.zip", cf->GetProperty("url", "some_hwid"));
EXPECT_EQ("some_name", cf->GetProperty("name", "some_hwid"));
cf.reset(new ConfigFile(kSampleConfigFile));
EXPECT_FALSE(cf->empty());
EXPECT_EQ(4u, cf->size());
EXPECT_EQ("", cf->GetProperty("version", "block_no_name"));
EXPECT_EQ("some_name1", cf->GetProperty("name", "hwid11"));
EXPECT_EQ("version1", cf->GetProperty("version", "hwid12"));
EXPECT_EQ("", cf->GetProperty("filesize", "hwid1_non_existent"));
EXPECT_EQ("http://image1.bin.zip", cf->GetProperty("url", "hwid13"));
EXPECT_EQ("", cf->GetProperty("hwid", "hwid11"));
EXPECT_EQ("", cf->GetProperty("", "hwid12"));
EXPECT_EQ("", cf->GetProperty("name", ""));
EXPECT_EQ("", cf->GetProperty("some_name", "hwid11"));
EXPECT_EQ("url", cf->GetProperty("file", "hwid11"));
EXPECT_EQ("http://image2.bin.zip", cf->GetProperty("url", "hwid21"));
EXPECT_EQ("some_name2", cf->GetProperty("name", "hwid23"));
EXPECT_EQ("http://image3.bin.zip", cf->GetProperty("url", "hwid31"));
EXPECT_EQ("some_name3", cf->GetProperty("name", "hwid31"));
EXPECT_EQ("some_name_invalid_block", cf->GetProperty("name", "hwid42"));
// TODO(tbarzic): make this pass.
// EXPECT_EQ("version", cf->GetProperty("version", "hwid42"));
EXPECT_EQ("", cf->GetProperty("filesize", "hwid42"));
EXPECT_EQ("", cf->GetProperty("url", "hwid42"));
// TODO(tbarzic): make this pass.
// EXPECT_EQ("", cf->GetProperty(" ", "hwid42"));
EXPECT_EQ("", cf->GetProperty("name", "hwid41"));
}
class MockStateMachineObserver : public StateMachine::Observer {
public:
MOCK_METHOD1(OnBurnStateChanged, void(StateMachine::State));
MOCK_METHOD1(OnError, void(int));
};
TEST(BurnManagerTest, StateMachineNormalWorkflow) {
scoped_ptr<StateMachine> state_machine(new StateMachine());
EXPECT_EQ(StateMachine::INITIAL, state_machine->state());
MockStateMachineObserver observer;
state_machine->AddObserver(&observer);
EXPECT_CALL(observer, OnBurnStateChanged(StateMachine::DOWNLOADING))
.Times(1)
.RetiresOnSaturation();
EXPECT_CALL(observer, OnBurnStateChanged(StateMachine::BURNING))
.Times(1)
.RetiresOnSaturation();
EXPECT_CALL(observer, OnBurnStateChanged(StateMachine::INITIAL))
.Times(1)
.RetiresOnSaturation();
EXPECT_FALSE(state_machine->download_started());
EXPECT_FALSE(state_machine->download_finished());
EXPECT_TRUE(state_machine->new_burn_posible());
state_machine->OnDownloadStarted();
EXPECT_EQ(StateMachine::DOWNLOADING, state_machine->state());
EXPECT_TRUE(state_machine->download_started());
EXPECT_FALSE(state_machine->download_finished());
EXPECT_FALSE(state_machine->new_burn_posible());
state_machine->OnDownloadFinished();
// TODO(tbarzic): make this pass.
// EXPECT_EQ(StateMachine::INITIAL, state_machine->state());
EXPECT_TRUE(state_machine->download_started());
EXPECT_TRUE(state_machine->download_finished());
EXPECT_FALSE(state_machine->new_burn_posible());
state_machine->OnBurnStarted();
EXPECT_EQ(StateMachine::BURNING, state_machine->state());
EXPECT_TRUE(state_machine->download_started());
EXPECT_TRUE(state_machine->download_finished());
EXPECT_FALSE(state_machine->new_burn_posible());
state_machine->OnSuccess();
EXPECT_EQ(StateMachine::INITIAL, state_machine->state());
EXPECT_TRUE(state_machine->download_started());
EXPECT_TRUE(state_machine->download_finished());
EXPECT_TRUE(state_machine->new_burn_posible());
}
TEST(BurnManagerTest, StateMachineError) {
scoped_ptr<StateMachine> state_machine(new StateMachine());
MockStateMachineObserver observer;
// We don't want state change to INITIAL due to error to be reported to
// observers. We use OnError for that.
EXPECT_CALL(observer, OnBurnStateChanged(_))
.Times(AnyNumber());
EXPECT_CALL(observer, OnBurnStateChanged(StateMachine::INITIAL))
.Times(0);
{
InSequence error_calls;
EXPECT_CALL(observer, OnError(1234))
.Times(1);
EXPECT_CALL(observer, OnError(4321))
.Times(1);
EXPECT_CALL(observer, OnError(0))
.Times(1);
}
state_machine->AddObserver(&observer);
state_machine->OnDownloadStarted();
state_machine->OnError(1234);
// If called before download finished, download flags should be reset.
EXPECT_FALSE(state_machine->download_started());
EXPECT_EQ(state_machine->state(), StateMachine::INITIAL);
EXPECT_TRUE(state_machine->new_burn_posible());
state_machine->OnDownloadStarted();
state_machine->OnDownloadFinished();
state_machine->OnError(4321);
// If called after download finished, download flags should not be changed.
EXPECT_TRUE(state_machine->download_started());
EXPECT_TRUE(state_machine->download_finished());
EXPECT_EQ(state_machine->state(), StateMachine::INITIAL);
EXPECT_TRUE(state_machine->new_burn_posible());
state_machine->OnBurnStarted();
state_machine->OnError(0);
EXPECT_EQ(state_machine->state(), StateMachine::INITIAL);
EXPECT_TRUE(state_machine->new_burn_posible());
}
TEST(BurnManagerTest, StateMachineObservers) {
scoped_ptr<StateMachine> state_machine(new StateMachine());
MockStateMachineObserver observer1, observer2;
EXPECT_CALL(observer1, OnBurnStateChanged(_))
.Times(0);
EXPECT_CALL(observer2, OnBurnStateChanged(_))
.Times(0);
EXPECT_CALL(observer1, OnError(_))
.Times(0);
EXPECT_CALL(observer2, OnError(_))
.Times(0);
state_machine->OnDownloadStarted();
state_machine->OnError(1);
state_machine->AddObserver(&observer1);
state_machine->AddObserver(&observer2);
EXPECT_CALL(observer1, OnBurnStateChanged(_))
.Times(1);
EXPECT_CALL(observer2, OnBurnStateChanged(_))
.Times(1);
EXPECT_CALL(observer1, OnError(_))
.Times(1);
EXPECT_CALL(observer2, OnError(_))
.Times(1);
state_machine->OnDownloadStarted();
state_machine->OnError(1);
state_machine->RemoveObserver(&observer1);
EXPECT_CALL(observer1, OnBurnStateChanged(_))
.Times(0);
EXPECT_CALL(observer2, OnBurnStateChanged(_))
.Times(1);
EXPECT_CALL(observer1, OnError(_))
.Times(0);
EXPECT_CALL(observer2, OnError(_))
.Times(1);
state_machine->OnDownloadStarted();
state_machine->OnError(1);
}
} // namespace imageburner
} // namespace chromeos
<!DOCTYPE html> <!DOCTYPE html>
<html i18n-values="dir:textdirection;"> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8"></meta> <!-- TODO(crbug.com/427785): Remove this file after 2015-10-31. -->
<title i18n-content="title"></title> <meta http-equiv="refresh"
<link rel="stylesheet" href="image_burner.css"> content="0;url=http://google.com/chromeos/recovery">
<script src="chrome://resources/js/util.js"></script>
<script src="chrome://resources/js/load_time_data.js"></script>
<script src="chrome://imageburner/strings.js"></script>
<script src="chrome://imageburner/image_burner.js"></script>
</head> </head>
<body class="default-text" i18n-values=".style.fontFamily:fontfamily"> <body></body>
<header id="burn-header">
<h1 i18n-content="headerTitle"></h1>
<p i18n-content="headerDescription"></p>
<a id="more-info-link" i18n-values="href:moreInfoLink" target="_blank"
i18n-content="headerLink"></a>
</header>
<div id="main-content">
<div id="status-icon"></div>
<div id="status-info">
<h2 id="status-text" class="status-text"></h2>
<div id="progress-status-div">
<p id="progress-text" class="progress-text"></p>
<div id="progress-status" class="float-start">
<progress id="progress-div" class="float-start"></progress>
<button id="cancel-button" class="float-start"
i18n-content="cancelButton">
</button>
</div>
<p id="pending-time" class="progress-text"></p>
</div>
<ul id="device-selection"></ul>
<div id="warning-div">
<div id="warning-icon" class="float-start"></div>
<p id="warning-text" class="float-start"></p>
<button id="warning-button" class="float-start"></button>
</div>
<div class="new-line"></div>
</div>
<div id="burn-footer"></div>
</div>
<script src="chrome://resources/js/i18n_template2.js"></script>
</body>
</html> </html>
This diff is collapsed.
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
//
// TODO(crbug.com/427785): Remove this file after 2015-10-31.
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_IMAGEBURNER_IMAGEBURNER_UI_H_ #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_IMAGEBURNER_IMAGEBURNER_UI_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_IMAGEBURNER_IMAGEBURNER_UI_H_ #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_IMAGEBURNER_IMAGEBURNER_UI_H_
...@@ -16,4 +18,3 @@ class ImageBurnUI : public content::WebUIController { ...@@ -16,4 +18,3 @@ class ImageBurnUI : public content::WebUIController {
}; };
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_IMAGEBURNER_IMAGEBURNER_UI_H_ #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_IMAGEBURNER_IMAGEBURNER_UI_H_
...@@ -373,12 +373,6 @@ ...@@ -373,12 +373,6 @@
'browser/chromeos/geolocation/simple_geolocation_request.h', 'browser/chromeos/geolocation/simple_geolocation_request.h',
'browser/chromeos/idle_detector.cc', 'browser/chromeos/idle_detector.cc',
'browser/chromeos/idle_detector.h', 'browser/chromeos/idle_detector.h',
'browser/chromeos/imageburner/burn_controller.cc',
'browser/chromeos/imageburner/burn_controller.h',
'browser/chromeos/imageburner/burn_device_handler.cc',
'browser/chromeos/imageburner/burn_device_handler.h',
'browser/chromeos/imageburner/burn_manager.cc',
'browser/chromeos/imageburner/burn_manager.h',
'browser/chromeos/input_method/accessibility.cc', 'browser/chromeos/input_method/accessibility.cc',
'browser/chromeos/input_method/accessibility.h', 'browser/chromeos/input_method/accessibility.h',
'browser/chromeos/input_method/browser_state_monitor.cc', 'browser/chromeos/input_method/browser_state_monitor.cc',
......
...@@ -185,8 +185,6 @@ ...@@ -185,8 +185,6 @@
'browser/chromeos/fileapi/file_access_permissions_unittest.cc', 'browser/chromeos/fileapi/file_access_permissions_unittest.cc',
'browser/chromeos/fileapi/file_system_backend_unittest.cc', 'browser/chromeos/fileapi/file_system_backend_unittest.cc',
'browser/chromeos/geolocation/simple_geolocation_unittest.cc', 'browser/chromeos/geolocation/simple_geolocation_unittest.cc',
'browser/chromeos/imageburner/burn_device_handler_unittest.cc',
'browser/chromeos/imageburner/burn_manager_unittest.cc',
'browser/chromeos/input_method/browser_state_monitor_unittest.cc', 'browser/chromeos/input_method/browser_state_monitor_unittest.cc',
'browser/chromeos/input_method/input_method_configuration_unittest.cc', 'browser/chromeos/input_method/input_method_configuration_unittest.cc',
'browser/chromeos/input_method/input_method_engine_unittest.cc', 'browser/chromeos/input_method/input_method_engine_unittest.cc',
......
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