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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 222 |
223 GQuark GetBrowserWindowQuarkKey() { | 223 GQuark GetBrowserWindowQuarkKey() { |
224 static GQuark quark = g_quark_from_static_string(kBrowserWindowKey); | 224 static GQuark quark = g_quark_from_static_string(kBrowserWindowKey); |
225 return quark; | 225 return quark; |
226 } | 226 } |
227 | 227 |
228 } // namespace | 228 } // namespace |
229 | 229 |
230 BrowserWindowGtk::BrowserWindowGtk(Browser* browser) | 230 BrowserWindowGtk::BrowserWindowGtk(Browser* browser) |
231 : window_(NULL), | 231 : window_(NULL), |
232 window_has_shown_(false), | |
233 window_container_(NULL), | 232 window_container_(NULL), |
234 window_vbox_(NULL), | 233 window_vbox_(NULL), |
235 render_area_vbox_(NULL), | 234 render_area_vbox_(NULL), |
236 render_area_floating_container_(NULL), | 235 render_area_floating_container_(NULL), |
237 render_area_event_box_(NULL), | 236 render_area_event_box_(NULL), |
238 toolbar_border_(NULL), | 237 toolbar_border_(NULL), |
239 browser_(browser), | 238 browser_(browser), |
240 state_(GDK_WINDOW_STATE_WITHDRAWN), | 239 state_(GDK_WINDOW_STATE_WITHDRAWN), |
241 devtools_dock_side_(DEVTOOLS_DOCK_SIDE_BOTTOM), | 240 devtools_dock_side_(DEVTOOLS_DOCK_SIDE_BOTTOM), |
242 contents_hsplit_(NULL), | 241 contents_hsplit_(NULL), |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 gtk_window_iconify(window_); | 596 gtk_window_iconify(window_); |
598 show_state_after_show_ = ui::SHOW_STATE_NORMAL; | 597 show_state_after_show_ = ui::SHOW_STATE_NORMAL; |
599 } | 598 } |
600 | 599 |
601 // If we have sized the window by setting a size request for the render | 600 // If we have sized the window by setting a size request for the render |
602 // area, then undo it so that the render view can later adjust its own | 601 // area, then undo it so that the render view can later adjust its own |
603 // size. | 602 // size. |
604 gtk_widget_set_size_request(contents_container_->widget(), -1, -1); | 603 gtk_widget_set_size_request(contents_container_->widget(), -1, -1); |
605 | 604 |
606 browser()->OnWindowDidShow(); | 605 browser()->OnWindowDidShow(); |
607 window_has_shown_ = true; | |
608 UpdateDevTools(); | |
609 } | 606 } |
610 | 607 |
611 void BrowserWindowGtk::ShowInactive() { | 608 void BrowserWindowGtk::ShowInactive() { |
612 gtk_window_set_focus_on_map(window_, false); | 609 gtk_window_set_focus_on_map(window_, false); |
613 gtk_widget_show(GTK_WIDGET(window_)); | 610 gtk_widget_show(GTK_WIDGET(window_)); |
614 } | 611 } |
615 | 612 |
616 void BrowserWindowGtk::SetBoundsImpl(const gfx::Rect& bounds, | 613 void BrowserWindowGtk::SetBoundsImpl(const gfx::Rect& bounds, |
617 bool exterior, | 614 bool exterior, |
618 bool move) { | 615 bool move) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 // Cancel any pending callback from the window configure debounce timer. | 667 // Cancel any pending callback from the window configure debounce timer. |
671 window_configure_debounce_timer_.Stop(); | 668 window_configure_debounce_timer_.Stop(); |
672 | 669 |
673 // Likewise for the loading animation. | 670 // Likewise for the loading animation. |
674 loading_animation_timer_.Stop(); | 671 loading_animation_timer_.Stop(); |
675 | 672 |
676 GtkWidget* window = GTK_WIDGET(window_); | 673 GtkWidget* window = GTK_WIDGET(window_); |
677 // To help catch bugs in any event handlers that might get fired during the | 674 // To help catch bugs in any event handlers that might get fired during the |
678 // destruction, set window_ to NULL before any handlers will run. | 675 // destruction, set window_ to NULL before any handlers will run. |
679 window_ = NULL; | 676 window_ = NULL; |
680 window_has_shown_ = false; | |
681 titlebar_->set_window(NULL); | 677 titlebar_->set_window(NULL); |
682 | 678 |
683 // We don't want GlobalMenuBar handling any notifications or commands after | 679 // We don't want GlobalMenuBar handling any notifications or commands after |
684 // the window is destroyed. | 680 // the window is destroyed. |
685 global_menu_bar_->Disable(); | 681 global_menu_bar_->Disable(); |
686 gtk_widget_destroy(window); | 682 gtk_widget_destroy(window); |
687 } | 683 } |
688 | 684 |
689 void BrowserWindowGtk::Activate() { | 685 void BrowserWindowGtk::Activate() { |
690 gtk_window_present(window_); | 686 gtk_window_present(window_); |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 | 1342 |
1347 toolbar_->UpdateForBookmarkBarVisibility(state == BookmarkBar::DETACHED); | 1343 toolbar_->UpdateForBookmarkBarVisibility(state == BookmarkBar::DETACHED); |
1348 PlaceBookmarkBar(state == BookmarkBar::DETACHED); | 1344 PlaceBookmarkBar(state == BookmarkBar::DETACHED); |
1349 bookmark_bar_->SetBookmarkBarState( | 1345 bookmark_bar_->SetBookmarkBarState( |
1350 state, | 1346 state, |
1351 animate ? BookmarkBar::ANIMATE_STATE_CHANGE : | 1347 animate ? BookmarkBar::ANIMATE_STATE_CHANGE : |
1352 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 1348 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
1353 } | 1349 } |
1354 | 1350 |
1355 void BrowserWindowGtk::UpdateDevToolsForContents(WebContents* contents) { | 1351 void BrowserWindowGtk::UpdateDevToolsForContents(WebContents* contents) { |
1356 if (!window_has_shown_) | |
1357 return; | |
1358 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::UpdateDevToolsForContents"); | 1352 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::UpdateDevToolsForContents"); |
1359 TabContents* old_devtools = devtools_container_->tab(); | 1353 TabContents* old_devtools = devtools_container_->tab(); |
1360 TabContents* devtools_contents = contents ? | 1354 TabContents* devtools_contents = contents ? |
1361 DevToolsWindow::GetDevToolsContents(contents) : NULL; | 1355 DevToolsWindow::GetDevToolsContents(contents) : NULL; |
1362 if (old_devtools == devtools_contents) | 1356 if (old_devtools == devtools_contents) |
1363 return; | 1357 return; |
1364 | 1358 |
1365 if (old_devtools) | 1359 if (old_devtools) |
1366 devtools_container_->DetachTab(old_devtools); | 1360 devtools_container_->DetachTab(old_devtools); |
1367 | 1361 |
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2427 wm_type == ui::WM_OPENBOX || | 2421 wm_type == ui::WM_OPENBOX || |
2428 wm_type == ui::WM_XFWM4); | 2422 wm_type == ui::WM_XFWM4); |
2429 } | 2423 } |
2430 | 2424 |
2431 // static | 2425 // static |
2432 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2426 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
2433 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); | 2427 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); |
2434 browser_window_gtk->Init(); | 2428 browser_window_gtk->Init(); |
2435 return browser_window_gtk; | 2429 return browser_window_gtk; |
2436 } | 2430 } |
OLD | NEW |