OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" |
6 | 6 |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/managed_mode.h" | 8 #include "chrome/browser/managed_mode.h" |
9 #include "chrome/browser/profiles/avatar_menu_model.h" | 9 #include "chrome/browser/profiles/avatar_menu_model.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/profiles/profile_info_cache.h" | 11 #include "chrome/browser/profiles/profile_info_cache.h" |
12 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
| 13 #include "chrome/browser/themes/theme_service.h" |
| 14 #include "chrome/browser/ui/search/search.h" |
13 #include "chrome/browser/ui/views/avatar_menu_button.h" | 15 #include "chrome/browser/ui/views/avatar_menu_button.h" |
14 #include "chrome/browser/ui/views/frame/browser_view.h" | 16 #include "chrome/browser/ui/views/frame/browser_view.h" |
15 #include "grit/theme_resources.h" | 17 #include "grit/theme_resources.h" |
16 #include "grit/theme_resources_standard.h" | 18 #include "grit/theme_resources_standard.h" |
17 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
18 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
19 | 21 |
20 BrowserNonClientFrameView::BrowserNonClientFrameView(BrowserFrame* frame, | 22 BrowserNonClientFrameView::BrowserNonClientFrameView(BrowserFrame* frame, |
21 BrowserView* browser_view) | 23 BrowserView* browser_view) |
22 : frame_(frame), | 24 : frame_(frame), |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // For popups and panels which don't have the avatar button, we still | 79 // For popups and panels which don't have the avatar button, we still |
78 // need to draw the taskbar decoration. | 80 // need to draw the taskbar decoration. |
79 if (AvatarMenuModel::ShouldShowAvatarMenu() || | 81 if (AvatarMenuModel::ShouldShowAvatarMenu() || |
80 ManagedMode::IsInManagedMode()) { | 82 ManagedMode::IsInManagedMode()) { |
81 DrawTaskBarDecoration(frame_->GetNativeWindow(), &avatar); | 83 DrawTaskBarDecoration(frame_->GetNativeWindow(), &avatar); |
82 } else { | 84 } else { |
83 DrawTaskBarDecoration(frame_->GetNativeWindow(), NULL); | 85 DrawTaskBarDecoration(frame_->GetNativeWindow(), NULL); |
84 } | 86 } |
85 } | 87 } |
86 | 88 |
| 89 SkColor BrowserNonClientFrameView::GetToolbarBackgroundColor( |
| 90 chrome::search::Mode::Type mode) { |
| 91 ui::ThemeProvider* theme_provider = GetThemeProvider(); |
| 92 DCHECK(theme_provider); |
| 93 |
| 94 Browser* browser = browser_view_->browser(); |
| 95 if (!chrome::search::IsInstantExtendedAPIEnabled(browser->profile())) |
| 96 return theme_provider->GetColor(ThemeService::COLOR_TOOLBAR); |
| 97 |
| 98 switch (mode) { |
| 99 case chrome::search::Mode::MODE_NTP: |
| 100 return theme_provider->GetColor( |
| 101 ThemeService::COLOR_SEARCH_NTP_BACKGROUND); |
| 102 |
| 103 case chrome::search::Mode::MODE_SEARCH: |
| 104 return theme_provider->GetColor( |
| 105 ThemeService::COLOR_SEARCH_SEARCH_BACKGROUND); |
| 106 |
| 107 case chrome::search::Mode::MODE_DEFAULT: |
| 108 default: |
| 109 return theme_provider->GetColor( |
| 110 ThemeService::COLOR_SEARCH_DEFAULT_BACKGROUND); |
| 111 } |
| 112 } |
| 113 |
| 114 gfx::ImageSkia* BrowserNonClientFrameView::GetToolbarBackgroundImage( |
| 115 chrome::search::Mode::Type mode) { |
| 116 ui::ThemeProvider* theme_provider = GetThemeProvider(); |
| 117 DCHECK(theme_provider); |
| 118 Browser* browser = browser_view_->browser(); |
| 119 if (!chrome::search::IsInstantExtendedAPIEnabled(browser->profile())) |
| 120 return theme_provider->GetImageSkiaNamed(IDR_THEME_TOOLBAR); |
| 121 |
| 122 switch (mode) { |
| 123 case chrome::search::Mode::MODE_NTP: |
| 124 return theme_provider->GetImageSkiaNamed(IDR_THEME_NTP_BACKGROUND); |
| 125 |
| 126 case chrome::search::Mode::MODE_SEARCH: |
| 127 case chrome::search::Mode::MODE_DEFAULT: |
| 128 default: |
| 129 return theme_provider->GetImageSkiaNamed(IDR_THEME_TOOLBAR_SEARCH); |
| 130 } |
| 131 } |
| 132 |
87 void BrowserNonClientFrameView::VisibilityChanged(views::View* starting_from, | 133 void BrowserNonClientFrameView::VisibilityChanged(views::View* starting_from, |
88 bool is_visible) { | 134 bool is_visible) { |
89 if (!is_visible) | 135 if (!is_visible) |
90 return; | 136 return; |
91 // The first time UpdateAvatarInfo() is called the window is not visible so | 137 // The first time UpdateAvatarInfo() is called the window is not visible so |
92 // DrawTaskBarDecoration() has no effect. Therefore we need to call it again | 138 // DrawTaskBarDecoration() has no effect. Therefore we need to call it again |
93 // once the window is visible. | 139 // once the window is visible. |
94 UpdateAvatarInfo(); | 140 UpdateAvatarInfo(); |
95 } | 141 } |
OLD | NEW |