| 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 return tab ? tab->extension_tab_helper()->active_tab_permission_granter() |
| 1317 : NULL; |
| 1318 } |
| 1319 |
| 1312 void BrowserWindowGtk::MaybeShowBookmarkBar(bool animate) { | 1320 void BrowserWindowGtk::MaybeShowBookmarkBar(bool animate) { |
| 1313 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::MaybeShowBookmarkBar"); | 1321 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::MaybeShowBookmarkBar"); |
| 1314 if (!IsBookmarkBarSupported()) | 1322 if (!IsBookmarkBarSupported()) |
| 1315 return; | 1323 return; |
| 1316 | 1324 |
| 1317 TabContents* tab = GetDisplayedTab(); | 1325 TabContents* tab = GetDisplayedTab(); |
| 1318 | 1326 |
| 1319 if (tab) | 1327 if (tab) |
| 1320 bookmark_bar_->SetPageNavigator(browser_.get()); | 1328 bookmark_bar_->SetPageNavigator(browser_.get()); |
| 1321 | 1329 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 GdkEvent* event) { | 1533 GdkEvent* event) { |
| 1526 Close(); | 1534 Close(); |
| 1527 | 1535 |
| 1528 // Return true to prevent the gtk window from being destroyed. Close will | 1536 // Return true to prevent the gtk window from being destroyed. Close will |
| 1529 // destroy it for us. | 1537 // destroy it for us. |
| 1530 return TRUE; | 1538 return TRUE; |
| 1531 } | 1539 } |
| 1532 | 1540 |
| 1533 void BrowserWindowGtk::OnMainWindowDestroy(GtkWidget* widget) { | 1541 void BrowserWindowGtk::OnMainWindowDestroy(GtkWidget* widget) { |
| 1534 // Make sure we destroy this object while the main window is still valid. | 1542 // Make sure we destroy this object while the main window is still valid. |
| 1535 extension_keybinding_registry_.reset(NULL); | 1543 extension_keybinding_registry_.reset(); |
| 1536 | 1544 |
| 1537 // BUG 8712. When we gtk_widget_destroy() in Close(), this will emit the | 1545 // 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 | 1546 // 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 | 1547 // call stack). In order to not reenter Close(), and to also follow the |
| 1540 // expectations of BrowserList, we should run the BrowserWindowGtk destructor | 1548 // expectations of BrowserList, we should run the BrowserWindowGtk destructor |
| 1541 // not now, but after the run loop goes back to process messages. Otherwise | 1549 // 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. | 1550 // 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 | 1551 // 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 | 1552 // set window_ to NULL, otherwise we will try to close the window again when |
| 1545 // we call Close() in the destructor. | 1553 // we call Close() in the destructor. |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1818 } | 1826 } |
| 1819 | 1827 |
| 1820 // We have to realize the window before we try to apply a window shape mask. | 1828 // We have to realize the window before we try to apply a window shape mask. |
| 1821 gtk_widget_realize(GTK_WIDGET(window_)); | 1829 gtk_widget_realize(GTK_WIDGET(window_)); |
| 1822 state_ = gdk_window_get_state(gtk_widget_get_window(GTK_WIDGET(window_))); | 1830 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 | 1831 // Note that calling this the first time is necessary to get the |
| 1824 // proper control layout. | 1832 // proper control layout. |
| 1825 UpdateCustomFrame(); | 1833 UpdateCustomFrame(); |
| 1826 | 1834 |
| 1827 // Add the keybinding registry, now that the window has been realized. | 1835 // Add the keybinding registry, now that the window has been realized. |
| 1828 extension_keybinding_registry_.reset( | 1836 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryGtk( |
| 1829 new ExtensionKeybindingRegistryGtk(browser_->profile(), window_, | 1837 browser_->profile(), |
| 1830 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS)); | 1838 window_, |
| 1839 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, |
| 1840 this)); |
| 1831 | 1841 |
| 1832 // We have to call this after the first window is created, but after that only | 1842 // 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 | 1843 // when the theme changes. This sets the icon that will be used for windows |
| 1834 // that have not explicitly been assigned an icon. | 1844 // that have not explicitly been assigned an icon. |
| 1835 static bool default_icon_set = false; | 1845 static bool default_icon_set = false; |
| 1836 if (!default_icon_set) { | 1846 if (!default_icon_set) { |
| 1837 gtk_util::SetDefaultWindowIcon(window_); | 1847 gtk_util::SetDefaultWindowIcon(window_); |
| 1838 default_icon_set = true; | 1848 default_icon_set = true; |
| 1839 } | 1849 } |
| 1840 // Set this window's (potentially profile-avatar-emblemed) icon, overriding | 1850 // 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 || | 2447 wm_type == ui::WM_OPENBOX || |
| 2438 wm_type == ui::WM_XFWM4); | 2448 wm_type == ui::WM_XFWM4); |
| 2439 } | 2449 } |
| 2440 | 2450 |
| 2441 // static | 2451 // static |
| 2442 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2452 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 2443 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); | 2453 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); |
| 2444 browser_window_gtk->Init(); | 2454 browser_window_gtk->Init(); |
| 2445 return browser_window_gtk; | 2455 return browser_window_gtk; |
| 2446 } | 2456 } |
| OLD | NEW |