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 <dlfcn.h> | 7 #include <dlfcn.h> |
8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 34 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
35 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
36 #include "chrome/browser/themes/theme_service.h" | 36 #include "chrome/browser/themes/theme_service.h" |
37 #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" |
38 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 38 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
39 #include "chrome/browser/ui/browser.h" | 39 #include "chrome/browser/ui/browser.h" |
40 #include "chrome/browser/ui/browser_command_controller.h" | 40 #include "chrome/browser/ui/browser_command_controller.h" |
41 #include "chrome/browser/ui/browser_commands.h" | 41 #include "chrome/browser/ui/browser_commands.h" |
42 #include "chrome/browser/ui/browser_dialogs.h" | 42 #include "chrome/browser/ui/browser_dialogs.h" |
43 #include "chrome/browser/ui/browser_list.h" | 43 #include "chrome/browser/ui/browser_list.h" |
| 44 #include "chrome/browser/ui/browser_tabstrip.h" |
44 #include "chrome/browser/ui/browser_window_state.h" | 45 #include "chrome/browser/ui/browser_window_state.h" |
45 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 46 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
46 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 47 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
47 #include "chrome/browser/ui/gtk/accelerators_gtk.h" | 48 #include "chrome/browser/ui/gtk/accelerators_gtk.h" |
48 #include "chrome/browser/ui/gtk/avatar_menu_bubble_gtk.h" | 49 #include "chrome/browser/ui/gtk/avatar_menu_bubble_gtk.h" |
49 #include "chrome/browser/ui/gtk/avatar_menu_button_gtk.h" | 50 #include "chrome/browser/ui/gtk/avatar_menu_button_gtk.h" |
50 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h" | 51 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h" |
51 #include "chrome/browser/ui/gtk/browser_titlebar.h" | 52 #include "chrome/browser/ui/gtk/browser_titlebar.h" |
52 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" | 53 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" |
53 #include "chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h" | 54 #include "chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h" |
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 if (ShouldShowWindowIcon()) | 823 if (ShouldShowWindowIcon()) |
823 titlebar_->UpdateTitleAndIcon(); | 824 titlebar_->UpdateTitleAndIcon(); |
824 } | 825 } |
825 | 826 |
826 void BrowserWindowGtk::BookmarkBarStateChanged( | 827 void BrowserWindowGtk::BookmarkBarStateChanged( |
827 BookmarkBar::AnimateChangeType change_type) { | 828 BookmarkBar::AnimateChangeType change_type) { |
828 MaybeShowBookmarkBar(change_type == BookmarkBar::ANIMATE_STATE_CHANGE); | 829 MaybeShowBookmarkBar(change_type == BookmarkBar::ANIMATE_STATE_CHANGE); |
829 } | 830 } |
830 | 831 |
831 void BrowserWindowGtk::UpdateDevTools() { | 832 void BrowserWindowGtk::UpdateDevTools() { |
832 UpdateDevToolsForContents( | 833 UpdateDevToolsForContents(chrome::GetActiveWebContents(browser_.get())); |
833 browser_->GetActiveWebContents()); | |
834 } | 834 } |
835 | 835 |
836 void BrowserWindowGtk::SetDevToolsDockSide(DevToolsDockSide side) { | 836 void BrowserWindowGtk::SetDevToolsDockSide(DevToolsDockSide side) { |
837 if (devtools_dock_side_ == side) | 837 if (devtools_dock_side_ == side) |
838 return; | 838 return; |
839 | 839 |
840 if (devtools_container_->tab()) { | 840 if (devtools_container_->tab()) { |
841 HideDevToolsContainer(); | 841 HideDevToolsContainer(); |
842 devtools_dock_side_ = side; | 842 devtools_dock_side_ = side; |
843 ShowDevToolsContainer(); | 843 ShowDevToolsContainer(); |
(...skipping 22 matching lines...) Expand all Loading... |
866 void BrowserWindowGtk::LoadingAnimationCallback() { | 866 void BrowserWindowGtk::LoadingAnimationCallback() { |
867 if (browser_->is_type_tabbed()) { | 867 if (browser_->is_type_tabbed()) { |
868 // Loading animations are shown in the tab for tabbed windows. We check the | 868 // Loading animations are shown in the tab for tabbed windows. We check the |
869 // browser type instead of calling IsTabStripVisible() because the latter | 869 // browser type instead of calling IsTabStripVisible() because the latter |
870 // will return false for fullscreen windows, but we still need to update | 870 // will return false for fullscreen windows, but we still need to update |
871 // their animations (so that when they come out of fullscreen mode they'll | 871 // their animations (so that when they come out of fullscreen mode they'll |
872 // be correct). | 872 // be correct). |
873 tabstrip_->UpdateLoadingAnimations(); | 873 tabstrip_->UpdateLoadingAnimations(); |
874 } else if (ShouldShowWindowIcon()) { | 874 } else if (ShouldShowWindowIcon()) { |
875 // ... or in the window icon area for popups and app windows. | 875 // ... or in the window icon area for popups and app windows. |
876 WebContents* web_contents = browser_->GetActiveWebContents(); | 876 WebContents* web_contents = chrome::GetActiveWebContents(browser_.get()); |
877 // GetSelectedTabContents can return NULL for example under Purify when | 877 // GetSelectedTabContents can return NULL for example under Purify when |
878 // the animations are running slowly and this function is called on | 878 // the animations are running slowly and this function is called on |
879 // a timer through LoadingAnimationCallback. | 879 // a timer through LoadingAnimationCallback. |
880 titlebar_->UpdateThrobber(web_contents); | 880 titlebar_->UpdateThrobber(web_contents); |
881 } | 881 } |
882 } | 882 } |
883 | 883 |
884 void BrowserWindowGtk::SetStarredState(bool is_starred) { | 884 void BrowserWindowGtk::SetStarredState(bool is_starred) { |
885 toolbar_->GetLocationBarView()->SetStarred(is_starred); | 885 toolbar_->GetLocationBarView()->SetStarred(is_starred); |
886 } | 886 } |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 | 1279 |
1280 void BrowserWindowGtk::ShowAvatarBubbleFromAvatarButton() { | 1280 void BrowserWindowGtk::ShowAvatarBubbleFromAvatarButton() { |
1281 if (titlebar_->avatar_button()) | 1281 if (titlebar_->avatar_button()) |
1282 titlebar_->avatar_button()->ShowAvatarBubble(); | 1282 titlebar_->avatar_button()->ShowAvatarBubble(); |
1283 } | 1283 } |
1284 | 1284 |
1285 void BrowserWindowGtk::ShowPasswordGenerationBubble( | 1285 void BrowserWindowGtk::ShowPasswordGenerationBubble( |
1286 const gfx::Rect& rect, | 1286 const gfx::Rect& rect, |
1287 autofill::PasswordGenerator* password_generator, | 1287 autofill::PasswordGenerator* password_generator, |
1288 const webkit::forms::PasswordForm& form) { | 1288 const webkit::forms::PasswordForm& form) { |
1289 WebContents* web_contents = browser_->GetActiveWebContents(); | 1289 WebContents* web_contents = chrome::GetActiveWebContents(browser_.get()); |
1290 if (!web_contents || !web_contents->GetContentNativeView()) { | 1290 if (!web_contents || !web_contents->GetContentNativeView()) { |
1291 return; | 1291 return; |
1292 } | 1292 } |
1293 | 1293 |
1294 TabContents* tab_contents = TabContents::FromWebContents(web_contents); | 1294 TabContents* tab_contents = TabContents::FromWebContents(web_contents); |
1295 if (!tab_contents) | 1295 if (!tab_contents) |
1296 return; | 1296 return; |
1297 | 1297 |
1298 new PasswordGenerationBubbleGtk(rect, form, tab_contents, password_generator); | 1298 new PasswordGenerationBubbleGtk(rect, form, tab_contents, password_generator); |
1299 } | 1299 } |
(...skipping 20 matching lines...) Expand all Loading... |
1320 gtk_util::SetWindowIcon(window_, browser_->profile()); | 1320 gtk_util::SetWindowIcon(window_, browser_->profile()); |
1321 break; | 1321 break; |
1322 default: | 1322 default: |
1323 break; | 1323 break; |
1324 } | 1324 } |
1325 } | 1325 } |
1326 | 1326 |
1327 void BrowserWindowGtk::TabDetachedAt(TabContents* contents, int index) { | 1327 void BrowserWindowGtk::TabDetachedAt(TabContents* contents, int index) { |
1328 // We use index here rather than comparing |contents| because by this time | 1328 // We use index here rather than comparing |contents| because by this time |
1329 // the model has already removed |contents| from its list, so | 1329 // the model has already removed |contents| from its list, so |
1330 // browser_->GetActiveWebContents() will return NULL or something else. | 1330 // chrome::GetActiveWebContents(browser_.get()) will return NULL or something |
| 1331 // else. |
1331 if (index == browser_->active_index()) { | 1332 if (index == browser_->active_index()) { |
1332 infobar_container_->ChangeTabContents(NULL); | 1333 infobar_container_->ChangeTabContents(NULL); |
1333 UpdateDevToolsForContents(NULL); | 1334 UpdateDevToolsForContents(NULL); |
1334 } | 1335 } |
1335 contents_container_->DetachTab(contents); | 1336 contents_container_->DetachTab(contents); |
1336 } | 1337 } |
1337 | 1338 |
1338 void BrowserWindowGtk::ActiveTabChanged(TabContents* old_contents, | 1339 void BrowserWindowGtk::ActiveTabChanged(TabContents* old_contents, |
1339 TabContents* new_contents, | 1340 TabContents* new_contents, |
1340 int index, | 1341 int index, |
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2213 | 2214 |
2214 // Let the focused widget have first crack at the key event so we don't | 2215 // Let the focused widget have first crack at the key event so we don't |
2215 // override their accelerators, except if there is a priority keybinding | 2216 // override their accelerators, except if there is a priority keybinding |
2216 // handler registered (it should take precedence). | 2217 // handler registered (it should take precedence). |
2217 gboolean BrowserWindowGtk::OnKeyPress(GtkWidget* widget, GdkEventKey* event) { | 2218 gboolean BrowserWindowGtk::OnKeyPress(GtkWidget* widget, GdkEventKey* event) { |
2218 if (extension_keybinding_registry_->HasPriorityHandler(event)) | 2219 if (extension_keybinding_registry_->HasPriorityHandler(event)) |
2219 return FALSE; | 2220 return FALSE; |
2220 | 2221 |
2221 // If a widget besides the native view is focused, we have to try to handle | 2222 // If a widget besides the native view is focused, we have to try to handle |
2222 // the custom accelerators before letting it handle them. | 2223 // the custom accelerators before letting it handle them. |
2223 WebContents* current_web_contents = | 2224 WebContents* current_web_contents = chrome::GetActiveWebContents(browser()); |
2224 browser()->GetActiveWebContents(); | |
2225 // The current tab might not have a render view if it crashed. | 2225 // The current tab might not have a render view if it crashed. |
2226 if (!current_web_contents || !current_web_contents->GetContentNativeView() || | 2226 if (!current_web_contents || !current_web_contents->GetContentNativeView() || |
2227 !gtk_widget_is_focus(current_web_contents->GetContentNativeView())) { | 2227 !gtk_widget_is_focus(current_web_contents->GetContentNativeView())) { |
2228 int command_id = GetCustomCommandId(event); | 2228 int command_id = GetCustomCommandId(event); |
2229 if (command_id == -1) | 2229 if (command_id == -1) |
2230 command_id = GetPreHandleCommandId(event); | 2230 command_id = GetPreHandleCommandId(event); |
2231 | 2231 |
2232 if (command_id != -1 && chrome::ExecuteCommand(browser_.get(), command_id)) | 2232 if (command_id != -1 && chrome::ExecuteCommand(browser_.get(), command_id)) |
2233 return TRUE; | 2233 return TRUE; |
2234 | 2234 |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2603 wm_type == ui::WM_OPENBOX || | 2603 wm_type == ui::WM_OPENBOX || |
2604 wm_type == ui::WM_XFWM4); | 2604 wm_type == ui::WM_XFWM4); |
2605 } | 2605 } |
2606 | 2606 |
2607 // static | 2607 // static |
2608 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2608 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
2609 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); | 2609 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); |
2610 browser_window_gtk->Init(); | 2610 browser_window_gtk->Init(); |
2611 return browser_window_gtk; | 2611 return browser_window_gtk; |
2612 } | 2612 } |
OLD | NEW |