Commit 05d72ceb authored by estade's avatar estade Committed by Commit bot

Vectorize MD otr frame icon

BUG=501377

Review URL: https://codereview.chromium.org/1452923002

Cr-Commit-Position: refs/heads/master@{#360499}
parent de465d94
...@@ -542,9 +542,7 @@ ...@@ -542,9 +542,7 @@
<structure type="chrome_scaled_image" name="IDR_OMNIBOX_TTS" file="common/omnibox_tts.png" /> <structure type="chrome_scaled_image" name="IDR_OMNIBOX_TTS" file="common/omnibox_tts.png" />
<structure type="chrome_scaled_image" name="IDR_OMNIBOX_TTS_SELECTED" file="common/omnibox_tts_selected.png" /> <structure type="chrome_scaled_image" name="IDR_OMNIBOX_TTS_SELECTED" file="common/omnibox_tts_selected.png" />
<if expr="toolkit_views and not is_macosx"> <if expr="toolkit_views and not is_macosx">
<!-- In Material Design the Ash image is the same as the common one, so <!-- This image is not used in Material Design and can be removed when that mode is default. -->
once that mode is always on, these should be collapsed and the
duplicate image removed from the tree. -->
<if expr="not use_ash"> <if expr="not use_ash">
<structure type="chrome_scaled_image" name="IDR_OTR_ICON" file="common/otr_icon.png" /> <structure type="chrome_scaled_image" name="IDR_OTR_ICON" file="common/otr_icon.png" />
</if> </if>
......
...@@ -208,8 +208,7 @@ void BrowserNonClientFrameView::UpdateOldAvatarButton() { ...@@ -208,8 +208,7 @@ void BrowserNonClientFrameView::UpdateOldAvatarButton() {
AddChildView(supervised_user_avatar_label_); AddChildView(supervised_user_avatar_label_);
} }
#endif #endif
avatar_button_ = new AvatarMenuButton( avatar_button_ = new AvatarMenuButton(browser_view_);
browser_view_->browser(), !browser_view_->IsRegularOrGuestSession());
avatar_button_->set_id(VIEW_ID_AVATAR_BUTTON); avatar_button_->set_id(VIEW_ID_AVATAR_BUTTON);
AddChildView(avatar_button_); AddChildView(avatar_button_);
// Invalidate here because adding a child does not invalidate the layout. // Invalidate here because adding a child does not invalidate the layout.
...@@ -239,9 +238,9 @@ void BrowserNonClientFrameView::UpdateOldAvatarButton() { ...@@ -239,9 +238,9 @@ void BrowserNonClientFrameView::UpdateOldAvatarButton() {
bool should_show_avatar_menu = bool should_show_avatar_menu =
avatar_button_ || AvatarMenu::ShouldShowAvatarMenu(); avatar_button_ || AvatarMenu::ShouldShowAvatarMenu();
if (!AvatarMenuButton::GetAvatarImages( if (!AvatarMenuButton::GetAvatarImages(browser_view_, should_show_avatar_menu,
browser_view_->browser()->profile(), should_show_avatar_menu, &avatar, &avatar, &taskbar_badge_avatar,
&taskbar_badge_avatar, &is_rectangle)) { &is_rectangle)) {
return; return;
} }
...@@ -307,10 +306,9 @@ void BrowserNonClientFrameView::UpdateTaskbarDecoration() { ...@@ -307,10 +306,9 @@ void BrowserNonClientFrameView::UpdateTaskbarDecoration() {
// returns false, don't bother trying to update the taskbar decoration since // returns false, don't bother trying to update the taskbar decoration since
// the returned images are not initialized. This can happen if the user // the returned images are not initialized. This can happen if the user
// deletes the current profile. // deletes the current profile.
if (AvatarMenuButton::GetAvatarImages(browser_view_->browser()->profile(), if (AvatarMenuButton::GetAvatarImages(
AvatarMenu::ShouldShowAvatarMenu(), browser_view_, AvatarMenu::ShouldShowAvatarMenu(), &avatar,
&avatar, &taskbar_badge_avatar, &taskbar_badge_avatar, &is_rectangle)) {
&is_rectangle)) {
// For popups and panels which don't have the avatar button, we still // For popups and panels which don't have the avatar button, we still
// need to draw the taskbar decoration. Even though we have an icon on the // need to draw the taskbar decoration. Even though we have an icon on the
// window's relaunch details, we draw over it because the user may have // window's relaunch details, we draw over it because the user may have
......
...@@ -133,8 +133,10 @@ ...@@ -133,8 +133,10 @@
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/color_utils.h" #include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/rect_conversions.h" #include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/scoped_canvas.h" #include "ui/gfx/scoped_canvas.h"
#include "ui/gfx/screen.h" #include "ui/gfx/screen.h"
#include "ui/gfx/vector_icons_public.h"
#include "ui/strings/grit/ui_strings.h" #include "ui/strings/grit/ui_strings.h"
#include "ui/views/controls/button/menu_button.h" #include "ui/views/controls/button/menu_button.h"
#include "ui/views/controls/textfield/textfield.h" #include "ui/views/controls/textfield/textfield.h"
...@@ -156,6 +158,7 @@ ...@@ -156,6 +158,7 @@
#if defined(OS_WIN) #if defined(OS_WIN)
#include "base/win/windows_version.h" #include "base/win/windows_version.h"
#include "chrome/browser/jumplist_win.h" #include "chrome/browser/jumplist_win.h"
#include "ui/gfx/color_palette.h"
#include "ui/views/win/scoped_fullscreen_visibility.h" #include "ui/views/win/scoped_fullscreen_visibility.h"
#endif #endif
...@@ -681,7 +684,19 @@ WebContents* BrowserView::GetActiveWebContents() const { ...@@ -681,7 +684,19 @@ WebContents* BrowserView::GetActiveWebContents() const {
} }
gfx::ImageSkia BrowserView::GetOTRAvatarIcon() const { gfx::ImageSkia BrowserView::GetOTRAvatarIcon() const {
return *GetThemeProvider()->GetImageSkiaNamed(IDR_OTR_ICON); if (ui::MaterialDesignController::IsModeMaterial()) {
SkColor icon_color = SK_ColorWHITE;
#if defined(OS_WIN)
// On Windows 10, we can't change the frame color so must assume it's white.
if (base::win::GetVersion() == base::win::VERSION_WIN10)
icon_color = gfx::kChromeIconGrey;
#endif
return gfx::CreateVectorIcon(gfx::VectorIconId::INCOGNITO, 24, icon_color);
}
// GetThemeProvider() can return null if this view is not yet part of the
// widget hierarchy, but the frame's theme provider is always valid.
return *frame_->GetThemeProvider()->GetImageSkiaNamed(IDR_OTR_ICON);
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
......
...@@ -33,10 +33,10 @@ static inline int Round(double x) { ...@@ -33,10 +33,10 @@ static inline int Round(double x) {
// static // static
const char AvatarMenuButton::kViewClassName[] = "AvatarMenuButton"; const char AvatarMenuButton::kViewClassName[] = "AvatarMenuButton";
AvatarMenuButton::AvatarMenuButton(Browser* browser, bool disabled) AvatarMenuButton::AvatarMenuButton(BrowserView* browser_view)
: MenuButton(NULL, base::string16(), this, false), : MenuButton(NULL, base::string16(), this, false),
browser_(browser), browser_view_(browser_view),
disabled_(disabled), enabled_(browser_view_->IsRegularOrGuestSession()),
is_rectangle_(false), is_rectangle_(false),
old_height_(0), old_height_(0),
button_on_right_(false) { button_on_right_(false) {
...@@ -94,17 +94,17 @@ void AvatarMenuButton::SetAvatarIcon(const gfx::Image& icon, ...@@ -94,17 +94,17 @@ void AvatarMenuButton::SetAvatarIcon(const gfx::Image& icon,
} }
// static // static
bool AvatarMenuButton::GetAvatarImages(Profile* profile, bool AvatarMenuButton::GetAvatarImages(BrowserView* browser_view,
bool should_show_avatar_menu, bool should_show_avatar_menu,
gfx::Image* avatar, gfx::Image* avatar,
gfx::Image* taskbar_badge_avatar, gfx::Image* taskbar_badge_avatar,
bool* is_rectangle) { bool* is_rectangle) {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); const Profile* profile = browser_view->browser()->profile();
if (profile->GetProfileType() == Profile::GUEST_PROFILE) { if (profile->GetProfileType() == Profile::GUEST_PROFILE) {
*avatar = rb. *avatar = ui::ResourceBundle::GetSharedInstance().GetImageNamed(
GetImageNamed(profiles::GetPlaceholderAvatarIconResourceID()); profiles::GetPlaceholderAvatarIconResourceID());
} else if (profile->GetProfileType() == Profile::INCOGNITO_PROFILE) { } else if (profile->GetProfileType() == Profile::INCOGNITO_PROFILE) {
*avatar = rb.GetImageNamed(IDR_OTR_ICON); *avatar = gfx::Image(browser_view->GetOTRAvatarIcon());
// TODO(nkostylev): Allow this on ChromeOS once the ChromeOS test // TODO(nkostylev): Allow this on ChromeOS once the ChromeOS test
// environment handles profile directories correctly. // environment handles profile directories correctly.
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
...@@ -143,13 +143,13 @@ bool AvatarMenuButton::GetAvatarImages(Profile* profile, ...@@ -143,13 +143,13 @@ bool AvatarMenuButton::GetAvatarImages(Profile* profile,
bool AvatarMenuButton::DoesIntersectRect(const views::View* target, bool AvatarMenuButton::DoesIntersectRect(const views::View* target,
const gfx::Rect& rect) const { const gfx::Rect& rect) const {
CHECK_EQ(target, this); CHECK_EQ(target, this);
return !disabled_ && return enabled_ &&
views::ViewTargeterDelegate::DoesIntersectRect(target, rect); views::ViewTargeterDelegate::DoesIntersectRect(target, rect);
} }
// views::MenuButtonListener implementation // views::MenuButtonListener implementation
void AvatarMenuButton::OnMenuButtonClicked(views::View* source, void AvatarMenuButton::OnMenuButtonClicked(views::View* source,
const gfx::Point& point) { const gfx::Point& point) {
if (!disabled_) if (enabled_)
chrome::ShowAvatarMenu(browser_); chrome::ShowAvatarMenu(browser_view_->browser());
} }
...@@ -17,7 +17,7 @@ namespace gfx { ...@@ -17,7 +17,7 @@ namespace gfx {
class Canvas; class Canvas;
class Image; class Image;
} }
class Browser; class BrowserView;
class Profile; class Profile;
// AvatarMenuButton // AvatarMenuButton
...@@ -32,9 +32,8 @@ class AvatarMenuButton : public views::MenuButton, ...@@ -32,9 +32,8 @@ class AvatarMenuButton : public views::MenuButton,
// Internal class name. // Internal class name.
static const char kViewClassName[]; static const char kViewClassName[];
// Creates a new button. Unless |disabled| is true, clicking on the button // Creates a new button for the given browser view.
// will cause the profile menu to be displayed. explicit AvatarMenuButton(BrowserView* browser_view);
AvatarMenuButton(Browser* browser, bool disabled);
~AvatarMenuButton() override; ~AvatarMenuButton() override;
...@@ -51,12 +50,12 @@ class AvatarMenuButton : public views::MenuButton, ...@@ -51,12 +50,12 @@ class AvatarMenuButton : public views::MenuButton,
} }
bool button_on_right() { return button_on_right_; } bool button_on_right() { return button_on_right_; }
// Get avatar images for the profile. |avatar| is used in the browser window // Get avatar images for the BrowserView. |avatar| is used in the browser
// whereas |taskbar_badge_avatar| is used for the OS taskbar. If // window whereas |taskbar_badge_avatar| is used for the OS taskbar. If
// |taskbar_badge_avatar| is empty then |avatar| should be used for the // |taskbar_badge_avatar| is empty then |avatar| should be used for the
// taskbar as well. Returns false if the cache doesn't have an entry for a // taskbar as well. Returns false if the cache doesn't have an entry for a
// Profile::REGULAR_PROFILE type |profile|, otherwise return true. // Profile::REGULAR_PROFILE type Profile, otherwise return true.
static bool GetAvatarImages(Profile* profile, static bool GetAvatarImages(BrowserView* browser_view,
bool should_show_avatar_menu, bool should_show_avatar_menu,
gfx::Image* avatar, gfx::Image* avatar,
gfx::Image* taskbar_badge_avatar, gfx::Image* taskbar_badge_avatar,
...@@ -71,8 +70,8 @@ class AvatarMenuButton : public views::MenuButton, ...@@ -71,8 +70,8 @@ class AvatarMenuButton : public views::MenuButton,
void OnMenuButtonClicked(views::View* source, void OnMenuButtonClicked(views::View* source,
const gfx::Point& point) override; const gfx::Point& point) override;
Browser* browser_; BrowserView* browser_view_;
bool disabled_; bool enabled_;
scoped_ptr<ui::MenuModel> menu_model_; scoped_ptr<ui::MenuModel> menu_model_;
// Use a scoped ptr because gfx::Image doesn't have a default constructor. // Use a scoped ptr because gfx::Image doesn't have a default constructor.
......
...@@ -467,6 +467,8 @@ action("aggregate_vector_icons") { ...@@ -467,6 +467,8 @@ action("aggregate_vector_icons") {
"vector_icons/globe.icon", "vector_icons/globe.icon",
"vector_icons/help_outline.icon", "vector_icons/help_outline.icon",
"vector_icons/image.icon", "vector_icons/image.icon",
"vector_icons/incognito.1x.icon",
"vector_icons/incognito.icon",
"vector_icons/keyword_search.1x.icon", "vector_icons/keyword_search.1x.icon",
"vector_icons/keyword_search.icon", "vector_icons/keyword_search.icon",
"vector_icons/laptop.icon", "vector_icons/laptop.icon",
......
// Copyright 2015 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.
CANVAS_DIMENSIONS, 24,
MOVE_TO, 11, 18,
R_CUBIC_TO, 0, 1.66f, -1.34f, 3, -3, 3,
R_CUBIC_TO, -1.66f, 0, -3, -1.34f, -3, -3,
R_CUBIC_TO, 0, -1.66f, 1.34f, -3, 3, -3,
R_CUBIC_TO, 1.66f, 0, 3, 1.34f, 3, 3,
CLOSE,
R_MOVE_TO, -3, 2,
R_CUBIC_TO, 1.11f, 0, 2, -0.89f, 2, -2,
R_CUBIC_TO, 0, -1.11f, -0.89f, -2, -2, -2,
R_CUBIC_TO, -1.11f, 0, -2, 0.9f, -2, 2,
R_CUBIC_TO, 0, 1.1f, 0.9f, 2, 2, 2,
CLOSE,
MOVE_TO, 19, 18,
R_CUBIC_TO, 0, 1.66f, -1.34f, 3, -3, 3,
R_CUBIC_TO, -1.66f, 0, -3, -1.34f, -3, -3,
R_CUBIC_TO, 0, -1.66f, 1.34f, -3, 3, -3,
R_CUBIC_TO, 1.66f, 0, 3, 1.34f, 3, 3,
CLOSE,
R_MOVE_TO, -3, -2,
R_CUBIC_TO, -1.1f, 0, -2, 0.89f, -2, 2,
R_CUBIC_TO, 0, 1.11f, 0.89f, 2, 2, 2,
R_CUBIC_TO, 1.11f, 0, 2, -0.89f, 2, -2,
R_CUBIC_TO, 0, -1.1f, -0.89f, -2, -2, -2,
CLOSE,
MOVE_TO, 12, 18,
R_CUBIC_TO, 0.93f, 0, 1.71f, 0.64f, 1.93f, 1.5f,
R_CUBIC_TO, 0.04f, -0.16f, 0.07f, -0.33f, 0.07f, -0.5f,
R_CUBIC_TO, 0, -1.1f, -0.9f, -2, -2, -2,
R_CUBIC_TO, -1.1f, 0, -2, 0.9f, -2, 2,
R_CUBIC_TO, 0, 0.17f, 0.03f, 0.34f, 0.07f, 0.5f,
R_CUBIC_TO, 0.22f, -0.86f, 1, -1.5f, 1.93f, -1.5f,
MOVE_TO, 16.39f, 9,
LINE_TO, 15, 5,
R_LINE_TO, -3, 1,
R_LINE_TO, -3, -1,
R_LINE_TO, -1.3f, 4,
R_H_LINE_TO, 8.7f,
CLOSE,
R_MOVE_TO, -9.46f, 2,
LINE_TO, 3, 13,
R_H_LINE_TO, 18,
R_LINE_TO, -3.8f, -2,
H_LINE_TO, 6.93f,
CLOSE,
END
// Copyright 2015 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.
MOVE_TO, 22.15f, 33.23f,
R_CUBIC_TO, 0, 3.06f, -2.48f, 5.54f, -5.54f, 5.54f,
R_CUBIC_TO, -3.06f, 0, -5.54f, -2.48f, -5.54f, -5.54f,
R_CUBIC_TO, 0, -3.06f, 2.48f, -5.54f, 5.54f, -5.54f,
R_CUBIC_TO, 3.06f, 0, 5.54f, 2.48f, 5.54f, 5.54f,
CLOSE,
R_MOVE_TO, -5.54f, 3.69f,
R_CUBIC_TO, 2.04f, 0, 3.69f, -1.65f, 3.69f, -3.69f,
R_CUBIC_TO, 0, -2.04f, -1.65f, -3.69f, -3.69f, -3.69f,
R_CUBIC_TO, -2.04f, 0, -3.69f, 1.65f, -3.69f, 3.69f,
R_CUBIC_TO, 0, 2.04f, 1.65f, 3.69f, 3.69f, 3.69f,
CLOSE,
MOVE_TO, 36.92f, 33.23f,
R_CUBIC_TO, 0, 3.06f, -2.48f, 5.54f, -5.54f, 5.54f,
R_CUBIC_TO, -3.06f, 0, -5.54f, -2.48f, -5.54f, -5.54f,
R_CUBIC_TO, 0, -3.06f, 2.48f, -5.54f, 5.54f, -5.54f,
R_CUBIC_TO, 3.06f, 0, 5.54f, 2.48f, 5.54f, 5.54f,
CLOSE,
R_MOVE_TO, -5.54f, -3.69f,
R_CUBIC_TO, -2.04f, 0, -3.69f, 1.66f, -3.69f, 3.69f,
R_CUBIC_TO, 0, 2.04f, 1.66f, 3.69f, 3.69f, 3.69f,
R_CUBIC_TO, 2.04f, 0, 3.69f, -1.66f, 3.69f, -3.69f,
R_CUBIC_TO, 0, -2.04f, -1.66f, -3.69f, -3.69f, -3.69f,
CLOSE,
MOVE_TO, 24, 33.23f,
R_CUBIC_TO, 1.72f, 0, 3.15f, 1.18f, 3.56f, 2.77f,
R_CUBIC_TO, 0.08f, -0.3f, 0.13f, -0.6f, 0.13f, -0.92f,
R_CUBIC_TO, 0, -2.04f, -1.65f, -3.69f, -3.69f, -3.69f,
R_CUBIC_TO, -2.04f, 0, -3.69f, 1.65f, -3.69f, 3.69f,
R_CUBIC_TO, 0, 0.32f, 0.05f, 0.63f, 0.13f, 0.92f,
R_CUBIC_TO, 0.41f, -1.59f, 1.84f, -2.77f, 3.56f, -2.77f,
MOVE_TO, 33.29f, 20,
R_LINE_TO, 0.06f, 0.18f,
LINE_TO, 40.62f, 24,
H_LINE_TO, 7.39f,
R_LINE_TO, 7.51f, -3.82f,
R_LINE_TO, 0.06f, -0.18f,
R_H_LINE_TO, 18.34f,
CLOSE,
R_MOVE_TO, -1.39f, -4,
R_LINE_TO, -2.36f, -6.77f,
LINE_TO, 24, 11.08f,
LINE_TO, 18.46f, 9.23f,
LINE_TO, 16.26f, 16,
R_H_LINE_TO, 15.64f,
CLOSE,
END
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment