OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 view->GetLocalBounds()); | 226 view->GetLocalBounds()); |
227 } | 227 } |
228 | 228 |
229 // Paints the background (including the theme image behind content area) for | 229 // Paints the background (including the theme image behind content area) for |
230 // the Bookmarks Bar when it is attached to the Toolbar into |bounds|. | 230 // the Bookmarks Bar when it is attached to the Toolbar into |bounds|. |
231 // |background_origin| is the origin to use for painting the theme image. | 231 // |background_origin| is the origin to use for painting the theme image. |
232 void PaintBackgroundAttachedMode(gfx::Canvas* canvas, | 232 void PaintBackgroundAttachedMode(gfx::Canvas* canvas, |
233 ui::ThemeProvider* theme_provider, | 233 ui::ThemeProvider* theme_provider, |
234 const gfx::Rect& bounds, | 234 const gfx::Rect& bounds, |
235 const gfx::Point& background_origin, | 235 const gfx::Point& background_origin, |
236 chrome::HostDesktopType host_desktop_type) { | 236 ui::HostDesktopType host_desktop_type) { |
237 canvas->FillRect(bounds, | 237 canvas->FillRect(bounds, |
238 theme_provider->GetColor(ThemeProperties::COLOR_TOOLBAR)); | 238 theme_provider->GetColor(ThemeProperties::COLOR_TOOLBAR)); |
239 canvas->TileImageInt(*theme_provider->GetImageSkiaNamed(IDR_THEME_TOOLBAR), | 239 canvas->TileImageInt(*theme_provider->GetImageSkiaNamed(IDR_THEME_TOOLBAR), |
240 background_origin.x(), | 240 background_origin.x(), |
241 background_origin.y(), | 241 background_origin.y(), |
242 bounds.x(), | 242 bounds.x(), |
243 bounds.y(), | 243 bounds.y(), |
244 bounds.width(), | 244 bounds.width(), |
245 bounds.height()); | 245 bounds.height()); |
246 | 246 |
247 if (host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH && | 247 if (host_desktop_type == ui::HOST_DESKTOP_TYPE_ASH && |
248 !ui::MaterialDesignController::IsModeMaterial()) { | 248 !ui::MaterialDesignController::IsModeMaterial()) { |
249 // The pre-material design version of Ash provides additional lightening | 249 // The pre-material design version of Ash provides additional lightening |
250 // at the edges of the toolbar. | 250 // at the edges of the toolbar. |
251 gfx::ImageSkia* toolbar_left = | 251 gfx::ImageSkia* toolbar_left = |
252 theme_provider->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_LEFT); | 252 theme_provider->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_LEFT); |
253 canvas->TileImageInt(*toolbar_left, | 253 canvas->TileImageInt(*toolbar_left, |
254 bounds.x(), | 254 bounds.x(), |
255 bounds.y(), | 255 bounds.y(), |
256 toolbar_left->width(), | 256 toolbar_left->width(), |
257 bounds.height()); | 257 bounds.height()); |
258 gfx::ImageSkia* toolbar_right = | 258 gfx::ImageSkia* toolbar_right = |
259 theme_provider->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_RIGHT); | 259 theme_provider->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_RIGHT); |
260 canvas->TileImageInt(*toolbar_right, | 260 canvas->TileImageInt(*toolbar_right, |
261 bounds.right() - toolbar_right->width(), | 261 bounds.right() - toolbar_right->width(), |
262 bounds.y(), | 262 bounds.y(), |
263 toolbar_right->width(), | 263 toolbar_right->width(), |
264 bounds.height()); | 264 bounds.height()); |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 void PaintAttachedBookmarkBar(gfx::Canvas* canvas, | 268 void PaintAttachedBookmarkBar(gfx::Canvas* canvas, |
269 BookmarkBarView* view, | 269 BookmarkBarView* view, |
270 BrowserView* browser_view, | 270 BrowserView* browser_view, |
271 chrome::HostDesktopType host_desktop_type, | 271 ui::HostDesktopType host_desktop_type, |
272 int toolbar_overlap) { | 272 int toolbar_overlap) { |
273 // Paint background for attached state, this is fade in/out. | 273 // Paint background for attached state, this is fade in/out. |
274 gfx::Point background_image_offset = | 274 gfx::Point background_image_offset = |
275 browser_view->OffsetPointForToolbarBackgroundImage( | 275 browser_view->OffsetPointForToolbarBackgroundImage( |
276 gfx::Point(view->GetMirroredX(), view->y())); | 276 gfx::Point(view->GetMirroredX(), view->y())); |
277 PaintBackgroundAttachedMode(canvas, | 277 PaintBackgroundAttachedMode(canvas, |
278 view->GetThemeProvider(), | 278 view->GetThemeProvider(), |
279 view->GetLocalBounds(), | 279 view->GetLocalBounds(), |
280 background_image_offset, | 280 background_image_offset, |
281 host_desktop_type); | 281 host_desktop_type); |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 | 688 |
689 void BrowserView::Show() { | 689 void BrowserView::Show() { |
690 #if !defined(OS_WIN) | 690 #if !defined(OS_WIN) |
691 // The Browser associated with this browser window must become the active | 691 // The Browser associated with this browser window must become the active |
692 // browser at the time |Show()| is called. This is the natural behavior under | 692 // browser at the time |Show()| is called. This is the natural behavior under |
693 // Windows and Ash, but other platforms will not trigger | 693 // Windows and Ash, but other platforms will not trigger |
694 // OnWidgetActivationChanged() until we return to the runloop. Therefore any | 694 // OnWidgetActivationChanged() until we return to the runloop. Therefore any |
695 // calls to Browser::GetLastActive() will return the wrong result if we do not | 695 // calls to Browser::GetLastActive() will return the wrong result if we do not |
696 // explicitly set it here. | 696 // explicitly set it here. |
697 // A similar block also appears in BrowserWindowCocoa::Show(). | 697 // A similar block also appears in BrowserWindowCocoa::Show(). |
698 if (browser()->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) | 698 if (browser()->host_desktop_type() != ui::HOST_DESKTOP_TYPE_ASH) |
699 BrowserList::SetLastActive(browser()); | 699 BrowserList::SetLastActive(browser()); |
700 #endif | 700 #endif |
701 | 701 |
702 // If the window is already visible, just activate it. | 702 // If the window is already visible, just activate it. |
703 if (frame_->IsVisible()) { | 703 if (frame_->IsVisible()) { |
704 frame_->Activate(); | 704 frame_->Activate(); |
705 return; | 705 return; |
706 } | 706 } |
707 | 707 |
708 // Showing the window doesn't make the browser window active right away. | 708 // Showing the window doesn't make the browser window active right away. |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1701 return GetWindowTitle(); | 1701 return GetWindowTitle(); |
1702 } | 1702 } |
1703 | 1703 |
1704 views::View* BrowserView::GetInitiallyFocusedView() { | 1704 views::View* BrowserView::GetInitiallyFocusedView() { |
1705 return nullptr; | 1705 return nullptr; |
1706 } | 1706 } |
1707 | 1707 |
1708 bool BrowserView::ShouldShowWindowTitle() const { | 1708 bool BrowserView::ShouldShowWindowTitle() const { |
1709 // For Ash only, trusted windows (apps and settings) do not show a title, | 1709 // For Ash only, trusted windows (apps and settings) do not show a title, |
1710 // crbug.com/119411. Child windows (i.e. popups) do show a title. | 1710 // crbug.com/119411. Child windows (i.e. popups) do show a title. |
1711 if (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH && | 1711 if (browser_->host_desktop_type() == ui::HOST_DESKTOP_TYPE_ASH && |
1712 browser_->is_trusted_source() && | 1712 browser_->is_trusted_source() && |
1713 !browser_->SupportsWindowFeature(Browser::FEATURE_WEBAPPFRAME)) | 1713 !browser_->SupportsWindowFeature(Browser::FEATURE_WEBAPPFRAME)) |
1714 return false; | 1714 return false; |
1715 | 1715 |
1716 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); | 1716 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); |
1717 } | 1717 } |
1718 | 1718 |
1719 gfx::ImageSkia BrowserView::GetWindowAppIcon() { | 1719 gfx::ImageSkia BrowserView::GetWindowAppIcon() { |
1720 if (browser_->is_app()) { | 1720 if (browser_->is_app()) { |
1721 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); | 1721 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); |
(...skipping 13 matching lines...) Expand all Loading... |
1735 return gfx::ImageSkia(); | 1735 return gfx::ImageSkia(); |
1736 | 1736 |
1737 if (browser_->is_app() || browser_->is_type_popup()) | 1737 if (browser_->is_app() || browser_->is_type_popup()) |
1738 return browser_->GetCurrentPageIcon().AsImageSkia(); | 1738 return browser_->GetCurrentPageIcon().AsImageSkia(); |
1739 return gfx::ImageSkia(); | 1739 return gfx::ImageSkia(); |
1740 } | 1740 } |
1741 | 1741 |
1742 bool BrowserView::ShouldShowWindowIcon() const { | 1742 bool BrowserView::ShouldShowWindowIcon() const { |
1743 // For Ash only, trusted windows (apps and settings) do not show an icon, | 1743 // For Ash only, trusted windows (apps and settings) do not show an icon, |
1744 // crbug.com/119411. Child windows (i.e. popups) do show an icon. | 1744 // crbug.com/119411. Child windows (i.e. popups) do show an icon. |
1745 if (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH && | 1745 if (browser_->host_desktop_type() == ui::HOST_DESKTOP_TYPE_ASH && |
1746 browser_->is_trusted_source() && | 1746 browser_->is_trusted_source() && |
1747 !browser_->SupportsWindowFeature(Browser::FEATURE_WEBAPPFRAME)) | 1747 !browser_->SupportsWindowFeature(Browser::FEATURE_WEBAPPFRAME)) |
1748 return false; | 1748 return false; |
1749 | 1749 |
1750 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); | 1750 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); |
1751 } | 1751 } |
1752 | 1752 |
1753 bool BrowserView::ExecuteWindowsCommand(int command_id) { | 1753 bool BrowserView::ExecuteWindowsCommand(int command_id) { |
1754 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND. | 1754 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND. |
1755 #if defined(OS_WIN) | 1755 #if defined(OS_WIN) |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2362 | 2362 |
2363 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); | 2363 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); |
2364 if (contents && PermissionBubbleManager::FromWebContents(contents)) | 2364 if (contents && PermissionBubbleManager::FromWebContents(contents)) |
2365 PermissionBubbleManager::FromWebContents(contents)->UpdateAnchorPosition(); | 2365 PermissionBubbleManager::FromWebContents(contents)->UpdateAnchorPosition(); |
2366 } | 2366 } |
2367 | 2367 |
2368 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const { | 2368 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const { |
2369 // Kiosk mode needs the whole screen, and if we're not in an Ash desktop | 2369 // Kiosk mode needs the whole screen, and if we're not in an Ash desktop |
2370 // immersive fullscreen doesn't exist. | 2370 // immersive fullscreen doesn't exist. |
2371 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) || | 2371 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) || |
2372 browser()->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) { | 2372 browser()->host_desktop_type() != ui::HOST_DESKTOP_TYPE_ASH) { |
2373 return false; | 2373 return false; |
2374 } | 2374 } |
2375 | 2375 |
2376 return url.is_empty(); | 2376 return url.is_empty(); |
2377 } | 2377 } |
2378 | 2378 |
2379 void BrowserView::LoadAccelerators() { | 2379 void BrowserView::LoadAccelerators() { |
2380 views::FocusManager* focus_manager = GetFocusManager(); | 2380 views::FocusManager* focus_manager = GetFocusManager(); |
2381 DCHECK(focus_manager); | 2381 DCHECK(focus_manager); |
2382 | 2382 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2634 return immersive_mode_controller()->IsEnabled(); | 2634 return immersive_mode_controller()->IsEnabled(); |
2635 } | 2635 } |
2636 | 2636 |
2637 views::Widget* BrowserView::GetBubbleAssociatedWidget() { | 2637 views::Widget* BrowserView::GetBubbleAssociatedWidget() { |
2638 return GetWidget(); | 2638 return GetWidget(); |
2639 } | 2639 } |
2640 | 2640 |
2641 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { | 2641 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { |
2642 return top_container_->GetBoundsInScreen(); | 2642 return top_container_->GetBoundsInScreen(); |
2643 } | 2643 } |
OLD | NEW |