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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 #include "ui/views/window/dialog_delegate.h" | 123 #include "ui/views/window/dialog_delegate.h" |
124 | 124 |
125 #if defined(USE_ASH) | 125 #if defined(USE_ASH) |
126 #include "ash/launcher/launcher.h" | 126 #include "ash/launcher/launcher.h" |
127 #include "ash/launcher/launcher_model.h" | 127 #include "ash/launcher/launcher_model.h" |
128 #include "ash/shell.h" | 128 #include "ash/shell.h" |
129 #include "chrome/browser/ui/ash/ash_util.h" | 129 #include "chrome/browser/ui/ash/ash_util.h" |
130 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" | 130 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" |
131 #include "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h" | 131 #include "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h" |
132 #include "chrome/browser/ui/ash/window_positioner.h" | 132 #include "chrome/browser/ui/ash/window_positioner.h" |
133 #elif defined(OS_WIN) && !defined(USE_AURA) | |
134 #include "base/win/metro.h" | |
135 #include "chrome/browser/jumplist_win.h" | |
136 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" | |
137 #include "ui/views/widget/native_widget_win.h" | |
138 #include "ui/views/win/scoped_fullscreen_visibility.h" | |
139 #endif | 133 #endif |
140 | 134 |
141 #if defined(USE_AURA) | 135 #if defined(USE_AURA) |
142 #include "chrome/browser/ui/views/accelerator_table.h" | 136 #include "chrome/browser/ui/views/accelerator_table.h" |
143 #include "chrome/browser/ui/webui/task_manager/task_manager_dialog.h" | 137 #include "chrome/browser/ui/webui/task_manager/task_manager_dialog.h" |
144 #include "ui/aura/window.h" | 138 #include "ui/aura/window.h" |
145 #include "ui/gfx/screen.h" | 139 #include "ui/gfx/screen.h" |
140 #elif defined(OS_WIN) | |
robertshield
2012/12/03 19:48:48
I feel that this would be more readable as a stand
gab
2012/12/04 00:19:06
Ok, added comment at end of line.
| |
141 #include "chrome/browser/jumplist_win.h" | |
142 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" | |
143 #include "ui/views/widget/native_widget_win.h" | |
144 #include "ui/views/win/scoped_fullscreen_visibility.h" | |
145 #endif | |
146 | |
147 #if defined(OS_WIN) | |
148 #include "win8/util/win8_util.h" | |
146 #endif | 149 #endif |
147 | 150 |
148 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 151 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
149 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h" | 152 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h" |
150 #endif | 153 #endif |
151 | 154 |
152 using base::TimeDelta; | 155 using base::TimeDelta; |
153 using content::NativeWebKeyboardEvent; | 156 using content::NativeWebKeyboardEvent; |
154 using content::SSLStatus; | 157 using content::SSLStatus; |
155 using content::UserMetricsAction; | 158 using content::UserMetricsAction; |
(...skipping 21 matching lines...) Expand all Loading... | |
177 // Returned from BrowserView::GetClassName. | 180 // Returned from BrowserView::GetClassName. |
178 const char BrowserView::kViewClassName[] = "browser/ui/views/BrowserView"; | 181 const char BrowserView::kViewClassName[] = "browser/ui/views/BrowserView"; |
179 // static | 182 // static |
180 const int BrowserView::kTabstripIndex = 0; | 183 const int BrowserView::kTabstripIndex = 0; |
181 const int BrowserView::kInfoBarIndex = 1; | 184 const int BrowserView::kInfoBarIndex = 1; |
182 const int BrowserView::kToolbarIndex = 2; | 185 const int BrowserView::kToolbarIndex = 2; |
183 | 186 |
184 namespace { | 187 namespace { |
185 | 188 |
186 bool ShouldSaveOrRestoreWindowPos() { | 189 bool ShouldSaveOrRestoreWindowPos() { |
187 #if defined(OS_WIN) && !defined(USE_AURA) | 190 #if defined(OS_WIN) |
188 // In Windows 8 metro mode the window is always maximized (without the | 191 // In Windows 8 metro mode the window is always maximized (without the |
cpu_(ooo_6.6-7.5)
2012/12/03 20:56:26
reword
gab
2012/12/04 00:19:06
Done.
| |
189 // WS_MAXIMIZE) style. | 192 // WS_MAXIMIZE style). |
190 if (base::win::IsMetroProcess()) | 193 if (win8::IsSingleWindowMetroMode()) |
191 return false; | 194 return false; |
192 #endif | 195 #endif |
193 return true; | 196 return true; |
194 } | 197 } |
195 | 198 |
196 #if !defined(USE_AURA) | 199 #if !defined(USE_AURA) |
197 // Draw the background to match the new tab page. The trick is to align it | 200 // Draw the background to match the new tab page. The trick is to align it |
198 // properly because without Aura, the bookmark bar is not drawn as a semi | 201 // properly because without Aura, the bookmark bar is not drawn as a semi |
199 // transparent layer on top of the ntp, instead, the ntp is cropped and the bar | 202 // transparent layer on top of the ntp, instead, the ntp is cropped and the bar |
200 // is drawn below it. This code could live in ntp_background_util.cc, but won't | 203 // is drawn below it. This code could live in ntp_background_util.cc, but won't |
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1544 return contents_->GetPreviewBounds(); | 1547 return contents_->GetPreviewBounds(); |
1545 } | 1548 } |
1546 | 1549 |
1547 bool BrowserView::IsInstantTabShowing() { | 1550 bool BrowserView::IsInstantTabShowing() { |
1548 return preview_controller_->preview() != NULL; | 1551 return preview_controller_->preview() != NULL; |
1549 } | 1552 } |
1550 | 1553 |
1551 WindowOpenDisposition BrowserView::GetDispositionForPopupBounds( | 1554 WindowOpenDisposition BrowserView::GetDispositionForPopupBounds( |
1552 const gfx::Rect& bounds) { | 1555 const gfx::Rect& bounds) { |
1553 #if defined(OS_WIN) | 1556 #if defined(OS_WIN) |
1554 #if defined(USE_AURA) | |
1555 return NEW_POPUP; | |
1556 #else | |
1557 // If we are in windows metro-mode, we can't allow popup windows. | 1557 // If we are in windows metro-mode, we can't allow popup windows. |
cpu_(ooo_6.6-7.5)
2012/12/03 20:56:26
reword
gab
2012/12/04 00:19:06
Done.
| |
1558 return base::win::IsMetroProcess() ? NEW_BACKGROUND_TAB : NEW_POPUP; | 1558 return win8::IsSingleWindowMetroMode() ? NEW_BACKGROUND_TAB : NEW_POPUP; |
1559 #endif | |
1560 #else | 1559 #else |
1561 return NEW_POPUP; | 1560 return NEW_POPUP; |
1562 #endif | 1561 #endif |
1563 } | 1562 } |
1564 | 1563 |
1565 FindBar* BrowserView::CreateFindBar() { | 1564 FindBar* BrowserView::CreateFindBar() { |
1566 return chrome::CreateFindBar(this); | 1565 return chrome::CreateFindBar(this); |
1567 } | 1566 } |
1568 | 1567 |
1569 bool BrowserView::GetConstrainedWindowTopY(int* top_y) { | 1568 bool BrowserView::GetConstrainedWindowTopY(int* top_y) { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1782 // For Ash only, app host windows do not show an icon, crbug.com/119411. | 1781 // For Ash only, app host windows do not show an icon, crbug.com/119411. |
1783 // Child windows (e.g. extension panels, popups) do show an icon. | 1782 // Child windows (e.g. extension panels, popups) do show an icon. |
1784 if (browser_->is_app() && browser_->app_type() == Browser::APP_TYPE_HOST) | 1783 if (browser_->is_app() && browser_->app_type() == Browser::APP_TYPE_HOST) |
1785 return false; | 1784 return false; |
1786 #endif | 1785 #endif |
1787 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); | 1786 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); |
1788 } | 1787 } |
1789 | 1788 |
1790 bool BrowserView::ExecuteWindowsCommand(int command_id) { | 1789 bool BrowserView::ExecuteWindowsCommand(int command_id) { |
1791 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND. | 1790 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND. |
1792 #if defined(OS_WIN) && !defined(USE_AURA) | 1791 #if defined(OS_WIN) |
1793 if (command_id == IDC_DEBUG_FRAME_TOGGLE) | 1792 if (command_id == IDC_DEBUG_FRAME_TOGGLE) |
1794 GetWidget()->DebugToggleFrameType(); | 1793 GetWidget()->DebugToggleFrameType(); |
robertshield
2012/12/03 19:48:48
this introduces a change in behaviour for the line
gab
2012/12/04 00:19:06
This is can only ever be called if switches::kDebu
| |
1795 | 1794 |
1796 // In Windows 8 metro mode prevent sizing and moving. | 1795 // In Windows 8 metro mode prevent sizing and moving. |
1797 if (base::win::IsMetroProcess()) { | 1796 if (win8::IsSingleWindowMetroMode()) { |
1798 // Windows uses the 4 lower order bits of |notification_code| for type- | 1797 // Windows uses the 4 lower order bits of |notification_code| for type- |
1799 // specific information so we must exclude this when comparing. | 1798 // specific information so we must exclude this when comparing. |
1800 static const int sc_mask = 0xFFF0; | 1799 static const int sc_mask = 0xFFF0; |
1801 if (((command_id & sc_mask) == SC_MOVE) || | 1800 if (((command_id & sc_mask) == SC_MOVE) || |
1802 ((command_id & sc_mask) == SC_SIZE) || | 1801 ((command_id & sc_mask) == SC_SIZE) || |
1803 ((command_id & sc_mask) == SC_MAXIMIZE)) | 1802 ((command_id & sc_mask) == SC_MAXIMIZE)) |
1804 return true; | 1803 return true; |
1805 } | 1804 } |
1806 #endif | 1805 #endif |
1807 // Translate WM_APPCOMMAND command ids into a command id that the browser | 1806 // Translate WM_APPCOMMAND command ids into a command id that the browser |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2123 | 2122 |
2124 void BrowserView::OnSysColorChange() { | 2123 void BrowserView::OnSysColorChange() { |
2125 chrome::MaybeShowInvertBubbleView(browser_.get(), contents_); | 2124 chrome::MaybeShowInvertBubbleView(browser_.get(), contents_); |
2126 } | 2125 } |
2127 | 2126 |
2128 int BrowserView::GetOTRIconResourceID() const { | 2127 int BrowserView::GetOTRIconResourceID() const { |
2129 int otr_resource_id = IDR_OTR_ICON; | 2128 int otr_resource_id = IDR_OTR_ICON; |
2130 if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) { | 2129 if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) { |
2131 if (IsFullscreen()) | 2130 if (IsFullscreen()) |
2132 otr_resource_id = IDR_OTR_ICON_FULLSCREEN; | 2131 otr_resource_id = IDR_OTR_ICON_FULLSCREEN; |
2133 #if defined(OS_WIN) && !defined(USE_AURA) | 2132 #if defined(OS_WIN) |
2134 if (base::win::IsMetroProcess()) | 2133 if (win8::IsSingleWindowMetroMode()) |
2135 otr_resource_id = IDR_OTR_ICON_FULLSCREEN; | 2134 otr_resource_id = IDR_OTR_ICON_FULLSCREEN; |
2136 #endif | 2135 #endif |
2137 } | 2136 } |
2138 | 2137 |
2139 return otr_resource_id; | 2138 return otr_resource_id; |
2140 } | 2139 } |
2141 | 2140 |
2142 views::LayoutManager* BrowserView::CreateLayoutManager() const { | 2141 views::LayoutManager* BrowserView::CreateLayoutManager() const { |
2143 return new BrowserViewLayout; | 2142 return new BrowserViewLayout; |
2144 } | 2143 } |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2789 modal_browser->window()->Activate(); | 2788 modal_browser->window()->Activate(); |
2790 } | 2789 } |
2791 | 2790 |
2792 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); | 2791 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); |
2793 } | 2792 } |
2794 | 2793 |
2795 void BrowserView::MaybeStackBookmarkBarAtTop() { | 2794 void BrowserView::MaybeStackBookmarkBarAtTop() { |
2796 if (bookmark_bar_view_.get()) | 2795 if (bookmark_bar_view_.get()) |
2797 bookmark_bar_view_->MaybeStackAtTop(); | 2796 bookmark_bar_view_->MaybeStackAtTop(); |
2798 } | 2797 } |
OLD | NEW |