summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-14 04:14:57 +0000
committerzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-14 04:14:57 +0000
commitb5828c7bcdb69c690c7158bc4e5b6de2bc212462 (patch)
treec58fafd7c1abb70bc8390dd59bde563f3de4032f /ash
parentbba581bfe9545788b157b44f4835cda0cadbe0f6 (diff)
downloadchromium_src-b5828c7bcdb69c690c7158bc4e5b6de2bc212462.zip
chromium_src-b5828c7bcdb69c690c7158bc4e5b6de2bc212462.tar.gz
chromium_src-b5828c7bcdb69c690c7158bc4e5b6de2bc212462.tar.bz2
Reland 126256:
Show a different icon in the launcher for incognito windows TBR=sky@chromium.org BUG=116932 TEST=Open an incognito window and a normal window. Check that the icons are different Review URL: http://codereview.chromium.org/9691027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126557 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/launcher/launcher_model.cc12
-rw-r--r--ash/launcher/launcher_types.cc8
-rw-r--r--ash/launcher/launcher_types.h4
-rw-r--r--ash/launcher/launcher_unittest.cc6
-rw-r--r--ash/launcher/launcher_view.cc8
-rw-r--r--ash/launcher/tabbed_launcher_button.cc31
-rw-r--r--ash/launcher/tabbed_launcher_button.h23
-rw-r--r--ash/shell/shell_main.cc3
8 files changed, 71 insertions, 24 deletions
diff --git a/ash/launcher/launcher_model.cc b/ash/launcher/launcher_model.cc
index 33aa5bb..34de1d2 100644
--- a/ash/launcher/launcher_model.cc
+++ b/ash/launcher/launcher_model.cc
@@ -10,8 +10,16 @@
namespace ash {
LauncherModel::LauncherModel() : next_id_(1) {
- Add(0, LauncherItem(TYPE_APP_LIST));
- Add(1, LauncherItem(TYPE_BROWSER_SHORTCUT));
+ LauncherItem app_list;
+ app_list.type = TYPE_APP_LIST;
+ app_list.is_incognito = false;
+
+ LauncherItem browser_shortcut;
+ browser_shortcut.type = TYPE_BROWSER_SHORTCUT;
+ browser_shortcut.is_incognito = false;
+
+ Add(0, app_list);
+ Add(1, browser_shortcut);
}
LauncherModel::~LauncherModel() {
diff --git a/ash/launcher/launcher_types.cc b/ash/launcher/launcher_types.cc
index f70e616..24f58ce 100644
--- a/ash/launcher/launcher_types.cc
+++ b/ash/launcher/launcher_types.cc
@@ -11,13 +11,7 @@ const int kLauncherPreferredHeight = 48;
LauncherItem::LauncherItem()
: type(TYPE_TABBED),
num_tabs(1),
- id(0),
- status(STATUS_CLOSED) {
-}
-
-LauncherItem::LauncherItem(LauncherItemType type)
- : type(type),
- num_tabs(0),
+ is_incognito(false),
id(0),
status(STATUS_CLOSED) {
}
diff --git a/ash/launcher/launcher_types.h b/ash/launcher/launcher_types.h
index 8773505..3b73975 100644
--- a/ash/launcher/launcher_types.h
+++ b/ash/launcher/launcher_types.h
@@ -47,7 +47,6 @@ enum ASH_EXPORT LauncherItemStatus {
struct ASH_EXPORT LauncherItem {
LauncherItem();
- explicit LauncherItem(LauncherItemType type);
~LauncherItem();
LauncherItemType type;
@@ -55,6 +54,9 @@ struct ASH_EXPORT LauncherItem {
// Number of tabs. Only used if this is TYPE_TABBED.
int num_tabs;
+ // Whether it is incognito. Only used if this is TYPE_TABBED.
+ bool is_incognito;
+
// Image to display in the launcher. If this item is TYPE_TABBED the image is
// a favicon image.
SkBitmap image;
diff --git a/ash/launcher/launcher_unittest.cc b/ash/launcher/launcher_unittest.cc
index b0b1be6..86b2af5 100644
--- a/ash/launcher/launcher_unittest.cc
+++ b/ash/launcher/launcher_unittest.cc
@@ -48,7 +48,8 @@ TEST_F(LauncherTest, LaunchApp) {
int item_count = model->item_count();
// Add closed app.
- LauncherItem item(TYPE_APP);
+ LauncherItem item;
+ item.type = TYPE_APP;
model->Add(item_count, item);
ASSERT_EQ(++button_count, test.GetButtonCount());
LauncherButton* button = test.GetButton(button_count - 1);
@@ -86,7 +87,8 @@ TEST_F(LauncherTest, OpenBrowser) {
int item_count = model->item_count();
// Add running tab.
- LauncherItem item(TYPE_TABBED);
+ LauncherItem item;
+ item.type = TYPE_TABBED;
item.status = STATUS_RUNNING;
model->Add(item_count, item);
ASSERT_EQ(++button_count, test.GetButtonCount());
diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc
index 3a5e204..be26a98 100644
--- a/ash/launcher/launcher_view.cc
+++ b/ash/launcher/launcher_view.cc
@@ -328,7 +328,13 @@ views::View* LauncherView::CreateViewForItem(const LauncherItem& item) {
views::View* view = NULL;
switch (item.type) {
case TYPE_TABBED: {
- TabbedLauncherButton* button = TabbedLauncherButton::Create(this, this);
+ TabbedLauncherButton* button =
+ TabbedLauncherButton::Create(
+ this,
+ this,
+ item.is_incognito ?
+ TabbedLauncherButton::STATE_INCOGNITO :
+ TabbedLauncherButton::STATE_NOT_INCOGNITO);
button->SetTabImage(item.image);
button->set_context_menu_controller(this);
ReflectItemStatus(item, button);
diff --git a/ash/launcher/tabbed_launcher_button.cc b/ash/launcher/tabbed_launcher_button.cc
index e3f7286..17a11d1d 100644
--- a/ash/launcher/tabbed_launcher_button.cc
+++ b/ash/launcher/tabbed_launcher_button.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include "ash/launcher/launcher_button_host.h"
+#include "ash/launcher/launcher_types.h"
#include "grit/ui_resources.h"
#include "ui/base/accessibility/accessible_view_state.h"
#include "ui/base/animation/multi_animation.h"
@@ -18,7 +19,9 @@
namespace ash {
namespace internal {
-TabbedLauncherButton::IconView::IconView(TabbedLauncherButton* host)
+TabbedLauncherButton::IconView::IconView(
+ TabbedLauncherButton* host,
+ TabbedLauncherButton::IncognitoState is_incognito)
: host_(host),
show_image_(true) {
if (!browser_image_) {
@@ -26,11 +29,19 @@ TabbedLauncherButton::IconView::IconView(TabbedLauncherButton* host)
browser_image_ = new SkBitmap(
*rb.GetImageNamed(IDR_AURA_LAUNCHER_BROWSER).ToSkBitmap());
+ incognito_browser_image_ = new SkBitmap(
+ *rb.GetImageNamed(IDR_AURA_LAUNCHER_INCOGNITO_BROWSER).ToSkBitmap());
browser_panel_image_ = new SkBitmap(
*rb.GetImageNamed(IDR_AURA_LAUNCHER_BROWSER_PANEL).ToSkBitmap());
+ incognito_browser_panel_image_ = new SkBitmap(
+ *rb.GetImageNamed(
+ IDR_AURA_LAUNCHER_INCOGNITO_BROWSER_PANEL).ToSkBitmap());
}
set_icon_size(0);
- LauncherButton::IconView::SetImage(*browser_image_);
+ if (is_incognito == STATE_NOT_INCOGNITO)
+ LauncherButton::IconView::SetImage(*browser_image_);
+ else
+ LauncherButton::IconView::SetImage(*incognito_browser_image_);
}
TabbedLauncherButton::IconView::~IconView() {
@@ -92,19 +103,25 @@ void TabbedLauncherButton::IconView::OnPaint(gfx::Canvas* canvas) {
// static
SkBitmap* TabbedLauncherButton::IconView::browser_image_ = NULL;
+SkBitmap* TabbedLauncherButton::IconView::incognito_browser_image_ = NULL;
SkBitmap* TabbedLauncherButton::IconView::browser_panel_image_ = NULL;
+SkBitmap* TabbedLauncherButton::IconView::incognito_browser_panel_image_ = NULL;
TabbedLauncherButton* TabbedLauncherButton::Create(
views::ButtonListener* listener,
- LauncherButtonHost* host) {
- TabbedLauncherButton* button = new TabbedLauncherButton(listener, host);
+ LauncherButtonHost* host,
+ IncognitoState is_incognito) {
+ TabbedLauncherButton* button =
+ new TabbedLauncherButton(listener, host, is_incognito);
button->Init();
return button;
}
TabbedLauncherButton::TabbedLauncherButton(views::ButtonListener* listener,
- LauncherButtonHost* host)
- : LauncherButton(listener, host) {
+ LauncherButtonHost* host,
+ IncognitoState is_incognito)
+ : LauncherButton(listener, host),
+ is_incognito_(is_incognito) {
set_accessibility_focusable(true);
}
@@ -125,7 +142,7 @@ void TabbedLauncherButton::GetAccessibleState(ui::AccessibleViewState* state) {
}
LauncherButton::IconView* TabbedLauncherButton::CreateIconView() {
- return new IconView(this);
+ return new IconView(this, is_incognito_);
}
} // namespace internal
diff --git a/ash/launcher/tabbed_launcher_button.h b/ash/launcher/tabbed_launcher_button.h
index 625c1c6..066f539 100644
--- a/ash/launcher/tabbed_launcher_button.h
+++ b/ash/launcher/tabbed_launcher_button.h
@@ -18,13 +18,23 @@ 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);
+ LauncherButtonHost* host,
+ IncognitoState is_incognito);
virtual ~TabbedLauncherButton();
// Notification that the images are about to change. Kicks off an animation.
@@ -35,7 +45,8 @@ class TabbedLauncherButton : public LauncherButton {
protected:
TabbedLauncherButton(views::ButtonListener* listener,
- LauncherButtonHost* host);
+ LauncherButtonHost* host,
+ IncognitoState is_incognito);
// View override.
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
@@ -47,7 +58,7 @@ class TabbedLauncherButton : public LauncherButton {
class IconView : public LauncherButton::IconView,
public ui::AnimationDelegate {
public:
- explicit IconView(TabbedLauncherButton* host);
+ IconView(TabbedLauncherButton* host, IncognitoState is_incognito);
virtual ~IconView();
// ui::AnimationDelegateImpl overrides:
@@ -78,8 +89,10 @@ class TabbedLauncherButton : public LauncherButton {
// Background images. Which one is chosen depends on the type of the window.
static SkBitmap* browser_image_;
+ static SkBitmap* incognito_browser_image_;
// TODO[dave] implement panel specific image.
static SkBitmap* browser_panel_image_;
+ static SkBitmap* incognito_browser_panel_image_;
DISALLOW_COPY_AND_ASSIGN(IconView);
};
@@ -88,6 +101,10 @@ class TabbedLauncherButton : public LauncherButton {
return static_cast<IconView*>(icon_view());
}
+ // Indicates if the tabbed browser associated with this is an incognito
+ // window.
+ const IncognitoState is_incognito_;
+
DISALLOW_COPY_AND_ASSIGN(TabbedLauncherButton);
};
diff --git a/ash/shell/shell_main.cc b/ash/shell/shell_main.cc
index 339010b..b56cfe0 100644
--- a/ash/shell/shell_main.cc
+++ b/ash/shell/shell_main.cc
@@ -76,7 +76,8 @@ class WindowWatcher : public aura::WindowObserver {
virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE {
static int image_count = 0;
ash::LauncherModel* model = ash::Shell::GetInstance()->launcher()->model();
- ash::LauncherItem item(ash::TYPE_TABBED);
+ ash::LauncherItem item;
+ item.type = ash::TYPE_TABBED;
id_to_window_[model->next_id()] = new_window;
item.num_tabs = image_count + 1;
item.image.setConfig(SkBitmap::kARGB_8888_Config, 16, 16);