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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 #include "ui/base/accelerators/accelerator.h" | 122 #include "ui/base/accelerators/accelerator.h" |
123 #include "ui/base/hit_test.h" | 123 #include "ui/base/hit_test.h" |
124 #include "ui/base/l10n/l10n_util.h" | 124 #include "ui/base/l10n/l10n_util.h" |
125 #include "ui/base/resource/resource_bundle.h" | 125 #include "ui/base/resource/resource_bundle.h" |
126 #include "ui/base/theme_provider.h" | 126 #include "ui/base/theme_provider.h" |
127 #include "ui/events/event_utils.h" | 127 #include "ui/events/event_utils.h" |
128 #include "ui/gfx/canvas.h" | 128 #include "ui/gfx/canvas.h" |
129 #include "ui/gfx/color_utils.h" | 129 #include "ui/gfx/color_utils.h" |
130 #include "ui/gfx/rect_conversions.h" | 130 #include "ui/gfx/rect_conversions.h" |
131 #include "ui/gfx/screen.h" | 131 #include "ui/gfx/screen.h" |
132 #include "ui/gfx/sys_color_change_listener.h" | |
133 #include "ui/views/controls/button/menu_button.h" | 132 #include "ui/views/controls/button/menu_button.h" |
134 #include "ui/views/controls/textfield/textfield.h" | 133 #include "ui/views/controls/textfield/textfield.h" |
135 #include "ui/views/controls/webview/webview.h" | 134 #include "ui/views/controls/webview/webview.h" |
136 #include "ui/views/focus/external_focus_tracker.h" | 135 #include "ui/views/focus/external_focus_tracker.h" |
137 #include "ui/views/focus/view_storage.h" | 136 #include "ui/views/focus/view_storage.h" |
138 #include "ui/views/layout/grid_layout.h" | 137 #include "ui/views/layout/grid_layout.h" |
139 #include "ui/views/widget/native_widget.h" | 138 #include "ui/views/widget/native_widget.h" |
140 #include "ui/views/widget/root_view.h" | 139 #include "ui/views/widget/root_view.h" |
141 #include "ui/views/widget/widget.h" | 140 #include "ui/views/widget/widget.h" |
142 #include "ui/views/window/dialog_delegate.h" | 141 #include "ui/views/window/dialog_delegate.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 initialized_(false), | 411 initialized_(false), |
413 in_process_fullscreen_(false), | 412 in_process_fullscreen_(false), |
414 #if defined(OS_WIN) | 413 #if defined(OS_WIN) |
415 hung_window_detector_(&hung_plugin_action_), | 414 hung_window_detector_(&hung_plugin_action_), |
416 ticker_(0), | 415 ticker_(0), |
417 #endif | 416 #endif |
418 force_location_bar_focus_(false), | 417 force_location_bar_focus_(false), |
419 #if defined(OS_CHROMEOS) | 418 #if defined(OS_CHROMEOS) |
420 scroll_end_effect_controller_(ScrollEndEffectController::Create()), | 419 scroll_end_effect_controller_(ScrollEndEffectController::Create()), |
421 #endif | 420 #endif |
422 color_change_listener_(this), | |
423 activate_modal_dialog_factory_(this) { | 421 activate_modal_dialog_factory_(this) { |
424 } | 422 } |
425 | 423 |
426 BrowserView::~BrowserView() { | 424 BrowserView::~BrowserView() { |
427 // All the tabs should have been destroyed already. If we were closed by the | 425 // All the tabs should have been destroyed already. If we were closed by the |
428 // OS with some tabs than the NativeBrowserFrame should have destroyed them. | 426 // OS with some tabs than the NativeBrowserFrame should have destroyed them. |
429 DCHECK_EQ(0, browser_->tab_strip_model()->count()); | 427 DCHECK_EQ(0, browser_->tab_strip_model()->count()); |
430 | 428 |
431 // Immersive mode may need to reparent views before they are removed/deleted. | 429 // Immersive mode may need to reparent views before they are removed/deleted. |
432 immersive_mode_controller_.reset(); | 430 immersive_mode_controller_.reset(); |
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1830 } | 1828 } |
1831 | 1829 |
1832 void BrowserView::ChildPreferredSizeChanged(View* child) { | 1830 void BrowserView::ChildPreferredSizeChanged(View* child) { |
1833 Layout(); | 1831 Layout(); |
1834 } | 1832 } |
1835 | 1833 |
1836 void BrowserView::GetAccessibleState(ui::AXViewState* state) { | 1834 void BrowserView::GetAccessibleState(ui::AXViewState* state) { |
1837 state->role = ui::AX_ROLE_CLIENT; | 1835 state->role = ui::AX_ROLE_CLIENT; |
1838 } | 1836 } |
1839 | 1837 |
| 1838 void BrowserView::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| 1839 // Do not handle native theme changes before the browser view is initialized. |
| 1840 if (!initialized_) |
| 1841 return; |
| 1842 ClientView::OnNativeThemeChanged(theme); |
| 1843 UserChangedTheme(); |
| 1844 chrome::MaybeShowInvertBubbleView(this); |
| 1845 } |
| 1846 |
1840 /////////////////////////////////////////////////////////////////////////////// | 1847 /////////////////////////////////////////////////////////////////////////////// |
1841 // BrowserView, ui::AcceleratorTarget overrides: | 1848 // BrowserView, ui::AcceleratorTarget overrides: |
1842 | 1849 |
1843 bool BrowserView::AcceleratorPressed(const ui::Accelerator& accelerator) { | 1850 bool BrowserView::AcceleratorPressed(const ui::Accelerator& accelerator) { |
1844 #if defined(OS_CHROMEOS) | 1851 #if defined(OS_CHROMEOS) |
1845 // If accessibility is enabled, stop speech and return false so that key | 1852 // If accessibility is enabled, stop speech and return false so that key |
1846 // combinations involving Search can be used for extra accessibility | 1853 // combinations involving Search can be used for extra accessibility |
1847 // functionality. | 1854 // functionality. |
1848 if (accelerator.key_code() == ui::VKEY_LWIN && | 1855 if (accelerator.key_code() == ui::VKEY_LWIN && |
1849 g_browser_process->local_state()->GetBoolean( | 1856 g_browser_process->local_state()->GetBoolean( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1887 | 1894 |
1888 bool BrowserView::DrawInfoBarArrows(int* x) const { | 1895 bool BrowserView::DrawInfoBarArrows(int* x) const { |
1889 if (x) { | 1896 if (x) { |
1890 gfx::Point anchor(toolbar_->location_bar()->GetLocationBarAnchorPoint()); | 1897 gfx::Point anchor(toolbar_->location_bar()->GetLocationBarAnchorPoint()); |
1891 ConvertPointToTarget(toolbar_->location_bar(), this, &anchor); | 1898 ConvertPointToTarget(toolbar_->location_bar(), this, &anchor); |
1892 *x = anchor.x(); | 1899 *x = anchor.x(); |
1893 } | 1900 } |
1894 return true; | 1901 return true; |
1895 } | 1902 } |
1896 | 1903 |
1897 void BrowserView::OnSysColorChange() { | |
1898 chrome::MaybeShowInvertBubbleView(this); | |
1899 } | |
1900 | |
1901 void BrowserView::InitViews() { | 1904 void BrowserView::InitViews() { |
1902 GetWidget()->AddObserver(this); | 1905 GetWidget()->AddObserver(this); |
1903 | 1906 |
1904 // Stow a pointer to this object onto the window handle so that we can get at | 1907 // Stow a pointer to this object onto the window handle so that we can get at |
1905 // it later when all we have is a native view. | 1908 // it later when all we have is a native view. |
1906 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this); | 1909 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this); |
1907 | 1910 |
1908 // Stow a pointer to the browser's profile onto the window handle so that we | 1911 // Stow a pointer to the browser's profile onto the window handle so that we |
1909 // can get it later when all we have is a native view. | 1912 // can get it later when all we have is a native view. |
1910 GetWidget()->SetNativeWindowProperty(Profile::kProfileKey, | 1913 GetWidget()->SetNativeWindowProperty(Profile::kProfileKey, |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2542 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { | 2545 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { |
2543 gfx::Point icon_bottom( | 2546 gfx::Point icon_bottom( |
2544 toolbar_->location_bar()->GetLocationBarAnchorPoint()); | 2547 toolbar_->location_bar()->GetLocationBarAnchorPoint()); |
2545 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); | 2548 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); |
2546 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); | 2549 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); |
2547 ConvertPointToTarget(infobar_container_, this, &infobar_top); | 2550 ConvertPointToTarget(infobar_container_, this, &infobar_top); |
2548 top_arrow_height = infobar_top.y() - icon_bottom.y(); | 2551 top_arrow_height = infobar_top.y() - icon_bottom.y(); |
2549 } | 2552 } |
2550 return top_arrow_height; | 2553 return top_arrow_height; |
2551 } | 2554 } |
OLD | NEW |