| 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 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 // the animations are running slowly and this function is called on | 783 // the animations are running slowly and this function is called on |
| 784 // a timer through LoadingAnimationCallback. | 784 // a timer through LoadingAnimationCallback. |
| 785 titlebar_->UpdateThrobber(web_contents); | 785 titlebar_->UpdateThrobber(web_contents); |
| 786 } | 786 } |
| 787 } | 787 } |
| 788 | 788 |
| 789 void BrowserWindowGtk::SetStarredState(bool is_starred) { | 789 void BrowserWindowGtk::SetStarredState(bool is_starred) { |
| 790 toolbar_->GetLocationBarView()->SetStarred(is_starred); | 790 toolbar_->GetLocationBarView()->SetStarred(is_starred); |
| 791 } | 791 } |
| 792 | 792 |
| 793 void BrowserWindowGtk::OnActiveTabChanged(WebContents* old_contents, |
| 794 WebContents* new_contents, |
| 795 int index, |
| 796 int reason) { |
| 797 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::ActiveTabChanged"); |
| 798 if (old_contents && !old_contents->IsBeingDestroyed()) |
| 799 old_contents->GetView()->StoreFocus(); |
| 800 |
| 801 // Update various elements that are interested in knowing the current |
| 802 // WebContents. |
| 803 UpdateDevToolsForContents(new_contents); |
| 804 infobar_container_->ChangeInfoBarService( |
| 805 InfoBarService::FromWebContents(new_contents)); |
| 806 contents_container_->SetTab(new_contents); |
| 807 |
| 808 // TODO(estade): after we manage browser activation, add a check to make sure |
| 809 // we are the active browser before calling RestoreFocus(). |
| 810 if (!browser_->tab_strip_model()->closing_all()) { |
| 811 new_contents->GetView()->RestoreFocus(); |
| 812 FindTabHelper* find_tab_helper = |
| 813 FindTabHelper::FromWebContents(new_contents); |
| 814 if (find_tab_helper->find_ui_active()) |
| 815 browser_->GetFindBarController()->find_bar()->SetFocusAndSelection(); |
| 816 } |
| 817 |
| 818 // Update all the UI bits. |
| 819 UpdateTitleBar(); |
| 820 MaybeShowBookmarkBar(false); |
| 821 } |
| 793 void BrowserWindowGtk::ZoomChangedForActiveTab(bool can_show_bubble) { | 822 void BrowserWindowGtk::ZoomChangedForActiveTab(bool can_show_bubble) { |
| 794 toolbar_->GetLocationBarView()->ZoomChangedForActiveTab( | 823 toolbar_->GetLocationBarView()->ZoomChangedForActiveTab( |
| 795 can_show_bubble && !toolbar_->IsWrenchMenuShowing()); | 824 can_show_bubble && !toolbar_->IsWrenchMenuShowing()); |
| 796 } | 825 } |
| 797 | 826 |
| 798 gfx::Rect BrowserWindowGtk::GetRestoredBounds() const { | 827 gfx::Rect BrowserWindowGtk::GetRestoredBounds() const { |
| 799 return restored_bounds_; | 828 return restored_bounds_; |
| 800 } | 829 } |
| 801 | 830 |
| 802 ui::WindowShowState BrowserWindowGtk::GetRestoredState() const { | 831 ui::WindowShowState BrowserWindowGtk::GetRestoredState() const { |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 // the model has already removed |contents| from its list, so | 1238 // the model has already removed |contents| from its list, so |
| 1210 // browser_->tab_strip_model()->GetActiveWebContents() will return NULL or | 1239 // browser_->tab_strip_model()->GetActiveWebContents() will return NULL or |
| 1211 // something else. | 1240 // something else. |
| 1212 if (index == browser_->tab_strip_model()->active_index()) { | 1241 if (index == browser_->tab_strip_model()->active_index()) { |
| 1213 infobar_container_->ChangeInfoBarService(NULL); | 1242 infobar_container_->ChangeInfoBarService(NULL); |
| 1214 UpdateDevToolsForContents(NULL); | 1243 UpdateDevToolsForContents(NULL); |
| 1215 } | 1244 } |
| 1216 contents_container_->DetachTab(contents); | 1245 contents_container_->DetachTab(contents); |
| 1217 } | 1246 } |
| 1218 | 1247 |
| 1219 void BrowserWindowGtk::ActiveTabChanged(WebContents* old_contents, | |
| 1220 WebContents* new_contents, | |
| 1221 int index, | |
| 1222 int reason) { | |
| 1223 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::ActiveTabChanged"); | |
| 1224 if (old_contents && !old_contents->IsBeingDestroyed()) | |
| 1225 old_contents->GetView()->StoreFocus(); | |
| 1226 | |
| 1227 // Update various elements that are interested in knowing the current | |
| 1228 // WebContents. | |
| 1229 UpdateDevToolsForContents(new_contents); | |
| 1230 infobar_container_->ChangeInfoBarService( | |
| 1231 InfoBarService::FromWebContents(new_contents)); | |
| 1232 contents_container_->SetTab(new_contents); | |
| 1233 | |
| 1234 // TODO(estade): after we manage browser activation, add a check to make sure | |
| 1235 // we are the active browser before calling RestoreFocus(). | |
| 1236 if (!browser_->tab_strip_model()->closing_all()) { | |
| 1237 new_contents->GetView()->RestoreFocus(); | |
| 1238 FindTabHelper* find_tab_helper = | |
| 1239 FindTabHelper::FromWebContents(new_contents); | |
| 1240 if (find_tab_helper->find_ui_active()) | |
| 1241 browser_->GetFindBarController()->find_bar()->SetFocusAndSelection(); | |
| 1242 } | |
| 1243 | |
| 1244 // Update all the UI bits. | |
| 1245 UpdateTitleBar(); | |
| 1246 MaybeShowBookmarkBar(false); | |
| 1247 } | |
| 1248 | |
| 1249 void BrowserWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { | 1248 void BrowserWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { |
| 1250 // Do nothing if we're in the process of closing the browser window. | 1249 // Do nothing if we're in the process of closing the browser window. |
| 1251 if (!window_) | 1250 if (!window_) |
| 1252 return; | 1251 return; |
| 1253 | 1252 |
| 1254 bool is_active = gtk_widget_get_window(GTK_WIDGET(window_)) == active_window; | 1253 bool is_active = gtk_widget_get_window(GTK_WIDGET(window_)) == active_window; |
| 1255 bool changed = (is_active != is_active_); | 1254 bool changed = (is_active != is_active_); |
| 1256 | 1255 |
| 1257 if (is_active && changed) { | 1256 if (is_active && changed) { |
| 1258 // If there's an app modal dialog (e.g., JS alert), try to redirect | 1257 // If there's an app modal dialog (e.g., JS alert), try to redirect |
| (...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2414 wm_type == ui::WM_OPENBOX || | 2413 wm_type == ui::WM_OPENBOX || |
| 2415 wm_type == ui::WM_XFWM4); | 2414 wm_type == ui::WM_XFWM4); |
| 2416 } | 2415 } |
| 2417 | 2416 |
| 2418 // static | 2417 // static |
| 2419 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2418 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 2420 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); | 2419 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); |
| 2421 browser_window_gtk->Init(); | 2420 browser_window_gtk->Init(); |
| 2422 return browser_window_gtk; | 2421 return browser_window_gtk; |
| 2423 } | 2422 } |
| OLD | NEW |