diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-24 16:11:39 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-24 16:11:39 +0000 |
commit | 860f594adad88104987735b515344f7491b1e8ff (patch) | |
tree | 70581b5c8b447c706cf005eb8550da7e612ac448 | |
parent | 69d5be3f63008c46a937ffb9e62d230ec50ac981 (diff) | |
download | chromium_src-860f594adad88104987735b515344f7491b1e8ff.zip chromium_src-860f594adad88104987735b515344f7491b1e8ff.tar.gz chromium_src-860f594adad88104987735b515344f7491b1e8ff.tar.bz2 |
Revert 133691 because it accidentally reverted revs 133686 and 133684.
TBR=sadrul@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10202012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133699 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/ash.gyp | 4 | ||||
-rw-r--r-- | ash/focus_cycler_unittest.cc | 49 | ||||
-rw-r--r-- | ash/shell.cc | 72 | ||||
-rw-r--r-- | ash/shell.h | 6 | ||||
-rw-r--r-- | ash/system/network/tray_network.cc | 30 | ||||
-rw-r--r-- | ash/system/tray/system_tray.cc | 81 | ||||
-rw-r--r-- | ash/system/tray/system_tray.h | 13 | ||||
-rw-r--r-- | ash/system/tray/system_tray_widget_delegate.cc (renamed from ash/status_area/status_area_view.cc) | 26 | ||||
-rw-r--r-- | ash/system/tray/system_tray_widget_delegate.h (renamed from ash/status_area/status_area_view.h) | 6 | ||||
-rw-r--r-- | chrome/browser/resources/file_manager/js/directory_model.js | 371 | ||||
-rw-r--r-- | chrome/browser/resources/file_manager/js/file_manager.js | 86 | ||||
-rw-r--r-- | chrome/browser/resources/file_manager/js/file_manager_pyauto.js | 6 |
12 files changed, 398 insertions, 352 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp index 5eb5c8a..3d774e4 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -117,8 +117,6 @@ 'shell_delegate.h', 'shell_factory.h', 'shell_window_ids.h', - 'status_area/status_area_view.cc', - 'status_area/status_area_view.h', 'system/audio/audio_observer.h', 'system/audio/tray_volume.cc', 'system/audio/tray_volume.h', @@ -152,6 +150,8 @@ 'system/tray/system_tray_delegate.h', 'system/tray/system_tray_item.cc', 'system/tray/system_tray_item.h', + 'system/tray/system_tray_widget_delegate.cc', + 'system/tray/system_tray_widget_delegate.h', 'system/tray/tray_constants.cc', 'system/tray/tray_constants.h', 'system/tray/tray_empty.cc', diff --git a/ash/focus_cycler_unittest.cc b/ash/focus_cycler_unittest.cc index 23468f3..9f3e429 100644 --- a/ash/focus_cycler_unittest.cc +++ b/ash/focus_cycler_unittest.cc @@ -7,7 +7,8 @@ #include "ash/launcher/launcher.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" -#include "ash/status_area/status_area_view.h" +#include "ash/system/tray/system_tray.h" +#include "ash/system/tray/system_tray_widget_delegate.h" #include "ash/wm/window_util.h" #include "ash/test/ash_test_base.h" #include "ash/shell_factory.h" @@ -30,6 +31,12 @@ internal::StatusAreaView* GetStatusAreaView(views::Widget* widget) { widget->GetContentsView()); } +SystemTray* CreateSystemTray() { + SystemTray* tray = new SystemTray; + tray->CreateWidget(); + return tray; +} + } // namespace typedef AshTestBase FocusCyclerTest; @@ -54,10 +61,10 @@ TEST_F(FocusCyclerTest, CycleFocusForward) { scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); // Add the Status area - views::Widget* status_widget = internal::CreateStatusArea(NULL); - ASSERT_TRUE(status_widget); - focus_cycler->AddWidget(status_widget); - GetStatusAreaView(status_widget)->SetFocusCyclerForTesting( + scoped_ptr<SystemTray> tray(CreateSystemTray()); + ASSERT_TRUE(tray->widget()); + focus_cycler->AddWidget(tray->widget()); + GetStatusAreaView(tray->widget())->SetFocusCyclerForTesting( focus_cycler.get()); // Add the launcher @@ -77,7 +84,7 @@ TEST_F(FocusCyclerTest, CycleFocusForward) { // Cycle focus to the status area focus_cycler->RotateFocus(FocusCycler::FORWARD); - EXPECT_TRUE(status_widget->IsActive()); + EXPECT_TRUE(tray->widget()->IsActive()); // Cycle focus to the launcher focus_cycler->RotateFocus(FocusCycler::FORWARD); @@ -92,10 +99,10 @@ TEST_F(FocusCyclerTest, CycleFocusBackward) { scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); // Add the Status area - views::Widget* status_widget = internal::CreateStatusArea(NULL); - ASSERT_TRUE(status_widget); - focus_cycler->AddWidget(status_widget); - GetStatusAreaView(status_widget)->SetFocusCyclerForTesting( + scoped_ptr<SystemTray> tray(CreateSystemTray()); + ASSERT_TRUE(tray->widget()); + focus_cycler->AddWidget(tray->widget()); + GetStatusAreaView(tray->widget())->SetFocusCyclerForTesting( focus_cycler.get()); // Add the launcher @@ -119,7 +126,7 @@ TEST_F(FocusCyclerTest, CycleFocusBackward) { // Cycle focus to the status area focus_cycler->RotateFocus(FocusCycler::BACKWARD); - EXPECT_TRUE(status_widget->IsActive()); + EXPECT_TRUE(tray->widget()->IsActive()); // Cycle focus to the browser focus_cycler->RotateFocus(FocusCycler::BACKWARD); @@ -161,10 +168,10 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusForwardInvisible) { scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); // Add the Status area - views::Widget* status_widget = internal::CreateStatusArea(NULL); - ASSERT_TRUE(status_widget); - focus_cycler->AddWidget(status_widget); - GetStatusAreaView(status_widget)->SetFocusCyclerForTesting( + scoped_ptr<SystemTray> tray(CreateSystemTray()); + ASSERT_TRUE(tray->widget()); + focus_cycler->AddWidget(tray->widget()); + GetStatusAreaView(tray->widget())->SetFocusCyclerForTesting( focus_cycler.get()); // Add the launcher @@ -184,7 +191,7 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusForwardInvisible) { // Cycle focus to the status area focus_cycler->RotateFocus(FocusCycler::FORWARD); - EXPECT_TRUE(status_widget->IsActive()); + EXPECT_TRUE(tray->widget()->IsActive()); // Cycle focus to the browser focus_cycler->RotateFocus(FocusCycler::FORWARD); @@ -195,10 +202,10 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusBackwardInvisible) { scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); // Add the Status area - views::Widget* status_widget = internal::CreateStatusArea(NULL); - ASSERT_TRUE(status_widget); - focus_cycler->AddWidget(status_widget); - GetStatusAreaView(status_widget)->SetFocusCyclerForTesting( + scoped_ptr<SystemTray> tray(CreateSystemTray()); + ASSERT_TRUE(tray->widget()); + focus_cycler->AddWidget(tray->widget()); + GetStatusAreaView(tray->widget())->SetFocusCyclerForTesting( focus_cycler.get()); // Add the launcher @@ -218,7 +225,7 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusBackwardInvisible) { // Cycle focus to the status area focus_cycler->RotateFocus(FocusCycler::BACKWARD); - EXPECT_TRUE(status_widget->IsActive()); + EXPECT_TRUE(tray->widget()->IsActive()); // Cycle focus to the browser focus_cycler->RotateFocus(FocusCycler::BACKWARD); diff --git a/ash/shell.cc b/ash/shell.cc index e985684..83b7aac 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -22,23 +22,10 @@ #include "ash/shell_delegate.h" #include "ash/shell_factory.h" #include "ash/shell_window_ids.h" -#include "ash/system/audio/tray_volume.h" -#include "ash/system/bluetooth/tray_bluetooth.h" -#include "ash/system/brightness/tray_brightness.h" -#include "ash/system/date/tray_date.h" -#include "ash/system/ime/tray_ime.h" -#include "ash/system/network/tray_network.h" -#include "ash/system/power/power_status_observer.h" -#include "ash/system/power/power_supply_status.h" -#include "ash/system/power/tray_power.h" -#include "ash/system/settings/tray_settings.h" +#include "ash/system/bluetooth/bluetooth_observer.h" +#include "ash/system/network/network_observer.h" #include "ash/system/tray/system_tray.h" #include "ash/system/tray/system_tray_delegate.h" -#include "ash/system/tray/tray_empty.h" -#include "ash/system/tray_accessibility.h" -#include "ash/system/tray_caps_lock.h" -#include "ash/system/tray_update.h" -#include "ash/system/user/tray_user.h" #include "ash/tooltips/tooltip_controller.h" #include "ash/wm/activation_controller.h" #include "ash/wm/base_layout_manager.h" @@ -530,8 +517,7 @@ Shell::Shell(ShellDelegate* delegate) delegate_(delegate), shelf_(NULL), panel_layout_manager_(NULL), - root_window_layout_(NULL), - status_widget_(NULL) { + root_window_layout_(NULL) { gfx::Screen::SetInstance(screen_); ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get())); } @@ -681,55 +667,13 @@ void Shell::Init() { CommandLine* command_line = CommandLine::ForCurrentProcess(); - // TODO(sad): All of these initialization should happen in SystemTray. tray_.reset(new SystemTray()); if (delegate_.get()) tray_delegate_.reset(delegate_->CreateSystemTrayDelegate(tray_.get())); if (!tray_delegate_.get()) tray_delegate_.reset(new DummySystemTrayDelegate()); - - internal::TrayVolume* tray_volume = new internal::TrayVolume(); - internal::TrayBluetooth* tray_bluetooth = new internal::TrayBluetooth(); - internal::TrayBrightness* tray_brightness = new internal::TrayBrightness(); - internal::TrayDate* tray_date = new internal::TrayDate(); - internal::TrayPower* tray_power = new internal::TrayPower(); - internal::TrayNetwork* tray_network = new internal::TrayNetwork; - internal::TrayUser* tray_user = new internal::TrayUser; - internal::TrayAccessibility* tray_accessibility = - new internal::TrayAccessibility; - internal::TrayCapsLock* tray_caps_lock = new internal::TrayCapsLock; - internal::TrayIME* tray_ime = new internal::TrayIME; - internal::TrayUpdate* tray_update = new internal::TrayUpdate; - - tray_->accessibility_observer_ = tray_accessibility; - tray_->audio_observer_ = tray_volume; - tray_->bluetooth_observer_ = tray_bluetooth; - tray_->brightness_observer_ = tray_brightness; - tray_->caps_lock_observer_ = tray_caps_lock; - tray_->clock_observer_ = tray_date; - tray_->ime_observer_ = tray_ime; - tray_->network_observer_ = tray_network; - tray_->power_status_observer_ = tray_power; - tray_->update_observer_ = tray_update; - tray_->user_observer_ = tray_user; - - tray_->AddTrayItem(tray_user); - tray_->AddTrayItem(new internal::TrayEmpty()); - tray_->AddTrayItem(tray_power); - tray_->AddTrayItem(tray_network); - tray_->AddTrayItem(tray_bluetooth); - tray_->AddTrayItem(tray_ime); - tray_->AddTrayItem(tray_volume); - tray_->AddTrayItem(tray_brightness); - tray_->AddTrayItem(tray_update); - tray_->AddTrayItem(new internal::TraySettings()); - tray_->AddTrayItem(tray_accessibility); - tray_->AddTrayItem(tray_caps_lock); - tray_->AddTrayItem(tray_date); - tray_->SetVisible(tray_delegate_->GetTrayVisibilityOnStartup()); - - // TODO(sad): Replace uses of status_widget_ with tray_->GetWidget(). - status_widget_ = internal::CreateStatusArea(tray_.get()); + tray_->CreateItems(); + tray_->CreateWidget(); // This controller needs to be set before SetupManagedWindowMode. desktop_background_controller_.reset(new DesktopBackgroundController); @@ -746,7 +690,7 @@ void Shell::Init() { } focus_cycler_.reset(new internal::FocusCycler()); - focus_cycler_->AddWidget(status_widget_); + focus_cycler_->AddWidget(tray_->widget()); if (!delegate_.get() || delegate_->IsUserLoggedIn()) CreateLauncher(); @@ -914,10 +858,10 @@ bool Shell::IsInMaximizedMode() const { void Shell::InitLayoutManagers() { DCHECK(root_window_layout_); - DCHECK(status_widget_); + DCHECK(tray_->widget()); internal::ShelfLayoutManager* shelf_layout_manager = - new internal::ShelfLayoutManager(status_widget_); + new internal::ShelfLayoutManager(tray_->widget()); GetContainer(internal::kShellWindowId_LauncherContainer)-> SetLayoutManager(shelf_layout_manager); shelf_ = shelf_layout_manager; diff --git a/ash/shell.h b/ash/shell.h index 56a12c3..74ff8fc 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -365,11 +365,7 @@ class ASH_EXPORT Shell { // Owned by aura::RootWindow, cached here for type safety. internal::RootWindowLayoutManager* root_window_layout_; - // Status area with clock, Wi-Fi signal, etc. - views::Widget* status_widget_; - - // System tray with clock, Wi-Fi signal, etc. (a replacement in progress for - // |status_widget_|). + // System tray with clock, Wi-Fi signal, etc. scoped_ptr<SystemTray> tray_; // Used by ash/shell. diff --git a/ash/system/network/tray_network.cc b/ash/system/network/tray_network.cc index f3aedef..1dd542b 100644 --- a/ash/system/network/tray_network.cc +++ b/ash/system/network/tray_network.cc @@ -379,17 +379,24 @@ class NetworkDetailedView : public views::View, } void ToggleInfoBubble() { - if (info_bubble_) { - info_bubble_->GetWidget()->CloseNow(); - info_bubble_ = NULL; + if (ResetInfoBubble()) return; - } + info_bubble_ = new NonActivatableSettingsBubble( info_icon_, CreateNetworkInfoView()); views::BubbleDelegateView::CreateBubble(info_bubble_); info_bubble_->Show(); } + // Returns whether an existing info-bubble was closed. + bool ResetInfoBubble() { + if (!info_bubble_) + return false; + info_bubble_->GetWidget()->Close(); + info_bubble_ = NULL; + return true; + } + // Overridden from views::View. virtual void Layout() OVERRIDE { views::View::Layout(); @@ -410,9 +417,15 @@ class NetworkDetailedView : public views::View, const views::Event& event) OVERRIDE { ash::SystemTrayDelegate* delegate = ash::Shell::GetInstance()->tray_delegate(); - if (sender == info_icon_) + if (sender == info_icon_) { ToggleInfoBubble(); - else if (sender == button_wifi_) + return; + } + + // If the info bubble was visible, close it when some other item is clicked + // on. + ResetInfoBubble(); + if (sender == button_wifi_) delegate->ToggleWifi(); else if (sender == button_cellular_) delegate->ToggleCellular(); @@ -434,10 +447,7 @@ class NetworkDetailedView : public views::View, ash::Shell::GetInstance()->tray_delegate(); // If the info bubble was visible, close it when some other item is clicked // on. - if (info_bubble_) { - info_bubble_->GetWidget()->Close(); - info_bubble_ = NULL; - } + ResetInfoBubble(); if (sender == header_text_) Shell::GetInstance()->tray()->ShowDefaultView(); diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc index 5870e55..6fa88820 100644 --- a/ash/system/tray/system_tray.cc +++ b/ash/system/tray/system_tray.cc @@ -7,9 +7,25 @@ #include "ash/shell.h" #include "ash/shell/panel_window.h" #include "ash/shell_window_ids.h" +#include "ash/system/audio/tray_volume.h" +#include "ash/system/bluetooth/tray_bluetooth.h" +#include "ash/system/brightness/tray_brightness.h" +#include "ash/system/date/tray_date.h" +#include "ash/system/ime/tray_ime.h" +#include "ash/system/network/tray_network.h" +#include "ash/system/power/power_status_observer.h" +#include "ash/system/power/power_supply_status.h" +#include "ash/system/power/tray_power.h" +#include "ash/system/settings/tray_settings.h" +#include "ash/system/tray/tray_empty.h" #include "ash/system/tray/tray_constants.h" #include "ash/system/tray/system_tray_delegate.h" #include "ash/system/tray/system_tray_item.h" +#include "ash/system/tray/system_tray_widget_delegate.h" +#include "ash/system/tray_accessibility.h" +#include "ash/system/tray_caps_lock.h" +#include "ash/system/tray_update.h" +#include "ash/system/user/tray_user.h" #include "ash/system/user/login_status.h" #include "ash/wm/shadow_types.h" #include "ash/wm/shelf_layout_manager.h" @@ -406,6 +422,7 @@ SystemTray::SystemTray() power_status_observer_(NULL), update_observer_(NULL), user_observer_(NULL), + widget_(NULL), bubble_(NULL), popup_(NULL), background_(new internal::SystemTrayBackground), @@ -442,6 +459,70 @@ SystemTray::~SystemTray() { popup_->CloseNow(); } +void SystemTray::CreateItems() { + internal::TrayVolume* tray_volume = new internal::TrayVolume(); + internal::TrayBluetooth* tray_bluetooth = new internal::TrayBluetooth(); + internal::TrayBrightness* tray_brightness = new internal::TrayBrightness(); + internal::TrayDate* tray_date = new internal::TrayDate(); + internal::TrayPower* tray_power = new internal::TrayPower(); + internal::TrayNetwork* tray_network = new internal::TrayNetwork; + internal::TrayUser* tray_user = new internal::TrayUser; + internal::TrayAccessibility* tray_accessibility = + new internal::TrayAccessibility; + internal::TrayCapsLock* tray_caps_lock = new internal::TrayCapsLock; + internal::TrayIME* tray_ime = new internal::TrayIME; + internal::TrayUpdate* tray_update = new internal::TrayUpdate; + + accessibility_observer_ = tray_accessibility; + audio_observer_ = tray_volume; + bluetooth_observer_ = tray_bluetooth; + brightness_observer_ = tray_brightness; + caps_lock_observer_ = tray_caps_lock; + clock_observer_ = tray_date; + ime_observer_ = tray_ime; + network_observer_ = tray_network; + power_status_observer_ = tray_power; + update_observer_ = tray_update; + user_observer_ = tray_user; + + AddTrayItem(tray_user); + AddTrayItem(new internal::TrayEmpty()); + AddTrayItem(tray_power); + AddTrayItem(tray_network); + AddTrayItem(tray_bluetooth); + AddTrayItem(tray_ime); + AddTrayItem(tray_volume); + AddTrayItem(tray_brightness); + AddTrayItem(tray_update); + AddTrayItem(new internal::TraySettings()); + AddTrayItem(tray_accessibility); + AddTrayItem(tray_caps_lock); + AddTrayItem(tray_date); + SetVisible(ash::Shell::GetInstance()->tray_delegate()-> + GetTrayVisibilityOnStartup()); +} + +void SystemTray::CreateWidget() { + if (widget_) + widget_->Close(); + widget_ = new views::Widget; + internal::StatusAreaView* status_area_view = new internal::StatusAreaView; + views::Widget::InitParams params( + views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); + gfx::Size ps = GetPreferredSize(); + params.bounds = gfx::Rect(0, 0, ps.width(), ps.height()); + params.delegate = status_area_view; + params.parent = Shell::GetInstance()->GetContainer( + ash::internal::kShellWindowId_StatusContainer); + params.transparent = true; + widget_->Init(params); + widget_->set_focus_on_creation(false); + status_area_view->AddChildView(this); + widget_->SetContentsView(status_area_view); + widget_->Show(); + widget_->GetNativeView()->SetName("StatusTrayWidget"); +} + void SystemTray::AddTrayItem(SystemTrayItem* item) { items_.push_back(item); diff --git a/ash/system/tray/system_tray.h b/ash/system/tray/system_tray.h index 58049ec..b9dbab2 100644 --- a/ash/system/tray/system_tray.h +++ b/ash/system/tray/system_tray.h @@ -49,6 +49,12 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( SystemTray(); virtual ~SystemTray(); + // Creates the default set of items for the sytem tray. + void CreateItems(); + + // Creates the widget for the tray. + void CreateWidget(); + // Adds a new item in the tray. void AddTrayItem(SystemTrayItem* item); @@ -82,6 +88,8 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( // Returns true if the launcher should show. bool should_show_launcher() const { return popup_ && should_show_launcher_; } + views::Widget* widget() const { return widget_; } + AccessibilityObserver* accessibility_observer() const { return accessibility_observer_; } @@ -117,8 +125,6 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( } private: - friend class Shell; - void ShowItems(std::vector<SystemTrayItem*>& items, bool details, bool activate); @@ -164,6 +170,9 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( UpdateObserver* update_observer_; UserObserver* user_observer_; + // The widget hosting the tray. + views::Widget* widget_; + // The popup widget and the delegate. internal::SystemTrayBubble* bubble_; views::Widget* popup_; diff --git a/ash/status_area/status_area_view.cc b/ash/system/tray/system_tray_widget_delegate.cc index 7e1478f..acc937a 100644 --- a/ash/status_area/status_area_view.cc +++ b/ash/system/tray/system_tray_widget_delegate.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/status_area/status_area_view.h" +#include "ash/system/tray/system_tray_widget_delegate.h" #include "ash/ash_export.h" #include "ash/focus_cycler.h" @@ -65,29 +65,5 @@ bool StatusAreaView::CanActivate() const { void StatusAreaView::DeleteDelegate() { } -ASH_EXPORT views::Widget* CreateStatusArea(views::View* contents) { - if (!contents) { - contents = new views::View; - contents->set_focusable(true); - } - StatusAreaView* status_area_view = new StatusAreaView; - views::Widget* widget = new views::Widget; - views::Widget::InitParams params( - views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); - gfx::Size ps = contents->GetPreferredSize(); - params.bounds = gfx::Rect(0, 0, ps.width(), ps.height()); - params.delegate = status_area_view; - params.parent = Shell::GetInstance()->GetContainer( - ash::internal::kShellWindowId_StatusContainer); - params.transparent = true; - widget->Init(params); - widget->set_focus_on_creation(false); - status_area_view->AddChildView(contents); - widget->SetContentsView(status_area_view); - widget->Show(); - widget->GetNativeView()->SetName("StatusAreaView"); - return widget; -} - } // namespace internal } // namespace ash diff --git a/ash/status_area/status_area_view.h b/ash/system/tray/system_tray_widget_delegate.h index 9046573..1834afd 100644 --- a/ash/status_area/status_area_view.h +++ b/ash/system/tray/system_tray_widget_delegate.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ASH_STATUS_AREA_STATUS_AREA_VIEW_H_ -#define ASH_STATUS_AREA_STATUS_AREA_VIEW_H_ +#ifndef ASH_SYSTEM_TRAY_SYSTEM_TRAY_WIDGET_DELEGATE_H_ +#define ASH_SYSTEM_TRAY_SYSTEM_TRAY_WIDGET_DELEGATE_H_ #pragma once #include "ash/ash_export.h" @@ -46,4 +46,4 @@ class ASH_EXPORT StatusAreaView : public views::WidgetDelegate, } // namespace internal } // namespace ash -#endif // ASH_STATUS_AREA_STATUS_AREA_VIEW_H_ +#endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_WIDGET_DELEGATE_H_ diff --git a/chrome/browser/resources/file_manager/js/directory_model.js b/chrome/browser/resources/file_manager/js/directory_model.js index 79af6ad..55a92eb 100644 --- a/chrome/browser/resources/file_manager/js/directory_model.js +++ b/chrome/browser/resources/file_manager/js/directory_model.js @@ -50,7 +50,7 @@ function DirectoryModel(root, singleSelection, showGData, metadataCache) { // The map 'name' -> callback. Callbacks are function(entry) -> boolean. this.filters_ = {}; - this.filterHidden = true; + this.setFilterHidden(true); // Readonly status. this.readonly_ = false; @@ -91,136 +91,169 @@ DirectoryModel.DOWNLOADS_DIRECTORY = 'Downloads'; */ DirectoryModel.GDATA_DIRECTORY = 'gdata'; -DirectoryModel.prototype = { - __proto__: cr.EventTarget.prototype, +/** + * DirectoryModel extends cr.EventTarget. + */ +DirectoryModel.prototype.__proto__ = cr.EventTarget.prototype; - /** - * Files in the current directory. - * @type {cr.ui.ArrayDataModel} - */ - get fileList() { - return this.fileList_; - }, +/** + * @return {cr.ui.ArrayDataModel} Files in the current directory. + */ +DirectoryModel.prototype.getFileList = function() { + return this.fileList_; +}; - /** - * Selection in the fileList. - * @type {cr.ui.ListSelectionModel|cr.ui.ListSingleSelectionModel} - */ - get fileListSelection() { - return this.fileListSelection_; - }, +/** + * Sort the file list. + * @param {string} sortField Sort field. + * @param {string} sortDirection "asc" or "desc". + */ +DirectoryModel.prototype.sortFileList = function(sortField, sortDirection) { + this.fileList_.sort(sortField, sortDirection); +}; - get rootType() { - return DirectoryModel.getRootType(this.currentEntry.fullPath); - }, +/** + * @return {cr.ui.ListSelectionModel|cr.ui.ListSingleSelectionModel} Selection + * in the fileList. + */ +DirectoryModel.prototype.getFileListSelection = function() { + return this.fileListSelection_; +}; - get rootName() { - return DirectoryModel.getRootName(this.currentEntry.fullPath); - }, +/** + * @return {DirectoryModel.RootType} Root type of current root. + */ +DirectoryModel.prototype.getRootType = function() { + return DirectoryModel.getRootType(this.currentDirEntry_.fullPath); +}; - /** - * True if current directory is read only. - * @type {boolean} - */ - get readonly() { - return this.readonly_; - }, - - get offline() { - return this.offline_; - }, - set offline(value) { - if (this.offline_ != value) { - this.offline_ = !!value; - this.updateReadonlyStatus_(); - } - }, - - get isSystemDirectoy() { - var path = this.currentEntry.fullPath; - return path == '/' || - path == '/' + DirectoryModel.REMOVABLE_DIRECTORY || - path == '/' + DirectoryModel.ARCHIVE_DIRECTORY; - }, - - get filterHidden() { - return !!this.filters_['hidden']; - }, - - set filterHidden(value) { - if (value) { - this.addFilter('hidden', - function(e) {return e.name.substr(0, 1) != '.';}); - } else { - this.removeFilter('hidden'); - } - }, +/** + * @return {string} Root name. + */ +DirectoryModel.prototype.getRootName = function() { + return DirectoryModel.getRootName(this.currentDirEntry_.fullPath); +}; - /** - * Current directory. - * @type {DirectoryEntry} - */ - get currentEntry() { - return this.currentDirEntry_; - }, +/** + * @return {boolean} True if current directory is read only. + */ +DirectoryModel.prototype.isReadOnly = function() { + return this.readonly_; +}; - set autoSelectIndex(value) { - this.autoSelectIndex_ = value; - }, +/** + * @return {boolean} If offline. + */ +DirectoryModel.prototype.isOffline = function() { + return this.offline_; +}; - /** - * Names of selected files. - * @type {Array.<string>} - */ - get selectedNames() { - var indexes = this.fileListSelection_.selectedIndexes; - var dataModel = this.fileList_; - if (dataModel) { - return indexes.map(function(i) { - return dataModel.item(i).name; - }); - } - return []; - }, - - set selectedNames(value) { - var indexes = []; - var dataModel = this.fileList_; - - function safeKey(key) { - // The transformation must: - // 1. Never generate a reserved name ('__proto__') - // 2. Keep different keys different. - return '#' + key; - } +/** + * @param {boolean} value New online status. + */ +DirectoryModel.prototype.setOffline = function(value) { + if (this.offline_ != value) { + this.offline_ = !!value; + this.updateReadonlyStatus_(); + } +}; - var hash = {}; +/** + * @return {boolean} If current directory is system. + */ +DirectoryModel.prototype.isSystemDirectory = function() { + var path = this.currentDirEntry_.fullPath; + return path == '/' || + path == '/' + DirectoryModel.REMOVABLE_DIRECTORY || + path == '/' + DirectoryModel.ARCHIVE_DIRECTORY; +}; - for (var i = 0; i < value.length; i++) - hash[safeKey(value[i])] = 1; +/** + * @return {boolean} If the files with names starting with "." are not shown. + */ +DirectoryModel.prototype.isFilterHiddenOn = function() { + return !!this.filters_['hidden']; +}; - for (var i = 0; i < dataModel.length; i++) { - if (hash.hasOwnProperty(safeKey(dataModel.item(i).name))) - indexes.push(i); - } - this.fileListSelection_.selectedIndexes = indexes; - }, +/** + * @param {boolean} value Whether files with leading "." are hidden. + */ +DirectoryModel.prototype.setFilterHidden = function(value) { + if (value) { + this.addFilter('hidden', + function(e) {return e.name.substr(0, 1) != '.';}); + } else { + this.removeFilter('hidden'); + } +}; - /** - * Lead item file name. - * @type {string?} - */ - get leadName() { - var index = this.fileListSelection_.leadIndex; - return index >= 0 && this.fileList_.item(index).name; - }, - - set leadName(value) { - for (var i = 0; i < this.fileList_.length; i++) { - if (this.fileList_.item(i).name == value) { - this.fileListSelection_.leadIndex = i; - return; - } +/** + * @return {DirectoryEntry} Current directory. + */ +DirectoryModel.prototype.getCurrentDirEntry = function() { + return this.currentDirEntry_; +}; + +/** + * @private + * @return {Array.<string>} Names of selected files. + */ +DirectoryModel.prototype.getSelectedNames_ = function() { + var indexes = this.fileListSelection_.selectedIndexes; + var dataModel = this.fileList_; + if (dataModel) { + return indexes.map(function(i) { + return dataModel.item(i).name; + }); + } + return []; +}; + +/** + * @private + * @param {Array.<string>} value List of names of selected files. + */ +DirectoryModel.prototype.setSelectedNames_ = function(value) { + var indexes = []; + var dataModel = this.fileList_; + + function safeKey(key) { + // The transformation must: + // 1. Never generate a reserved name ('__proto__') + // 2. Keep different keys different. + return '#' + key; + } + + var hash = {}; + + for (var i = 0; i < value.length; i++) + hash[safeKey(value[i])] = 1; + + for (var i = 0; i < dataModel.length; i++) { + if (hash.hasOwnProperty(safeKey(dataModel.item(i).name))) + indexes.push(i); + } + this.fileListSelection_.selectedIndexes = indexes; +}; + +/** + * @private + * @return {string} Lead item file name. + */ +DirectoryModel.prototype.getLeadName_ = function() { + var index = this.fileListSelection_.leadIndex; + return index >= 0 && this.fileList_.item(index).name; +}; + +/** + * @private + * @param {string} value The name of new lead index. + */ +DirectoryModel.prototype.setLeadName_ = function(value) { + for (var i = 0; i < this.fileList_.length; i++) { + if (this.fileList_.item(i).name == value) { + this.fileListSelection_.leadIndex = i; + return; } } }; @@ -334,7 +367,7 @@ DirectoryModel.prototype.rescan = function() { /** * @private - * @param {Array.<Entry>|cr.ui.ArrayDataModel} list + * @param {Array.<Entry>|cr.ui.ArrayDataModel} list File list. * @param {function} successCallback Callback on success. * @return {DirectoryModel.Scanner} New Scanner instance. */ @@ -369,24 +402,24 @@ DirectoryModel.prototype.createScanner_ = function(list, successCallback) { /** * @private - * @param {Array.<Entry>} entries + * @param {Array.<Entry>} entries List of files. */ DirectoryModel.prototype.replaceFileList_ = function(entries) { cr.dispatchSimpleEvent(this, 'begin-update-files'); this.fileListSelection_.beginChange(); - var selectedNames = this.selectedNames; + var selectedNames = this.getSelectedNames_(); // Restore leadIndex in case leadName no longer exists. var leadIndex = this.fileListSelection_.leadIndex; - var leadName = this.leadName; + var leadName = this.getLeadName_(); var spliceArgs = [].slice.call(entries); spliceArgs.unshift(0, this.fileList_.length); this.fileList_.splice.apply(this.fileList_, spliceArgs); - this.selectedNames = selectedNames; + this.setSelectedNames_(selectedNames); this.fileListSelection_.leadIndex = leadIndex; - this.leadName = leadName; + this.setLeadName_(leadName); this.fileListSelection_.endChange(); cr.dispatchSimpleEvent(this, 'end-update-files'); }; @@ -433,8 +466,8 @@ DirectoryModel.prototype.scan_ = function(callback) { /** * @private - * @param {Array.<Entry>} entries - * @param {function} callback + * @param {Array.<Entry>} entries Files. + * @param {function} callback Callback on done. */ DirectoryModel.prototype.prefetchCacheForSorting_ = function(entries, callback) { @@ -480,17 +513,17 @@ DirectoryModel.prototype.deleteEntries = function(entries, opt_callback) { }; /** - * @param {string} name + * @param {string} name Filename. */ DirectoryModel.prototype.onEntryChanged = function(name) { - var currentEntry = this.currentEntry; + var currentEntry = this.currentDirEntry_; var dm = this.fileList_; var self = this; function onEntryFound(entry) { self.prefetchCacheForSorting_([entry], function() { // Do nothing if current directory changed during async operations. - if (self.currentEntry != currentEntry) + if (self.currentDirEntry_ != currentEntry) return; var index = self.findIndexByName_(name); @@ -503,7 +536,7 @@ DirectoryModel.prototype.onEntryChanged = function(name) { function onError(err) { // Do nothing if current directory changed during async operations. - if (self.currentEntry != currentEntry) + if (self.currentDirEntry_ != currentEntry) return; if (err.code != FileError.NOT_FOUND_ERR) { self.rescanLater(); @@ -515,12 +548,12 @@ DirectoryModel.prototype.onEntryChanged = function(name) { dm.splice(index, 1); }; - util.resolvePath(currentEntry, name, onEntryFound, onError); + util.resolvePath(this.currentDirEntry_, name, onEntryFound, onError); }; /** * @private - * @param {string} name + * @param {string} name Filename. * @return {number} The index in the fileList. */ DirectoryModel.prototype.findIndexByName_ = function(name) { @@ -534,7 +567,7 @@ DirectoryModel.prototype.findIndexByName_ = function(name) { /** * Rename the entry in the filesystem and update the file list. * @param {Entry} entry Entry to rename. - * @param {string} newName + * @param {string} newName New name. * @param {function} errorCallback Called on error. * @param {function} opt_successCallback Called on success. */ @@ -554,8 +587,7 @@ DirectoryModel.prototype.renameEntry = function(entry, newName, errorCallback, opt_successCallback(); }); } - entry.moveTo(this.currentEntry, newName, - onSuccess, errorCallback); + entry.moveTo(this.currentDirEntry_, newName, onSuccess, errorCallback); }; /** @@ -566,7 +598,7 @@ DirectoryModel.prototype.renameEntry = function(entry, newName, errorCallback, * is true if it's a file. */ DirectoryModel.prototype.doesExist = function(newName, callback) { - util.resolvePath(this.currentEntry, newName, + util.resolvePath(this.currentDirEntry_, newName, function(entry) { callback(true, entry.isFile); }, @@ -576,9 +608,9 @@ DirectoryModel.prototype.doesExist = function(newName, callback) { /** * Creates directory and updates the file list. * - * @param {string} name - * @param {function} successCallback - * @param {function} errorCallback + * @param {string} name Directory name. + * @param {function} successCallback Callback on success. + * @param {function} errorCallback Callback on failure. */ DirectoryModel.prototype.createDirectory = function(name, successCallback, errorCallback) { @@ -593,17 +625,17 @@ DirectoryModel.prototype.createDirectory = function(name, successCallback, self.selectEntry(name); successCallback(existing[0]); } else { - self.fileListSelection.beginChange(); + self.fileListSelection_.beginChange(); fileList.splice(0, 0, newEntry); self.selectEntry(name); - self.fileListSelection.endChange(); + self.fileListSelection_.endChange(); successCallback(newEntry); } }); } - this.currentEntry.getDirectory(name, {create: true, exclusive: true}, - onSuccess, errorCallback); + this.currentDirEntry_.getDirectory(name, {create: true, exclusive: true}, + onSuccess, errorCallback); }; /** @@ -653,7 +685,7 @@ DirectoryModel.prototype.changeDirectory = function(path, opt_OnError) { * @param {DirectoryEntry} dirEntry A new directory entry. */ DirectoryModel.prototype.changeDirectoryEntry_ = function(initial, dirEntry) { - var previous = this.currentEntry; + var previous = this.currentDirEntry_; this.currentDirEntry_ = dirEntry; function onRescanComplete() { // For tests that open the dialog to empty directories, everything @@ -785,30 +817,21 @@ DirectoryModel.prototype.setupPath = function(path, opt_loadedCallback, }; /** - * @param {function} opt_callback + * @param {function} opt_callback Callback on done. */ DirectoryModel.prototype.setupDefaultPath = function(opt_callback) { - var overridden = false; - function onExternalDirChange() { overridden = true } - this.addEventListener('directory-changed', onExternalDirChange); - - this.getDefaultDirectory_(function(path) { - this.removeEventListener('directory-changed', onExternalDirChange); - if (!overridden) - this.setupPath(path, opt_callback); - }.bind(this)); + this.setupPath(this.getDefaultDirectory(), opt_callback); }; /** - * @private - * @param {function} callback + * @return {string} The default directory. */ DirectoryModel.prototype.getDefaultDirectory = function() { return '/' + DirectoryModel.DOWNLOADS_DIRECTORY; }; /** - * @param {string} name + * @param {string} name Filename. */ DirectoryModel.prototype.selectEntry = function(name) { var dm = this.fileList_; @@ -821,7 +844,7 @@ DirectoryModel.prototype.selectEntry = function(name) { }; /** - * @param {number} index + * @param {number} index Index of file. */ DirectoryModel.prototype.selectIndex = function(index) { // this.focusCurrentList_(); @@ -838,8 +861,8 @@ DirectoryModel.prototype.selectIndex = function(index) { * This is called by the table code before a sort happens, so that we can * go fetch data for the sort field that we may not have yet. * @private - * @param {string} field - * @param {function} callback + * @param {string} field Sort field. + * @param {function} callback Called when done. */ DirectoryModel.prototype.prepareSort_ = function(field, callback) { this.prepareSortEntries_(this.fileList_.slice(), field, callback); @@ -847,9 +870,9 @@ DirectoryModel.prototype.prepareSort_ = function(field, callback) { /** * @private - * @param {Array.<Entry>} entries - * @param {string} field - * @param {function} callback + * @param {Array.<Entry>} entries Files. + * @param {string} field Sort field. + * @param {function} callback Called when done. */ DirectoryModel.prototype.prepareSortEntries_ = function(entries, field, callback) { @@ -1003,7 +1026,7 @@ DirectoryModel.prototype.updateRootsListSelection_ = function() { * @private */ DirectoryModel.prototype.updateReadonlyStatus_ = function() { - switch (this.rootType) { + switch (this.getRootType()) { case DirectoryModel.RootType.REMOVABLE: this.readonly_ = !!this.currentVolumeMetadata_.isReadOnly; break; @@ -1014,7 +1037,7 @@ DirectoryModel.prototype.updateReadonlyStatus_ = function() { this.readonly_ = false; break; case DirectoryModel.RootType.GDATA: - this.readonly_ = this.offline; + this.readonly_ = this.offline_; break; default: this.readonly_ = true; @@ -1048,7 +1071,7 @@ DirectoryModel.prototype.updateVolumeMetadata_ = function() { /** * Prepare the root for the unmount. * - * @param {string} rootPath + * @param {string} rootPath The path to the root. */ DirectoryModel.prototype.prepareUnmount = function(rootPath) { var index = this.findRootsListItem_(rootPath); @@ -1073,7 +1096,7 @@ DirectoryModel.prototype.prepareUnmount = function(rootPath) { }; /** - * @param {string} path + * @param {string} path Any path. * @return {string} The root path. */ DirectoryModel.getRootPath = function(path) { @@ -1097,8 +1120,8 @@ DirectoryModel.getRootPath = function(path) { }; /** - * @param {string} path - * @return {string} + * @param {string} path Any path. + * @return {string} The name of the root. */ DirectoryModel.getRootName = function(path) { var root = DirectoryModel.getRootPath(path); @@ -1107,7 +1130,7 @@ DirectoryModel.getRootName = function(path) { }; /** - * @param {string} path Path. + * @param {string} path A path. * @return {string} A root type. */ DirectoryModel.getRootType = function(path) { @@ -1127,8 +1150,8 @@ DirectoryModel.getRootType = function(path) { }; /** - * @param {string} path - * @return {boolean} + * @param {string} path A path. + * @return {boolean} True if it is a path to the root. */ DirectoryModel.isRootPath = function(path) { if (path[path.length - 1] == '/') @@ -1193,7 +1216,7 @@ DirectoryModel.Scanner.prototype.readNextChunk_ = function() { /** * @private - * @param {Array.<Entry>} entries + * @param {Array.<Entry>} entries File list. */ DirectoryModel.Scanner.prototype.onChunkComplete_ = function(entries) { if (this.cancelled_) diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js index e481880..e245418 100644 --- a/chrome/browser/resources/file_manager/js/file_manager.js +++ b/chrome/browser/resources/file_manager/js/file_manager.js @@ -507,7 +507,7 @@ FileManager.prototype = { 'modificationTime'; var sortDirection = window.localStorage['sort-direction-' + this.dialogType_] || 'desc'; - this.directoryModel_.fileList.sort(sortField, sortDirection); + this.directoryModel_.sortFileList(sortField, sortDirection); this.refocus(); @@ -519,7 +519,7 @@ FileManager.prototype = { return self.getMetadataProvider().isInitialized(); }); - this.directoryModel_.offline = this.isOffline(); + this.directoryModel_.setOffline(this.isOffline()); if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) this.initDataTransferOperations_(); @@ -539,8 +539,8 @@ FileManager.prototype = { this.onCopyManagerOperationComplete_.bind(this)); var controller = this.fileTransferController_ = new FileTransferController( - this.directoryModel_.fileList, - this.directoryModel_.fileListSelection, + this.directoryModel_.getFileList(), + this.directoryModel_.getFileListSelection(), GridItem.bind(null, this), this.copyManager_, this.directoryModel_); @@ -721,7 +721,7 @@ FileManager.prototype = { str('ENABLE_GDATA') == '1', this.metadataCache_); - var dataModel = this.directoryModel_.fileList; + var dataModel = this.directoryModel_.getFileList(); var collator = this.collator_; // TODO(dgozman): refactor comparison functions together with // render/update/display. @@ -740,12 +740,9 @@ FileManager.prototype = { dataModel.addEventListener('permuted', this.onDataModelPermuted_.bind(this)); - this.directoryModel_.fileListSelection.addEventListener( + this.directoryModel_.getFileListSelection().addEventListener( 'change', this.onSelectionChanged_.bind(this)); - this.directoryModel_.autoSelectIndex = - this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE ? -1 : 0; - this.initTable_(); this.initGrid_(); this.initRootsList_(); @@ -885,7 +882,7 @@ FileManager.prototype = { }; FileManager.prototype.onDataModelPermuted_ = function(event) { - var sortStatus = this.directoryModel_.fileList.sortStatus; + var sortStatus = this.directoryModel_.getFileList().sortStatus; window.localStorage['sort-field-' + this.dialogType_] = sortStatus.field; window.localStorage['sort-direction-' + this.dialogType_] = sortStatus.direction; @@ -1157,8 +1154,8 @@ FileManager.prototype = { // style and only then set dataModel. if (type == FileManager.ListType.DETAIL) { - this.table_.dataModel = this.directoryModel_.fileList; - this.table_.selectionModel = this.directoryModel_.fileListSelection; + this.table_.dataModel = this.directoryModel_.getFileList(); + this.table_.selectionModel = this.directoryModel_.getFileListSelection(); this.table_.style.display = ''; this.grid_.style.display = 'none'; this.grid_.selectionModel = this.emptySelectionModel_; @@ -1171,8 +1168,8 @@ FileManager.prototype = { this.dialogDom_.querySelector('div.thumbnail-view') .removeAttribute('disabled'); } else if (type == FileManager.ListType.THUMBNAIL) { - this.grid_.dataModel = this.directoryModel_.fileList; - this.grid_.selectionModel = this.directoryModel_.fileListSelection; + this.grid_.dataModel = this.directoryModel_.getFileList(); + this.grid_.selectionModel = this.directoryModel_.getFileListSelection(); this.grid_.style.display = ''; this.table_.style.display = 'none'; this.table_.selectionModel = this.emptySelectionModel_; @@ -1355,7 +1352,7 @@ FileManager.prototype = { * update event). */ FileManager.prototype.onCopyManagerOperationComplete_ = function(event) { - var currentPath = this.directoryModel_.currentEntry.fullPath; + var currentPath = this.directoryModel_.getCurrentDirEntry().fullPath; function inCurrentDirectory(entry) { var fullPath = entry.fullPath; var dirPath = fullPath.substr(0, fullPath.length - @@ -1429,7 +1426,7 @@ FileManager.prototype = { // Nothing left to do if the current directory is not changing. This happens // if we are exiting the Gallery. if (this.getPathFromUrlOrParams_() == - this.directoryModel_.currentEntry.fullPath) + this.directoryModel_.getCurrentDirEntry().fullPath) return; this.setupCurrentDirectory_(true /* invokeHandler */); }; @@ -1679,7 +1676,7 @@ FileManager.prototype = { * Update check and disable states of the 'Select all' checkbox. */ FileManager.prototype.updateSelectAllCheckboxState_ = function(checkbox) { - var dm = this.directoryModel_.fileList; + var dm = this.directoryModel_.getFileList(); checkbox.checked = this.selection && dm.length > 0 && dm.length == this.selection.totalCount; checkbox.disabled = dm.length == 0; @@ -1946,8 +1943,9 @@ FileManager.prototype = { var fileName = this.document_.createElement('div'); fileName.className = 'filename-label'; - fileName.textContent = this.directoryModel_.currentEntry.name == '' ? - this.getRootLabel_(entry.name) : entry.name; + fileName.textContent = + this.directoryModel_.getCurrentDirEntry().name == '' ? + this.getRootLabel_(entry.name) : entry.name; return fileName; }; @@ -2041,7 +2039,7 @@ FileManager.prototype = { FileManager.prototype.displayDateInDiv_ = function(div, filesystemProps) { if (!filesystemProps) return; - if (this.directoryModel_.isSystemDirectoy && + if (this.directoryModel_.isSystemDirectory() && filesystemProps.modificationTime.getTime() == 0) { // Mount points for FAT volumes have this time associated with them. // We'd rather display nothing than this bogus date. @@ -2077,7 +2075,7 @@ FileManager.prototype = { }; FileManager.prototype.refreshCurrentDirectoryMetadata_ = function() { - var entries = this.directoryModel_.fileList.slice(); + var entries = this.directoryModel_.getFileList().slice(); this.metadataCache_.clear(entries, 'filesystem'); // We don't pass callback here. When new metadata arrives, we have an // observer registered to update the UI. @@ -2089,7 +2087,7 @@ FileManager.prototype = { if (this.listType_ != FileManager.ListType.DETAIL) return; var items = {}; - var dm = this.directoryModel_.fileList; + var dm = this.directoryModel_.getFileList(); for (var index = 0; index < dm.length; index++) { var listItem = this.currentList_.getListItemByIndex(index); if (!listItem) continue; @@ -2121,11 +2119,11 @@ FileManager.prototype = { return; var dm = this.directoryModel_; - var leadIndex = dm.fileListSelection.leadIndex; + var leadIndex = dm.getFileListSelection().leadIndex; if (leadIndex < 0) return; - var leadEntry = dm.fileList.item(leadIndex); + var leadEntry = dm.getFileList().item(leadIndex); if (this.renameInput_.currentEntry.fullPath != leadEntry.fullPath) return; @@ -2194,7 +2192,7 @@ FileManager.prototype = { } for (var i = 0; i < selection.indexes.length; i++) { - var entry = this.directoryModel_.fileList.item(selection.indexes[i]); + var entry = this.directoryModel_.getFileList().item(selection.indexes[i]); if (!entry) continue; @@ -2614,7 +2612,7 @@ FileManager.prototype = { console.log('ONLINE'); this.dialogContainer_.removeAttribute('offline'); } - this.directoryModel_.offline = this.isOffline(); + this.directoryModel_.setOffline(this.isOffline()); }; FileManager.prototype.isOnGDataOffline = function() { @@ -2622,7 +2620,7 @@ FileManager.prototype = { }; FileManager.prototype.isOnReadonlyDirectory = function() { - return this.directoryModel_.readonly; + return this.directoryModel_.isReadOnly(); }; /** @@ -2651,7 +2649,7 @@ FileManager.prototype = { if (this.setupCurrentDirectoryPostponed_) { this.setupCurrentDirectoryPostponed_(false /* execute */); } else if (this.isOnGData() && - this.directoryModel_.currentEntry.unmounted) { + this.directoryModel_.getCurrentDirEntry().unmounted) { // We are currently on an unmounted GData directory, force a rescan. changeDirectoryTo = this.directoryModel_.getCurrentRootPath(); } @@ -2791,9 +2789,9 @@ FileManager.prototype = { FileManager.prototype.getAllUrlsInCurrentDirectory_ = function() { var urls = []; - var dm = this.directoryModel_.fileList; - for (var i = 0; i != dm.length; i++) { - urls.push(dm.item(i).toURL()); + var fileList = this.directoryModel_.getFileList(); + for (var i = 0; i != fileList.length; i++) { + urls.push(fileList.item(i).toURL()); } return urls; }; @@ -2837,7 +2835,7 @@ FileManager.prototype = { selectedUrl = urls[0]; } - var dirPath = this.directoryModel_.currentEntry.fullPath; + var dirPath = this.directoryModel_.getCurrentDirEntry().fullPath; // Push a temporary state which will be replaced every time an individual // item is selected in the Gallery. @@ -2851,7 +2849,7 @@ FileManager.prototype = { // Gallery shoud treat GData folder as readonly even when online // until we learn to save files directly to GData. var readonly = self.isOnReadonlyDirectory() || self.isOnGData(); - var currentDir = self.directoryModel_.currentEntry; + var currentDir = self.directoryModel_.getCurrentDirEntry(); var downloadsDir = self.directoryModel_.getRootsList().item(0); var gallerySelection; @@ -2861,7 +2859,7 @@ FileManager.prototype = { readonly ? (self.isOnGData() ? self.getRootLabel_(currentDir.fullPath) : - self.directoryModel_.rootName) : + self.directoryModel_.getRootName()) : null, saveDirEntry: readonly ? downloadsDir : currentDir, metadataProvider: self.getMetadataProvider(), @@ -2892,7 +2890,7 @@ FileManager.prototype = { removeChildren(bc); var rootPath = this.directoryModel_.getCurrentRootPath(); - var relativePath = this.directoryModel_.currentEntry.fullPath. + var relativePath = this.directoryModel_.getCurrentDirEntry().fullPath. substring(rootPath.length).replace(/\/$/, ''); var pathNames = relativePath.replace(/\/$/, '').split('/'); @@ -3066,7 +3064,7 @@ FileManager.prototype = { */ FileManager.prototype.getCurrentDirectory = function() { return this.directoryModel_ && - this.directoryModel_.currentEntry.fullPath; + this.directoryModel_.getCurrentDirEntry().fullPath; }; /** @@ -3074,7 +3072,7 @@ FileManager.prototype = { */ FileManager.prototype.getCurrentDirectoryURL = function() { return this.directoryModel_ && - this.directoryModel_.currentEntry.toURL(); + this.directoryModel_.getCurrentDirEntry().toURL(); }; FileManager.prototype.deleteEntries = function(entries, force, opt_callback) { @@ -3170,7 +3168,7 @@ FileManager.prototype = { }; FileManager.prototype.onCheckboxClick_ = function(event) { - var sm = this.directoryModel_.fileListSelection; + var sm = this.directoryModel_.getFileListSelection(); var listItem = this.findListItemForEvent_(event); sm.setIndexSelected(listItem.listIndex, event.target.checked); }; @@ -3440,7 +3438,7 @@ FileManager.prototype = { this.metadataCache_.removeObserver(this.metadataObserverId_); this.metadataObserverId_ = this.metadataCache_.addObserver( - this.directoryModel_.currentEntry, + this.directoryModel_.getCurrentDirEntry(), MetadataCache.CHILDREN, 'filesystem', this.updateFilesystemPropertiesInUI_.bind(this)); @@ -3676,7 +3674,7 @@ FileManager.prototype = { var defaultName = str('DEFAULT_NEW_FOLDER_NAME'); // Find a name that doesn't exist in the data model. - var files = this.directoryModel_.fileList; + var files = this.directoryModel_.getFileList(); var hash = {}; for (var i = 0; i < files.length; i++) { var name = files.item(i).name; @@ -3749,7 +3747,7 @@ FileManager.prototype = { switch (util.getKeyModifiers(event) + event.keyCode) { case 'Ctrl-190': // Ctrl-. => Toggle filter files. var dm = this.directoryModel_; - dm.filterHidden = !dm.filterHidden; + dm.setFilterHidden(!dm.getFilterHidden()); event.preventDefault(); return; @@ -3903,7 +3901,7 @@ FileManager.prototype = { if (!text) return; - var dm = this.directoryModel_.fileList; + var dm = this.directoryModel_.getFileList(); for (var index = 0; index < dm.length; ++index) { var name = dm.item(index).name; if (name.substring(0, text.length).toLowerCase() == text) { @@ -4144,7 +4142,7 @@ FileManager.prototype = { if (!selectedIndexes.length) throw new Error('Nothing selected!'); - var dm = this.directoryModel_.fileList; + var dm = this.directoryModel_.getFileList(); for (var i = 0; i < selectedIndexes.length; i++) { var entry = dm.item(selectedIndexes[i]); if (!entry) { @@ -4210,7 +4208,7 @@ FileManager.prototype = { msg = str('ERROR_WHITESPACE_NAME'); } else if (/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i.test(name)) { msg = str('ERROR_RESERVED_NAME'); - } else if (this.directoryModel_.filterHidden && name[0] == '.') { + } else if (this.directoryModel_.getFilterHidden() && name[0] == '.') { msg = str('ERROR_HIDDEN_NAME'); } diff --git a/chrome/browser/resources/file_manager/js/file_manager_pyauto.js b/chrome/browser/resources/file_manager/js/file_manager_pyauto.js index 86ffc3a..2d1a8b2 100644 --- a/chrome/browser/resources/file_manager/js/file_manager_pyauto.js +++ b/chrome/browser/resources/file_manager/js/file_manager_pyauto.js @@ -8,6 +8,8 @@ * * Refer to chrome/test/functional/chromeos_file_browser.py for examples * of how this API is used. + * + * TODO(olege): Fix style warnings. */ var pyautoAPI = { /** @@ -18,7 +20,7 @@ var pyautoAPI = { */ addItemToSelection: function(name) { var entryExists = false; - var dm = fileManager.directoryModel_.fileList; + var dm = fileManager.directoryModel_.getFileList(); for (var i = 0; i < dm.length; i++) { if (dm.item(i).name == name) { fileManager.currentList_.selectionModel.setIndexSelected(i, true); @@ -39,7 +41,7 @@ var pyautoAPI = { */ listDirectory: function() { var list = []; - var dm = fileManager.directoryModel_.fileList; + var dm = fileManager.directoryModel_.getFileList(); for (var i = 0; i < dm.length; i++) { list.push(dm.item(i).name); } |