Chromium Code Reviews| 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 if (!initialized_) | |
|
sky
2014/04/25 15:32:08
This is subtle enough to warrant a comment.
msw
2014/04/25 15:45:31
Done.
| |
| 1840 return; | |
| 1841 ClientView::OnNativeThemeChanged(theme); | |
| 1842 UserChangedTheme(); | |
| 1843 chrome::MaybeShowInvertBubbleView(this); | |
| 1844 } | |
| 1845 | |
| 1840 /////////////////////////////////////////////////////////////////////////////// | 1846 /////////////////////////////////////////////////////////////////////////////// |
| 1841 // BrowserView, ui::AcceleratorTarget overrides: | 1847 // BrowserView, ui::AcceleratorTarget overrides: |
| 1842 | 1848 |
| 1843 bool BrowserView::AcceleratorPressed(const ui::Accelerator& accelerator) { | 1849 bool BrowserView::AcceleratorPressed(const ui::Accelerator& accelerator) { |
| 1844 #if defined(OS_CHROMEOS) | 1850 #if defined(OS_CHROMEOS) |
| 1845 // If accessibility is enabled, stop speech and return false so that key | 1851 // If accessibility is enabled, stop speech and return false so that key |
| 1846 // combinations involving Search can be used for extra accessibility | 1852 // combinations involving Search can be used for extra accessibility |
| 1847 // functionality. | 1853 // functionality. |
| 1848 if (accelerator.key_code() == ui::VKEY_LWIN && | 1854 if (accelerator.key_code() == ui::VKEY_LWIN && |
| 1849 g_browser_process->local_state()->GetBoolean( | 1855 g_browser_process->local_state()->GetBoolean( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1887 | 1893 |
| 1888 bool BrowserView::DrawInfoBarArrows(int* x) const { | 1894 bool BrowserView::DrawInfoBarArrows(int* x) const { |
| 1889 if (x) { | 1895 if (x) { |
| 1890 gfx::Point anchor(toolbar_->location_bar()->GetLocationBarAnchorPoint()); | 1896 gfx::Point anchor(toolbar_->location_bar()->GetLocationBarAnchorPoint()); |
| 1891 ConvertPointToTarget(toolbar_->location_bar(), this, &anchor); | 1897 ConvertPointToTarget(toolbar_->location_bar(), this, &anchor); |
| 1892 *x = anchor.x(); | 1898 *x = anchor.x(); |
| 1893 } | 1899 } |
| 1894 return true; | 1900 return true; |
| 1895 } | 1901 } |
| 1896 | 1902 |
| 1897 void BrowserView::OnSysColorChange() { | |
| 1898 chrome::MaybeShowInvertBubbleView(this); | |
| 1899 } | |
| 1900 | |
| 1901 void BrowserView::InitViews() { | 1903 void BrowserView::InitViews() { |
| 1902 GetWidget()->AddObserver(this); | 1904 GetWidget()->AddObserver(this); |
| 1903 | 1905 |
| 1904 // Stow a pointer to this object onto the window handle so that we can get at | 1906 // 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. | 1907 // it later when all we have is a native view. |
| 1906 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this); | 1908 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this); |
| 1907 | 1909 |
| 1908 // Stow a pointer to the browser's profile onto the window handle so that we | 1910 // 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. | 1911 // can get it later when all we have is a native view. |
| 1910 GetWidget()->SetNativeWindowProperty(Profile::kProfileKey, | 1912 GetWidget()->SetNativeWindowProperty(Profile::kProfileKey, |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2542 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { | 2544 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { |
| 2543 gfx::Point icon_bottom( | 2545 gfx::Point icon_bottom( |
| 2544 toolbar_->location_bar()->GetLocationBarAnchorPoint()); | 2546 toolbar_->location_bar()->GetLocationBarAnchorPoint()); |
| 2545 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); | 2547 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); |
| 2546 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); | 2548 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); |
| 2547 ConvertPointToTarget(infobar_container_, this, &infobar_top); | 2549 ConvertPointToTarget(infobar_container_, this, &infobar_top); |
| 2548 top_arrow_height = infobar_top.y() - icon_bottom.y(); | 2550 top_arrow_height = infobar_top.y() - icon_bottom.y(); |
| 2549 } | 2551 } |
| 2550 return top_arrow_height; | 2552 return top_arrow_height; |
| 2551 } | 2553 } |
| OLD | NEW |