summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/launcher/launcher_button.h1
-rw-r--r--ash/launcher/launcher_model.cc9
-rw-r--r--ash/launcher/launcher_model_unittest.cc46
-rw-r--r--ash/launcher/launcher_navigator_unittest.cc16
-rw-r--r--ash/launcher/launcher_types.cc3
-rw-r--r--ash/launcher/launcher_types.h13
-rw-r--r--ash/launcher/launcher_unittest.cc17
-rw-r--r--ash/launcher/launcher_view.cc39
-rw-r--r--ash/launcher/launcher_view_unittest.cc136
-rw-r--r--ash/launcher/tabbed_launcher_button.cc153
-rw-r--r--ash/launcher/tabbed_launcher_button.h112
-rw-r--r--ash/shell/launcher_delegate_impl.cc2
-rw-r--r--ash/shell/window_watcher.cc2
-rw-r--r--ash/test/test_launcher_delegate.cc3
-rw-r--r--chrome/browser/ui/ash/launcher/browser_launcher_item_controller.cc268
-rw-r--r--chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h144
-rw-r--r--chrome/browser/ui/ash/launcher/browser_status_monitor.cc196
-rw-r--r--chrome/browser/ui/ash/launcher/browser_status_monitor.h99
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc23
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller.h15
-rw-r--r--chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc2
-rw-r--r--chrome/browser/ui/ash/launcher/launcher_item_controller.cc2
-rw-r--r--chrome/browser/ui/ash/launcher/launcher_item_controller.h1
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc25
-rw-r--r--chrome/browser/ui/views/frame/browser_view.h25
-rw-r--r--chrome/chrome_browser_ui.gypi4
27 files changed, 433 insertions, 925 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 1507ca4..e0d7e56 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -165,8 +165,6 @@
'launcher/overflow_button.cc',
'launcher/overflow_button.h',
'launcher/scoped_observer_with_duplicated_sources.h',
- 'launcher/tabbed_launcher_button.cc',
- 'launcher/tabbed_launcher_button.h',
'magnifier/magnification_controller.cc',
'magnifier/magnification_controller.h',
'magnifier/magnifier_constants.h',
diff --git a/ash/launcher/launcher_button.h b/ash/launcher/launcher_button.h
index df32253..273640d 100644
--- a/ash/launcher/launcher_button.h
+++ b/ash/launcher/launcher_button.h
@@ -27,7 +27,6 @@ class ASH_EXPORT LauncherButton : public views::CustomButton {
// Button has mouse hovering on it.
STATE_HOVERED = 1 << 0,
// Underlying LauncherItem has a running instance.
- // e.g. A TYPE_TABBED item that has a window.
STATE_RUNNING = 1 << 1,
// Underlying LauncherItem is active (i.e. has focus).
STATE_ACTIVE = 1 << 2,
diff --git a/ash/launcher/launcher_model.cc b/ash/launcher/launcher_model.cc
index 9607de6..e82e8de 100644
--- a/ash/launcher/launcher_model.cc
+++ b/ash/launcher/launcher_model.cc
@@ -22,11 +22,13 @@ int LauncherItemTypeToWeight(LauncherItemType type) {
case TYPE_APP_SHORTCUT:
case TYPE_WINDOWED_APP:
return 1;
- case TYPE_TABBED:
case TYPE_PLATFORM_APP:
return 2;
case TYPE_APP_PANEL:
return 3;
+ case TYPE_UNDEFINED:
+ NOTREACHED() << "LauncherItemType must be set";
+ return -1;
}
} else {
switch (type) {
@@ -34,13 +36,15 @@ int LauncherItemTypeToWeight(LauncherItemType type) {
case TYPE_APP_SHORTCUT:
case TYPE_WINDOWED_APP:
return 0;
- case TYPE_TABBED:
case TYPE_PLATFORM_APP:
return 1;
case TYPE_APP_LIST:
return 2;
case TYPE_APP_PANEL:
return 3;
+ case TYPE_UNDEFINED:
+ NOTREACHED() << "LauncherItemType must be set";
+ return -1;
}
}
@@ -57,7 +61,6 @@ bool CompareByWeight(const LauncherItem& a, const LauncherItem& b) {
LauncherModel::LauncherModel() : next_id_(1), status_(STATUS_NORMAL) {
LauncherItem app_list;
app_list.type = TYPE_APP_LIST;
- app_list.is_incognito = false;
AddAt(0, app_list);
}
diff --git a/ash/launcher/launcher_model_unittest.cc b/ash/launcher/launcher_model_unittest.cc
index c91a040..7011e27 100644
--- a/ash/launcher/launcher_model_unittest.cc
+++ b/ash/launcher/launcher_model_unittest.cc
@@ -83,6 +83,7 @@ TEST(LauncherModel, BasicAssertions) {
// Add an item.
model.AddObserver(&observer);
LauncherItem item;
+ item.type = TYPE_APP_SHORTCUT;
int index = model.Add(item);
EXPECT_EQ(2, model.item_count());
EXPECT_EQ("added=1", observer.StateStringAndClear());
@@ -93,12 +94,13 @@ TEST(LauncherModel, BasicAssertions) {
ids.insert(model.items()[i].id);
EXPECT_EQ(model.item_count(), static_cast<int>(ids.size()));
- // Change a tabbed image.
+ // Change to a platform app item.
LauncherID original_id = model.items()[index].id;
- model.Set(index, LauncherItem());
+ item.type = TYPE_PLATFORM_APP;
+ model.Set(index, item);
EXPECT_EQ(original_id, model.items()[index].id);
EXPECT_EQ("changed=1", observer.StateStringAndClear());
- EXPECT_EQ(TYPE_TABBED, model.items()[index].type);
+ EXPECT_EQ(TYPE_PLATFORM_APP, model.items()[index].type);
// Remove the item.
model.RemoveItemAt(index);
@@ -143,16 +145,17 @@ TEST(LauncherModel, AddIndices) {
int browser_shortcut_index = model.Add(browser_shortcut);
EXPECT_EQ(0, browser_shortcut_index);
- // Tabbed items should be after browser shortcut.
+ // platform app items should be after browser shortcut.
LauncherItem item;
- int tabbed_index1 = model.Add(item);
- EXPECT_EQ(1, tabbed_index1);
+ item.type = TYPE_PLATFORM_APP;
+ int platform_app_index1 = model.Add(item);
+ EXPECT_EQ(1, platform_app_index1);
- // Add another tabbed item, it should follow first.
- int tabbed_index2 = model.Add(item);
- EXPECT_EQ(2, tabbed_index2);
+ // Add another platform app item, it should follow first.
+ int platform_app_index2 = model.Add(item);
+ EXPECT_EQ(2, platform_app_index2);
- // APP_SHORTCUT's priority is higher than TABBED but same as
+ // APP_SHORTCUT's priority is higher than PLATFORM_APP but same as
// BROWSER_SHORTCUT. So APP_SHORTCUT is located after BROWSER_SHORCUT.
item.type = TYPE_APP_SHORTCUT;
int app_shortcut_index1 = model.Add(item);
@@ -181,26 +184,27 @@ TEST(LauncherModel, AddIndices) {
// Before there are any panels, no icons should be right aligned.
EXPECT_EQ(model.item_count(), model.FirstPanelIndex());
- // Check that AddAt() figures out the correct indexes for tabs and panels.
- item.type = TYPE_TABBED;
- int tabbed_index3 = model.AddAt(2, item);
- EXPECT_EQ(6, tabbed_index3);
+ // Check that AddAt() figures out the correct indexes for platform apps and
+ // panels.
+ item.type = TYPE_PLATFORM_APP;
+ int platform_app_index3 = model.AddAt(2, item);
+ EXPECT_EQ(6, platform_app_index3);
item.type = TYPE_APP_PANEL;
int app_panel_index1 = model.AddAt(2, item);
EXPECT_EQ(10, app_panel_index1);
- item.type = TYPE_TABBED;
- int tabbed_index4 = model.AddAt(11, item);
- EXPECT_EQ(9, tabbed_index4);
+ item.type = TYPE_PLATFORM_APP;
+ int platform_app_index4 = model.AddAt(11, item);
+ EXPECT_EQ(9, platform_app_index4);
item.type = TYPE_APP_PANEL;
int app_panel_index2 = model.AddAt(12, item);
EXPECT_EQ(12, app_panel_index2);
- item.type = TYPE_TABBED;
- int tabbed_index5 = model.AddAt(7, item);
- EXPECT_EQ(7, tabbed_index5);
+ item.type = TYPE_PLATFORM_APP;
+ int platform_app_index5 = model.AddAt(7, item);
+ EXPECT_EQ(7, platform_app_index5);
item.type = TYPE_APP_PANEL;
int app_panel_index3 = model.AddAt(13, item);
@@ -236,7 +240,7 @@ TEST(LauncherModel, LauncherIDTests) {
// Adding another item to the list should also produce a new ID.
LauncherItem item;
- item.type = TYPE_TABBED;
+ item.type = TYPE_PLATFORM_APP;
model.Add(item);
EXPECT_NE(model.next_id(), id2);
}
diff --git a/ash/launcher/launcher_navigator_unittest.cc b/ash/launcher/launcher_navigator_unittest.cc
index 6013390..78f1261 100644
--- a/ash/launcher/launcher_navigator_unittest.cc
+++ b/ash/launcher/launcher_navigator_unittest.cc
@@ -40,14 +40,14 @@ class LauncherNavigatorTest : public testing::Test {
LauncherItem new_item;
new_item.type = types[i];
new_item.status =
- (types[i] == TYPE_TABBED) ? STATUS_RUNNING : STATUS_CLOSED;
+ (types[i] == TYPE_PLATFORM_APP) ? STATUS_RUNNING : STATUS_CLOSED;
model_->Add(new_item);
}
// Set the focused item.
if (focused_index >= 0) {
LauncherItem focused_item =model_->items()[focused_index];
- if (focused_item.type == TYPE_TABBED) {
+ if (focused_item.type == TYPE_PLATFORM_APP) {
focused_item.status = STATUS_ACTIVE;
model_->Set(focused_index, focused_item);
}
@@ -65,12 +65,12 @@ class LauncherNavigatorTest : public testing::Test {
} // namespace
TEST_F(LauncherNavigatorTest, BasicCycle) {
- // An app shortcut and three windows
+ // An app shortcut and three platform apps.
LauncherItemType types[] = {
- TYPE_APP_SHORTCUT, TYPE_TABBED, TYPE_TABBED, TYPE_TABBED,
+ TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP,
};
// LauncherModel automatically adds BROWSER_SHORTCUT item at the
- // beginning, so '2' refers the first TYPE_TABBED item.
+ // beginning, so '2' refers the first TYPE_PLATFORM_APP item.
SetupMockLauncherModel(types, arraysize(types), 2);
EXPECT_EQ(3, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
@@ -82,7 +82,7 @@ TEST_F(LauncherNavigatorTest, BasicCycle) {
TEST_F(LauncherNavigatorTest, WrapToBeginning) {
LauncherItemType types[] = {
- TYPE_APP_SHORTCUT, TYPE_TABBED, TYPE_TABBED, TYPE_TABBED,
+ TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP,
};
SetupMockLauncherModel(types, arraysize(types), 4);
@@ -99,7 +99,7 @@ TEST_F(LauncherNavigatorTest, Empty) {
}
TEST_F(LauncherNavigatorTest, SingleEntry) {
- LauncherItemType type = TYPE_TABBED;
+ LauncherItemType type = TYPE_PLATFORM_APP;
SetupMockLauncherModel(&type, 1, 1);
// If there's only one item there and it is already active, there's no item
@@ -110,7 +110,7 @@ TEST_F(LauncherNavigatorTest, SingleEntry) {
TEST_F(LauncherNavigatorTest, NoActive) {
LauncherItemType types[] = {
- TYPE_TABBED, TYPE_TABBED,
+ TYPE_PLATFORM_APP, TYPE_PLATFORM_APP,
};
// Special case: no items are 'STATUS_ACTIVE'.
SetupMockLauncherModel(types, arraysize(types), -1);
diff --git a/ash/launcher/launcher_types.cc b/ash/launcher/launcher_types.cc
index a6080b0..46fc827 100644
--- a/ash/launcher/launcher_types.cc
+++ b/ash/launcher/launcher_types.cc
@@ -10,8 +10,7 @@ const int kLauncherPreferredSize = 48;
const int kLauncherBackgroundAlpha = 204;
LauncherItem::LauncherItem()
- : type(TYPE_TABBED),
- is_incognito(false),
+ : type(TYPE_UNDEFINED),
id(0),
status(STATUS_CLOSED) {
}
diff --git a/ash/launcher/launcher_types.h b/ash/launcher/launcher_types.h
index f4eed67..c600629 100644
--- a/ash/launcher/launcher_types.h
+++ b/ash/launcher/launcher_types.h
@@ -23,9 +23,6 @@ ASH_EXPORT extern const int kLauncherBackgroundAlpha;
// Type the LauncherItem represents.
enum LauncherItemType {
- // Represents a tabbed browser.
- TYPE_TABBED,
-
// Represents a running app panel.
TYPE_APP_PANEL,
@@ -43,6 +40,9 @@ enum LauncherItemType {
// Represents a windowed V1 browser app.
TYPE_WINDOWED_APP,
+
+ // Default value.
+ TYPE_UNDEFINED,
};
// Represents the status of pinned or running app launcher items.
@@ -63,12 +63,7 @@ struct ASH_EXPORT LauncherItem {
LauncherItemType type;
- // Whether it is drawn as an incognito icon or not. Only used if this is
- // TYPE_TABBED. Note: This cannot be used for identifying incognito windows.
- bool is_incognito;
-
- // Image to display in the launcher. If this item is TYPE_TABBED the image is
- // a favicon image.
+ // Image to display in the launcher.
gfx::ImageSkia image;
// Assigned by the model when the item is added.
diff --git a/ash/launcher/launcher_unittest.cc b/ash/launcher/launcher_unittest.cc
index b1798e3..688a29a 100644
--- a/ash/launcher/launcher_unittest.cc
+++ b/ash/launcher/launcher_unittest.cc
@@ -29,9 +29,8 @@ using ash::internal::LauncherButton;
namespace ash {
-// Confirm that launching a browser gets the appropriate state reflected in
-// its button.
-TEST_F(LauncherTest, OpenBrowser) {
+// Confirms that LauncherItem reflects the appropriated state.
+TEST_F(LauncherTest, StatusReflection) {
Launcher* launcher = Launcher::ForPrimaryDisplay();
ASSERT_TRUE(launcher);
LauncherView* launcher_view = launcher->GetLauncherViewForTest();
@@ -41,9 +40,9 @@ TEST_F(LauncherTest, OpenBrowser) {
// Initially we have the app list and chrome icon.
int button_count = test.GetButtonCount();
- // Add running tab.
+ // Add running platform app.
LauncherItem item;
- item.type = TYPE_TABBED;
+ item.type = TYPE_PLATFORM_APP;
item.status = STATUS_RUNNING;
int index = model->Add(item);
ASSERT_EQ(++button_count, test.GetButtonCount());
@@ -67,9 +66,9 @@ TEST_F(LauncherTest, checkHoverAfterMenu) {
// Initially we have the app list and chrome icon.
int button_count = test.GetButtonCount();
- // Add running tab.
+ // Add running platform app.
LauncherItem item;
- item.type = TYPE_TABBED;
+ item.type = TYPE_PLATFORM_APP;
item.status = STATUS_RUNNING;
int index = model->Add(item);
ASSERT_EQ(++button_count, test.GetButtonCount());
@@ -92,11 +91,11 @@ TEST_F(LauncherTest, ShowOverflowBubble) {
LauncherModel* model = launcher_view->model();
LauncherID first_item_id = model->next_id();
- // Add tabbed browser until overflow.
+ // Add platform app button until overflow.
int items_added = 0;
while (!test.IsOverflowButtonVisible()) {
LauncherItem item;
- item.type = TYPE_TABBED;
+ item.type = TYPE_PLATFORM_APP;
item.status = STATUS_RUNNING;
model->Add(item);
diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc
index dd0e468..9114032 100644
--- a/ash/launcher/launcher_view.cc
+++ b/ash/launcher/launcher_view.cc
@@ -18,7 +18,6 @@
#include "ash/launcher/launcher_tooltip_manager.h"
#include "ash/launcher/overflow_bubble.h"
#include "ash/launcher/overflow_button.h"
-#include "ash/launcher/tabbed_launcher_button.h"
#include "ash/root_window_controller.h"
#include "ash/scoped_target_root_window.h"
#include "ash/shelf/alternate_app_list_button.h"
@@ -906,21 +905,6 @@ void LauncherView::AnimateToIdealBounds() {
views::View* LauncherView::CreateViewForItem(const LauncherItem& item) {
views::View* view = NULL;
switch (item.type) {
- case TYPE_TABBED: {
- TabbedLauncherButton* button =
- TabbedLauncherButton::Create(
- this,
- this,
- tooltip_->shelf_layout_manager(),
- item.is_incognito ?
- TabbedLauncherButton::STATE_INCOGNITO :
- TabbedLauncherButton::STATE_NOT_INCOGNITO);
- button->SetTabImage(item.image);
- ReflectItemStatus(item, button);
- view = button;
- break;
- }
-
case TYPE_BROWSER_SHORTCUT:
case TYPE_APP_SHORTCUT:
case TYPE_WINDOWED_APP:
@@ -1165,16 +1149,17 @@ void LauncherView::FinalizeRipOffDrag(bool cancel) {
bool LauncherView::SameDragType(LauncherItemType typea,
LauncherItemType typeb) const {
switch (typea) {
- case TYPE_TABBED:
- case TYPE_PLATFORM_APP:
- return (typeb == TYPE_TABBED || typeb == TYPE_PLATFORM_APP);
case TYPE_APP_SHORTCUT:
case TYPE_BROWSER_SHORTCUT:
return (typeb == TYPE_APP_SHORTCUT || typeb == TYPE_BROWSER_SHORTCUT);
+ case TYPE_PLATFORM_APP:
case TYPE_WINDOWED_APP:
case TYPE_APP_LIST:
case TYPE_APP_PANEL:
return typeb == typea;
+ case TYPE_UNDEFINED:
+ NOTREACHED() << "LauncherItemType must be set.";
+ return false;
}
NOTREACHED();
return false;
@@ -1445,17 +1430,6 @@ void LauncherView::LauncherItemChanged(int model_index,
views::View* view = view_model_->view_at(model_index);
switch (item.type) {
- case TYPE_TABBED: {
- TabbedLauncherButton* button = static_cast<TabbedLauncherButton*>(view);
- gfx::Size pref = button->GetPreferredSize();
- button->SetTabImage(item.image);
- if (pref != button->GetPreferredSize())
- AnimateToIdealBounds();
- else
- button->SchedulePaint();
- ReflectItemStatus(item, button);
- break;
- }
case TYPE_BROWSER_SHORTCUT:
// Fallthrough for the new Launcher since it needs to show the activation
// change as well.
@@ -1635,9 +1609,12 @@ void LauncherView::ButtonPressed(views::Button* sender,
UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON);
break;
- case TYPE_TABBED:
case TYPE_APP_PANEL:
break;
+
+ case TYPE_UNDEFINED:
+ NOTREACHED() << "LauncherItemType must be set.";
+ break;
}
LauncherItemDelegate* item_delegate =
diff --git a/ash/launcher/launcher_view_unittest.cc b/ash/launcher/launcher_view_unittest.cc
index 7731655..6c43404 100644
--- a/ash/launcher/launcher_view_unittest.cc
+++ b/ash/launcher/launcher_view_unittest.cc
@@ -224,7 +224,6 @@ class LauncherViewTest : public AshTestBase {
LauncherID AddBrowserShortcut() {
LauncherItem browser_shortcut;
browser_shortcut.type = TYPE_BROWSER_SHORTCUT;
- browser_shortcut.is_incognito = false;
LauncherID id = model_->next_id();
model_->AddAt(0, browser_shortcut);
@@ -243,22 +242,6 @@ class LauncherViewTest : public AshTestBase {
return id;
}
- LauncherID AddTabbedBrowserNoWait() {
- LauncherItem item;
- item.type = TYPE_TABBED;
- item.status = STATUS_RUNNING;
-
- LauncherID id = model_->next_id();
- model_->Add(item);
- return id;
- }
-
- LauncherID AddTabbedBrowser() {
- LauncherID id = AddTabbedBrowserNoWait();
- test_api_->RunMessageLoopUntilAnimationsDone();
- return id;
- }
-
LauncherID AddPanel() {
LauncherID id = AddPanelNoWait();
test_api_->RunMessageLoopUntilAnimationsDone();
@@ -439,7 +422,7 @@ class LauncherViewTextDirectionTest
// Checks that the ideal item icon bounds match the view's bounds in the screen
// in both LTR and RTL.
TEST_P(LauncherViewTextDirectionTest, IdealBoundsOfItemIcon) {
- LauncherID id = AddTabbedBrowser();
+ LauncherID id = AddPlatformApp();
internal::LauncherButton* button = GetButtonByID(id);
gfx::Rect item_bounds = button->GetBoundsInScreen();
gfx::Point icon_offset = button->GetIconBounds().origin();
@@ -454,14 +437,6 @@ TEST_P(LauncherViewTextDirectionTest, IdealBoundsOfItemIcon) {
// Checks that launcher view contents are considered in the correct drag group.
TEST_F(LauncherViewTest, EnforceDragType) {
- EXPECT_TRUE(test_api_->SameDragType(TYPE_TABBED, TYPE_TABBED));
- EXPECT_TRUE(test_api_->SameDragType(TYPE_TABBED, TYPE_PLATFORM_APP));
- EXPECT_FALSE(test_api_->SameDragType(TYPE_TABBED, TYPE_APP_SHORTCUT));
- EXPECT_FALSE(test_api_->SameDragType(TYPE_TABBED, TYPE_BROWSER_SHORTCUT));
- EXPECT_FALSE(test_api_->SameDragType(TYPE_TABBED, TYPE_WINDOWED_APP));
- EXPECT_FALSE(test_api_->SameDragType(TYPE_TABBED, TYPE_APP_LIST));
- EXPECT_FALSE(test_api_->SameDragType(TYPE_TABBED, TYPE_APP_PANEL));
-
EXPECT_TRUE(test_api_->SameDragType(TYPE_PLATFORM_APP, TYPE_PLATFORM_APP));
EXPECT_FALSE(test_api_->SameDragType(TYPE_PLATFORM_APP, TYPE_APP_SHORTCUT));
EXPECT_FALSE(test_api_->SameDragType(TYPE_PLATFORM_APP,
@@ -495,21 +470,21 @@ TEST_F(LauncherViewTest, EnforceDragType) {
EXPECT_TRUE(test_api_->SameDragType(TYPE_APP_PANEL, TYPE_APP_PANEL));
}
-// Adds browser button until overflow and verifies that the last added browser
-// button is hidden.
+// Adds platform app button until overflow and verifies that the last added
+// platform app button is hidden.
TEST_F(LauncherViewTest, AddBrowserUntilOverflow) {
// All buttons should be visible.
ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1,
test_api_->GetButtonCount());
- // Add tabbed browser until overflow.
+ // Add platform app button until overflow.
int items_added = 0;
- LauncherID last_added = AddTabbedBrowser();
+ LauncherID last_added = AddPlatformApp();
while (!test_api_->IsOverflowButtonVisible()) {
// Added button is visible after animation while in this loop.
EXPECT_TRUE(GetButtonByID(last_added)->visible());
- last_added = AddTabbedBrowser();
+ last_added = AddPlatformApp();
++items_added;
ASSERT_LT(items_added, 10000);
}
@@ -518,15 +493,15 @@ TEST_F(LauncherViewTest, AddBrowserUntilOverflow) {
EXPECT_FALSE(GetButtonByID(last_added)->visible());
}
-// Adds one browser button then adds app shortcut until overflow. Verifies that
-// the browser button gets hidden on overflow and last added app shortcut is
-// still visible.
+// Adds one platform app button then adds app shortcut until overflow. Verifies
+// that the browser button gets hidden on overflow and last added app shortcut
+// is still visible.
TEST_F(LauncherViewTest, AddAppShortcutWithBrowserButtonUntilOverflow) {
// All buttons should be visible.
ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1,
test_api_->GetButtonCount());
- LauncherID browser_button_id = AddTabbedBrowser();
+ LauncherID browser_button_id = AddPlatformApp();
// Add app shortcut until overflow.
int items_added = 0;
@@ -542,21 +517,22 @@ TEST_F(LauncherViewTest, AddAppShortcutWithBrowserButtonUntilOverflow) {
// The last added app short button should be visible.
EXPECT_TRUE(GetButtonByID(last_added)->visible());
- // And the browser button is invisible.
+ // And the platform app button is invisible.
EXPECT_FALSE(GetButtonByID(browser_button_id)->visible());
}
-TEST_F(LauncherViewTest, AddPanelHidesTabbedBrowser) {
+TEST_F(LauncherViewTest, AddPanelHidesPlatformAppButton) {
ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1,
test_api_->GetButtonCount());
- // Add tabbed browser until overflow, remember last visible tabbed browser.
+ // Add platform app button until overflow, remember last visible platform app
+ // button.
int items_added = 0;
- LauncherID first_added = AddTabbedBrowser();
+ LauncherID first_added = AddPlatformApp();
EXPECT_TRUE(GetButtonByID(first_added)->visible());
LauncherID last_visible = first_added;
while (true) {
- LauncherID added = AddTabbedBrowser();
+ LauncherID added = AddPlatformApp();
if (test_api_->IsOverflowButtonVisible()) {
EXPECT_FALSE(GetButtonByID(added)->visible());
break;
@@ -574,17 +550,17 @@ TEST_F(LauncherViewTest, AddPanelHidesTabbedBrowser) {
EXPECT_TRUE(GetButtonByID(last_visible)->visible());
}
-// When there are more panels then browsers we should hide panels rather
-// than browsers.
-TEST_F(LauncherViewTest, BrowserHidesExcessPanels) {
+// When there are more panels then platform app buttons we should hide panels
+// rather than platform apps.
+TEST_F(LauncherViewTest, PlatformAppHidesExcessPanels) {
ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1,
test_api_->GetButtonCount());
- // Add tabbed browser.
- LauncherID browser = AddTabbedBrowser();
+ // Add platform app button.
+ LauncherID platform_app = AddPlatformApp();
LauncherID first_panel = AddPanel();
- EXPECT_TRUE(GetButtonByID(browser)->visible());
+ EXPECT_TRUE(GetButtonByID(platform_app)->visible());
EXPECT_TRUE(GetButtonByID(first_panel)->visible());
// Add panels until there is an overflow.
@@ -596,22 +572,23 @@ TEST_F(LauncherViewTest, BrowserHidesExcessPanels) {
ASSERT_LT(items_added, 10000);
}
- // The first panel should now be hidden by the new browsers needing space.
+ // The first panel should now be hidden by the new platform apps needing
+ // space.
EXPECT_FALSE(GetButtonByID(first_panel)->visible());
EXPECT_TRUE(GetButtonByID(last_panel)->visible());
- EXPECT_TRUE(GetButtonByID(browser)->visible());
+ EXPECT_TRUE(GetButtonByID(platform_app)->visible());
- // Adding browsers should eventually begin to hide browsers. We will add
- // browsers until either the last panel or browser is hidden.
+ // Adding platform apps should eventually begin to hide platform apps. We will
+ // add platform apps until either the last panel or platform app is hidden.
items_added = 0;
- while (GetButtonByID(browser)->visible() &&
+ while (GetButtonByID(platform_app)->visible() &&
GetButtonByID(last_panel)->visible()) {
- browser = AddTabbedBrowser();
+ platform_app = AddPlatformApp();
++items_added;
ASSERT_LT(items_added, 10000);
}
EXPECT_TRUE(GetButtonByID(last_panel)->visible());
- EXPECT_FALSE(GetButtonByID(browser)->visible());
+ EXPECT_FALSE(GetButtonByID(platform_app)->visible());
}
// Adds button until overflow then removes first added one. Verifies that
@@ -622,12 +599,12 @@ TEST_F(LauncherViewTest, RemoveButtonRevealsOverflowed) {
ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1,
test_api_->GetButtonCount());
- // Add tabbed browser until overflow.
+ // Add platform app buttons until overflow.
int items_added = 0;
- LauncherID first_added = AddTabbedBrowser();
+ LauncherID first_added = AddPlatformApp();
LauncherID last_added = first_added;
while (!test_api_->IsOverflowButtonVisible()) {
- last_added = AddTabbedBrowser();
+ last_added = AddPlatformApp();
++items_added;
ASSERT_LT(items_added, 10000);
}
@@ -652,11 +629,11 @@ TEST_F(LauncherViewTest, RemoveLastOverflowed) {
ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1,
test_api_->GetButtonCount());
- // Add tabbed browser until overflow.
+ // Add platform app button until overflow.
int items_added = 0;
- LauncherID last_added = AddTabbedBrowser();
+ LauncherID last_added = AddPlatformApp();
while (!test_api_->IsOverflowButtonVisible()) {
- last_added = AddTabbedBrowser();
+ last_added = AddPlatformApp();
++items_added;
ASSERT_LT(items_added, 10000);
}
@@ -665,17 +642,17 @@ TEST_F(LauncherViewTest, RemoveLastOverflowed) {
EXPECT_FALSE(test_api_->IsOverflowButtonVisible());
}
-// Adds browser button without waiting for animation to finish and verifies
+// Adds platform app button without waiting for animation to finish and verifies
// that all added buttons are visible.
TEST_F(LauncherViewTest, AddButtonQuickly) {
// All buttons should be visible.
ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1,
test_api_->GetButtonCount());
- // Add a few tabbed browser quickly without wait for animation.
+ // Add a few platform buttons quickly without wait for animation.
int added_count = 0;
while (!test_api_->IsOverflowButtonVisible()) {
- AddTabbedBrowserNoWait();
+ AddPlatformAppNoWait();
++added_count;
ASSERT_LT(added_count, 10000);
}
@@ -843,8 +820,8 @@ TEST_F(LauncherViewTest, LauncherItemStatus) {
ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1,
test_api_->GetButtonCount());
- // Add tabbed browser.
- LauncherID last_added = AddTabbedBrowser();
+ // Add platform app button.
+ LauncherID last_added = AddPlatformApp();
LauncherItem item = GetItemByID(last_added);
int index = model_->ItemIndexByID(last_added);
internal::LauncherButton* button = GetButtonByID(last_added);
@@ -862,7 +839,7 @@ TEST_F(LauncherViewTest, LauncherItemPositionReflectedOnStateChanged) {
test_api_->GetButtonCount());
// Add 2 items to the launcher.
- LauncherID item1_id = AddTabbedBrowser();
+ LauncherID item1_id = AddPlatformApp();
LauncherID item2_id = AddPlatformAppNoWait();
internal::LauncherButton* item1_button = GetButtonByID(item1_id);
internal::LauncherButton* item2_button = GetButtonByID(item2_id);
@@ -908,7 +885,7 @@ TEST_F(LauncherViewTest, LauncherItemStatusPlatformApp) {
ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1,
test_api_->GetButtonCount());
- // Add tabbed browser.
+ // Add platform app button.
LauncherID last_added = AddPlatformApp();
LauncherItem item = GetItemByID(last_added);
int index = model_->ItemIndexByID(last_added);
@@ -941,10 +918,10 @@ TEST_F(LauncherViewTest, LauncherTooltipTest) {
// Prepare some items to the launcher.
LauncherID app_button_id = AddAppShortcut();
- LauncherID tab_button_id = AddTabbedBrowser();
+ LauncherID platform_button_id = AddPlatformApp();
internal::LauncherButton* app_button = GetButtonByID(app_button_id);
- internal::LauncherButton* tab_button = GetButtonByID(tab_button_id);
+ internal::LauncherButton* platform_button = GetButtonByID(platform_button_id);
internal::LauncherButtonHost* button_host = launcher_view_;
internal::LauncherTooltipManager* tooltip_manager =
@@ -966,24 +943,24 @@ TEST_F(LauncherViewTest, LauncherTooltipTest) {
// When entered to another item, it switches to the new item. There is no
// delay for the visibility.
- button_host->MouseEnteredButton(tab_button);
+ button_host->MouseEnteredButton(platform_button);
EXPECT_TRUE(tooltip_manager->IsVisible());
- EXPECT_EQ(tab_button, GetTooltipAnchorView());
+ EXPECT_EQ(platform_button, GetTooltipAnchorView());
- button_host->MouseExitedButton(tab_button);
+ button_host->MouseExitedButton(platform_button);
tooltip_manager->Close();
// Next time: enter app_button -> move immediately to tab_button.
button_host->MouseEnteredButton(app_button);
button_host->MouseExitedButton(app_button);
- button_host->MouseEnteredButton(tab_button);
+ button_host->MouseEnteredButton(platform_button);
EXPECT_FALSE(tooltip_manager->IsVisible());
- EXPECT_EQ(tab_button, GetTooltipAnchorView());
+ EXPECT_EQ(platform_button, GetTooltipAnchorView());
}
TEST_F(LauncherViewTest, ShouldHideTooltipTest) {
LauncherID app_button_id = AddAppShortcut();
- LauncherID tab_button_id = AddTabbedBrowser();
+ LauncherID platform_button_id = AddPlatformApp();
// The tooltip shouldn't hide if the mouse is on normal buttons.
for (int i = 0; i < test_api_->GetButtonCount(); i++) {
@@ -1003,10 +980,11 @@ TEST_F(LauncherViewTest, ShouldHideTooltipTest) {
// The tooltip shouldn't hide if the mouse is in the gap between two buttons.
gfx::Rect app_button_rect = GetButtonByID(app_button_id)->GetMirroredBounds();
- gfx::Rect tab_button_rect = GetButtonByID(tab_button_id)->GetMirroredBounds();
- ASSERT_FALSE(app_button_rect.Intersects(tab_button_rect));
+ gfx::Rect platform_button_rect =
+ GetButtonByID(platform_button_id)->GetMirroredBounds();
+ ASSERT_FALSE(app_button_rect.Intersects(platform_button_rect));
EXPECT_FALSE(launcher_view_->ShouldHideTooltip(
- gfx::UnionRects(app_button_rect, tab_button_rect).CenterPoint()));
+ gfx::UnionRects(app_button_rect, platform_button_rect).CenterPoint()));
// The tooltip should hide if it's outside of all buttons.
gfx::Rect all_area;
@@ -1104,10 +1082,10 @@ TEST_F(LauncherViewTest, ResizeDuringOverflowAddAnimation) {
// Add buttons until overflow. Let the non-overflow add animations finish but
// leave the last running.
int items_added = 0;
- AddTabbedBrowserNoWait();
+ AddPlatformAppNoWait();
while (!test_api_->IsOverflowButtonVisible()) {
test_api_->RunMessageLoopUntilAnimationsDone();
- AddTabbedBrowserNoWait();
+ AddPlatformAppNoWait();
++items_added;
ASSERT_LT(items_added, 10000);
}
diff --git a/ash/launcher/tabbed_launcher_button.cc b/ash/launcher/tabbed_launcher_button.cc
deleted file mode 100644
index 517607c..0000000
--- a/ash/launcher/tabbed_launcher_button.cc
+++ /dev/null
@@ -1,153 +0,0 @@
-// 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 "ash/launcher/tabbed_launcher_button.h"
-
-#include <algorithm>
-
-#include "ash/launcher/launcher_button_host.h"
-#include "ash/launcher/launcher_types.h"
-#include "grit/ash_resources.h"
-#include "ui/base/accessibility/accessible_view_state.h"
-#include "ui/base/animation/multi_animation.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/image/image.h"
-#include "ui/gfx/insets.h"
-
-namespace {
-const int kIconOffsetY = 7;
-}
-
-namespace ash {
-namespace internal {
-
-TabbedLauncherButton::IconView::IconView(
- TabbedLauncherButton* host)
- : host_(host) {
- if (!browser_image_) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
-
- browser_image_ = rb.GetImageNamed(IDR_AURA_LAUNCHER_BROWSER).ToImageSkia();
- incognito_browser_image_ =
- rb.GetImageNamed(IDR_AURA_LAUNCHER_INCOGNITO_BROWSER).ToImageSkia();
- browser_panel_image_ =
- rb.GetImageNamed(IDR_AURA_LAUNCHER_BROWSER_PANEL).ToImageSkia();
- incognito_browser_panel_image_ =
- rb.GetImageNamed(
- IDR_AURA_LAUNCHER_INCOGNITO_BROWSER_PANEL).ToImageSkia();
- }
- set_icon_size(0);
- if (host->is_incognito() == STATE_NOT_INCOGNITO)
- LauncherButton::IconView::SetImage(*browser_image_);
- else
- LauncherButton::IconView::SetImage(*incognito_browser_image_);
-}
-
-TabbedLauncherButton::IconView::~IconView() {
-}
-
-void TabbedLauncherButton::IconView::AnimationEnded(
- const ui::Animation* animation) {
- AnimationProgressed(animation);
- animating_image_ = gfx::ImageSkia();
-}
-
-void TabbedLauncherButton::IconView::AnimationProgressed(
- const ui::Animation* animation) {
- if (animation_->current_part_index() == 1)
- SchedulePaint();
-}
-
-void TabbedLauncherButton::IconView::SetTabImage(const gfx::ImageSkia& image) {
- if (image.isNull()) {
- if (!image_.isNull()) {
- // Pause for 500ms, then ease out for 200ms.
- ui::MultiAnimation::Parts animation_parts;
- animation_parts.push_back(ui::MultiAnimation::Part(500, ui::Tween::ZERO));
- animation_parts.push_back(
- ui::MultiAnimation::Part(200, ui::Tween::EASE_OUT));
- animation_.reset(new ui::MultiAnimation(
- animation_parts,
- ui::MultiAnimation::GetDefaultTimerInterval()));
- animation_->set_continuous(false);
- animation_->set_delegate(this);
- animation_->Start();
- animating_image_ = image_;
- image_ = image;
- }
- } else {
- animation_.reset();
- SchedulePaint();
- image_ = image;
- }
-}
-
-void TabbedLauncherButton::IconView::OnPaint(gfx::Canvas* canvas) {
- LauncherButton::IconView::OnPaint(canvas);
-
- // Only non incognito icons show the tab image.
- if (host_->is_incognito() != STATE_NOT_INCOGNITO)
- return;
-
- if ((animation_.get() && animation_->is_animating() &&
- animation_->current_part_index() == 1)) {
- int x = (width() - animating_image_.width()) / 2;
- canvas->SaveLayerAlpha(animation_->CurrentValueBetween(255, 0));
- canvas->DrawImageInt(animating_image_, x, kIconOffsetY);
- canvas->Restore();
- } else {
- int x = (width() - image_.width()) / 2;
- canvas->DrawImageInt(image_, x, kIconOffsetY);
- }
-}
-
-// static
-const gfx::ImageSkia* TabbedLauncherButton::IconView::browser_image_ = NULL;
-const gfx::ImageSkia* TabbedLauncherButton::IconView::incognito_browser_image_ =
- NULL;
-const gfx::ImageSkia* TabbedLauncherButton::IconView::browser_panel_image_ =
- NULL;
-const gfx::ImageSkia*
- TabbedLauncherButton::IconView::incognito_browser_panel_image_ = NULL;
-
-TabbedLauncherButton* TabbedLauncherButton::Create(
- views::ButtonListener* listener,
- LauncherButtonHost* host,
- ShelfLayoutManager* shelf_layout_manager,
- IncognitoState is_incognito) {
- TabbedLauncherButton* button = new TabbedLauncherButton(
- listener, host, shelf_layout_manager, is_incognito);
- button->Init();
- return button;
-}
-
-TabbedLauncherButton::TabbedLauncherButton(
- views::ButtonListener* listener,
- LauncherButtonHost* host,
- ShelfLayoutManager* shelf_layout_manager,
- IncognitoState is_incognito)
- : LauncherButton(listener, host, shelf_layout_manager),
- is_incognito_(is_incognito) {
- set_accessibility_focusable(true);
-}
-
-TabbedLauncherButton::~TabbedLauncherButton() {
-}
-
-void TabbedLauncherButton::SetTabImage(const gfx::ImageSkia& image) {
- tabbed_icon_view()->SetTabImage(image);
-}
-
-void TabbedLauncherButton::GetAccessibleState(ui::AccessibleViewState* state) {
- state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON;
- state->name = host()->GetAccessibleName(this);
-}
-
-LauncherButton::IconView* TabbedLauncherButton::CreateIconView() {
- return new IconView(this);
-}
-
-} // namespace internal
-} // namespace ash
diff --git a/ash/launcher/tabbed_launcher_button.h b/ash/launcher/tabbed_launcher_button.h
deleted file mode 100644
index 0ac2c3b..0000000
--- a/ash/launcher/tabbed_launcher_button.h
+++ /dev/null
@@ -1,112 +0,0 @@
-// 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 ASH_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_
-#define ASH_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_
-
-#include "ash/launcher/launcher_button.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/timer/timer.h"
-#include "ui/base/animation/animation_delegate.h"
-#include "ui/views/controls/button/image_button.h"
-#include "ui/views/controls/glow_hover_controller.h"
-
-namespace gfx {
-class ImageSkia;
-}
-
-namespace ui {
-class MultiAnimation;
-}
-
-namespace ash {
-
-struct LauncherItem;
-
-namespace internal {
-
-// Button used for items on the launcher corresponding to tabbed windows.
-class TabbedLauncherButton : public LauncherButton {
- public:
- // Indicates if this button is incognito or not.
- enum IncognitoState {
- STATE_INCOGNITO,
- STATE_NOT_INCOGNITO,
- };
-
- static TabbedLauncherButton* Create(views::ButtonListener* listener,
- LauncherButtonHost* host,
- ShelfLayoutManager* shelf_layout_manager,
- IncognitoState is_incognito);
- virtual ~TabbedLauncherButton();
-
- // Sets the images to display for this entry.
- void SetTabImage(const gfx::ImageSkia& image);
-
- // This only defines how the icon is drawn. Do not use it for other purposes.
- IncognitoState is_incognito() const { return is_incognito_; }
-
- protected:
- TabbedLauncherButton(views::ButtonListener* listener,
- LauncherButtonHost* host,
- ShelfLayoutManager* shelf_layout_manager,
- IncognitoState is_incognito);
- // View override.
- virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
-
- // LauncherButton override.
- virtual IconView* CreateIconView() OVERRIDE;
-
- private:
- // Used as the delegate for |animation_|.
- class IconView : public LauncherButton::IconView,
- public ui::AnimationDelegate {
- public:
- explicit IconView(TabbedLauncherButton* host);
- virtual ~IconView();
-
- // ui::AnimationDelegateImpl overrides:
- virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
- virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
-
- // Sets the image to display for this entry.
- void SetTabImage(const gfx::ImageSkia& image);
-
- protected:
- // View override.
- virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
-
- private:
- TabbedLauncherButton* host_;
- gfx::ImageSkia image_;
- gfx::ImageSkia animating_image_;
-
- // Used to animate image.
- scoped_ptr<ui::MultiAnimation> animation_;
-
- // Background images. Which one is chosen depends on the type of the window.
- static const gfx::ImageSkia* browser_image_;
- static const gfx::ImageSkia* incognito_browser_image_;
- // TODO[dave] implement panel specific image.
- static const gfx::ImageSkia* browser_panel_image_;
- static const gfx::ImageSkia* incognito_browser_panel_image_;
-
- DISALLOW_COPY_AND_ASSIGN(IconView);
- };
-
- IconView* tabbed_icon_view() {
- return static_cast<IconView*>(icon_view());
- }
-
- // Indicates how the icon is drawn. If true an Incognito symbol will be
- // drawn. It does not necessarily indicate if the window is 'incognito'.
- const IncognitoState is_incognito_;
-
- DISALLOW_COPY_AND_ASSIGN(TabbedLauncherButton);
-};
-
-} // namespace internal
-} // namespace ash
-
-#endif // ASH_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_
diff --git a/ash/shell/launcher_delegate_impl.cc b/ash/shell/launcher_delegate_impl.cc
index 5664b00..1e14db8 100644
--- a/ash/shell/launcher_delegate_impl.cc
+++ b/ash/shell/launcher_delegate_impl.cc
@@ -21,8 +21,8 @@ LauncherDelegateImpl::LauncherDelegateImpl(WindowWatcher* watcher)
: watcher_(watcher) {
ash::LauncherItemDelegateManager* manager =
ash::Shell::GetInstance()->launcher_item_delegate_manager();
- manager->RegisterLauncherItemDelegate(ash::TYPE_TABBED, this);
manager->RegisterLauncherItemDelegate(ash::TYPE_APP_PANEL, this);
+ manager->RegisterLauncherItemDelegate(ash::TYPE_PLATFORM_APP, this);
}
LauncherDelegateImpl::~LauncherDelegateImpl() {
diff --git a/ash/shell/window_watcher.cc b/ash/shell/window_watcher.cc
index 0963eb7..4dfcea4 100644
--- a/ash/shell/window_watcher.cc
+++ b/ash/shell/window_watcher.cc
@@ -107,7 +107,7 @@ void WindowWatcher::OnWindowAdded(aura::Window* new_window) {
ash::LauncherModel* model = Shell::GetInstance()->launcher_model();
ash::LauncherItem item;
item.type = new_window->type() == aura::client::WINDOW_TYPE_PANEL ?
- ash::TYPE_APP_PANEL : ash::TYPE_TABBED;
+ ash::TYPE_APP_PANEL : ash::TYPE_PLATFORM_APP;
id_to_window_[model->next_id()] = new_window;
SkBitmap icon_bitmap;
diff --git a/ash/test/test_launcher_delegate.cc b/ash/test/test_launcher_delegate.cc
index 7ca1663..b0025b5 100644
--- a/ash/test/test_launcher_delegate.cc
+++ b/ash/test/test_launcher_delegate.cc
@@ -27,7 +27,6 @@ TestLauncherDelegate::TestLauncherDelegate(LauncherModel* model)
ash::LauncherItemDelegateManager* manager =
ash::Shell::GetInstance()->launcher_item_delegate_manager();
manager->RegisterLauncherItemDelegate(ash::TYPE_APP_PANEL, this);
- manager->RegisterLauncherItemDelegate(ash::TYPE_TABBED, this);
manager->RegisterLauncherItemDelegate(ash::TYPE_APP_SHORTCUT, this);
manager->RegisterLauncherItemDelegate(ash::TYPE_BROWSER_SHORTCUT, this);
manager->RegisterLauncherItemDelegate(ash::TYPE_PLATFORM_APP, this);
@@ -49,7 +48,7 @@ void TestLauncherDelegate::AddLauncherItem(
if (window->type() == aura::client::WINDOW_TYPE_PANEL)
item.type = ash::TYPE_APP_PANEL;
else
- item.type = ash::TYPE_TABBED;
+ item.type = ash::TYPE_PLATFORM_APP;
DCHECK(window_to_id_.find(window) == window_to_id_.end());
window_to_id_[window] = model_->next_id();
item.status = status;
diff --git a/chrome/browser/ui/ash/launcher/browser_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/browser_launcher_item_controller.cc
deleted file mode 100644
index 04668bb..0000000
--- a/chrome/browser/ui/ash/launcher/browser_launcher_item_controller.cc
+++ /dev/null
@@ -1,268 +0,0 @@
-// 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/ui/ash/launcher/browser_launcher_item_controller.h"
-
-#include "ash/launcher/launcher.h"
-#include "ash/launcher/launcher_model.h"
-#include "ash/shell.h"
-#include "ash/wm/window_util.h"
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/tab_helper.h"
-#include "chrome/browser/favicon/favicon_tab_helper.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h"
-#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_list.h"
-#include "chrome/browser/ui/browser_window.h"
-#include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "chrome/browser/web_applications/web_app.h"
-#include "chrome/common/extensions/manifest_handlers/icons_handler.h"
-#include "content/public/browser/web_contents.h"
-#include "grit/ui_resources.h"
-#include "ui/aura/client/aura_constants.h"
-#include "ui/aura/window.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/views/widget/widget.h"
-
-BrowserLauncherItemController::BrowserLauncherItemController(
- Type type,
- aura::Window* window,
- TabStripModel* tab_model,
- ChromeLauncherController* launcher_controller,
- const std::string& app_id)
- : LauncherItemController(type, app_id, launcher_controller),
- window_(window),
- tab_model_(tab_model),
- is_incognito_(tab_model->profile()->GetOriginalProfile() !=
- tab_model->profile() &&
- !tab_model->profile()->IsGuestSession()) {
- DCHECK(window_);
- window_->AddObserver(this);
-}
-
-BrowserLauncherItemController::~BrowserLauncherItemController() {
- tab_model_->RemoveObserver(this);
- window_->RemoveObserver(this);
- if (launcher_id() > 0)
- launcher_controller()->CloseLauncherItem(launcher_id());
- if (type() == TYPE_WINDOWED_APP)
- launcher_controller()->UnlockV1AppWithID(LauncherItemController::app_id());
-}
-
-const std::string& BrowserLauncherItemController::app_id() const {
- if (type() == TYPE_WINDOWED_APP)
- return empty_app_id_;
- return LauncherItemController::app_id();
-}
-
-void BrowserLauncherItemController::Init() {
- tab_model_->AddObserver(this);
- ash::LauncherItemStatus app_status =
- ash::wm::IsActiveWindow(window_) ?
- ash::STATUS_ACTIVE : ash::STATUS_RUNNING;
- if (type() != TYPE_TABBED && type() != TYPE_WINDOWED_APP)
- launcher_controller()->CreateAppLauncherItem(this, app_id(), app_status);
- else if (type() == TYPE_WINDOWED_APP)
- launcher_controller()->LockV1AppWithID(LauncherItemController::app_id());
-
- // In testing scenarios we can get tab strips with no active contents.
- if (tab_model_->active_index() != TabStripModel::kNoTab)
- UpdateLauncher(tab_model_->GetActiveWebContents());
-}
-
-// static
-BrowserLauncherItemController* BrowserLauncherItemController::Create(
- Browser* browser) {
- // Under testing this can be called before the controller is created.
- if (!ChromeLauncherController::instance())
- return NULL;
-
- Type type;
- std::string app_id;
- if (browser->is_type_tabbed() || browser->is_type_popup()) {
- type = TYPE_TABBED;
- if (!browser->is_type_tabbed() &&
- browser->is_type_popup() &&
- browser->is_app()) {
- app_id = web_app::GetExtensionIdFromApplicationName(
- browser->app_name());
- // Only allow this for known applications. Some unit tests for example
- // do not have one.
- if (!app_id.empty())
- type = TYPE_WINDOWED_APP;
- }
- } else if (browser->is_app()) {
- type = TYPE_TABBED;
- app_id = web_app::GetExtensionIdFromApplicationName(browser->app_name());
- } else {
- return NULL;
- }
- BrowserLauncherItemController* controller =
- new BrowserLauncherItemController(type,
- browser->window()->GetNativeWindow(),
- browser->tab_strip_model(),
- ChromeLauncherController::instance(),
- app_id);
- controller->Init();
- return controller;
-}
-
-void BrowserLauncherItemController::BrowserActivationStateChanged() {
- content::WebContents* active_contents = tab_model_->GetActiveWebContents();
- if (active_contents)
- UpdateAppState(active_contents);
- UpdateItemStatus();
-}
-
-string16 BrowserLauncherItemController::GetTitle() {
- if (type() == TYPE_TABBED) {
- if (tab_model_->active_index() != TabStripModel::kNoTab) {
- const content::WebContents* contents = tab_model_->GetActiveWebContents();
- if (contents)
- return contents->GetTitle();
- }
- }
- return GetAppTitle();
-}
-
-bool BrowserLauncherItemController::IsCurrentlyShownInWindow(
- aura::Window* window) const {
- return window_ == window;
-}
-
-bool BrowserLauncherItemController::IsOpen() const {
- return true;
-}
-
-bool BrowserLauncherItemController::IsVisible() const {
- return window_->IsVisible();
-}
-
-void BrowserLauncherItemController::Launch(int event_flags) {
- DCHECK(!app_id().empty());
- launcher_controller()->LaunchApp(app_id(), event_flags);
-}
-
-void BrowserLauncherItemController::Activate() {
- window_->Show();
- ash::wm::ActivateWindow(window_);
-}
-
-void BrowserLauncherItemController::Close() {
- views::Widget* widget = views::Widget::GetWidgetForNativeView(window_);
- if (widget)
- widget->Close();
-}
-
-void BrowserLauncherItemController::Clicked(const ui::Event& event) {
- views::Widget* widget =
- views::Widget::GetWidgetForNativeView(window_);
- if (widget && widget->IsActive()) {
- widget->Minimize();
- } else {
- Activate();
- }
-}
-
-void BrowserLauncherItemController::OnRemoved() {
-}
-
-void BrowserLauncherItemController::LauncherItemChanged(
- int index,
- const ash::LauncherItem& old_item) {
-}
-
-ChromeLauncherAppMenuItems
-BrowserLauncherItemController::GetApplicationList(int event_flags) {
- // This will never be called and the entire class will go away.
- ChromeLauncherAppMenuItems items;
- return items.Pass();
-}
-
-void BrowserLauncherItemController::ActiveTabChanged(
- content::WebContents* old_contents,
- content::WebContents* new_contents,
- int index,
- int reason) {
- // Update immediately on a tab change.
- if (old_contents &&
- TabStripModel::kNoTab !=
- tab_model_->GetIndexOfWebContents(old_contents))
- UpdateAppState(old_contents);
- UpdateAppState(new_contents);
- UpdateLauncher(new_contents);
-}
-
-void BrowserLauncherItemController::TabInsertedAt(
- content::WebContents* contents,
- int index,
- bool foreground) {
- UpdateAppState(contents);
-}
-
-void BrowserLauncherItemController::TabDetachedAt(
- content::WebContents* contents,
- int index) {
- launcher_controller()->UpdateAppState(
- contents, ChromeLauncherController::APP_STATE_REMOVED);
-}
-
-void BrowserLauncherItemController::TabChangedAt(
- content::WebContents* contents,
- int index,
- TabStripModelObserver::TabChangeType change_type) {
- UpdateAppState(contents);
- if (index != tab_model_->active_index() ||
- !(change_type != TabStripModelObserver::LOADING_ONLY &&
- change_type != TabStripModelObserver::TITLE_NOT_LOADING)) {
- return;
- }
-
- UpdateLauncher(contents);
-}
-
-void BrowserLauncherItemController::TabReplacedAt(
- TabStripModel* tab_strip_model,
- content::WebContents* old_contents,
- content::WebContents* new_contents,
- int index) {
- launcher_controller()->UpdateAppState(
- old_contents,
- ChromeLauncherController::APP_STATE_REMOVED);
- UpdateAppState(new_contents);
-}
-
-void BrowserLauncherItemController::OnWindowPropertyChanged(
- aura::Window* window,
- const void* key,
- intptr_t old) {
- if (key == aura::client::kDrawAttentionKey)
- UpdateItemStatus();
-}
-
-void BrowserLauncherItemController::UpdateItemStatus() {
-}
-
-void BrowserLauncherItemController::UpdateLauncher(content::WebContents* tab) {
-}
-
-void BrowserLauncherItemController::UpdateAppState(content::WebContents* tab) {
- ChromeLauncherController::AppState app_state;
-
- if (tab_model_->GetActiveWebContents() == tab) {
- if (ash::wm::IsActiveWindow(window_))
- app_state = ChromeLauncherController::APP_STATE_WINDOW_ACTIVE;
- else
- app_state = ChromeLauncherController::APP_STATE_ACTIVE;
- } else {
- app_state = ChromeLauncherController::APP_STATE_INACTIVE;
- }
- launcher_controller()->UpdateAppState(tab, app_state);
-}
-
-ash::LauncherModel* BrowserLauncherItemController::launcher_model() {
- return launcher_controller()->model();
-}
diff --git a/chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h b/chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h
deleted file mode 100644
index 51fbc33..0000000
--- a/chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h
+++ /dev/null
@@ -1,144 +0,0 @@
-// 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_UI_ASH_LAUNCHER_BROWSER_LAUNCHER_ITEM_CONTROLLER_H_
-#define CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_LAUNCHER_ITEM_CONTROLLER_H_
-
-#include <string>
-
-#include "ash/launcher/launcher_types.h"
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "base/gtest_prod_util.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/strings/string16.h"
-#include "chrome/browser/ui/ash/launcher/launcher_favicon_loader.h"
-#include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
-#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
-#include "ui/aura/window_observer.h"
-
-class Browser;
-
-namespace ash {
-class LauncherModel;
-}
-
-// BrowserLauncherItemController is responsible for keeping the launcher
-// representation of a window up to date as the active tab changes.
-class BrowserLauncherItemController : public LauncherItemController,
- public TabStripModelObserver,
- public aura::WindowObserver {
- public:
- // This API is to be used as part of testing only.
- class TestApi {
- public:
- explicit TestApi(BrowserLauncherItemController* controller)
- : controller_(controller) {}
- ~TestApi() {}
-
- // Returns the launcher id for the browser window.
- ash::LauncherID item_id() const { return controller_->launcher_id(); }
-
- private:
- BrowserLauncherItemController* controller_;
- };
-
- BrowserLauncherItemController(Type type,
- aura::Window* window,
- TabStripModel* tab_model,
- ChromeLauncherController* launcher_controller,
- const std::string& app_id);
- virtual ~BrowserLauncherItemController();
-
- // Overriding the app id for V1 apps.
- virtual const std::string& app_id() const OVERRIDE;
-
- // Sets up this BrowserLauncherItemController.
- void Init();
-
- // Creates and returns a new BrowserLauncherItemController for |browser|. This
- // returns NULL if a BrowserLauncherItemController is not needed for the
- // specified browser.
- static BrowserLauncherItemController* Create(Browser* browser);
-
- // Call to indicate that the window the tabcontents are in has changed its
- // activation state.
- void BrowserActivationStateChanged();
-
- // LauncherItemController overrides:
- virtual string16 GetTitle() OVERRIDE;
- virtual bool IsCurrentlyShownInWindow(aura::Window* window) const OVERRIDE;
- virtual bool IsOpen() const OVERRIDE;
- virtual bool IsVisible() const OVERRIDE;
- virtual void Launch(int event_flags) OVERRIDE;
- virtual void Activate() OVERRIDE;
- virtual void Close() OVERRIDE;
- virtual void Clicked(const ui::Event& event) OVERRIDE;
- virtual void OnRemoved() OVERRIDE;
- virtual void LauncherItemChanged(int index,
- const ash::LauncherItem& old_item) OVERRIDE;
- virtual ChromeLauncherAppMenuItems GetApplicationList(
- int event_flags) OVERRIDE;
-
- // TabStripModel overrides:
- virtual void ActiveTabChanged(content::WebContents* old_contents,
- content::WebContents* new_contents,
- int index,
- int reason) OVERRIDE;
- virtual void TabInsertedAt(content::WebContents* contents,
- int index,
- bool foreground) OVERRIDE;
- virtual void TabDetachedAt(content::WebContents* contents,
- int index) OVERRIDE;
- virtual void TabChangedAt(
- content::WebContents* contents,
- int index,
- TabStripModelObserver::TabChangeType change_type) OVERRIDE;
- virtual void TabReplacedAt(TabStripModel* tab_strip_model,
- content::WebContents* old_contents,
- content::WebContents* new_contents,
- int index) OVERRIDE;
-
- // aura::WindowObserver overrides:
- virtual void OnWindowPropertyChanged(aura::Window* window,
- const void* key,
- intptr_t old) OVERRIDE;
-
- private:
- FRIEND_TEST_ALL_PREFIXES(BrowserLauncherItemControllerTest, PanelItem);
-
- // Used to identify what an update corresponds to.
- enum UpdateType {
- UPDATE_TAB_REMOVED,
- UPDATE_TAB_CHANGED,
- UPDATE_TAB_INSERTED,
- };
-
- // Updates the launcher item status base on the activation and attention
- // state of the window.
- void UpdateItemStatus();
-
- // Updates the launcher from |tab|.
- void UpdateLauncher(content::WebContents* tab);
-
- void UpdateAppState(content::WebContents* tab);
-
- ash::LauncherModel* launcher_model();
-
- // Browser window we're in.
- aura::Window* window_;
-
- // If running a windowed V1 app with the new launcher, this (empty) app id
- // will be returned by app_id().
- std::string empty_app_id_;
-
- TabStripModel* tab_model_;
-
- // Whether this is associated with an incognito profile.
- const bool is_incognito_;
-
- DISALLOW_COPY_AND_ASSIGN(BrowserLauncherItemController);
-};
-
-#endif // CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_LAUNCHER_ITEM_CONTROLLER_H_
diff --git a/chrome/browser/ui/ash/launcher/browser_status_monitor.cc b/chrome/browser/ui/ash/launcher/browser_status_monitor.cc
new file mode 100644
index 0000000..06b0178
--- /dev/null
+++ b/chrome/browser/ui/ash/launcher/browser_status_monitor.cc
@@ -0,0 +1,196 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/ash/launcher/browser_status_monitor.h"
+
+#include "ash/shell.h"
+#include "ash/wm/window_util.h"
+#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/browser/web_applications/web_app.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_view.h"
+#include "ui/aura/client/activation_client.h"
+#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
+#include "ui/gfx/screen.h"
+
+BrowserStatusMonitor::BrowserStatusMonitor(
+ ChromeLauncherController* launcher_controller)
+ : launcher_controller_(launcher_controller),
+ observed_activation_clients_(this),
+ observed_root_windows_(this) {
+ DCHECK(launcher_controller_);
+ BrowserList* browser_list =
+ BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
+
+ browser_list->AddObserver(this);
+
+ // This check needs for win7_aura. Without this, all tests in
+ // ChromeLauncherController will fail in win7_aura.
+ if (ash::Shell::HasInstance()) {
+ // We can't assume all RootWindows have the same ActivationClient.
+ // Add a RootWindow and its ActivationClient to the observed list.
+ ash::Shell::RootWindowList root_windows = ash::Shell::GetAllRootWindows();
+ ash::Shell::RootWindowList::const_iterator iter = root_windows.begin();
+ for (; iter != root_windows.end(); ++iter) {
+ // |observed_activation_clients_| can have the same activation client
+ // multiple times - which would be handled by the used
+ // |ScopedObserverWithDuplicatedSources|.
+ observed_activation_clients_.Add(
+ aura::client::GetActivationClient(*iter));
+ observed_root_windows_.Add(static_cast<aura::Window*>(*iter));
+ }
+ ash::Shell::GetInstance()->GetScreen()->AddObserver(this);
+ }
+}
+
+BrowserStatusMonitor::~BrowserStatusMonitor() {
+ // This check needs for win7_aura. Without this, all tests in
+ // ChromeLauncherController will fail in win7_aura.
+ if (ash::Shell::HasInstance())
+ ash::Shell::GetInstance()->GetScreen()->RemoveObserver(this);
+
+ BrowserList* browser_list =
+ BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
+
+ browser_list->RemoveObserver(this);
+}
+
+void BrowserStatusMonitor::OnWindowActivated(aura::Window* gained_active,
+ aura::Window* lost_active) {
+ Browser* browser = chrome::FindBrowserWithWindow(lost_active);
+ content::WebContents* active_contents = NULL;
+
+ if (browser) {
+ active_contents = browser->tab_strip_model()->GetActiveWebContents();
+ if (active_contents)
+ UpdateAppState(active_contents);
+ }
+
+ browser = chrome::FindBrowserWithWindow(gained_active);
+ if (browser) {
+ active_contents = browser->tab_strip_model()->GetActiveWebContents();
+ if (active_contents)
+ UpdateAppState(active_contents);
+ }
+}
+
+void BrowserStatusMonitor::OnWindowDestroyed(aura::Window* window) {
+ // Remove RootWindow and its ActivationClient from observed list.
+ observed_root_windows_.Remove(window);
+ observed_activation_clients_.Remove(aura::client::GetActivationClient(
+ static_cast<aura::RootWindow*>(window)));
+}
+
+void BrowserStatusMonitor::OnBrowserAdded(Browser* browser) {
+ browser->tab_strip_model()->AddObserver(this);
+
+ if (browser->is_type_popup() && browser->is_app()) {
+ std::string app_id =
+ web_app::GetExtensionIdFromApplicationName(browser->app_name());
+ if (!app_id.empty()) {
+ browser_to_app_id_map_[browser] = app_id;
+ launcher_controller_->LockV1AppWithID(app_id);
+ }
+ }
+}
+
+void BrowserStatusMonitor::OnBrowserRemoved(Browser* browser) {
+ browser->tab_strip_model()->RemoveObserver(this);
+
+ if (browser_to_app_id_map_.find(browser) != browser_to_app_id_map_.end()) {
+ launcher_controller_->UnlockV1AppWithID(browser_to_app_id_map_[browser]);
+ browser_to_app_id_map_.erase(browser);
+ }
+ launcher_controller_->UpdateBrowserItemStatus();
+}
+
+void BrowserStatusMonitor::OnDisplayBoundsChanged(
+ const gfx::Display& display) {
+ // Do nothing here.
+}
+
+void BrowserStatusMonitor::OnDisplayAdded(const gfx::Display& new_display) {
+ // Add a new RootWindow and its ActivationClient to observed list.
+ aura::RootWindow* root_window = ash::Shell::GetInstance()->
+ display_controller()->GetRootWindowForDisplayId(new_display.id());
+ observed_activation_clients_.Add(
+ aura::client::GetActivationClient(root_window));
+}
+
+void BrowserStatusMonitor::OnDisplayRemoved(const gfx::Display& old_display) {
+ // When this is called, RootWindow of |old_display| is already removed.
+ // Instead, we can remove RootWindow and its ActivationClient in the
+ // OnWindowRemoved().
+ // Do nothing here.
+}
+
+void BrowserStatusMonitor::ActiveTabChanged(content::WebContents* old_contents,
+ content::WebContents* new_contents,
+ int index,
+ int reason) {
+ Browser* browser = NULL;
+ if (old_contents)
+ browser = chrome::FindBrowserWithWebContents(old_contents);
+
+ // Update immediately on a tab change.
+ if (browser &&
+ (TabStripModel::kNoTab !=
+ browser->tab_strip_model()->GetIndexOfWebContents(old_contents)))
+ UpdateAppState(old_contents);
+
+ UpdateAppState(new_contents);
+}
+
+void BrowserStatusMonitor::TabInsertedAt(content::WebContents* contents,
+ int index,
+ bool foreground) {
+ UpdateAppState(contents);
+}
+
+void BrowserStatusMonitor::TabDetachedAt(content::WebContents* contents,
+ int index) {
+ launcher_controller_->UpdateAppState(
+ contents, ChromeLauncherController::APP_STATE_REMOVED);
+}
+
+void BrowserStatusMonitor::TabChangedAt(
+ content::WebContents* contents,
+ int index,
+ TabStripModelObserver::TabChangeType change_type) {
+ UpdateAppState(contents);
+}
+
+void BrowserStatusMonitor::TabReplacedAt(TabStripModel* tab_strip_model,
+ content::WebContents* old_contents,
+ content::WebContents* new_contents,
+ int index) {
+ launcher_controller_->UpdateAppState(
+ old_contents,
+ ChromeLauncherController::APP_STATE_REMOVED);
+ UpdateAppState(new_contents);
+}
+
+void BrowserStatusMonitor::UpdateAppState(content::WebContents* contents) {
+ if (!contents)
+ return;
+
+ ChromeLauncherController::AppState app_state =
+ ChromeLauncherController::APP_STATE_INACTIVE;
+
+ Browser* browser = chrome::FindBrowserWithWebContents(contents);
+ if (browser->tab_strip_model()->GetActiveWebContents() == contents) {
+ if (browser->window()->IsActive())
+ app_state = ChromeLauncherController::APP_STATE_WINDOW_ACTIVE;
+ else
+ app_state = ChromeLauncherController::APP_STATE_ACTIVE;
+ }
+
+ launcher_controller_->UpdateAppState(contents, app_state);
+}
diff --git a/chrome/browser/ui/ash/launcher/browser_status_monitor.h b/chrome/browser/ui/ash/launcher/browser_status_monitor.h
new file mode 100644
index 0000000..9c2880a
--- /dev/null
+++ b/chrome/browser/ui/ash/launcher/browser_status_monitor.h
@@ -0,0 +1,99 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_STATUS_MONITOR_H_
+#define CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_STATUS_MONITOR_H_
+
+#include <map>
+#include <string>
+
+#include "ash/launcher/scoped_observer_with_duplicated_sources.h"
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/scoped_observer.h"
+#include "chrome/browser/ui/browser_list_observer.h"
+#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
+#include "ui/aura/client/activation_change_observer.h"
+#include "ui/aura/window_observer.h"
+#include "ui/gfx/display_observer.h"
+
+namespace aura {
+class Window;
+
+namespace client {
+class ActivationClient;
+}
+} // namespace aura
+
+class Browser;
+class ChromeLauncherController;
+
+// BrowserStatusMonitor monitors creation/deletion of Browser and its
+// TabStripModel to keep the launcher representation up to date as the
+// active tab changes.
+class BrowserStatusMonitor : public aura::client::ActivationChangeObserver,
+ public aura::WindowObserver,
+ public chrome::BrowserListObserver,
+ public gfx::DisplayObserver,
+ public TabStripModelObserver {
+ public:
+ explicit BrowserStatusMonitor(ChromeLauncherController* launcher_controller);
+ virtual ~BrowserStatusMonitor();
+
+ // aura::client::ActivationChangeObserver overrides:
+ virtual void OnWindowActivated(aura::Window* gained_active,
+ aura::Window* lost_active) OVERRIDE;
+
+ // aura::WindowObserver overrides:
+ virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE;
+
+ // chrome::BrowserListObserver overrides:
+ virtual void OnBrowserAdded(Browser* browser) OVERRIDE;
+ virtual void OnBrowserRemoved(Browser* browser) OVERRIDE;
+
+ // gfx::DisplayObserver overrides:
+ virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE;
+ virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE;
+ virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE;
+
+ // TabStripModelObserver overrides:
+ virtual void ActiveTabChanged(content::WebContents* old_contents,
+ content::WebContents* new_contents,
+ int index,
+ int reason) OVERRIDE;
+ virtual void TabInsertedAt(content::WebContents* contents,
+ int index,
+ bool foreground) OVERRIDE;
+ virtual void TabDetachedAt(content::WebContents* contents,
+ int index) OVERRIDE;
+ virtual void TabChangedAt(
+ content::WebContents* contents,
+ int index,
+ TabStripModelObserver::TabChangeType change_type) OVERRIDE;
+ virtual void TabReplacedAt(TabStripModel* tab_strip_model,
+ content::WebContents* old_contents,
+ content::WebContents* new_contents,
+ int index) OVERRIDE;
+
+ private:
+ typedef std::map<Browser*, std::string> BrowserToAppIDMap;
+
+ // Update app state for |contents|.
+ void UpdateAppState(content::WebContents* contents);
+
+ ChromeLauncherController* launcher_controller_;
+
+ // Hold all observed activation clients.
+ ScopedObserverWithDuplicatedSources<aura::client::ActivationClient,
+ aura::client::ActivationChangeObserver> observed_activation_clients_;
+
+ // Hold all observed root windows.
+ ScopedObserver<aura::Window, aura::WindowObserver> observed_root_windows_;
+
+ BrowserToAppIDMap browser_to_app_id_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowserStatusMonitor);
+};
+
+#endif // CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_STATUS_MONITOR_H_
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
index a072cac..9b0bc44 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
@@ -36,6 +36,7 @@
#include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
#include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h"
#include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.h"
+#include "chrome/browser/ui/ash/launcher/browser_status_monitor.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h"
@@ -208,8 +209,8 @@ ChromeLauncherController::ChromeLauncherController(
app_sync_ui_state_->AddObserver(this);
}
+ browser_status_monitor_.reset(new BrowserStatusMonitor(this));
model_->AddObserver(this);
- BrowserList::AddObserver(this);
// Right now ash::Shell isn't created for tests.
// TODO(mukai): Allows it to observe display change and write tests.
if (ash::Shell::HasInstance())
@@ -261,15 +262,11 @@ ChromeLauncherController::~ChromeLauncherController() {
(*iter)->shelf_widget()->shelf_layout_manager()->RemoveObserver(this);
model_->RemoveObserver(this);
- BrowserList::RemoveObserver(this);
if (ash::Shell::HasInstance())
ash::Shell::GetInstance()->display_controller()->RemoveObserver(this);
for (IDToItemControllerMap::iterator i = id_to_item_controller_map_.begin();
i != id_to_item_controller_map_.end(); ++i) {
i->second->OnRemoved();
- // TODO(skuhne): After getting rid of the old launcher, get also rid of the
- // BrowserLauncherItemController (since it is only used for activation
- // tracking at that point.
int index = model_->ItemIndexByID(i->first);
// A "browser proxy" is not known to the model and this removal does
// therefore not need to be propagated to the model.
@@ -1206,13 +1203,6 @@ string16 ChromeLauncherController::GetAppListTitle(
return l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE);
}
-void ChromeLauncherController::OnBrowserRemoved(Browser* browser) {
- // When called by a unit test it is possible that there is no shell.
- // In that case, the following function should not get called.
- if (ash::Shell::HasInstance())
- UpdateBrowserItemStatus();
-}
-
ash::LauncherID ChromeLauncherController::CreateAppShortcutLauncherItem(
const std::string& app_id,
int index) {
@@ -1247,6 +1237,12 @@ ash::LauncherID ChromeLauncherController::CreateAppShortcutLauncherItemWithType(
}
void ChromeLauncherController::UpdateBrowserItemStatus() {
+ // This check needs for win7_aura. UpdateBrowserItemStatus() access Shell.
+ // Without this ChromeLauncherControllerTest.BrowserMenuGeneration test will
+ // fail.
+ if (!ash::Shell::HasInstance())
+ return;
+
// Determine the new browser's active state and change if necessary.
size_t browser_index = ash::launcher::GetBrowserItemIndex(*model_);
DCHECK_GE(browser_index, 0u);
@@ -1526,7 +1522,6 @@ ash::LauncherID ChromeLauncherController::InsertAppLauncherItem(
ash::LauncherItem item;
item.type = launcher_item_type;
- item.is_incognito = false;
item.image = extensions::IconsInfo::GetDefaultAppIcon();
WebContents* active_tab = GetLastActiveWebContents(app_id);
@@ -1590,7 +1585,6 @@ ChromeLauncherController::GetBrowserShortcutLauncherItemController() {
ash::LauncherID ChromeLauncherController::CreateBrowserShortcutLauncherItem() {
ash::LauncherItem browser_shortcut;
browser_shortcut.type = ash::TYPE_BROWSER_SHORTCUT;
- browser_shortcut.is_incognito = false;
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
browser_shortcut.image = *rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_32);
ash::LauncherID id = model_->next_id();
@@ -1663,7 +1657,6 @@ void ChromeLauncherController::RegisterLauncherItemDelegate() {
// is created.
ash::LauncherItemDelegateManager* manager =
ash::Shell::GetInstance()->launcher_item_delegate_manager();
- manager->RegisterLauncherItemDelegate(ash::TYPE_TABBED, this);
manager->RegisterLauncherItemDelegate(ash::TYPE_APP_PANEL, this);
manager->RegisterLauncherItemDelegate(ash::TYPE_APP_SHORTCUT, this);
manager->RegisterLauncherItemDelegate(ash::TYPE_BROWSER_SHORTCUT, this);
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.h b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.h
index 5ae9218..4cd78e9 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.h
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.h
@@ -29,7 +29,6 @@
#include "chrome/browser/prefs/pref_service_syncable_observer.h"
#include "chrome/browser/ui/ash/app_sync_ui_state_observer.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h"
-#include "chrome/browser/ui/browser_list_observer.h"
#include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h"
#include "content/public/browser/notification_observer.h"
#include "ui/aura/window_observer.h"
@@ -37,6 +36,7 @@
class AppSyncUIState;
class Browser;
class BrowserShortcutLauncherItemController;
+class BrowserStatusMonitor;
class ExtensionEnableFlow;
class GURL;
class LauncherItemController;
@@ -84,7 +84,6 @@ class ChromeLauncherController : public ash::LauncherDelegate,
public PrefServiceSyncableObserver,
public AppSyncUIStateObserver,
public ExtensionEnableFlowDelegate,
- public chrome::BrowserListObserver,
public ash::ShelfLayoutManagerObserver {
public:
// Indicates if a launcher item is incognito or not.
@@ -361,9 +360,6 @@ class ChromeLauncherController : public ash::LauncherDelegate,
// If |web_contents| has not loaded, returns "Net Tab".
string16 GetAppListTitle(content::WebContents* web_contents) const;
- // Overridden from chrome::BrowserListObserver.
- virtual void OnBrowserRemoved(Browser* browser) OVERRIDE;
-
// Returns true when the given |browser| is listed in the browser application
// list.
bool IsBrowserRepresentedInBrowserList(Browser* browser);
@@ -371,6 +367,9 @@ class ChromeLauncherController : public ash::LauncherDelegate,
// Returns the LauncherItemController of BrowserShortcut.
LauncherItemController* GetBrowserShortcutLauncherItemController();
+ // Updates the activation state of the Broswer item.
+ void UpdateBrowserItemStatus();
+
protected:
// Creates a new app shortcut item and controller on the launcher at |index|.
// Use kInsertItemAtEnd to add a shortcut as the last item.
@@ -401,9 +400,6 @@ class ChromeLauncherController : public ash::LauncherDelegate,
int index,
ash::LauncherItemType launcher_item_type);
- // Updates the activation state of the Broswer item.
- void UpdateBrowserItemStatus();
-
// Returns the profile used for new windows.
Profile* GetProfileForNewWindows();
@@ -513,6 +509,9 @@ class ChromeLauncherController : public ash::LauncherDelegate,
// The owned browser shortcut item.
scoped_ptr<BrowserShortcutLauncherItemController> browser_item_controller_;
+ // The owned browser status monitor.
+ scoped_ptr<BrowserStatusMonitor> browser_status_monitor_;
+
// If true, incoming pinned state changes should be ignored.
bool ignore_persist_pinned_state_change_;
diff --git a/chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc b/chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc
index 442e458..2b63cfd 100644
--- a/chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc
+++ b/chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc
@@ -4,9 +4,9 @@
#include "chrome/browser/ui/ash/launcher/launcher_favicon_loader.h"
+#include "ash/launcher/launcher_types.h"
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
-#include "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
diff --git a/chrome/browser/ui/ash/launcher/launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/launcher_item_controller.cc
index d0cb781..f8858bc 100644
--- a/chrome/browser/ui/ash/launcher/launcher_item_controller.cc
+++ b/chrome/browser/ui/ash/launcher/launcher_item_controller.cc
@@ -48,8 +48,6 @@ ash::LauncherItemType LauncherItemController::GetLauncherItemType() const {
return ash::TYPE_PLATFORM_APP;
case LauncherItemController::TYPE_APP_PANEL:
return ash::TYPE_APP_PANEL;
- case LauncherItemController::TYPE_TABBED:
- return ash::TYPE_TABBED;
}
NOTREACHED();
return ash::TYPE_APP_SHORTCUT;
diff --git a/chrome/browser/ui/ash/launcher/launcher_item_controller.h b/chrome/browser/ui/ash/launcher/launcher_item_controller.h
index 631a66f..c374b1f 100644
--- a/chrome/browser/ui/ash/launcher/launcher_item_controller.h
+++ b/chrome/browser/ui/ash/launcher/launcher_item_controller.h
@@ -32,7 +32,6 @@ class LauncherItemController {
TYPE_APP,
TYPE_APP_PANEL,
TYPE_SHORTCUT,
- TYPE_TABBED,
TYPE_WINDOWED_APP
};
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index f191d07..975abcc 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -132,7 +132,6 @@
#include "ash/launcher/launcher_model.h"
#include "ash/shell.h"
#include "chrome/browser/ui/ash/ash_util.h"
-#include "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h"
#endif
#if defined(USE_AURA)
@@ -422,12 +421,6 @@ BrowserView::BrowserView()
}
BrowserView::~BrowserView() {
-#if defined(USE_ASH)
- // Destroy BrowserLauncherItemController early on as it listens to the
- // TabstripModel, which is destroyed by the browser.
- launcher_item_controller_.reset();
-#endif
-
// Immersive mode may need to reparent views before they are removed/deleted.
immersive_mode_controller_.reset();
@@ -634,8 +627,6 @@ void BrowserView::Show() {
return;
}
- CreateLauncherIcon();
-
// Showing the window doesn't make the browser window active right away.
// This can cause SetFocusToLocationBar() to skip setting focus to the
// location bar. To avoid this we explicilty let SetFocusToLocationBar()
@@ -666,7 +657,6 @@ void BrowserView::Show() {
void BrowserView::ShowInactive() {
if (frame_->IsVisible())
return;
- CreateLauncherIcon();
frame_->ShowInactive();
}
@@ -1656,11 +1646,6 @@ views::ClientView* BrowserView::CreateClientView(views::Widget* widget) {
void BrowserView::OnWidgetActivationChanged(views::Widget* widget,
bool active) {
-#if defined(USE_ASH)
- if (launcher_item_controller_.get())
- launcher_item_controller_->BrowserActivationStateChanged();
-#endif
-
if (active)
BrowserList::SetLastActive(browser_.get());
}
@@ -2524,16 +2509,6 @@ void BrowserView::UpdateAcceleratorMetrics(
#endif
}
-void BrowserView::CreateLauncherIcon() {
-#if defined(USE_ASH)
- if (chrome::IsNativeWindowInAsh(GetNativeWindow()) &&
- !launcher_item_controller_.get()) {
- launcher_item_controller_.reset(
- BrowserLauncherItemController::Create(browser_.get()));
- }
-#endif // defined(USE_ASH)
-}
-
// static
BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
// Create the view and the frame. The frame will attach itself via the view
diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h
index 4c865e0..72e94e7 100644
--- a/chrome/browser/ui/views/frame/browser_view.h
+++ b/chrome/browser/ui/views/frame/browser_view.h
@@ -61,10 +61,6 @@ class TopContainerView;
class JumpList;
#endif
-#if defined(USE_ASH)
-class BrowserLauncherItemController;
-#endif
-
namespace autofill {
class PasswordGenerator;
}
@@ -256,17 +252,6 @@ class BrowserView : public BrowserWindow,
// animations.
void ToolbarSizeChanged(bool is_animating);
-#if defined(USE_ASH)
- // Test support.
- // Note: This is only needed to be BrowserLauncherItemController instead of
- // LauncherItemController because of the "favicon_loader" member - to be more
- // exact that member function is the only one being called.
- // TODO(skuhne): Remove once per-app is default.
- BrowserLauncherItemController* launcher_item_controller() const {
- return launcher_item_controller_.get();
- }
-#endif
-
// Overridden from BrowserWindow:
virtual void Show() OVERRIDE;
virtual void ShowInactive() OVERRIDE;
@@ -583,9 +568,6 @@ class BrowserView : public BrowserWindow,
void UpdateAcceleratorMetrics(const ui::Accelerator& accelerator,
int command_id);
- // Create an icon for this window in the launcher (currently only for Ash).
- void CreateLauncherIcon();
-
// Calls |method| which is either RenderWidgetHost::Cut, ::Copy, or ::Paste,
// first trying the content WebContents, then the devtools WebContents, and
// lastly the Views::Textfield if one is focused.
@@ -745,13 +727,6 @@ class BrowserView : public BrowserWindow,
scoped_refptr<JumpList> jumplist_;
#endif
-#if defined(USE_ASH)
- // Needs to be BrowserLauncerItemController for
- // "BrowserActivationStateChanged" and "favicon_loader".
- // TODO(skuhne): Remove once per-app is default.
- scoped_ptr<BrowserLauncherItemController> launcher_item_controller_;
-#endif
-
// The timer used to update frames for the Loading Animation.
base::RepeatingTimer<BrowserView> loading_animation_timer_;
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index ff550f5..f2d4270 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -223,10 +223,10 @@
'browser/ui/ash/ime_controller_chromeos.h',
'browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc',
'browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h',
- 'browser/ui/ash/launcher/browser_launcher_item_controller.cc',
- 'browser/ui/ash/launcher/browser_launcher_item_controller.h',
'browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc',
'browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.h',
+ 'browser/ui/ash/launcher/browser_status_monitor.cc',
+ 'browser/ui/ash/launcher/browser_status_monitor.h',
'browser/ui/ash/launcher/chrome_launcher_app_menu_item.cc',
'browser/ui/ash/launcher/chrome_launcher_app_menu_item.h',
'browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.cc',