| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 #include "chrome/browser/ui/gtk/browser_titlebar.h" | 50 #include "chrome/browser/ui/gtk/browser_titlebar.h" |
| 51 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" | 51 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" |
| 52 #include "chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h" | 52 #include "chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h" |
| 53 #include "chrome/browser/ui/gtk/download/download_in_progress_dialog_gtk.h" | 53 #include "chrome/browser/ui/gtk/download/download_in_progress_dialog_gtk.h" |
| 54 #include "chrome/browser/ui/gtk/download/download_shelf_gtk.h" | 54 #include "chrome/browser/ui/gtk/download/download_shelf_gtk.h" |
| 55 #include "chrome/browser/ui/gtk/edit_search_engine_dialog.h" | 55 #include "chrome/browser/ui/gtk/edit_search_engine_dialog.h" |
| 56 #include "chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.h" | 56 #include "chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.h" |
| 57 #include "chrome/browser/ui/gtk/find_bar_gtk.h" | 57 #include "chrome/browser/ui/gtk/find_bar_gtk.h" |
| 58 #include "chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.h" | 58 #include "chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.h" |
| 59 #include "chrome/browser/ui/gtk/global_menu_bar.h" | 59 #include "chrome/browser/ui/gtk/global_menu_bar.h" |
| 60 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 60 #include "chrome/browser/ui/gtk/gtk_util.h" | 61 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 61 #include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h" | 62 #include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h" |
| 62 #include "chrome/browser/ui/gtk/infobars/infobar_gtk.h" | 63 #include "chrome/browser/ui/gtk/infobars/infobar_gtk.h" |
| 63 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" | 64 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
| 64 #include "chrome/browser/ui/gtk/nine_box.h" | 65 #include "chrome/browser/ui/gtk/nine_box.h" |
| 65 #include "chrome/browser/ui/gtk/one_click_signin_bubble_gtk.h" | 66 #include "chrome/browser/ui/gtk/one_click_signin_bubble_gtk.h" |
| 66 #include "chrome/browser/ui/gtk/password_generation_bubble_gtk.h" | 67 #include "chrome/browser/ui/gtk/password_generation_bubble_gtk.h" |
| 67 #include "chrome/browser/ui/gtk/reload_button_gtk.h" | 68 #include "chrome/browser/ui/gtk/reload_button_gtk.h" |
| 68 #include "chrome/browser/ui/gtk/status_bubble_gtk.h" | 69 #include "chrome/browser/ui/gtk/status_bubble_gtk.h" |
| 69 #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" | 70 #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" |
| 70 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" | 71 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" |
| 71 #include "chrome/browser/ui/gtk/task_manager_gtk.h" | 72 #include "chrome/browser/ui/gtk/task_manager_gtk.h" |
| 72 #include "chrome/browser/ui/gtk/theme_service_gtk.h" | |
| 73 #include "chrome/browser/ui/gtk/update_recommended_dialog.h" | 73 #include "chrome/browser/ui/gtk/update_recommended_dialog.h" |
| 74 #include "chrome/browser/ui/omnibox/location_bar.h" | 74 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 75 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 75 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 76 #include "chrome/browser/ui/page_info_bubble.h" | 76 #include "chrome/browser/ui/page_info_bubble.h" |
| 77 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 77 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 78 #include "chrome/browser/ui/webui/task_manager/task_manager_dialog.h" | 78 #include "chrome/browser/ui/webui/task_manager/task_manager_dialog.h" |
| 79 #include "chrome/browser/website_settings.h" | 79 #include "chrome/browser/website_settings.h" |
| 80 #include "chrome/browser/web_applications/web_app.h" | 80 #include "chrome/browser/web_applications/web_app.h" |
| 81 #include "chrome/common/chrome_notification_types.h" | 81 #include "chrome/common/chrome_notification_types.h" |
| 82 #include "chrome/common/chrome_switches.h" | 82 #include "chrome/common/chrome_switches.h" |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 surface->SetSource(cr, widget, 0, GetVerticalOffset()); | 617 surface->SetSource(cr, widget, 0, GetVerticalOffset()); |
| 618 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REFLECT); | 618 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REFLECT); |
| 619 cairo_rectangle(cr, event->area.x, event->area.y, | 619 cairo_rectangle(cr, event->area.x, event->area.y, |
| 620 event->area.width, event->area.height); | 620 event->area.width, event->area.height); |
| 621 cairo_fill(cr); | 621 cairo_fill(cr); |
| 622 } | 622 } |
| 623 | 623 |
| 624 void BrowserWindowGtk::DrawCustomFrame(cairo_t* cr, | 624 void BrowserWindowGtk::DrawCustomFrame(cairo_t* cr, |
| 625 GtkWidget* widget, | 625 GtkWidget* widget, |
| 626 GdkEventExpose* event) { | 626 GdkEventExpose* event) { |
| 627 ThemeServiceGtk* theme_provider = ThemeServiceGtk::GetFrom( | 627 GtkThemeService* theme_provider = GtkThemeService::GetFrom( |
| 628 browser()->profile()); | 628 browser()->profile()); |
| 629 | 629 |
| 630 int image_name = GetThemeFrameResource(); | 630 int image_name = GetThemeFrameResource(); |
| 631 | 631 |
| 632 gfx::CairoCachedSurface* surface = theme_provider->GetImageNamed( | 632 gfx::CairoCachedSurface* surface = theme_provider->GetImageNamed( |
| 633 image_name)->ToCairo(); | 633 image_name)->ToCairo(); |
| 634 if (event->area.y < surface->Height()) { | 634 if (event->area.y < surface->Height()) { |
| 635 surface->SetSource(cr, widget, 0, GetVerticalOffset()); | 635 surface->SetSource(cr, widget, 0, GetVerticalOffset()); |
| 636 | 636 |
| 637 // The frame background isn't tiled vertically. | 637 // The frame background isn't tiled vertically. |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 if (changed) { | 1372 if (changed) { |
| 1373 SetBackgroundColor(); | 1373 SetBackgroundColor(); |
| 1374 InvalidateWindow(); | 1374 InvalidateWindow(); |
| 1375 // For some reason, the above two calls cause the window shape to be | 1375 // For some reason, the above two calls cause the window shape to be |
| 1376 // lost so reset it. | 1376 // lost so reset it. |
| 1377 UpdateWindowShape(bounds_.width(), bounds_.height()); | 1377 UpdateWindowShape(bounds_.width(), bounds_.height()); |
| 1378 } | 1378 } |
| 1379 } | 1379 } |
| 1380 | 1380 |
| 1381 SkColor BrowserWindowGtk::GetInfoBarSeparatorColor() const { | 1381 SkColor BrowserWindowGtk::GetInfoBarSeparatorColor() const { |
| 1382 ThemeServiceGtk* theme_service = ThemeServiceGtk::GetFrom( | 1382 GtkThemeService* theme_service = GtkThemeService::GetFrom( |
| 1383 browser()->profile()); | 1383 browser()->profile()); |
| 1384 return gfx::GdkColorToSkColor(theme_service->GetBorderColor()); | 1384 return gfx::GdkColorToSkColor(theme_service->GetBorderColor()); |
| 1385 } | 1385 } |
| 1386 | 1386 |
| 1387 void BrowserWindowGtk::InfoBarContainerStateChanged(bool is_animating) { | 1387 void BrowserWindowGtk::InfoBarContainerStateChanged(bool is_animating) { |
| 1388 InvalidateInfoBarBits(); | 1388 InvalidateInfoBarBits(); |
| 1389 } | 1389 } |
| 1390 | 1390 |
| 1391 bool BrowserWindowGtk::DrawInfoBarArrows(int* x) const { | 1391 bool BrowserWindowGtk::DrawInfoBarArrows(int* x) const { |
| 1392 if (x) { | 1392 if (x) { |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1933 // the default. | 1933 // the default. |
| 1934 gtk_util::SetWindowIcon(window_, browser_->profile()); | 1934 gtk_util::SetWindowIcon(window_, browser_->profile()); |
| 1935 | 1935 |
| 1936 gtk_container_add(GTK_CONTAINER(window_), window_container_); | 1936 gtk_container_add(GTK_CONTAINER(window_), window_container_); |
| 1937 gtk_widget_show(window_container_); | 1937 gtk_widget_show(window_container_); |
| 1938 browser_->tabstrip_model()->AddObserver(this); | 1938 browser_->tabstrip_model()->AddObserver(this); |
| 1939 } | 1939 } |
| 1940 | 1940 |
| 1941 void BrowserWindowGtk::SetBackgroundColor() { | 1941 void BrowserWindowGtk::SetBackgroundColor() { |
| 1942 Profile* profile = browser()->profile(); | 1942 Profile* profile = browser()->profile(); |
| 1943 ThemeServiceGtk* theme_provider = ThemeServiceGtk::GetFrom(profile); | 1943 GtkThemeService* theme_provider = GtkThemeService::GetFrom(profile); |
| 1944 int frame_color_id; | 1944 int frame_color_id; |
| 1945 if (UsingCustomPopupFrame()) { | 1945 if (UsingCustomPopupFrame()) { |
| 1946 frame_color_id = ThemeService::COLOR_TOOLBAR; | 1946 frame_color_id = ThemeService::COLOR_TOOLBAR; |
| 1947 } else if (IsActive()) { | 1947 } else if (IsActive()) { |
| 1948 frame_color_id = browser()->profile()->IsOffTheRecord() | 1948 frame_color_id = browser()->profile()->IsOffTheRecord() |
| 1949 ? ThemeService::COLOR_FRAME_INCOGNITO | 1949 ? ThemeService::COLOR_FRAME_INCOGNITO |
| 1950 : ThemeService::COLOR_FRAME; | 1950 : ThemeService::COLOR_FRAME; |
| 1951 } else { | 1951 } else { |
| 1952 frame_color_id = browser()->profile()->IsOffTheRecord() | 1952 frame_color_id = browser()->profile()->IsOffTheRecord() |
| 1953 ? ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE | 1953 ? ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2451 bool BrowserWindowGtk::IsToolbarSupported() const { | 2451 bool BrowserWindowGtk::IsToolbarSupported() const { |
| 2452 return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || | 2452 return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || |
| 2453 browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); | 2453 browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); |
| 2454 } | 2454 } |
| 2455 | 2455 |
| 2456 bool BrowserWindowGtk::IsBookmarkBarSupported() const { | 2456 bool BrowserWindowGtk::IsBookmarkBarSupported() const { |
| 2457 return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR); | 2457 return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR); |
| 2458 } | 2458 } |
| 2459 | 2459 |
| 2460 bool BrowserWindowGtk::UsingCustomPopupFrame() const { | 2460 bool BrowserWindowGtk::UsingCustomPopupFrame() const { |
| 2461 ThemeServiceGtk* theme_provider = ThemeServiceGtk::GetFrom( | 2461 GtkThemeService* theme_provider = GtkThemeService::GetFrom( |
| 2462 browser()->profile()); | 2462 browser()->profile()); |
| 2463 return !theme_provider->UsingNativeTheme() && browser()->is_type_popup(); | 2463 return !theme_provider->UsingNativeTheme() && browser()->is_type_popup(); |
| 2464 } | 2464 } |
| 2465 | 2465 |
| 2466 BrowserTitlebar* BrowserWindowGtk::CreateBrowserTitlebar() { | 2466 BrowserTitlebar* BrowserWindowGtk::CreateBrowserTitlebar() { |
| 2467 return new BrowserTitlebar(this, window_); | 2467 return new BrowserTitlebar(this, window_); |
| 2468 } | 2468 } |
| 2469 | 2469 |
| 2470 bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { | 2470 bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { |
| 2471 if (!UseCustomFrame()) | 2471 if (!UseCustomFrame()) |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2585 wm_type == ui::WM_OPENBOX || | 2585 wm_type == ui::WM_OPENBOX || |
| 2586 wm_type == ui::WM_XFWM4); | 2586 wm_type == ui::WM_XFWM4); |
| 2587 } | 2587 } |
| 2588 | 2588 |
| 2589 // static | 2589 // static |
| 2590 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2590 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 2591 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); | 2591 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); |
| 2592 browser_window_gtk->Init(); | 2592 browser_window_gtk->Init(); |
| 2593 return browser_window_gtk; | 2593 return browser_window_gtk; |
| 2594 } | 2594 } |
| OLD | NEW |