Chromium Code Reviews| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 const int kMinContentsSize = 50; | 152 const int kMinContentsSize = 50; |
| 153 | 153 |
| 154 // The number of milliseconds between loading animation frames. | 154 // The number of milliseconds between loading animation frames. |
| 155 const int kLoadingAnimationFrameTimeMs = 30; | 155 const int kLoadingAnimationFrameTimeMs = 30; |
| 156 // The amount of space we expect the window border to take up. | 156 // The amount of space we expect the window border to take up. |
| 157 const int kWindowBorderWidth = 5; | 157 const int kWindowBorderWidth = 5; |
| 158 | 158 |
| 159 // How round the 'new tab' style bookmarks bar is. | 159 // How round the 'new tab' style bookmarks bar is. |
| 160 const int kNewtabBarRoundness = 5; | 160 const int kNewtabBarRoundness = 5; |
| 161 | 161 |
| 162 #if !defined(USE_AURA) | |
| 163 extern "C" { | |
| 164 // Metro export for switching chrome windows. | |
| 165 typedef void (*FlipFrameWindows)(); | |
| 166 } | |
| 167 #endif | |
| 168 | |
| 162 } // namespace | 169 } // namespace |
| 163 | 170 |
| 164 // Returned from BrowserView::GetClassName. | 171 // Returned from BrowserView::GetClassName. |
| 165 const char BrowserView::kViewClassName[] = "browser/ui/views/BrowserView"; | 172 const char BrowserView::kViewClassName[] = "browser/ui/views/BrowserView"; |
| 166 | 173 |
| 167 /////////////////////////////////////////////////////////////////////////////// | 174 /////////////////////////////////////////////////////////////////////////////// |
| 168 // BookmarkExtensionBackground, private: | 175 // BookmarkExtensionBackground, private: |
| 169 // This object serves as the views::Background object which is used to layout | 176 // This object serves as the views::Background object which is used to layout |
| 170 // and paint the bookmark bar. | 177 // and paint the bookmark bar. |
| 171 class BookmarkExtensionBackground : public views::Background { | 178 class BookmarkExtensionBackground : public views::Background { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 | 305 |
| 299 BrowserView::BrowserView(Browser* browser) | 306 BrowserView::BrowserView(Browser* browser) |
| 300 : views::ClientView(NULL, NULL), | 307 : views::ClientView(NULL, NULL), |
| 301 last_focused_view_storage_id_( | 308 last_focused_view_storage_id_( |
| 302 views::ViewStorage::GetInstance()->CreateStorageID()), | 309 views::ViewStorage::GetInstance()->CreateStorageID()), |
| 303 frame_(NULL), | 310 frame_(NULL), |
| 304 browser_(browser), | 311 browser_(browser), |
| 305 active_bookmark_bar_(NULL), | 312 active_bookmark_bar_(NULL), |
| 306 tabstrip_(NULL), | 313 tabstrip_(NULL), |
| 307 toolbar_(NULL), | 314 toolbar_(NULL), |
| 315 window_switcher_button_(NULL), | |
| 308 infobar_container_(NULL), | 316 infobar_container_(NULL), |
| 309 contents_container_(NULL), | 317 contents_container_(NULL), |
| 310 devtools_container_(NULL), | 318 devtools_container_(NULL), |
| 311 preview_container_(NULL), | 319 preview_container_(NULL), |
| 312 contents_(NULL), | 320 contents_(NULL), |
| 313 contents_split_(NULL), | 321 contents_split_(NULL), |
| 314 devtools_dock_side_(DEVTOOLS_DOCK_SIDE_BOTTOM), | 322 devtools_dock_side_(DEVTOOLS_DOCK_SIDE_BOTTOM), |
| 315 initialized_(false), | 323 initialized_(false), |
| 316 ignore_layout_(true), | 324 ignore_layout_(true), |
| 317 #if defined(OS_WIN) && !defined(USE_AURA) | 325 #if defined(OS_WIN) && !defined(USE_AURA) |
| (...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1679 /////////////////////////////////////////////////////////////////////////////// | 1687 /////////////////////////////////////////////////////////////////////////////// |
| 1680 // BrowserView, views::View overrides: | 1688 // BrowserView, views::View overrides: |
| 1681 | 1689 |
| 1682 std::string BrowserView::GetClassName() const { | 1690 std::string BrowserView::GetClassName() const { |
| 1683 return kViewClassName; | 1691 return kViewClassName; |
| 1684 } | 1692 } |
| 1685 | 1693 |
| 1686 void BrowserView::Layout() { | 1694 void BrowserView::Layout() { |
| 1687 if (ignore_layout_) | 1695 if (ignore_layout_) |
| 1688 return; | 1696 return; |
| 1697 | |
| 1689 views::View::Layout(); | 1698 views::View::Layout(); |
| 1690 | 1699 |
| 1691 // The status bubble position requires that all other layout finish first. | 1700 // The status bubble position requires that all other layout finish first. |
| 1692 LayoutStatusBubble(); | 1701 LayoutStatusBubble(); |
| 1693 } | 1702 } |
| 1694 | 1703 |
| 1695 void BrowserView::PaintChildren(gfx::Canvas* canvas) { | 1704 void BrowserView::PaintChildren(gfx::Canvas* canvas) { |
| 1696 // Paint the |infobar_container_| last so that it may paint its | 1705 // Paint the |infobar_container_| last so that it may paint its |
| 1697 // overlapping tabs. | 1706 // overlapping tabs. |
| 1698 for (int i = 0; i < child_count(); ++i) { | 1707 for (int i = 0; i < child_count(); ++i) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1745 } | 1754 } |
| 1746 | 1755 |
| 1747 bool BrowserView::SplitHandleMoved(views::SingleSplitView* sender) { | 1756 bool BrowserView::SplitHandleMoved(views::SingleSplitView* sender) { |
| 1748 for (int i = 0; i < sender->child_count(); ++i) | 1757 for (int i = 0; i < sender->child_count(); ++i) |
| 1749 sender->child_at(i)->InvalidateLayout(); | 1758 sender->child_at(i)->InvalidateLayout(); |
| 1750 SchedulePaint(); | 1759 SchedulePaint(); |
| 1751 Layout(); | 1760 Layout(); |
| 1752 return false; | 1761 return false; |
| 1753 } | 1762 } |
| 1754 | 1763 |
| 1764 void BrowserView::ButtonPressed(views::Button* sender, | |
|
sky
2012/05/16 04:31:37
Can you move all of this code, save window_switche
| |
| 1765 const views::Event& event) { | |
| 1766 if (sender != window_switcher_button_) | |
| 1767 return; | |
| 1768 // Tellt the metro_driver to flip our window. This causes the current | |
| 1769 // browser window to be hidden and the next window to be shown. | |
| 1770 static FlipFrameWindows flip_window_fn = reinterpret_cast<FlipFrameWindows>( | |
| 1771 ::GetProcAddress(base::win::GetMetroModule(), "FlipFrameWindows")); | |
| 1772 if (flip_window_fn) | |
| 1773 flip_window_fn(); | |
| 1774 } | |
| 1775 | |
| 1755 void BrowserView::OnSysColorChange() { | 1776 void BrowserView::OnSysColorChange() { |
| 1756 InvertBubble::MaybeShowInvertBubble(browser_->profile(), contents_); | 1777 InvertBubble::MaybeShowInvertBubble(browser_->profile(), contents_); |
| 1757 } | 1778 } |
| 1758 | 1779 |
| 1759 views::LayoutManager* BrowserView::CreateLayoutManager() const { | 1780 views::LayoutManager* BrowserView::CreateLayoutManager() const { |
| 1760 return new BrowserViewLayout; | 1781 return new BrowserViewLayout; |
| 1761 } | 1782 } |
| 1762 | 1783 |
| 1763 ToolbarView* BrowserView::CreateToolbar() const { | 1784 ToolbarView* BrowserView::CreateToolbar() const { |
| 1764 return new ToolbarView(browser_.get()); | 1785 return new ToolbarView(browser_.get()); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 1787 LoadAccelerators(); | 1808 LoadAccelerators(); |
| 1788 | 1809 |
| 1789 // TabStrip takes ownership of the controller. | 1810 // TabStrip takes ownership of the controller. |
| 1790 BrowserTabStripController* tabstrip_controller = | 1811 BrowserTabStripController* tabstrip_controller = |
| 1791 new BrowserTabStripController(browser_.get(), | 1812 new BrowserTabStripController(browser_.get(), |
| 1792 browser_->tab_strip_model()); | 1813 browser_->tab_strip_model()); |
| 1793 tabstrip_ = new TabStrip(tabstrip_controller); | 1814 tabstrip_ = new TabStrip(tabstrip_controller); |
| 1794 AddChildView(tabstrip_); | 1815 AddChildView(tabstrip_); |
| 1795 tabstrip_controller->InitFromModel(tabstrip_); | 1816 tabstrip_controller->InitFromModel(tabstrip_); |
| 1796 | 1817 |
| 1818 if (!base::win::GetMetroModule()) { | |
| 1819 window_switcher_button_ = new views::ImageButton(this); | |
| 1820 window_switcher_button_->SetImage( | |
| 1821 views::ImageButton::BS_NORMAL, | |
| 1822 ui::ResourceBundle::GetSharedInstance().GetBitmapNamed( | |
| 1823 IDR_PAGEINFO_WARNING_MINOR)); | |
|
cpu_(ooo_6.6-7.5)
2012/05/16 01:31:37
the asset is a placeholder
| |
| 1824 window_switcher_button_->SetImageAlignment( | |
| 1825 views::ImageButton::ALIGN_CENTER, | |
| 1826 views::ImageButton::ALIGN_MIDDLE); | |
| 1827 gfx::Size ps = window_switcher_button_->GetPreferredSize(); | |
| 1828 window_switcher_button_->SetBounds(0,0, ps.width(), ps.height()); | |
| 1829 window_switcher_button_->SetVisible(true); | |
| 1830 AddChildView(window_switcher_button_); | |
| 1831 } | |
| 1832 | |
| 1797 SetToolbar(CreateToolbar()); | 1833 SetToolbar(CreateToolbar()); |
| 1798 | 1834 |
| 1799 infobar_container_ = new InfoBarContainerView(this); | 1835 infobar_container_ = new InfoBarContainerView(this); |
| 1800 AddChildView(infobar_container_); | 1836 AddChildView(infobar_container_); |
| 1801 | 1837 |
| 1802 contents_container_ = new views::WebView(browser_->profile()); | 1838 contents_container_ = new views::WebView(browser_->profile()); |
| 1803 contents_container_->set_id(VIEW_ID_TAB_CONTAINER); | 1839 contents_container_->set_id(VIEW_ID_TAB_CONTAINER); |
| 1804 contents_ = new ContentsContainer(contents_container_); | 1840 contents_ = new ContentsContainer(contents_container_); |
| 1805 | 1841 |
| 1806 SkColor bg_color = GetWidget()->GetThemeProvider()-> | 1842 SkColor bg_color = GetWidget()->GetThemeProvider()-> |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2405 return; | 2441 return; |
| 2406 | 2442 |
| 2407 PasswordGenerationBubbleView* bubble = | 2443 PasswordGenerationBubbleView* bubble = |
| 2408 new PasswordGenerationBubbleView(bounds, | 2444 new PasswordGenerationBubbleView(bounds, |
| 2409 this, | 2445 this, |
| 2410 web_contents->GetRenderViewHost()); | 2446 web_contents->GetRenderViewHost()); |
| 2411 views::BubbleDelegateView::CreateBubble(bubble); | 2447 views::BubbleDelegateView::CreateBubble(bubble); |
| 2412 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | 2448 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
| 2413 bubble->Show(); | 2449 bubble->Show(); |
| 2414 } | 2450 } |
| OLD | NEW |