| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 22 matching lines...) Expand all Loading... |
| 33 #include "chrome/browser/themes/theme_service.h" | 33 #include "chrome/browser/themes/theme_service.h" |
| 34 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 34 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
| 35 #include "chrome/browser/ui/browser.h" | 35 #include "chrome/browser/ui/browser.h" |
| 36 #include "chrome/browser/ui/browser_dialogs.h" | 36 #include "chrome/browser/ui/browser_dialogs.h" |
| 37 #include "chrome/browser/ui/browser_list.h" | 37 #include "chrome/browser/ui/browser_list.h" |
| 38 #include "chrome/browser/ui/browser_window_state.h" | 38 #include "chrome/browser/ui/browser_window_state.h" |
| 39 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 39 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| 40 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" | 40 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" |
| 41 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 41 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 42 #include "chrome/browser/ui/search/search.h" | 42 #include "chrome/browser/ui/search/search.h" |
| 43 #include "chrome/browser/ui/search/search_model.h" |
| 43 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 44 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 44 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 45 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
| 45 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 46 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 46 #include "chrome/browser/ui/view_ids.h" | 47 #include "chrome/browser/ui/view_ids.h" |
| 47 #include "chrome/browser/ui/views/accessibility/invert_bubble_view.h" | 48 #include "chrome/browser/ui/views/accessibility/invert_bubble_view.h" |
| 48 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" | 49 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" |
| 49 #include "chrome/browser/ui/views/avatar_menu_button.h" | 50 #include "chrome/browser/ui/views/avatar_menu_button.h" |
| 50 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | 51 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
| 51 #include "chrome/browser/ui/views/browser_dialogs.h" | 52 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 52 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" | 53 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 DetachableToolbarView::CalculateContentArea(current_state, h_padding, | 236 DetachableToolbarView::CalculateContentArea(current_state, h_padding, |
| 236 v_padding, &rect, &roundness, host_view_); | 237 v_padding, &rect, &roundness, host_view_); |
| 237 DetachableToolbarView::PaintContentAreaBackground(canvas, tp, rect, | 238 DetachableToolbarView::PaintContentAreaBackground(canvas, tp, rect, |
| 238 roundness); | 239 roundness); |
| 239 DetachableToolbarView::PaintContentAreaBorder(canvas, tp, rect, roundness); | 240 DetachableToolbarView::PaintContentAreaBorder(canvas, tp, rect, roundness); |
| 240 if (!toolbar_overlap) | 241 if (!toolbar_overlap) |
| 241 DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_); | 242 DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_); |
| 242 } else { | 243 } else { |
| 243 DetachableToolbarView::PaintBackgroundAttachedMode(canvas, host_view_, | 244 DetachableToolbarView::PaintBackgroundAttachedMode(canvas, host_view_, |
| 244 browser_view_->OffsetPointForToolbarBackgroundImage( | 245 browser_view_->OffsetPointForToolbarBackgroundImage( |
| 245 gfx::Point(host_view_->GetMirroredX(), host_view_->y()))); | 246 gfx::Point(host_view_->GetMirroredX(), host_view_->y())), |
| 247 browser_view_->GetToolbarBackgroundColor( |
| 248 browser_view_->browser()->search_model()->mode().mode), |
| 249 browser_view_->GetToolbarBackgroundImage( |
| 250 browser_view_->browser()->search_model()->mode().mode)); |
| 246 if (host_view_->height() >= toolbar_overlap) | 251 if (host_view_->height() >= toolbar_overlap) |
| 247 DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_); | 252 DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_); |
| 248 } | 253 } |
| 249 } | 254 } |
| 250 | 255 |
| 251 /////////////////////////////////////////////////////////////////////////////// | 256 /////////////////////////////////////////////////////////////////////////////// |
| 252 // ResizeCorner, private: | 257 // ResizeCorner, private: |
| 253 | 258 |
| 254 class ResizeCorner : public views::View { | 259 class ResizeCorner : public views::View { |
| 255 public: | 260 public: |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 // haven't changed contents_container_ won't get a Layout out and we'll end up | 854 // haven't changed contents_container_ won't get a Layout out and we'll end up |
| 850 // with a gray rect because the clip wasn't updated. Note that a reentrant | 855 // with a gray rect because the clip wasn't updated. Note that a reentrant |
| 851 // call never needs to do this, because after it returns, the normal call | 856 // call never needs to do this, because after it returns, the normal call |
| 852 // wrapping it will do it. | 857 // wrapping it will do it. |
| 853 if ((call_state == NORMAL) && !is_animating) { | 858 if ((call_state == NORMAL) && !is_animating) { |
| 854 contents_container_->InvalidateLayout(); | 859 contents_container_->InvalidateLayout(); |
| 855 contents_split_->Layout(); | 860 contents_split_->Layout(); |
| 856 } | 861 } |
| 857 } | 862 } |
| 858 | 863 |
| 864 SkColor BrowserView::GetToolbarBackgroundColor( |
| 865 chrome::search::Mode::Type mode) { |
| 866 ui::ThemeProvider* theme_provider = GetThemeProvider(); |
| 867 DCHECK(theme_provider); |
| 868 |
| 869 if (!chrome::search::IsInstantExtendedAPIEnabled(browser()->profile())) |
| 870 return theme_provider->GetColor(ThemeService::COLOR_TOOLBAR); |
| 871 |
| 872 switch (mode) { |
| 873 case chrome::search::Mode::MODE_NTP: |
| 874 return theme_provider->GetColor( |
| 875 ThemeService::COLOR_SEARCH_NTP_BACKGROUND); |
| 876 |
| 877 case chrome::search::Mode::MODE_SEARCH: |
| 878 return theme_provider->GetColor( |
| 879 ThemeService::COLOR_SEARCH_SEARCH_BACKGROUND); |
| 880 |
| 881 case chrome::search::Mode::MODE_DEFAULT: |
| 882 default: |
| 883 return theme_provider->GetColor( |
| 884 ThemeService::COLOR_SEARCH_DEFAULT_BACKGROUND); |
| 885 } |
| 886 } |
| 887 |
| 888 gfx::ImageSkia* BrowserView::GetToolbarBackgroundImage( |
| 889 chrome::search::Mode::Type mode) { |
| 890 ui::ThemeProvider* theme_provider = GetThemeProvider(); |
| 891 DCHECK(theme_provider); |
| 892 if (!chrome::search::IsInstantExtendedAPIEnabled(browser()->profile())) |
| 893 return theme_provider->GetImageSkiaNamed(IDR_THEME_TOOLBAR); |
| 894 |
| 895 switch (mode) { |
| 896 case chrome::search::Mode::MODE_NTP: |
| 897 return theme_provider->GetImageSkiaNamed(IDR_THEME_NTP_BACKGROUND); |
| 898 |
| 899 case chrome::search::Mode::MODE_SEARCH: |
| 900 case chrome::search::Mode::MODE_DEFAULT: |
| 901 default: |
| 902 return theme_provider->GetImageSkiaNamed(IDR_THEME_TOOLBAR_SEARCH); |
| 903 } |
| 904 } |
| 905 |
| 859 LocationBar* BrowserView::GetLocationBar() const { | 906 LocationBar* BrowserView::GetLocationBar() const { |
| 860 return GetLocationBarView(); | 907 return GetLocationBarView(); |
| 861 } | 908 } |
| 862 | 909 |
| 863 void BrowserView::SetFocusToLocationBar(bool select_all) { | 910 void BrowserView::SetFocusToLocationBar(bool select_all) { |
| 864 #if defined(OS_WIN) | 911 #if defined(OS_WIN) |
| 865 // On Windows changing focus to the location bar causes the browser window | 912 // On Windows changing focus to the location bar causes the browser window |
| 866 // to become active. This can steal focus if the user has another window | 913 // to become active. This can steal focus if the user has another window |
| 867 // open already. | 914 // open already. |
| 868 if (!force_location_bar_focus_ && !IsActive()) | 915 if (!force_location_bar_focus_ && !IsActive()) |
| (...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1852 switches::kDisableHangMonitor)) { | 1899 switches::kDisableHangMonitor)) { |
| 1853 InitHangMonitor(); | 1900 InitHangMonitor(); |
| 1854 } | 1901 } |
| 1855 | 1902 |
| 1856 LoadAccelerators(); | 1903 LoadAccelerators(); |
| 1857 | 1904 |
| 1858 // TabStrip takes ownership of the controller. | 1905 // TabStrip takes ownership of the controller. |
| 1859 BrowserTabStripController* tabstrip_controller = | 1906 BrowserTabStripController* tabstrip_controller = |
| 1860 new BrowserTabStripController(browser_.get(), | 1907 new BrowserTabStripController(browser_.get(), |
| 1861 browser_->tab_strip_model()); | 1908 browser_->tab_strip_model()); |
| 1862 tabstrip_ = new TabStrip(tabstrip_controller); | 1909 tabstrip_ = new TabStrip(tabstrip_controller, |
| 1910 chrome::search::IsInstantExtendedAPIEnabled( |
| 1911 browser_->profile())); |
| 1863 AddChildView(tabstrip_); | 1912 AddChildView(tabstrip_); |
| 1864 tabstrip_controller->InitFromModel(tabstrip_); | 1913 tabstrip_controller->InitFromModel(tabstrip_); |
| 1865 | 1914 |
| 1866 infobar_container_ = new InfoBarContainerView(this); | 1915 infobar_container_ = new InfoBarContainerView(this); |
| 1867 AddChildView(infobar_container_); | 1916 AddChildView(infobar_container_); |
| 1868 | 1917 |
| 1869 contents_container_ = new views::WebView(browser_->profile()); | 1918 contents_container_ = new views::WebView(browser_->profile()); |
| 1870 contents_container_->set_id(VIEW_ID_TAB_CONTAINER); | 1919 contents_container_->set_id(VIEW_ID_TAB_CONTAINER); |
| 1871 contents_ = new ContentsContainer(contents_container_); | 1920 contents_ = new ContentsContainer(contents_container_); |
| 1872 | 1921 |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2512 bubble->Show(); | 2561 bubble->Show(); |
| 2513 } | 2562 } |
| 2514 | 2563 |
| 2515 void BrowserView::RestackLocationBarContainer() { | 2564 void BrowserView::RestackLocationBarContainer() { |
| 2516 #if defined(USE_AURA) | 2565 #if defined(USE_AURA) |
| 2517 if (search_view_controller_.get()) | 2566 if (search_view_controller_.get()) |
| 2518 search_view_controller_->StackAtTop(); | 2567 search_view_controller_->StackAtTop(); |
| 2519 #endif | 2568 #endif |
| 2520 toolbar_->location_bar_container()->StackAtTop(); | 2569 toolbar_->location_bar_container()->StackAtTop(); |
| 2521 } | 2570 } |
| OLD | NEW |