| 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/collected_cookies_gtk.h" | 52 #include "chrome/browser/ui/gtk/collected_cookies_gtk.h" |
| 53 #include "chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h" | 53 #include "chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h" |
| 54 #include "chrome/browser/ui/gtk/download/download_in_progress_dialog_gtk.h" | 54 #include "chrome/browser/ui/gtk/download/download_in_progress_dialog_gtk.h" |
| 55 #include "chrome/browser/ui/gtk/download/download_shelf_gtk.h" | 55 #include "chrome/browser/ui/gtk/download/download_shelf_gtk.h" |
| 56 #include "chrome/browser/ui/gtk/edit_search_engine_dialog.h" | 56 #include "chrome/browser/ui/gtk/edit_search_engine_dialog.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" | |
| 61 #include "chrome/browser/ui/gtk/gtk_util.h" | 60 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 62 #include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h" | 61 #include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h" |
| 63 #include "chrome/browser/ui/gtk/infobars/infobar_gtk.h" | 62 #include "chrome/browser/ui/gtk/infobars/infobar_gtk.h" |
| 64 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" | 63 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
| 65 #include "chrome/browser/ui/gtk/nine_box.h" | 64 #include "chrome/browser/ui/gtk/nine_box.h" |
| 66 #include "chrome/browser/ui/gtk/reload_button_gtk.h" | 65 #include "chrome/browser/ui/gtk/reload_button_gtk.h" |
| 67 #include "chrome/browser/ui/gtk/status_bubble_gtk.h" | 66 #include "chrome/browser/ui/gtk/status_bubble_gtk.h" |
| 68 #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" | 67 #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" |
| 69 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" | 68 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" |
| 70 #include "chrome/browser/ui/gtk/task_manager_gtk.h" | 69 #include "chrome/browser/ui/gtk/task_manager_gtk.h" |
| 70 #include "chrome/browser/ui/gtk/theme_service_gtk.h" |
| 71 #include "chrome/browser/ui/gtk/update_recommended_dialog.h" | 71 #include "chrome/browser/ui/gtk/update_recommended_dialog.h" |
| 72 #include "chrome/browser/ui/omnibox/location_bar.h" | 72 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 73 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 73 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 74 #include "chrome/browser/ui/page_info_bubble.h" | 74 #include "chrome/browser/ui/page_info_bubble.h" |
| 75 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 75 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 76 #include "chrome/browser/ui/webui/task_manager_dialog.h" | 76 #include "chrome/browser/ui/webui/task_manager_dialog.h" |
| 77 #include "chrome/browser/web_applications/web_app.h" | 77 #include "chrome/browser/web_applications/web_app.h" |
| 78 #include "chrome/common/chrome_notification_types.h" | 78 #include "chrome/common/chrome_notification_types.h" |
| 79 #include "chrome/common/chrome_switches.h" | 79 #include "chrome/common/chrome_switches.h" |
| 80 #include "chrome/common/pref_names.h" | 80 #include "chrome/common/pref_names.h" |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 surface->SetSource(cr, widget, 0, GetVerticalOffset()); | 607 surface->SetSource(cr, widget, 0, GetVerticalOffset()); |
| 608 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REFLECT); | 608 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REFLECT); |
| 609 cairo_rectangle(cr, event->area.x, event->area.y, | 609 cairo_rectangle(cr, event->area.x, event->area.y, |
| 610 event->area.width, event->area.height); | 610 event->area.width, event->area.height); |
| 611 cairo_fill(cr); | 611 cairo_fill(cr); |
| 612 } | 612 } |
| 613 | 613 |
| 614 void BrowserWindowGtk::DrawCustomFrame(cairo_t* cr, | 614 void BrowserWindowGtk::DrawCustomFrame(cairo_t* cr, |
| 615 GtkWidget* widget, | 615 GtkWidget* widget, |
| 616 GdkEventExpose* event) { | 616 GdkEventExpose* event) { |
| 617 GtkThemeService* theme_provider = GtkThemeService::GetFrom( | 617 ThemeServiceGtk* theme_provider = ThemeServiceGtk::GetFrom( |
| 618 browser()->profile()); | 618 browser()->profile()); |
| 619 | 619 |
| 620 int image_name = GetThemeFrameResource(); | 620 int image_name = GetThemeFrameResource(); |
| 621 | 621 |
| 622 gfx::CairoCachedSurface* surface = theme_provider->GetImageNamed( | 622 gfx::CairoCachedSurface* surface = theme_provider->GetImageNamed( |
| 623 image_name)->ToCairo(); | 623 image_name)->ToCairo(); |
| 624 if (event->area.y < surface->Height()) { | 624 if (event->area.y < surface->Height()) { |
| 625 surface->SetSource(cr, widget, 0, GetVerticalOffset()); | 625 surface->SetSource(cr, widget, 0, GetVerticalOffset()); |
| 626 | 626 |
| 627 // The frame background isn't tiled vertically. | 627 // The frame background isn't tiled vertically. |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1345 if (changed) { | 1345 if (changed) { |
| 1346 SetBackgroundColor(); | 1346 SetBackgroundColor(); |
| 1347 InvalidateWindow(); | 1347 InvalidateWindow(); |
| 1348 // For some reason, the above two calls cause the window shape to be | 1348 // For some reason, the above two calls cause the window shape to be |
| 1349 // lost so reset it. | 1349 // lost so reset it. |
| 1350 UpdateWindowShape(bounds_.width(), bounds_.height()); | 1350 UpdateWindowShape(bounds_.width(), bounds_.height()); |
| 1351 } | 1351 } |
| 1352 } | 1352 } |
| 1353 | 1353 |
| 1354 SkColor BrowserWindowGtk::GetInfoBarSeparatorColor() const { | 1354 SkColor BrowserWindowGtk::GetInfoBarSeparatorColor() const { |
| 1355 GtkThemeService* theme_service = GtkThemeService::GetFrom( | 1355 ThemeServiceGtk* theme_service = ThemeServiceGtk::GetFrom( |
| 1356 browser()->profile()); | 1356 browser()->profile()); |
| 1357 return gfx::GdkColorToSkColor(theme_service->GetBorderColor()); | 1357 return gfx::GdkColorToSkColor(theme_service->GetBorderColor()); |
| 1358 } | 1358 } |
| 1359 | 1359 |
| 1360 void BrowserWindowGtk::InfoBarContainerStateChanged(bool is_animating) { | 1360 void BrowserWindowGtk::InfoBarContainerStateChanged(bool is_animating) { |
| 1361 InvalidateInfoBarBits(); | 1361 InvalidateInfoBarBits(); |
| 1362 } | 1362 } |
| 1363 | 1363 |
| 1364 bool BrowserWindowGtk::DrawInfoBarArrows(int* x) const { | 1364 bool BrowserWindowGtk::DrawInfoBarArrows(int* x) const { |
| 1365 if (x) { | 1365 if (x) { |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1901 // the default. | 1901 // the default. |
| 1902 gtk_util::SetWindowIcon(window_, browser_->profile()); | 1902 gtk_util::SetWindowIcon(window_, browser_->profile()); |
| 1903 | 1903 |
| 1904 gtk_container_add(GTK_CONTAINER(window_), window_container_); | 1904 gtk_container_add(GTK_CONTAINER(window_), window_container_); |
| 1905 gtk_widget_show(window_container_); | 1905 gtk_widget_show(window_container_); |
| 1906 browser_->tabstrip_model()->AddObserver(this); | 1906 browser_->tabstrip_model()->AddObserver(this); |
| 1907 } | 1907 } |
| 1908 | 1908 |
| 1909 void BrowserWindowGtk::SetBackgroundColor() { | 1909 void BrowserWindowGtk::SetBackgroundColor() { |
| 1910 Profile* profile = browser()->profile(); | 1910 Profile* profile = browser()->profile(); |
| 1911 GtkThemeService* theme_provider = GtkThemeService::GetFrom(profile); | 1911 ThemeServiceGtk* theme_provider = ThemeServiceGtk::GetFrom(profile); |
| 1912 int frame_color_id; | 1912 int frame_color_id; |
| 1913 if (UsingCustomPopupFrame()) { | 1913 if (UsingCustomPopupFrame()) { |
| 1914 frame_color_id = ThemeService::COLOR_TOOLBAR; | 1914 frame_color_id = ThemeService::COLOR_TOOLBAR; |
| 1915 } else if (IsActive()) { | 1915 } else if (IsActive()) { |
| 1916 frame_color_id = browser()->profile()->IsOffTheRecord() | 1916 frame_color_id = browser()->profile()->IsOffTheRecord() |
| 1917 ? ThemeService::COLOR_FRAME_INCOGNITO | 1917 ? ThemeService::COLOR_FRAME_INCOGNITO |
| 1918 : ThemeService::COLOR_FRAME; | 1918 : ThemeService::COLOR_FRAME; |
| 1919 } else { | 1919 } else { |
| 1920 frame_color_id = browser()->profile()->IsOffTheRecord() | 1920 frame_color_id = browser()->profile()->IsOffTheRecord() |
| 1921 ? ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE | 1921 ? ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2402 bool BrowserWindowGtk::IsToolbarSupported() const { | 2402 bool BrowserWindowGtk::IsToolbarSupported() const { |
| 2403 return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || | 2403 return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || |
| 2404 browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); | 2404 browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); |
| 2405 } | 2405 } |
| 2406 | 2406 |
| 2407 bool BrowserWindowGtk::IsBookmarkBarSupported() const { | 2407 bool BrowserWindowGtk::IsBookmarkBarSupported() const { |
| 2408 return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR); | 2408 return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR); |
| 2409 } | 2409 } |
| 2410 | 2410 |
| 2411 bool BrowserWindowGtk::UsingCustomPopupFrame() const { | 2411 bool BrowserWindowGtk::UsingCustomPopupFrame() const { |
| 2412 GtkThemeService* theme_provider = GtkThemeService::GetFrom( | 2412 ThemeServiceGtk* theme_provider = ThemeServiceGtk::GetFrom( |
| 2413 browser()->profile()); | 2413 browser()->profile()); |
| 2414 return !theme_provider->UsingNativeTheme() && | 2414 return !theme_provider->UsingNativeTheme() && |
| 2415 (browser()->is_type_popup() || browser()->is_type_panel()); | 2415 (browser()->is_type_popup() || browser()->is_type_panel()); |
| 2416 } | 2416 } |
| 2417 | 2417 |
| 2418 bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { | 2418 bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { |
| 2419 if (!UseCustomFrame()) | 2419 if (!UseCustomFrame()) |
| 2420 return false; | 2420 return false; |
| 2421 | 2421 |
| 2422 if (IsMaximized() || IsFullscreen()) | 2422 if (IsMaximized() || IsFullscreen()) |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2548 wm_type == ui::WM_OPENBOX || | 2548 wm_type == ui::WM_OPENBOX || |
| 2549 wm_type == ui::WM_XFWM4); | 2549 wm_type == ui::WM_XFWM4); |
| 2550 } | 2550 } |
| 2551 | 2551 |
| 2552 // static | 2552 // static |
| 2553 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2553 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 2554 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); | 2554 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); |
| 2555 browser_window_gtk->Init(); | 2555 browser_window_gtk->Init(); |
| 2556 return browser_window_gtk; | 2556 return browser_window_gtk; |
| 2557 } | 2557 } |
| OLD | NEW |