| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/frame/browser_view.h" | 5 #include "chrome/browser/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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 #include "grit/webkit_resources.h" | 75 #include "grit/webkit_resources.h" |
| 76 #include "views/controls/single_split_view.h" | 76 #include "views/controls/single_split_view.h" |
| 77 #include "views/focus/external_focus_tracker.h" | 77 #include "views/focus/external_focus_tracker.h" |
| 78 #include "views/focus/view_storage.h" | 78 #include "views/focus/view_storage.h" |
| 79 #include "views/grid_layout.h" | 79 #include "views/grid_layout.h" |
| 80 #include "views/widget/root_view.h" | 80 #include "views/widget/root_view.h" |
| 81 #include "views/window/dialog_delegate.h" | 81 #include "views/window/dialog_delegate.h" |
| 82 #include "views/window/window.h" | 82 #include "views/window/window.h" |
| 83 | 83 |
| 84 #if defined(OS_WIN) | 84 #if defined(OS_WIN) |
| 85 #include "app/view_prop.h" |
| 85 #include "app/win_util.h" | 86 #include "app/win_util.h" |
| 86 #include "chrome/browser/aeropeek_manager.h" | 87 #include "chrome/browser/aeropeek_manager.h" |
| 87 #include "chrome/browser/jumplist_win.h" | 88 #include "chrome/browser/jumplist_win.h" |
| 88 #elif defined(OS_LINUX) | 89 #elif defined(OS_LINUX) |
| 89 #include "chrome/browser/views/accelerator_table_gtk.h" | 90 #include "chrome/browser/views/accelerator_table_gtk.h" |
| 90 #include "views/window/hit_test.h" | 91 #include "views/window/hit_test.h" |
| 91 #include "views/window/window_gtk.h" | 92 #include "views/window/window_gtk.h" |
| 92 #endif | 93 #endif |
| 93 | 94 |
| 94 using base::TimeDelta; | 95 using base::TimeDelta; |
| 95 using views::ColumnSet; | 96 using views::ColumnSet; |
| 96 using views::GridLayout; | 97 using views::GridLayout; |
| 97 | 98 |
| 98 // The height of the status bubble. | 99 // The height of the status bubble. |
| 99 static const int kStatusBubbleHeight = 20; | 100 static const int kStatusBubbleHeight = 20; |
| 100 // The name of a key to store on the window handle so that other code can | 101 // The name of a key to store on the window handle so that other code can |
| 101 // locate this object using just the handle. | 102 // locate this object using just the handle. |
| 102 #if defined(OS_WIN) | 103 static const char* const kBrowserViewKey = "__BROWSER_VIEW__"; |
| 103 static const wchar_t* kBrowserViewKey = L"__BROWSER_VIEW__"; | |
| 104 #else | |
| 105 static const char* kBrowserViewKey = "__BROWSER_VIEW__"; | |
| 106 #endif | |
| 107 // How frequently we check for hung plugin windows. | 104 // How frequently we check for hung plugin windows. |
| 108 static const int kDefaultHungPluginDetectFrequency = 2000; | 105 static const int kDefaultHungPluginDetectFrequency = 2000; |
| 109 // How long do we wait before we consider a window hung (in ms). | 106 // How long do we wait before we consider a window hung (in ms). |
| 110 static const int kDefaultPluginMessageResponseTimeout = 30000; | 107 static const int kDefaultPluginMessageResponseTimeout = 30000; |
| 111 // The number of milliseconds between loading animation frames. | 108 // The number of milliseconds between loading animation frames. |
| 112 static const int kLoadingAnimationFrameTimeMs = 30; | 109 static const int kLoadingAnimationFrameTimeMs = 30; |
| 113 // The amount of space we expect the window border to take up. | 110 // The amount of space we expect the window border to take up. |
| 114 static const int kWindowBorderWidth = 5; | 111 static const int kWindowBorderWidth = 5; |
| 115 | 112 |
| 116 // If not -1, windows are shown with this state. | 113 // If not -1, windows are shown with this state. |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 | 476 |
| 480 // Explicitly set browser_ to NULL. | 477 // Explicitly set browser_ to NULL. |
| 481 browser_.reset(); | 478 browser_.reset(); |
| 482 } | 479 } |
| 483 | 480 |
| 484 // static | 481 // static |
| 485 BrowserView* BrowserView::GetBrowserViewForNativeWindow( | 482 BrowserView* BrowserView::GetBrowserViewForNativeWindow( |
| 486 gfx::NativeWindow window) { | 483 gfx::NativeWindow window) { |
| 487 #if defined(OS_WIN) | 484 #if defined(OS_WIN) |
| 488 if (IsWindow(window)) { | 485 if (IsWindow(window)) { |
| 489 HANDLE data = GetProp(window, kBrowserViewKey); | 486 return reinterpret_cast<BrowserView*>( |
| 490 if (data) | 487 app::ViewProp::GetValue(window, kBrowserViewKey)); |
| 491 return reinterpret_cast<BrowserView*>(data); | |
| 492 } | 488 } |
| 493 #else | 489 #else |
| 494 if (window) { | 490 if (window) { |
| 495 return static_cast<BrowserView*>( | 491 return static_cast<BrowserView*>( |
| 496 g_object_get_data(G_OBJECT(window), kBrowserViewKey)); | 492 g_object_get_data(G_OBJECT(window), kBrowserViewKey)); |
| 497 } | 493 } |
| 498 #endif | 494 #endif |
| 499 return NULL; | 495 return NULL; |
| 500 } | 496 } |
| 501 | 497 |
| (...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1882 /////////////////////////////////////////////////////////////////////////////// | 1878 /////////////////////////////////////////////////////////////////////////////// |
| 1883 // BrowserView, private: | 1879 // BrowserView, private: |
| 1884 | 1880 |
| 1885 void BrowserView::Init() { | 1881 void BrowserView::Init() { |
| 1886 accessible_view_helper_.reset(new AccessibleViewHelper( | 1882 accessible_view_helper_.reset(new AccessibleViewHelper( |
| 1887 this, browser_->profile())); | 1883 this, browser_->profile())); |
| 1888 | 1884 |
| 1889 SetLayoutManager(CreateLayoutManager()); | 1885 SetLayoutManager(CreateLayoutManager()); |
| 1890 // Stow a pointer to this object onto the window handle so that we can get | 1886 // Stow a pointer to this object onto the window handle so that we can get |
| 1891 // at it later when all we have is a native view. | 1887 // at it later when all we have is a native view. |
| 1892 #if defined(OS_WIN) | |
| 1893 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this); | 1888 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this); |
| 1894 #else | |
| 1895 g_object_set_data(G_OBJECT(GetWidget()->GetNativeView()), | |
| 1896 kBrowserViewKey, this); | |
| 1897 #endif | |
| 1898 | 1889 |
| 1899 // Start a hung plugin window detector for this browser object (as long as | 1890 // Start a hung plugin window detector for this browser object (as long as |
| 1900 // hang detection is not disabled). | 1891 // hang detection is not disabled). |
| 1901 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 1892 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 1902 switches::kDisableHangMonitor)) { | 1893 switches::kDisableHangMonitor)) { |
| 1903 InitHangMonitor(); | 1894 InitHangMonitor(); |
| 1904 } | 1895 } |
| 1905 | 1896 |
| 1906 LoadAccelerators(); | 1897 LoadAccelerators(); |
| 1907 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); | 1898 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2513 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); | 2504 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); |
| 2514 | 2505 |
| 2515 return view; | 2506 return view; |
| 2516 } | 2507 } |
| 2517 #endif | 2508 #endif |
| 2518 | 2509 |
| 2519 // static | 2510 // static |
| 2520 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2511 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
| 2521 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2512 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
| 2522 } | 2513 } |
| OLD | NEW |