| 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/gtk/browser_window_gtk.h" |     5 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 
|     6  |     6  | 
|     7 #include <gdk/gdkkeysyms.h> |     7 #include <gdk/gdkkeysyms.h> | 
|     8  |     8  | 
|     9 #include <algorithm> |     9 #include <algorithm> | 
|    10 #include <string> |    10 #include <string> | 
| (...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1209   TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::ActiveTabChanged"); |  1209   TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::ActiveTabChanged"); | 
|  1210   if (old_contents && !old_contents->IsBeingDestroyed()) |  1210   if (old_contents && !old_contents->IsBeingDestroyed()) | 
|  1211     old_contents->GetView()->StoreFocus(); |  1211     old_contents->GetView()->StoreFocus(); | 
|  1212  |  1212  | 
|  1213   // Update various elements that are interested in knowing the current |  1213   // Update various elements that are interested in knowing the current | 
|  1214   // WebContents. |  1214   // WebContents. | 
|  1215   UpdateDevToolsForContents(new_contents); |  1215   UpdateDevToolsForContents(new_contents); | 
|  1216   InfoBarTabHelper* new_infobar_tab_helper = |  1216   InfoBarTabHelper* new_infobar_tab_helper = | 
|  1217       InfoBarTabHelper::FromWebContents(new_contents); |  1217       InfoBarTabHelper::FromWebContents(new_contents); | 
|  1218   infobar_container_->ChangeTabContents(new_infobar_tab_helper); |  1218   infobar_container_->ChangeTabContents(new_infobar_tab_helper); | 
|  1219   contents_container_->SetTab(TabContents::FromWebContents(new_contents)); |  1219   contents_container_->SetTab(new_contents); | 
|  1220  |  1220  | 
|  1221   // TODO(estade): after we manage browser activation, add a check to make sure |  1221   // TODO(estade): after we manage browser activation, add a check to make sure | 
|  1222   // we are the active browser before calling RestoreFocus(). |  1222   // we are the active browser before calling RestoreFocus(). | 
|  1223   if (!browser_->tab_strip_model()->closing_all()) { |  1223   if (!browser_->tab_strip_model()->closing_all()) { | 
|  1224     new_contents->GetView()->RestoreFocus(); |  1224     new_contents->GetView()->RestoreFocus(); | 
|  1225     FindTabHelper* find_tab_helper = |  1225     FindTabHelper* find_tab_helper = | 
|  1226         FindTabHelper::FromWebContents(new_contents); |  1226         FindTabHelper::FromWebContents(new_contents); | 
|  1227     if (find_tab_helper->find_ui_active()) |  1227     if (find_tab_helper->find_ui_active()) | 
|  1228       browser_->GetFindBarController()->find_bar()->SetFocusAndSelection(); |  1228       browser_->GetFindBarController()->find_bar()->SetFocusAndSelection(); | 
|  1229   } |  1229   } | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1275     // This is a views specific call that made its way into the interface. We |  1275     // This is a views specific call that made its way into the interface. We | 
|  1276     // go through GetXPositionOfLocationIcon() since we need widget relativity. |  1276     // go through GetXPositionOfLocationIcon() since we need widget relativity. | 
|  1277     *x = 0; |  1277     *x = 0; | 
|  1278     NOTREACHED(); |  1278     NOTREACHED(); | 
|  1279   } |  1279   } | 
|  1280   return true; |  1280   return true; | 
|  1281 } |  1281 } | 
|  1282  |  1282  | 
|  1283 extensions::ActiveTabPermissionGranter* |  1283 extensions::ActiveTabPermissionGranter* | 
|  1284     BrowserWindowGtk::GetActiveTabPermissionGranter() { |  1284     BrowserWindowGtk::GetActiveTabPermissionGranter() { | 
|  1285   TabContents* tab = GetDisplayedTab(); |  1285   WebContents* tab = GetDisplayedTab(); | 
|  1286   if (!tab) |  1286   if (!tab) | 
|  1287     return NULL; |  1287     return NULL; | 
|  1288   return extensions::TabHelper::FromWebContents(tab->web_contents())-> |  1288   return extensions::TabHelper::FromWebContents(tab)-> | 
|  1289       active_tab_permission_granter(); |  1289       active_tab_permission_granter(); | 
|  1290 } |  1290 } | 
|  1291  |  1291  | 
|  1292 void BrowserWindowGtk::DestroyBrowser() { |  1292 void BrowserWindowGtk::DestroyBrowser() { | 
|  1293   browser_.reset(); |  1293   browser_.reset(); | 
|  1294 } |  1294 } | 
|  1295  |  1295  | 
|  1296 gboolean BrowserWindowGtk::OnConfigure(GtkWidget* widget, |  1296 gboolean BrowserWindowGtk::OnConfigure(GtkWidget* widget, | 
|  1297                                        GdkEventConfigure* event) { |  1297                                        GdkEventConfigure* event) { | 
|  1298   gfx::Rect bounds(event->x, event->y, event->width, event->height); |  1298   gfx::Rect bounds(event->x, event->y, event->width, event->height); | 
|  1299  |  1299  | 
|  1300   // When the window moves, we'll get multiple configure-event signals. We can |  1300   // When the window moves, we'll get multiple configure-event signals. We can | 
|  1301   // also get events when the bounds haven't changed, but the window's stacking |  1301   // also get events when the bounds haven't changed, but the window's stacking | 
|  1302   // has, which we aren't interested in. http://crbug.com/70125 |  1302   // has, which we aren't interested in. http://crbug.com/70125 | 
|  1303   if (bounds == configure_bounds_) |  1303   if (bounds == configure_bounds_) | 
|  1304     return FALSE; |  1304     return FALSE; | 
|  1305  |  1305  | 
|  1306   GetLocationBar()->GetLocationEntry()->CloseOmniboxPopup(); |  1306   GetLocationBar()->GetLocationEntry()->CloseOmniboxPopup(); | 
|  1307  |  1307  | 
|  1308   TabContents* tab = GetDisplayedTab(); |  1308   WebContents* tab = GetDisplayedTab(); | 
|  1309   if (tab) { |  1309   if (tab) | 
|  1310     tab->web_contents()->GetRenderViewHost()->NotifyMoveOrResizeStarted(); |  1310     tab->GetRenderViewHost()->NotifyMoveOrResizeStarted(); | 
|  1311   } |  | 
|  1312  |  1311  | 
|  1313   if (bounds_.size() != bounds.size()) |  1312   if (bounds_.size() != bounds.size()) | 
|  1314     UpdateWindowShape(bounds.width(), bounds.height()); |  1313     UpdateWindowShape(bounds.width(), bounds.height()); | 
|  1315  |  1314  | 
|  1316   // We update |bounds_| but not |restored_bounds_| here.  The latter needs |  1315   // We update |bounds_| but not |restored_bounds_| here.  The latter needs | 
|  1317   // to be updated conditionally when the window is non-maximized and non- |  1316   // to be updated conditionally when the window is non-maximized and non- | 
|  1318   // fullscreen, but whether those state updates have been processed yet is |  1317   // fullscreen, but whether those state updates have been processed yet is | 
|  1319   // window-manager specific.  We update |restored_bounds_| in the debounced |  1318   // window-manager specific.  We update |restored_bounds_| in the debounced | 
|  1320   // handler below, after the window state has been updated. |  1319   // handler below, after the window state has been updated. | 
|  1321   bounds_ = bounds; |  1320   bounds_ = bounds; | 
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1503   // is the case in Valgrind tests). |  1502   // is the case in Valgrind tests). | 
|  1504   if (ui::XDisplayExists() && |  1503   if (ui::XDisplayExists() && | 
|  1505       !prefs->HasPrefPath(prefs::kUseCustomChromeFrame)) { |  1504       !prefs->HasPrefPath(prefs::kUseCustomChromeFrame)) { | 
|  1506     custom_frame_default = GetCustomFramePrefDefault(); |  1505     custom_frame_default = GetCustomFramePrefDefault(); | 
|  1507   } |  1506   } | 
|  1508   prefs->RegisterBooleanPref(prefs::kUseCustomChromeFrame, |  1507   prefs->RegisterBooleanPref(prefs::kUseCustomChromeFrame, | 
|  1509                              custom_frame_default, |  1508                              custom_frame_default, | 
|  1510                              PrefService::SYNCABLE_PREF); |  1509                              PrefService::SYNCABLE_PREF); | 
|  1511 } |  1510 } | 
|  1512  |  1511  | 
|  1513 TabContents* BrowserWindowGtk::GetDisplayedTab() { |  1512 WebContents* BrowserWindowGtk::GetDisplayedTab() { | 
|  1514   return contents_container_->GetVisibleTab(); |  1513   return contents_container_->GetVisibleTab(); | 
|  1515 } |  1514 } | 
|  1516  |  1515  | 
|  1517 void BrowserWindowGtk::QueueToolbarRedraw() { |  1516 void BrowserWindowGtk::QueueToolbarRedraw() { | 
|  1518   gtk_widget_queue_draw(toolbar_->widget()); |  1517   gtk_widget_queue_draw(toolbar_->widget()); | 
|  1519 } |  1518 } | 
|  1520  |  1519  | 
|  1521 void BrowserWindowGtk::SetGeometryHints() { |  1520 void BrowserWindowGtk::SetGeometryHints() { | 
|  1522   // If we call gtk_window_maximize followed by gtk_window_present, compiz gets |  1521   // If we call gtk_window_maximize followed by gtk_window_present, compiz gets | 
|  1523   // confused and maximizes the window, but doesn't set the |  1522   // confused and maximizes the window, but doesn't set the | 
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1911   } |  1910   } | 
|  1912  |  1911  | 
|  1913   return x; |  1912   return x; | 
|  1914 } |  1913 } | 
|  1915  |  1914  | 
|  1916 void BrowserWindowGtk::MaybeShowBookmarkBar(bool animate) { |  1915 void BrowserWindowGtk::MaybeShowBookmarkBar(bool animate) { | 
|  1917   TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::MaybeShowBookmarkBar"); |  1916   TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::MaybeShowBookmarkBar"); | 
|  1918   if (!IsBookmarkBarSupported()) |  1917   if (!IsBookmarkBarSupported()) | 
|  1919     return; |  1918     return; | 
|  1920  |  1919  | 
|  1921   TabContents* tab = GetDisplayedTab(); |  1920   if (GetDisplayedTab()) | 
|  1922  |  | 
|  1923   if (tab) |  | 
|  1924     bookmark_bar_->SetPageNavigator(browser_.get()); |  1921     bookmark_bar_->SetPageNavigator(browser_.get()); | 
|  1925  |  1922  | 
|  1926   BookmarkBar::State state = browser_->bookmark_bar_state(); |  1923   BookmarkBar::State state = browser_->bookmark_bar_state(); | 
|  1927   if (contents_container_->HasPreview() && state == BookmarkBar::DETACHED) |  1924   if (contents_container_->HasPreview() && state == BookmarkBar::DETACHED) | 
|  1928     state = BookmarkBar::HIDDEN; |  1925     state = BookmarkBar::HIDDEN; | 
|  1929  |  1926  | 
|  1930   toolbar_->UpdateForBookmarkBarVisibility(state == BookmarkBar::DETACHED); |  1927   toolbar_->UpdateForBookmarkBarVisibility(state == BookmarkBar::DETACHED); | 
|  1931   PlaceBookmarkBar(state == BookmarkBar::DETACHED); |  1928   PlaceBookmarkBar(state == BookmarkBar::DETACHED); | 
|  1932   bookmark_bar_->SetBookmarkBarState( |  1929   bookmark_bar_->SetBookmarkBarState( | 
|  1933       state, |  1930       state, | 
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2302   if (devtools_window_ == new_devtools_window && (!new_devtools_window || |  2299   if (devtools_window_ == new_devtools_window && (!new_devtools_window || | 
|  2303         new_devtools_window->dock_side() == devtools_dock_side_)) |  2300         new_devtools_window->dock_side() == devtools_dock_side_)) | 
|  2304     return; |  2301     return; | 
|  2305  |  2302  | 
|  2306   // Replace tab contents. |  2303   // Replace tab contents. | 
|  2307   if (devtools_window_ != new_devtools_window) { |  2304   if (devtools_window_ != new_devtools_window) { | 
|  2308     if (devtools_window_) { |  2305     if (devtools_window_) { | 
|  2309       devtools_container_->DetachTab( |  2306       devtools_container_->DetachTab( | 
|  2310           devtools_window_->tab_contents()->web_contents()); |  2307           devtools_window_->tab_contents()->web_contents()); | 
|  2311     } |  2308     } | 
|  2312     devtools_container_->SetTab( |  2309     devtools_container_->SetTab(new_devtools_window ? | 
|  2313         new_devtools_window ? new_devtools_window->tab_contents() : NULL); |  2310         new_devtools_window->tab_contents()->web_contents() : NULL); | 
|  2314     if (new_devtools_window) { |  2311     if (new_devtools_window) { | 
|  2315       // WebContentsViewGtk::WasShown is not called when tab contents is shown |  2312       // WebContentsViewGtk::WasShown is not called when tab contents is shown | 
|  2316       // by anything other than user selecting a Tab. |  2313       // by anything other than user selecting a Tab. | 
|  2317       // See TabContentsViewViews::OnWindowPosChanged for reference on how it |  2314       // See TabContentsViewViews::OnWindowPosChanged for reference on how it | 
|  2318       // should be implemented. |  2315       // should be implemented. | 
|  2319       new_devtools_window->tab_contents()->web_contents()->WasShown(); |  2316       new_devtools_window->tab_contents()->web_contents()->WasShown(); | 
|  2320     } |  2317     } | 
|  2321   } |  2318   } | 
|  2322  |  2319  | 
|  2323   // Store last used position. |  2320   // Store last used position. | 
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2415           wm_type == ui::WM_OPENBOX || |  2412           wm_type == ui::WM_OPENBOX || | 
|  2416           wm_type == ui::WM_XFWM4); |  2413           wm_type == ui::WM_XFWM4); | 
|  2417 } |  2414 } | 
|  2418  |  2415  | 
|  2419 // static |  2416 // static | 
|  2420 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |  2417 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 
|  2421   BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); |  2418   BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); | 
|  2422   browser_window_gtk->Init(); |  2419   browser_window_gtk->Init(); | 
|  2423   return browser_window_gtk; |  2420   return browser_window_gtk; | 
|  2424 } |  2421 } | 
| OLD | NEW |