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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 #include "chrome/browser/ui/views/password_generation_bubble_view.h" | 80 #include "chrome/browser/ui/views/password_generation_bubble_view.h" |
81 #include "chrome/browser/ui/views/profile_chooser_view.h" | 81 #include "chrome/browser/ui/views/profile_chooser_view.h" |
82 #include "chrome/browser/ui/views/status_bubble_views.h" | 82 #include "chrome/browser/ui/views/status_bubble_views.h" |
83 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" | 83 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" |
84 #include "chrome/browser/ui/views/tabs/tab.h" | 84 #include "chrome/browser/ui/views/tabs/tab.h" |
85 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 85 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
86 #include "chrome/browser/ui/views/toolbar_view.h" | 86 #include "chrome/browser/ui/views/toolbar_view.h" |
87 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" | 87 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" |
88 #include "chrome/browser/ui/views/update_recommended_message_box.h" | 88 #include "chrome/browser/ui/views/update_recommended_message_box.h" |
89 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h
" | 89 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h
" |
| 90 #include "chrome/browser/ui/web_applications/hosted_app_tab_helper.h" |
90 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 91 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
91 #include "chrome/common/chrome_switches.h" | 92 #include "chrome/common/chrome_switches.h" |
92 #include "chrome/common/pref_names.h" | 93 #include "chrome/common/pref_names.h" |
93 #include "chrome/common/url_constants.h" | 94 #include "chrome/common/url_constants.h" |
94 #include "content/public/browser/download_manager.h" | 95 #include "content/public/browser/download_manager.h" |
95 #include "content/public/browser/native_web_keyboard_event.h" | 96 #include "content/public/browser/native_web_keyboard_event.h" |
96 #include "content/public/browser/notification_service.h" | 97 #include "content/public/browser/notification_service.h" |
97 #include "content/public/browser/render_view_host.h" | 98 #include "content/public/browser/render_view_host.h" |
98 #include "content/public/browser/render_widget_host.h" | 99 #include "content/public/browser/render_widget_host.h" |
99 #include "content/public/browser/user_metrics.h" | 100 #include "content/public/browser/user_metrics.h" |
100 #include "content/public/browser/web_contents.h" | 101 #include "content/public/browser/web_contents.h" |
101 #include "content/public/browser/web_contents_view.h" | 102 #include "content/public/browser/web_contents_view.h" |
102 #include "content/public/common/content_switches.h" | 103 #include "content/public/common/content_switches.h" |
103 #include "grit/chromium_strings.h" | 104 #include "grit/chromium_strings.h" |
104 #include "grit/generated_resources.h" | 105 #include "grit/generated_resources.h" |
105 #include "grit/locale_settings.h" | 106 #include "grit/locale_settings.h" |
106 #include "grit/theme_resources.h" | 107 #include "grit/theme_resources.h" |
107 #include "grit/ui_resources.h" | 108 #include "grit/ui_resources.h" |
108 #include "grit/ui_strings.h" | 109 #include "grit/ui_strings.h" |
109 #include "grit/webkit_resources.h" | 110 #include "grit/webkit_resources.h" |
110 #include "ui/base/accelerators/accelerator.h" | 111 #include "ui/base/accelerators/accelerator.h" |
111 #include "ui/base/accessibility/accessible_view_state.h" | 112 #include "ui/base/accessibility/accessible_view_state.h" |
112 #include "ui/base/hit_test.h" | 113 #include "ui/base/hit_test.h" |
113 #include "ui/base/l10n/l10n_util.h" | 114 #include "ui/base/l10n/l10n_util.h" |
114 #include "ui/base/resource/resource_bundle.h" | 115 #include "ui/base/resource/resource_bundle.h" |
115 #include "ui/base/theme_provider.h" | 116 #include "ui/base/theme_provider.h" |
116 #include "ui/events/event_utils.h" | 117 #include "ui/events/event_utils.h" |
117 #include "ui/gfx/canvas.h" | 118 #include "ui/gfx/canvas.h" |
118 #include "ui/gfx/color_utils.h" | 119 #include "ui/gfx/color_utils.h" |
| 120 #include "ui/gfx/icon_util.h" |
119 #include "ui/gfx/sys_color_change_listener.h" | 121 #include "ui/gfx/sys_color_change_listener.h" |
120 #include "ui/views/controls/button/menu_button.h" | 122 #include "ui/views/controls/button/menu_button.h" |
121 #include "ui/views/controls/single_split_view.h" | 123 #include "ui/views/controls/single_split_view.h" |
122 #include "ui/views/controls/textfield/textfield.h" | 124 #include "ui/views/controls/textfield/textfield.h" |
123 #include "ui/views/controls/webview/webview.h" | 125 #include "ui/views/controls/webview/webview.h" |
124 #include "ui/views/focus/external_focus_tracker.h" | 126 #include "ui/views/focus/external_focus_tracker.h" |
125 #include "ui/views/focus/view_storage.h" | 127 #include "ui/views/focus/view_storage.h" |
126 #include "ui/views/layout/grid_layout.h" | 128 #include "ui/views/layout/grid_layout.h" |
127 #include "ui/views/widget/native_widget.h" | 129 #include "ui/views/widget/native_widget.h" |
128 #include "ui/views/widget/root_view.h" | 130 #include "ui/views/widget/root_view.h" |
(...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1567 contents ? extensions::TabHelper::FromWebContents(contents) : NULL; | 1569 contents ? extensions::TabHelper::FromWebContents(contents) : NULL; |
1568 if (extensions_tab_helper && extensions_tab_helper->GetExtensionAppIcon()) | 1570 if (extensions_tab_helper && extensions_tab_helper->GetExtensionAppIcon()) |
1569 return gfx::ImageSkia::CreateFrom1xBitmap( | 1571 return gfx::ImageSkia::CreateFrom1xBitmap( |
1570 *extensions_tab_helper->GetExtensionAppIcon()); | 1572 *extensions_tab_helper->GetExtensionAppIcon()); |
1571 } | 1573 } |
1572 | 1574 |
1573 return GetWindowIcon(); | 1575 return GetWindowIcon(); |
1574 } | 1576 } |
1575 | 1577 |
1576 gfx::ImageSkia BrowserView::GetWindowIcon() { | 1578 gfx::ImageSkia BrowserView::GetWindowIcon() { |
1577 if (browser_->is_app() || browser_->is_type_popup()) | 1579 if (browser_->is_app() || browser_->is_type_popup()) { |
1578 return browser_->GetCurrentPageIcon().AsImageSkia(); | 1580 WebContents* web_contents = |
| 1581 browser_->tab_strip_model()->GetActiveWebContents(); |
| 1582 // |web_contents| can be NULL since GetCurrentPageIcon() is called by the |
| 1583 // window during the window's creation (before tabs have been added). |
| 1584 HostedAppTabHelper* hosted_app_tab_helper = |
| 1585 web_contents ? HostedAppTabHelper::FromWebContents(web_contents) |
| 1586 : NULL; |
| 1587 // Use IconUtil::kMediumIconSize as it is the size used for the Alt+Tab |
| 1588 // icon. |
| 1589 const gfx::Image* icon = hosted_app_tab_helper |
| 1590 ? hosted_app_tab_helper->image_family().GetBest( |
| 1591 IconUtil::kMediumIconSize, IconUtil::kMediumIconSize) |
| 1592 : NULL; |
| 1593 |
| 1594 return icon ? icon->AsImageSkia() : gfx::ImageSkia(); |
| 1595 } |
1579 return gfx::ImageSkia(); | 1596 return gfx::ImageSkia(); |
1580 } | 1597 } |
1581 | 1598 |
1582 bool BrowserView::ShouldShowWindowIcon() const { | 1599 bool BrowserView::ShouldShowWindowIcon() const { |
1583 // For Ash only, app host windows do not show an icon, crbug.com/119411. | 1600 // For Ash only, app host windows do not show an icon, crbug.com/119411. |
1584 // Child windows (i.e. popups) do show an icon. | 1601 // Child windows (i.e. popups) do show an icon. |
1585 if (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH && | 1602 if (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH && |
1586 browser_->is_app() && browser_->app_type() == Browser::APP_TYPE_HOST) | 1603 browser_->is_app() && browser_->app_type() == Browser::APP_TYPE_HOST) |
1587 return false; | 1604 return false; |
1588 | 1605 |
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2695 !GetLocationBar()->GetLocationEntry()->model()->popup_model()->IsOpen()) { | 2712 !GetLocationBar()->GetLocationEntry()->model()->popup_model()->IsOpen()) { |
2696 gfx::Point icon_bottom( | 2713 gfx::Point icon_bottom( |
2697 toolbar_->location_bar()->GetLocationBarAnchorPoint()); | 2714 toolbar_->location_bar()->GetLocationBarAnchorPoint()); |
2698 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); | 2715 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); |
2699 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); | 2716 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); |
2700 ConvertPointToTarget(infobar_container_, this, &infobar_top); | 2717 ConvertPointToTarget(infobar_container_, this, &infobar_top); |
2701 top_arrow_height = infobar_top.y() - icon_bottom.y(); | 2718 top_arrow_height = infobar_top.y() - icon_bottom.y(); |
2702 } | 2719 } |
2703 return top_arrow_height; | 2720 return top_arrow_height; |
2704 } | 2721 } |
OLD | NEW |