| 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/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 11 matching lines...) Expand all Loading... |
| 22 #include "base/nix/xdg_util.h" | 22 #include "base/nix/xdg_util.h" |
| 23 #include "base/path_service.h" | 23 #include "base/path_service.h" |
| 24 #include "base/string_util.h" | 24 #include "base/string_util.h" |
| 25 #include "base/time.h" | 25 #include "base/time.h" |
| 26 #include "base/utf_string_conversions.h" | 26 #include "base/utf_string_conversions.h" |
| 27 #include "chrome/app/chrome_command_ids.h" | 27 #include "chrome/app/chrome_command_ids.h" |
| 28 #include "chrome/browser/bookmarks/bookmark_utils.h" | 28 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 29 #include "chrome/browser/browser_process.h" | 29 #include "chrome/browser/browser_process.h" |
| 30 #include "chrome/browser/debugger/devtools_window.h" | 30 #include "chrome/browser/debugger/devtools_window.h" |
| 31 #include "chrome/browser/download/download_item_model.h" | 31 #include "chrome/browser/download/download_item_model.h" |
| 32 #include "chrome/browser/extensions/tab_helper.h" |
| 32 #include "chrome/browser/prefs/pref_service.h" | 33 #include "chrome/browser/prefs/pref_service.h" |
| 33 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 34 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 34 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
| 35 #include "chrome/browser/themes/theme_service.h" | 36 #include "chrome/browser/themes/theme_service.h" |
| 36 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 37 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
| 37 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 38 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
| 38 #include "chrome/browser/ui/browser.h" | 39 #include "chrome/browser/ui/browser.h" |
| 39 #include "chrome/browser/ui/browser_command_controller.h" | 40 #include "chrome/browser/ui/browser_command_controller.h" |
| 40 #include "chrome/browser/ui/browser_commands.h" | 41 #include "chrome/browser/ui/browser_commands.h" |
| 41 #include "chrome/browser/ui/browser_dialogs.h" | 42 #include "chrome/browser/ui/browser_dialogs.h" |
| (...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 bool BrowserWindowGtk::DrawInfoBarArrows(int* x) const { | 1303 bool BrowserWindowGtk::DrawInfoBarArrows(int* x) const { |
| 1303 if (x) { | 1304 if (x) { |
| 1304 // This is a views specific call that made its way into the interface. We | 1305 // This is a views specific call that made its way into the interface. We |
| 1305 // go through GetXPositionOfLocationIcon() since we need widget relativity. | 1306 // go through GetXPositionOfLocationIcon() since we need widget relativity. |
| 1306 *x = 0; | 1307 *x = 0; |
| 1307 NOTREACHED(); | 1308 NOTREACHED(); |
| 1308 } | 1309 } |
| 1309 return true; | 1310 return true; |
| 1310 } | 1311 } |
| 1311 | 1312 |
| 1313 extensions::ActiveTabPermissionGranter* |
| 1314 BrowserWindowGtk::GetActiveTabPermissionGranter() { |
| 1315 TabContents* tab = GetDisplayedTab(); |
| 1316 if (!tab) |
| 1317 return NULL; |
| 1318 return extensions::TabHelper::FromWebContents(tab->web_contents())-> |
| 1319 active_tab_permission_granter(); |
| 1320 } |
| 1321 |
| 1312 void BrowserWindowGtk::MaybeShowBookmarkBar(bool animate) { | 1322 void BrowserWindowGtk::MaybeShowBookmarkBar(bool animate) { |
| 1313 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::MaybeShowBookmarkBar"); | 1323 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::MaybeShowBookmarkBar"); |
| 1314 if (!IsBookmarkBarSupported()) | 1324 if (!IsBookmarkBarSupported()) |
| 1315 return; | 1325 return; |
| 1316 | 1326 |
| 1317 TabContents* tab = GetDisplayedTab(); | 1327 TabContents* tab = GetDisplayedTab(); |
| 1318 | 1328 |
| 1319 if (tab) | 1329 if (tab) |
| 1320 bookmark_bar_->SetPageNavigator(browser_.get()); | 1330 bookmark_bar_->SetPageNavigator(browser_.get()); |
| 1321 | 1331 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 GdkEvent* event) { | 1535 GdkEvent* event) { |
| 1526 Close(); | 1536 Close(); |
| 1527 | 1537 |
| 1528 // Return true to prevent the gtk window from being destroyed. Close will | 1538 // Return true to prevent the gtk window from being destroyed. Close will |
| 1529 // destroy it for us. | 1539 // destroy it for us. |
| 1530 return TRUE; | 1540 return TRUE; |
| 1531 } | 1541 } |
| 1532 | 1542 |
| 1533 void BrowserWindowGtk::OnMainWindowDestroy(GtkWidget* widget) { | 1543 void BrowserWindowGtk::OnMainWindowDestroy(GtkWidget* widget) { |
| 1534 // Make sure we destroy this object while the main window is still valid. | 1544 // Make sure we destroy this object while the main window is still valid. |
| 1535 extension_keybinding_registry_.reset(NULL); | 1545 extension_keybinding_registry_.reset(); |
| 1536 | 1546 |
| 1537 // BUG 8712. When we gtk_widget_destroy() in Close(), this will emit the | 1547 // BUG 8712. When we gtk_widget_destroy() in Close(), this will emit the |
| 1538 // signal right away, and we will be here (while Close() is still in the | 1548 // signal right away, and we will be here (while Close() is still in the |
| 1539 // call stack). In order to not reenter Close(), and to also follow the | 1549 // call stack). In order to not reenter Close(), and to also follow the |
| 1540 // expectations of BrowserList, we should run the BrowserWindowGtk destructor | 1550 // expectations of BrowserList, we should run the BrowserWindowGtk destructor |
| 1541 // not now, but after the run loop goes back to process messages. Otherwise | 1551 // not now, but after the run loop goes back to process messages. Otherwise |
| 1542 // we will remove ourself from BrowserList while it's being iterated. | 1552 // we will remove ourself from BrowserList while it's being iterated. |
| 1543 // Additionally, now that we know the window is gone, we need to make sure to | 1553 // Additionally, now that we know the window is gone, we need to make sure to |
| 1544 // set window_ to NULL, otherwise we will try to close the window again when | 1554 // set window_ to NULL, otherwise we will try to close the window again when |
| 1545 // we call Close() in the destructor. | 1555 // we call Close() in the destructor. |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1818 } | 1828 } |
| 1819 | 1829 |
| 1820 // We have to realize the window before we try to apply a window shape mask. | 1830 // We have to realize the window before we try to apply a window shape mask. |
| 1821 gtk_widget_realize(GTK_WIDGET(window_)); | 1831 gtk_widget_realize(GTK_WIDGET(window_)); |
| 1822 state_ = gdk_window_get_state(gtk_widget_get_window(GTK_WIDGET(window_))); | 1832 state_ = gdk_window_get_state(gtk_widget_get_window(GTK_WIDGET(window_))); |
| 1823 // Note that calling this the first time is necessary to get the | 1833 // Note that calling this the first time is necessary to get the |
| 1824 // proper control layout. | 1834 // proper control layout. |
| 1825 UpdateCustomFrame(); | 1835 UpdateCustomFrame(); |
| 1826 | 1836 |
| 1827 // Add the keybinding registry, now that the window has been realized. | 1837 // Add the keybinding registry, now that the window has been realized. |
| 1828 extension_keybinding_registry_.reset( | 1838 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryGtk( |
| 1829 new ExtensionKeybindingRegistryGtk(browser_->profile(), window_, | 1839 browser_->profile(), |
| 1830 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS)); | 1840 window_, |
| 1841 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, |
| 1842 this)); |
| 1831 | 1843 |
| 1832 // We have to call this after the first window is created, but after that only | 1844 // We have to call this after the first window is created, but after that only |
| 1833 // when the theme changes. This sets the icon that will be used for windows | 1845 // when the theme changes. This sets the icon that will be used for windows |
| 1834 // that have not explicitly been assigned an icon. | 1846 // that have not explicitly been assigned an icon. |
| 1835 static bool default_icon_set = false; | 1847 static bool default_icon_set = false; |
| 1836 if (!default_icon_set) { | 1848 if (!default_icon_set) { |
| 1837 gtk_util::SetDefaultWindowIcon(window_); | 1849 gtk_util::SetDefaultWindowIcon(window_); |
| 1838 default_icon_set = true; | 1850 default_icon_set = true; |
| 1839 } | 1851 } |
| 1840 // Set this window's (potentially profile-avatar-emblemed) icon, overriding | 1852 // Set this window's (potentially profile-avatar-emblemed) icon, overriding |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2437 wm_type == ui::WM_OPENBOX || | 2449 wm_type == ui::WM_OPENBOX || |
| 2438 wm_type == ui::WM_XFWM4); | 2450 wm_type == ui::WM_XFWM4); |
| 2439 } | 2451 } |
| 2440 | 2452 |
| 2441 // static | 2453 // static |
| 2442 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2454 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 2443 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); | 2455 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); |
| 2444 browser_window_gtk->Init(); | 2456 browser_window_gtk->Init(); |
| 2445 return browser_window_gtk; | 2457 return browser_window_gtk; |
| 2446 } | 2458 } |
| OLD | NEW |