Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(858)

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 6577003: Entire DOMBrowser stack (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #if defined(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 #if defined(OS_CHROMEOS) 98 #if defined(OS_CHROMEOS)
99 #include "chrome/browser/ui/views/keyboard_overlay_delegate.h" 99 #include "chrome/browser/ui/views/keyboard_overlay_delegate.h"
100 #endif 100 #endif
101 101
102 using base::TimeDelta; 102 using base::TimeDelta;
103 using views::ColumnSet; 103 using views::ColumnSet;
104 using views::GridLayout; 104 using views::GridLayout;
105 105
106 // The height of the status bubble. 106 // The height of the status bubble.
107 static const int kStatusBubbleHeight = 20; 107 static const int kStatusBubbleHeight = 20;
108 // The name of a key to store on the window handle so that other code can
109 // locate this object using just the handle.
110 static const char* const kBrowserViewKey = "__BROWSER_VIEW__";
111 // How frequently we check for hung plugin windows. 108 // How frequently we check for hung plugin windows.
112 static const int kDefaultHungPluginDetectFrequency = 2000; 109 static const int kDefaultHungPluginDetectFrequency = 2000;
113 // How long do we wait before we consider a window hung (in ms). 110 // How long do we wait before we consider a window hung (in ms).
114 static const int kDefaultPluginMessageResponseTimeout = 30000; 111 static const int kDefaultPluginMessageResponseTimeout = 30000;
115 // The number of milliseconds between loading animation frames. 112 // The number of milliseconds between loading animation frames.
116 static const int kLoadingAnimationFrameTimeMs = 30; 113 static const int kLoadingAnimationFrameTimeMs = 30;
117 // The amount of space we expect the window border to take up. 114 // The amount of space we expect the window border to take up.
118 static const int kWindowBorderWidth = 5; 115 static const int kWindowBorderWidth = 5;
119 116
120 // If not -1, windows are shown with this state. 117 // If not -1, windows are shown with this state.
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 contents_(NULL), 440 contents_(NULL),
444 contents_split_(NULL), 441 contents_split_(NULL),
445 initialized_(false), 442 initialized_(false),
446 ignore_layout_(true) 443 ignore_layout_(true)
447 #if defined(OS_WIN) 444 #if defined(OS_WIN)
448 , hung_window_detector_(&hung_plugin_action_), 445 , hung_window_detector_(&hung_plugin_action_),
449 ticker_(0) 446 ticker_(0)
450 #endif 447 #endif
451 { 448 {
452 browser_->tabstrip_model()->AddObserver(this); 449 browser_->tabstrip_model()->AddObserver(this);
453
454 registrar_.Add(this, 450 registrar_.Add(this,
455 NotificationType::SIDEBAR_CHANGED, 451 NotificationType::SIDEBAR_CHANGED,
456 Source<SidebarManager>(SidebarManager::GetInstance())); 452 Source<SidebarManager>(SidebarManager::GetInstance()));
457 } 453 }
458 454
459 BrowserView::~BrowserView() { 455 BrowserView::~BrowserView() {
460 browser_->tabstrip_model()->RemoveObserver(this); 456 browser_->tabstrip_model()->RemoveObserver(this);
461 457
462 #if defined(OS_WIN) 458 #if defined(OS_WIN)
463 // Remove this observer. 459 // Remove this observer.
464 if (aeropeek_manager_.get()) 460 if (aeropeek_manager_.get())
465 browser_->tabstrip_model()->RemoveObserver(aeropeek_manager_.get()); 461 browser_->tabstrip_model()->RemoveObserver(aeropeek_manager_.get());
466 462
467 // Stop hung plugin monitoring. 463 // Stop hung plugin monitoring.
468 ticker_.Stop(); 464 ticker_.Stop();
469 ticker_.UnregisterTickHandler(&hung_window_detector_); 465 ticker_.UnregisterTickHandler(&hung_window_detector_);
470 #endif 466 #endif
471 467
472 // We destroy the download shelf before |browser_| to remove its child 468 // We destroy the download shelf before |browser_| to remove its child
473 // download views from the set of download observers (since the observed 469 // download views from the set of download observers (since the observed
474 // downloads can be destroyed along with |browser_| and the observer 470 // downloads can be destroyed along with |browser_| and the observer
475 // notifications will call back into deleted objects). 471 // notifications will call back into deleted objects).
476 download_shelf_.reset(); 472 download_shelf_.reset();
477 473
478 // The TabStrip attaches a listener to the model. Make sure we shut down the 474 // The TabStrip attaches a listener to the model. Make sure we shut down the
479 // TabStrip first so that it can cleanly remove the listener. 475 // TabStrip first so that it can cleanly remove the listener.
480 tabstrip_->parent()->RemoveChildView(tabstrip_); 476 if(tabstrip_) {
481 delete tabstrip_; 477 tabstrip_->parent()->RemoveChildView(tabstrip_);
482 tabstrip_ = NULL; 478 delete tabstrip_;
483 479 tabstrip_ = NULL;
480 }
484 // Child views maintain PrefMember attributes that point to 481 // Child views maintain PrefMember attributes that point to
485 // OffTheRecordProfile's PrefService which gets deleted by ~Browser. 482 // OffTheRecordProfile's PrefService which gets deleted by ~Browser.
486 RemoveAllChildViews(true); 483 RemoveAllChildViews(true);
487 // Explicitly set browser_ to NULL. 484 // Explicitly set browser_ to NULL.
488 browser_.reset(); 485 browser_.reset();
489 } 486 }
490 487
491 // static 488 // static
492 BrowserView* BrowserView::GetBrowserViewForNativeWindow( 489 BrowserView* BrowserView::GetBrowserViewForNativeWindow(
493 gfx::NativeWindow window) { 490 gfx::NativeWindow window) {
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 set_window(window); 1684 set_window(window);
1688 return this; 1685 return this;
1689 } 1686 }
1690 1687
1691 /////////////////////////////////////////////////////////////////////////////// 1688 ///////////////////////////////////////////////////////////////////////////////
1692 // BrowserView, views::ClientView overrides: 1689 // BrowserView, views::ClientView overrides:
1693 1690
1694 bool BrowserView::CanClose() { 1691 bool BrowserView::CanClose() {
1695 // You cannot close a frame for which there is an active originating drag 1692 // You cannot close a frame for which there is an active originating drag
1696 // session. 1693 // session.
1697 if (tabstrip_->IsDragSessionActive()) 1694 if (tabstrip_) {
1698 return false; 1695 if (tabstrip_->IsDragSessionActive())
1699 1696 return false;
1697 }
1700 // Give beforeunload handlers the chance to cancel the close before we hide 1698 // Give beforeunload handlers the chance to cancel the close before we hide
1701 // the window below. 1699 // the window below.
1702 if (!browser_->ShouldCloseWindow()) 1700 if (!browser_->ShouldCloseWindow())
1703 return false; 1701 return false;
1704 1702
1705 if (!browser_->tabstrip_model()->empty()) { 1703 if (!browser_->tabstrip_model()->empty()) {
1706 // Tab strip isn't empty. Hide the frame (so it appears to have closed 1704 // Tab strip isn't empty. Hide the frame (so it appears to have closed
1707 // immediately) and close all the tabs, allowing the renderers to shut 1705 // immediately) and close all the tabs, allowing the renderers to shut
1708 // down. When the tab strip is empty we'll be called back again. 1706 // down. When the tab strip is empty we'll be called back again.
1709 frame_->GetWindow()->HideWindow(); 1707 frame_->GetWindow()->HideWindow();
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 new BrowserTabStripController(browser_.get(), model); 1846 new BrowserTabStripController(browser_.get(), model);
1849 1847
1850 tabstrip_ = CreateTabStrip(tabstrip_controller, UseVerticalTabs()); 1848 tabstrip_ = CreateTabStrip(tabstrip_controller, UseVerticalTabs());
1851 1849
1852 tabstrip_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_TABSTRIP)); 1850 tabstrip_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_TABSTRIP));
1853 AddChildView(tabstrip_); 1851 AddChildView(tabstrip_);
1854 1852
1855 tabstrip_controller->InitFromModel(tabstrip_); 1853 tabstrip_controller->InitFromModel(tabstrip_);
1856 } 1854 }
1857 1855
1856 void BrowserView::InitToolbar(Browser* browser) {
1857 toolbar_ = new ToolbarView(browser_.get());
1858 AddChildView(toolbar_);
1859 toolbar_->Init(browser_->profile());
1860 toolbar_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLBAR));
1861 }
1862
1858 /////////////////////////////////////////////////////////////////////////////// 1863 ///////////////////////////////////////////////////////////////////////////////
1859 // BrowserView, private: 1864 // BrowserView, private:
1860 1865
1861 void BrowserView::Init() { 1866 void BrowserView::Init() {
1862 SetLayoutManager(CreateLayoutManager()); 1867 if(!GetLayoutManager())
1868 SetLayoutManager(CreateLayoutManager());
1869
1863 // Stow a pointer to this object onto the window handle so that we can get at 1870 // Stow a pointer to this object onto the window handle so that we can get at
1864 // it later when all we have is a native view. 1871 // it later when all we have is a native view.
1865 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this); 1872 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this);
1866 1873
1867 // Stow a pointer to the browser's profile onto the window handle so that we 1874 // Stow a pointer to the browser's profile onto the window handle so that we
1868 // can get it later when all we have is a native view. 1875 // can get it later when all we have is a native view.
1869 GetWindow()->SetNativeWindowProperty(Profile::kProfileKey, 1876 GetWindow()->SetNativeWindowProperty(Profile::kProfileKey,
1870 browser_->profile()); 1877 browser_->profile());
1871 1878
1872 // Start a hung plugin window detector for this browser object (as long as 1879 // Start a hung plugin window detector for this browser object (as long as
1873 // hang detection is not disabled). 1880 // hang detection is not disabled).
1874 if (!CommandLine::ForCurrentProcess()->HasSwitch( 1881 if (!CommandLine::ForCurrentProcess()->HasSwitch(
1875 switches::kDisableHangMonitor)) { 1882 switches::kDisableHangMonitor)) {
1876 InitHangMonitor(); 1883 InitHangMonitor();
1877 } 1884 }
1878 1885
1879 LoadAccelerators(); 1886 LoadAccelerators();
1880 SetAccessibleName(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 1887 SetAccessibleName(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
1881 1888
1882 InitTabStrip(browser_->tabstrip_model()); 1889 InitTabStrip(browser_->tabstrip_model());
1883 1890
1884 toolbar_ = new ToolbarView(browser_.get()); 1891 InitToolbar(browser_.get());
1885 AddChildView(toolbar_);
1886 toolbar_->Init(browser_->profile());
1887 toolbar_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLBAR));
1888 1892
1889 infobar_container_ = new InfoBarContainer(this); 1893 infobar_container_ = new InfoBarContainer(this);
1890 AddChildView(infobar_container_); 1894 AddChildView(infobar_container_);
1891 1895
1892 contents_container_ = new TabContentsContainer; 1896 contents_container_ = new TabContentsContainer;
1893 contents_ = new ContentsContainer(contents_container_); 1897 contents_ = new ContentsContainer(contents_container_);
1894 1898
1895 SkColor bg_color = GetWidget()->GetThemeProvider()-> 1899 SkColor bg_color = GetWidget()->GetThemeProvider()->
1896 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); 1900 GetColor(BrowserThemeProvider::COLOR_TOOLBAR);
1897 1901
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
2570 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 2574 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
2571 2575
2572 return view; 2576 return view;
2573 } 2577 }
2574 #endif 2578 #endif
2575 2579
2576 // static 2580 // static
2577 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { 2581 FindBar* BrowserWindow::CreateFindBar(Browser* browser) {
2578 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); 2582 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window()));
2579 } 2583 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | chrome/browser/ui/views/frame/browser_view_layout.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698