| OLD | NEW |
| 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/gtk/browser_window_gtk.h" | 5 #include "chrome/browser/gtk/browser_window_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #include "chrome/browser/gtk/repost_form_warning_gtk.h" | 59 #include "chrome/browser/gtk/repost_form_warning_gtk.h" |
| 60 #include "chrome/browser/gtk/status_bubble_gtk.h" | 60 #include "chrome/browser/gtk/status_bubble_gtk.h" |
| 61 #include "chrome/browser/gtk/tab_contents_container_gtk.h" | 61 #include "chrome/browser/gtk/tab_contents_container_gtk.h" |
| 62 #include "chrome/browser/gtk/tabs/tab_strip_gtk.h" | 62 #include "chrome/browser/gtk/tabs/tab_strip_gtk.h" |
| 63 #include "chrome/browser/gtk/task_manager_gtk.h" | 63 #include "chrome/browser/gtk/task_manager_gtk.h" |
| 64 #include "chrome/browser/gtk/theme_install_bubble_view_gtk.h" | 64 #include "chrome/browser/gtk/theme_install_bubble_view_gtk.h" |
| 65 #include "chrome/browser/gtk/update_recommended_dialog.h" | 65 #include "chrome/browser/gtk/update_recommended_dialog.h" |
| 66 #include "chrome/browser/page_info_window.h" | 66 #include "chrome/browser/page_info_window.h" |
| 67 #include "chrome/browser/prefs/pref_service.h" | 67 #include "chrome/browser/prefs/pref_service.h" |
| 68 #include "chrome/browser/profiles/profile.h" | 68 #include "chrome/browser/profiles/profile.h" |
| 69 #include "chrome/browser/profiles/profile_manager.h" |
| 69 #include "chrome/browser/tab_contents/tab_contents.h" | 70 #include "chrome/browser/tab_contents/tab_contents.h" |
| 70 #include "chrome/browser/tab_contents/tab_contents_view.h" | 71 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 71 #include "chrome/browser/tabs/tab_strip_model.h" | 72 #include "chrome/browser/tabs/tab_strip_model.h" |
| 72 #include "chrome/browser/themes/browser_theme_provider.h" | 73 #include "chrome/browser/themes/browser_theme_provider.h" |
| 73 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 74 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
| 74 #include "chrome/browser/ui/browser.h" | 75 #include "chrome/browser/ui/browser.h" |
| 75 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 76 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 76 #include "chrome/browser/ui/omnibox/location_bar.h" | 77 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 77 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 78 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 78 #include "chrome/browser/ui/window_sizer.h" | 79 #include "chrome/browser/ui/window_sizer.h" |
| (...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 devtools_contents->ShowContents(); | 1267 devtools_contents->ShowContents(); |
| 1267 } | 1268 } |
| 1268 | 1269 |
| 1269 bool should_show = old_devtools == NULL && devtools_contents != NULL; | 1270 bool should_show = old_devtools == NULL && devtools_contents != NULL; |
| 1270 bool should_hide = old_devtools != NULL && devtools_contents == NULL; | 1271 bool should_hide = old_devtools != NULL && devtools_contents == NULL; |
| 1271 if (should_show) { | 1272 if (should_show) { |
| 1272 gtk_widget_show(devtools_container_->widget()); | 1273 gtk_widget_show(devtools_container_->widget()); |
| 1273 } else if (should_hide) { | 1274 } else if (should_hide) { |
| 1274 // Store split offset when hiding devtools window only. | 1275 // Store split offset when hiding devtools window only. |
| 1275 gint divider_offset = gtk_paned_get_position(GTK_PANED(contents_split_)); | 1276 gint divider_offset = gtk_paned_get_position(GTK_PANED(contents_split_)); |
| 1276 g_browser_process->local_state()->SetInteger( | 1277 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 1277 prefs::kDevToolsSplitLocation, divider_offset); | 1278 profile_manager->GetDefaultProfile()->GetPrefs()-> |
| 1279 SetInteger(prefs::kDevToolsSplitLocation, divider_offset); |
| 1278 gtk_widget_hide(devtools_container_->widget()); | 1280 gtk_widget_hide(devtools_container_->widget()); |
| 1279 } | 1281 } |
| 1280 } | 1282 } |
| 1281 | 1283 |
| 1282 void BrowserWindowGtk::DestroyBrowser() { | 1284 void BrowserWindowGtk::DestroyBrowser() { |
| 1283 browser_.reset(); | 1285 browser_.reset(); |
| 1284 } | 1286 } |
| 1285 | 1287 |
| 1286 void BrowserWindowGtk::OnBoundsChanged(const gfx::Rect& bounds) { | 1288 void BrowserWindowGtk::OnBoundsChanged(const gfx::Rect& bounds) { |
| 1287 GetLocationBar()->location_entry()->ClosePopup(); | 1289 GetLocationBar()->location_entry()->ClosePopup(); |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1590 contents_container_.reset(new TabContentsContainerGtk(status_bubble_.get())); | 1592 contents_container_.reset(new TabContentsContainerGtk(status_bubble_.get())); |
| 1591 devtools_container_.reset(new TabContentsContainerGtk(NULL)); | 1593 devtools_container_.reset(new TabContentsContainerGtk(NULL)); |
| 1592 ViewIDUtil::SetID(devtools_container_->widget(), VIEW_ID_DEV_TOOLS_DOCKED); | 1594 ViewIDUtil::SetID(devtools_container_->widget(), VIEW_ID_DEV_TOOLS_DOCKED); |
| 1593 contents_split_ = gtk_vpaned_new(); | 1595 contents_split_ = gtk_vpaned_new(); |
| 1594 gtk_paned_pack1(GTK_PANED(contents_split_), contents_container_->widget(), | 1596 gtk_paned_pack1(GTK_PANED(contents_split_), contents_container_->widget(), |
| 1595 TRUE, TRUE); | 1597 TRUE, TRUE); |
| 1596 gtk_paned_pack2(GTK_PANED(contents_split_), devtools_container_->widget(), | 1598 gtk_paned_pack2(GTK_PANED(contents_split_), devtools_container_->widget(), |
| 1597 FALSE, TRUE); | 1599 FALSE, TRUE); |
| 1598 gtk_box_pack_end(GTK_BOX(render_area_vbox_), contents_split_, TRUE, TRUE, 0); | 1600 gtk_box_pack_end(GTK_BOX(render_area_vbox_), contents_split_, TRUE, TRUE, 0); |
| 1599 // Restore split offset. | 1601 // Restore split offset. |
| 1600 int split_offset = g_browser_process->local_state()->GetInteger( | 1602 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 1601 prefs::kDevToolsSplitLocation); | 1603 int split_offset = profile_manager->GetDefaultProfile()->GetPrefs()-> |
| 1604 GetInteger(prefs::kDevToolsSplitLocation); |
| 1602 if (split_offset != -1) { | 1605 if (split_offset != -1) { |
| 1603 if (split_offset < kMinDevToolsHeight) | 1606 if (split_offset < kMinDevToolsHeight) |
| 1604 split_offset = kMinDevToolsHeight; | 1607 split_offset = kMinDevToolsHeight; |
| 1605 gtk_paned_set_position(GTK_PANED(contents_split_), split_offset); | 1608 gtk_paned_set_position(GTK_PANED(contents_split_), split_offset); |
| 1606 } else { | 1609 } else { |
| 1607 gtk_widget_set_size_request(devtools_container_->widget(), -1, | 1610 gtk_widget_set_size_request(devtools_container_->widget(), -1, |
| 1608 kDefaultDevToolsHeight); | 1611 kDefaultDevToolsHeight); |
| 1609 } | 1612 } |
| 1610 gtk_widget_show_all(render_area_floating_container_); | 1613 gtk_widget_show_all(render_area_floating_container_); |
| 1611 gtk_widget_hide(devtools_container_->widget()); | 1614 gtk_widget_hide(devtools_container_->widget()); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1751 } | 1754 } |
| 1752 | 1755 |
| 1753 void BrowserWindowGtk::SaveWindowPosition() { | 1756 void BrowserWindowGtk::SaveWindowPosition() { |
| 1754 // Browser::SaveWindowPlacement is used for session restore. | 1757 // Browser::SaveWindowPlacement is used for session restore. |
| 1755 if (browser_->ShouldSaveWindowPlacement()) | 1758 if (browser_->ShouldSaveWindowPlacement()) |
| 1756 browser_->SaveWindowPlacement(restored_bounds_, IsMaximized()); | 1759 browser_->SaveWindowPlacement(restored_bounds_, IsMaximized()); |
| 1757 | 1760 |
| 1758 // We also need to save the placement for startup. | 1761 // We also need to save the placement for startup. |
| 1759 // This is a web of calls between views and delegates on Windows, but the | 1762 // This is a web of calls between views and delegates on Windows, but the |
| 1760 // crux of the logic follows. See also cocoa/browser_window_controller.mm. | 1763 // crux of the logic follows. See also cocoa/browser_window_controller.mm. |
| 1761 if (!g_browser_process->local_state()) | 1764 if (!g_browser_process->profile_manager()) |
| 1762 return; | 1765 return; |
| 1763 | 1766 |
| 1764 std::string window_name = browser_->GetWindowPlacementKey(); | 1767 std::string window_name = browser_->GetWindowPlacementKey(); |
| 1765 DictionaryValue* window_preferences = | 1768 DictionaryValue* window_preferences = |
| 1766 g_browser_process->local_state()->GetMutableDictionary( | 1769 g_browser_process->profile_manager()->GetDefaultProfile()->GetPrefs()-> |
| 1767 window_name.c_str()); | 1770 GetMutableDictionary(window_name.c_str()); |
| 1768 // Note that we store left/top for consistency with Windows, but that we | 1771 // Note that we store left/top for consistency with Windows, but that we |
| 1769 // *don't* obey them; we only use them for computing width/height. See | 1772 // *don't* obey them; we only use them for computing width/height. See |
| 1770 // comments in SetGeometryHints(). | 1773 // comments in SetGeometryHints(). |
| 1771 window_preferences->SetInteger("left", restored_bounds_.x()); | 1774 window_preferences->SetInteger("left", restored_bounds_.x()); |
| 1772 window_preferences->SetInteger("top", restored_bounds_.y()); | 1775 window_preferences->SetInteger("top", restored_bounds_.y()); |
| 1773 window_preferences->SetInteger("right", restored_bounds_.right()); | 1776 window_preferences->SetInteger("right", restored_bounds_.right()); |
| 1774 window_preferences->SetInteger("bottom", restored_bounds_.bottom()); | 1777 window_preferences->SetInteger("bottom", restored_bounds_.bottom()); |
| 1775 window_preferences->SetBoolean("maximized", IsMaximized()); | 1778 window_preferences->SetBoolean("maximized", IsMaximized()); |
| 1776 | 1779 |
| 1777 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider( | 1780 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider( |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2242 // special-case the ones where the custom frame should be used. These names | 2245 // special-case the ones where the custom frame should be used. These names |
| 2243 // are taken from the WMs' source code. | 2246 // are taken from the WMs' source code. |
| 2244 return (wm_name == "Blackbox" || | 2247 return (wm_name == "Blackbox" || |
| 2245 wm_name == "compiz" || | 2248 wm_name == "compiz" || |
| 2246 wm_name == "e16" || // Enlightenment DR16 | 2249 wm_name == "e16" || // Enlightenment DR16 |
| 2247 wm_name == "Metacity" || | 2250 wm_name == "Metacity" || |
| 2248 wm_name == "Mutter" || | 2251 wm_name == "Mutter" || |
| 2249 wm_name == "Openbox" || | 2252 wm_name == "Openbox" || |
| 2250 wm_name == "Xfwm4"); | 2253 wm_name == "Xfwm4"); |
| 2251 } | 2254 } |
| OLD | NEW |