diff options
author | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-12 22:56:38 +0000 |
---|---|---|
committer | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-12 22:56:38 +0000 |
commit | 33c20bb809a26b1b20b4b1bd748d033b4b2c1ddf (patch) | |
tree | 2c71ea9291fbe3c2317b46dab7397dbb08f6e5c2 | |
parent | 0817545fa66d1ad0233966ce73c7bd4399eb57ae (diff) | |
download | chromium_src-33c20bb809a26b1b20b4b1bd748d033b4b2c1ddf.zip chromium_src-33c20bb809a26b1b20b4b1bd748d033b4b2c1ddf.tar.gz chromium_src-33c20bb809a26b1b20b4b1bd748d033b4b2c1ddf.tar.bz2 |
Show a different icon in the launcher for incognito windows
BUG=116932
TEST=Open an incognito window and a normal window. Check that the icons are different
Review URL: https://chromiumcodereview.appspot.com/9649013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126256 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/launcher/launcher_model.cc | 12 | ||||
-rw-r--r-- | ash/launcher/launcher_types.cc | 8 | ||||
-rw-r--r-- | ash/launcher/launcher_types.h | 4 | ||||
-rw-r--r-- | ash/launcher/launcher_unittest.cc | 6 | ||||
-rw-r--r-- | ash/launcher/launcher_view.cc | 8 | ||||
-rw-r--r-- | ash/launcher/tabbed_launcher_button.cc | 31 | ||||
-rw-r--r-- | ash/launcher/tabbed_launcher_button.h | 23 | ||||
-rw-r--r-- | chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc | 15 | ||||
-rw-r--r-- | chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h | 9 | ||||
-rw-r--r-- | chrome/browser/ui/views/ash/launcher/launcher_updater.cc | 11 | ||||
-rw-r--r-- | chrome/browser/ui/views/ash/launcher/launcher_updater.h | 3 | ||||
-rw-r--r-- | ui/resources/aura/launcher_incognito_browser.png | bin | 0 -> 1657 bytes | |||
-rw-r--r-- | ui/resources/aura/launcher_incognito_browser_panel.png | bin | 0 -> 1695 bytes | |||
-rw-r--r-- | ui/resources/ui_resources.grd | 2 |
14 files changed, 102 insertions, 30 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 07e306e..01f143e 100644 --- a/ash/launcher/launcher_types.cc +++ b/ash/launcher/launcher_types.cc @@ -9,13 +9,7 @@ namespace ash { 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 1bc0f78..403f802 100644 --- a/ash/launcher/launcher_types.h +++ b/ash/launcher/launcher_types.h @@ -43,7 +43,6 @@ enum ASH_EXPORT LauncherItemStatus { struct ASH_EXPORT LauncherItem { LauncherItem(); - explicit LauncherItem(LauncherItemType type); ~LauncherItem(); LauncherItemType type; @@ -51,6 +50,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 303f1ef..63f8a2a 100644 --- a/ash/launcher/launcher_view.cc +++ b/ash/launcher/launcher_view.cc @@ -332,7 +332,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..544ceb2 100644 --- a/ash/launcher/tabbed_launcher_button.h +++ b/ash/launcher/tabbed_launcher_button.h @@ -18,13 +18,23 @@ class MultiAnimation; } namespace ash { + +class 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/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc b/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc index 134a37e..7b2b99b 100644 --- a/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc +++ b/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc @@ -122,7 +122,8 @@ void ChromeLauncherDelegate::RegisterUserPrefs(PrefService* user_prefs) { } ash::LauncherID ChromeLauncherDelegate::CreateTabbedLauncherItem( - LauncherUpdater* updater) { + LauncherUpdater* updater, + IncognitoState is_incognito) { // Tabbed items always get a new item. Put the tabbed item before the app // tabs. If there are no app tabs put it at the end. int index = static_cast<int>(model_->items().size()); @@ -134,7 +135,9 @@ ash::LauncherID ChromeLauncherDelegate::CreateTabbedLauncherItem( } } ash::LauncherID id = model_->next_id(); - ash::LauncherItem item(ash::TYPE_TABBED); + ash::LauncherItem item; + item.type = ash::TYPE_TABBED; + item.is_incognito = (is_incognito == STATE_INCOGNITO); item.status = ash::STATUS_RUNNING; model_->Add(index, item); DCHECK(id_to_item_map_.find(id) == id_to_item_map_.end()); @@ -183,7 +186,9 @@ ash::LauncherID ChromeLauncherDelegate::CreateAppLauncherItem( int insert_index = min_app_index != item_count ? min_app_index : std::min(item_count, min_tab_index + 1); ash::LauncherID id = model_->next_id(); - ash::LauncherItem item(ash::TYPE_APP); + ash::LauncherItem item; + item.type = ash::TYPE_APP; + item.is_incognito = false; item.image = Extension::GetDefaultIcon(true); item.status = status; model_->Add(insert_index, item); @@ -225,7 +230,9 @@ void ChromeLauncherDelegate::ConvertTabbedToApp(ash::LauncherID id, id_to_item_map_[id].app_type = app_type; id_to_item_map_[id].app_id = app_id; - ash::LauncherItem item(ash::TYPE_APP); + ash::LauncherItem item; + item.type = ash::TYPE_APP; + item.is_incognito = false; item.id = id; model_->Set(model_->ItemIndexByID(id), item); diff --git a/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h b/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h index 7784e45..68d392e 100644 --- a/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h +++ b/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h @@ -43,6 +43,12 @@ class ChromeLauncherDelegate : public ash::LauncherDelegate, APP_TYPE_TAB }; + // Indicates if a launcher item is incognito or not. + enum IncognitoState { + STATE_INCOGNITO, + STATE_NOT_INCOGNITO, + }; + // Interface used to load app icons. This is in it's own class so that it can // be mocked. class AppIconLoader { @@ -75,7 +81,8 @@ class ChromeLauncherDelegate : public ash::LauncherDelegate, static void RegisterUserPrefs(PrefService* user_prefs); // Creates a new tabbed item on the launcher for |updater|. - ash::LauncherID CreateTabbedLauncherItem(LauncherUpdater* updater); + ash::LauncherID CreateTabbedLauncherItem(LauncherUpdater* updater, + IncognitoState is_incognito); // Creates a new app item on the launcher for |updater|. If there is an // existing pinned app that isn't running on the launcher, its id is returned. diff --git a/chrome/browser/ui/views/ash/launcher/launcher_updater.cc b/chrome/browser/ui/views/ash/launcher/launcher_updater.cc index 8f3c604..23ccd38 100644 --- a/chrome/browser/ui/views/ash/launcher/launcher_updater.cc +++ b/chrome/browser/ui/views/ash/launcher/launcher_updater.cc @@ -38,6 +38,8 @@ LauncherUpdater::LauncherUpdater(aura::Window* window, launcher_delegate_(delegate), type_(type), app_id_(app_id), + is_incognito_(tab_model->profile()->GetOriginalProfile() != + tab_model->profile()), item_id_(-1) { } @@ -272,7 +274,9 @@ void LauncherUpdater::UpdateAppTabState(TabContentsWrapper* tab, launcher_delegate_->LauncherItemClosed(launcher_id); CreateTabbedItem(); } - ash::LauncherItem item(ash::TYPE_TABBED); + ash::LauncherItem item; + item.type = ash::TYPE_TABBED; + item.is_incognito = is_incognito_; item.num_tabs = tab_model_->count(); launcher_model()->Set(launcher_model()->ItemIndexByID(item_id_), item); } else { @@ -325,7 +329,10 @@ void LauncherUpdater::RegisterAppItem(ash::LauncherID id, void LauncherUpdater::CreateTabbedItem() { DCHECK_EQ(-1, item_id_); - item_id_ = launcher_delegate_->CreateTabbedLauncherItem(this); + item_id_ = launcher_delegate_->CreateTabbedLauncherItem( + this, + is_incognito_ ? ChromeLauncherDelegate::STATE_INCOGNITO : + ChromeLauncherDelegate::STATE_NOT_INCOGNITO); } bool LauncherUpdater::ContainsID(ash::LauncherID id, TabContentsWrapper** tab) { diff --git a/chrome/browser/ui/views/ash/launcher/launcher_updater.h b/chrome/browser/ui/views/ash/launcher/launcher_updater.h index 2e0d4c2..fdb7efe 100644 --- a/chrome/browser/ui/views/ash/launcher/launcher_updater.h +++ b/chrome/browser/ui/views/ash/launcher/launcher_updater.h @@ -134,6 +134,9 @@ class LauncherUpdater : public TabStripModelObserver { const std::string app_id_; + // Whether the is associated with an incognito profile. + const bool is_incognito_; + // This is one of three possible values: // . If type_ == TYPE_APP, this is the ID of the app item. // . If type_ == TYPE_TABBED and all the tabs are app tabs this is -1. diff --git a/ui/resources/aura/launcher_incognito_browser.png b/ui/resources/aura/launcher_incognito_browser.png Binary files differnew file mode 100644 index 0000000..f2632e7 --- /dev/null +++ b/ui/resources/aura/launcher_incognito_browser.png diff --git a/ui/resources/aura/launcher_incognito_browser_panel.png b/ui/resources/aura/launcher_incognito_browser_panel.png Binary files differnew file mode 100644 index 0000000..ef64d0f --- /dev/null +++ b/ui/resources/aura/launcher_incognito_browser_panel.png diff --git a/ui/resources/ui_resources.grd b/ui/resources/ui_resources.grd index c7e9572..979bd97 100644 --- a/ui/resources/ui_resources.grd +++ b/ui/resources/ui_resources.grd @@ -140,6 +140,8 @@ <include name="IDR_AURA_LAUNCHER_ICON_APPLIST" file="aura/launcher_applist.png" type="BINDATA" /> <include name="IDR_AURA_LAUNCHER_ICON_APPLIST_HOT" file="aura/launcher_applist_h.png" type="BINDATA" /> <include name="IDR_AURA_LAUNCHER_ICON_APPLIST_PUSHED" file="aura/launcher_applist_p.png" type="BINDATA" /> + <include name="IDR_AURA_LAUNCHER_INCOGNITO_BROWSER" file="aura/launcher_incognito_browser.png" type="BINDATA" /> + <include name="IDR_AURA_LAUNCHER_INCOGNITO_BROWSER_PANEL" file="aura/launcher_incognito_browser_panel.png" type="BINDATA" /> <include name="IDR_AURA_LAUNCHER_NEW_BROWSER" file="aura/new_browser.png" type="BINDATA" /> <include name="IDR_AURA_LAUNCHER_NEW_BROWSER_HOT" file="aura/new_browser_h.png" type="BINDATA" /> <include name="IDR_AURA_LAUNCHER_NEW_BROWSER_PUSHED" file="aura/new_browser_p.png" type="BINDATA" /> |