Commit 258f2a66 authored by mfomitchev's avatar mfomitchev Committed by Commit bot

Getting rid of ChromeLauncherController::model().

Also updating comments/error output:
BrowserLauncherItemController -> BrowserShortcutLauncherItemController.

BUG=NONE

Review-Url: https://codereview.chromium.org/2039543002
Cr-Commit-Position: refs/heads/master@{#397848}
parent 1c9b983a
......@@ -21,7 +21,6 @@
#include "ash/shelf/shelf_model.h"
#include "ash/shelf/shelf_navigator.h"
#include "ash/shelf/shelf_util.h"
#include "ash/shelf/shelf_view.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/wm/window_properties.h"
......
......@@ -13,6 +13,7 @@
#include "ash/shelf/shelf_constants.h"
#include "ash/shelf/shelf_locking_manager.h"
#include "ash/shelf/shelf_types.h"
#include "ash/shelf/shelf_view.h"
#include "ash/shelf/shelf_widget.h"
#include "base/macros.h"
#include "ui/gfx/geometry/size.h"
......@@ -39,7 +40,6 @@ class FocusCycler;
class ShelfDelegate;
class ShelfIconObserver;
class ShelfModel;
class ShelfView;
namespace wm {
class WmShelfAura;
......@@ -144,6 +144,8 @@ class ASH_EXPORT Shelf {
ShelfWidget* shelf_widget() { return shelf_widget_; }
ShelfModel* shelf_model() { return shelf_view_->model(); }
// TODO(msw): ShelfLayoutManager should not be accessed externally.
ShelfLayoutManager* shelf_layout_manager() {
return shelf_widget_->shelf_layout_manager();
......
......@@ -58,11 +58,12 @@ bool IsSettingsBrowser(Browser* browser) {
} // namespace
BrowserShortcutLauncherItemController::BrowserShortcutLauncherItemController(
ChromeLauncherController* launcher_controller)
ChromeLauncherController* launcher_controller,
ash::ShelfModel* shelf_model)
: LauncherItemController(TYPE_SHORTCUT,
extension_misc::kChromeAppId,
launcher_controller) {
}
launcher_controller),
shelf_model_(shelf_model) {}
BrowserShortcutLauncherItemController::
~BrowserShortcutLauncherItemController() {
......@@ -74,12 +75,11 @@ void BrowserShortcutLauncherItemController::UpdateBrowserItemState() {
if (!ash::Shell::HasInstance())
return;
ash::ShelfModel* model = launcher_controller()->model();
// Determine the new browser's active state and change if necessary.
int browser_index = model->GetItemIndexForType(ash::TYPE_BROWSER_SHORTCUT);
int browser_index =
shelf_model_->GetItemIndexForType(ash::TYPE_BROWSER_SHORTCUT);
DCHECK_GE(browser_index, 0);
ash::ShelfItem browser_item = model->items()[browser_index];
ash::ShelfItem browser_item = shelf_model_->items()[browser_index];
ash::ShelfItemStatus browser_status = ash::STATUS_CLOSED;
aura::Window* window = ash::wm::GetActiveWindow();
......@@ -115,7 +115,7 @@ void BrowserShortcutLauncherItemController::UpdateBrowserItemState() {
if (browser_status != browser_item.status) {
browser_item.status = browser_status;
model->Set(browser_index, browser_item);
shelf_model_->Set(browser_index, browser_item);
}
}
......
......@@ -9,6 +9,10 @@
#include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
#include "chrome/browser/ui/browser_list.h"
namespace ash {
class ShelfModel;
}
namespace content {
class WebContents;
}
......@@ -23,8 +27,8 @@ class ChromeLauncherController;
// Item controller for an browser shortcut.
class BrowserShortcutLauncherItemController : public LauncherItemController {
public:
explicit BrowserShortcutLauncherItemController(
ChromeLauncherController* controller);
BrowserShortcutLauncherItemController(ChromeLauncherController* controller,
ash::ShelfModel* shelf_model);
~BrowserShortcutLauncherItemController() override;
......@@ -78,6 +82,8 @@ class BrowserShortcutLauncherItemController : public LauncherItemController {
// Get a list of active browsers.
BrowserList::BrowserVector GetListOfActiveBrowsers();
ash::ShelfModel* shelf_model_;
DISALLOW_COPY_AND_ASSIGN(BrowserShortcutLauncherItemController);
};
......
......@@ -841,10 +841,6 @@ void ChromeLauncherController::PersistPinnedState() {
base::Unretained(this)));
}
ash::ShelfModel* ChromeLauncherController::model() {
return model_;
}
Profile* ChromeLauncherController::profile() {
return profile_;
}
......@@ -1704,7 +1700,8 @@ ChromeLauncherController::GetBrowserShortcutLauncherItemController() {
if (item.type == ash::TYPE_BROWSER_SHORTCUT)
return static_cast<BrowserShortcutLauncherItemController*>(i->second);
}
NOTREACHED() << "There should be always a BrowserLauncherItemController.";
NOTREACHED()
<< "There should be always be a BrowserShortcutLauncherItemController.";
return nullptr;
}
......@@ -1717,7 +1714,7 @@ ash::ShelfID ChromeLauncherController::CreateBrowserShortcutLauncherItem() {
size_t index = GetChromeIconIndexForCreation();
model_->AddAt(index, browser_shortcut);
id_to_item_controller_map_[id] =
new BrowserShortcutLauncherItemController(this);
new BrowserShortcutLauncherItemController(this, model_);
id_to_item_controller_map_[id]->set_shelf_id(id);
// ShelfItemDelegateManager owns BrowserShortcutLauncherItemController.
SetShelfItemDelegate(id, id_to_item_controller_map_[id]);
......
......@@ -75,8 +75,8 @@ typedef ScopedVector<ChromeLauncherAppMenuItem> ChromeLauncherAppMenuItems;
// ChromeLauncherController manages the launcher items needed for content
// windows. Launcher items have a type, an optional app id, and a controller.
// This incarnation groups running tabs/windows in application specific lists.
// * Browser app windows have BrowserLauncherItemController, owned by the
// BrowserView instance.
// * Browser app windows have BrowserShortcutLauncherItemController, owned by
// the BrowserView instance.
// * App windows have AppWindowLauncherItemController, owned by
// AppWindowLauncherController.
// * Shortcuts have no LauncherItemController.
......@@ -217,8 +217,6 @@ class ChromeLauncherController
// id of the app.
void PersistPinnedState();
ash::ShelfModel* model();
// Accessor to the currently loaded profile. Note that in multi profile use
// cases this might change over time.
Profile* profile();
......
......@@ -198,7 +198,7 @@ class LauncherPlatformAppBrowserTest
ash::ShelfID CreateAppShortcutLauncherItem(const std::string& name) {
return controller_->CreateAppShortcutLauncherItem(
name, controller_->model()->item_count());
name, shelf_model()->item_count());
}
const ash::ShelfItem& GetLastLauncherItem() {
......
......@@ -19,6 +19,10 @@
#include "grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
namespace ash {
class ShelfModel;
}
namespace {
bool MenuItemHasLauncherContext(const extensions::MenuItem* item) {
......@@ -31,7 +35,8 @@ ExtensionLauncherContextMenu::ExtensionLauncherContextMenu(
ChromeLauncherController* controller,
const ash::ShelfItem* item,
ash::Shelf* shelf)
: LauncherContextMenu(controller, item, shelf) {
: LauncherContextMenu(controller, item, shelf),
shelf_model_(shelf->shelf_model()) {
Init();
}
......@@ -80,7 +85,7 @@ void ExtensionLauncherContextMenu::Init() {
AddItemWithStringId(MENU_NEW_INCOGNITO_WINDOW,
IDS_APP_LIST_NEW_INCOGNITO_WINDOW);
}
if (!BrowserShortcutLauncherItemController(controller())
if (!BrowserShortcutLauncherItemController(controller(), shelf_model_)
.IsListOfActiveBrowserEmpty()) {
AddItem(MENU_CLOSE,
l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE));
......
......@@ -15,6 +15,7 @@ class ChromeLauncherController;
namespace ash {
class Shelf;
struct ShelfItem;
class ShelfModel;
}
namespace extensions {
......@@ -41,6 +42,7 @@ class ExtensionLauncherContextMenu : public LauncherContextMenu {
void Init();
std::unique_ptr<extensions::ContextMenuMatcher> extension_items_;
ash::ShelfModel* shelf_model_;
DISALLOW_COPY_AND_ASSIGN(ExtensionLauncherContextMenu);
};
......
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