| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/browser_toolbar_gtk.h" | 5 #include "chrome/browser/gtk/browser_toolbar_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <X11/XF86keysym.h> | 8 #include <X11/XF86keysym.h> |
| 9 | 9 |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| 11 #include "app/resource_bundle.h" | 11 #include "app/resource_bundle.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/base_paths_linux.h" | 13 #include "base/base_paths_linux.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "chrome/app/chrome_dll_resource.h" | 15 #include "chrome/app/chrome_dll_resource.h" |
| 16 #include "chrome/browser/browser.h" | 16 #include "chrome/browser/browser.h" |
| 17 #include "chrome/browser/browser_theme_provider.h" | 17 #include "chrome/browser/browser_theme_provider.h" |
| 18 #include "chrome/browser/gtk/back_forward_button_gtk.h" | 18 #include "chrome/browser/gtk/back_forward_button_gtk.h" |
| 19 #include "chrome/browser/gtk/browser_window_gtk.h" | 19 #include "chrome/browser/gtk/browser_window_gtk.h" |
| 20 #include "chrome/browser/gtk/custom_button.h" | 20 #include "chrome/browser/gtk/custom_button.h" |
| 21 #include "chrome/browser/gtk/dnd_registry.h" | |
| 22 #include "chrome/browser/gtk/go_button_gtk.h" | 21 #include "chrome/browser/gtk/go_button_gtk.h" |
| 23 #include "chrome/browser/gtk/gtk_chrome_button.h" | 22 #include "chrome/browser/gtk/gtk_chrome_button.h" |
| 23 #include "chrome/browser/gtk/gtk_dnd_util.h" |
| 24 #include "chrome/browser/gtk/location_bar_view_gtk.h" | 24 #include "chrome/browser/gtk/location_bar_view_gtk.h" |
| 25 #include "chrome/browser/gtk/nine_box.h" | 25 #include "chrome/browser/gtk/nine_box.h" |
| 26 #include "chrome/browser/gtk/standard_menus.h" | 26 #include "chrome/browser/gtk/standard_menus.h" |
| 27 #include "chrome/browser/gtk/tabs/tab_strip_gtk.h" | 27 #include "chrome/browser/gtk/tabs/tab_strip_gtk.h" |
| 28 #include "chrome/browser/gtk/toolbar_star_toggle_gtk.h" | 28 #include "chrome/browser/gtk/toolbar_star_toggle_gtk.h" |
| 29 #include "chrome/browser/net/url_fixer_upper.h" | 29 #include "chrome/browser/net/url_fixer_upper.h" |
| 30 #include "chrome/browser/profile.h" | 30 #include "chrome/browser/profile.h" |
| 31 #include "chrome/common/gtk_util.h" | 31 #include "chrome/common/gtk_util.h" |
| 32 #include "chrome/common/notification_details.h" | 32 #include "chrome/common/notification_details.h" |
| 33 #include "chrome/common/notification_type.h" | 33 #include "chrome/common/notification_type.h" |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); | 342 GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); |
| 343 | 343 |
| 344 return button; | 344 return button; |
| 345 } | 345 } |
| 346 | 346 |
| 347 void BrowserToolbarGtk::SetUpDragForHomeButton() { | 347 void BrowserToolbarGtk::SetUpDragForHomeButton() { |
| 348 // TODO(estade): we should use a custom drag-drop handler so that we can | 348 // TODO(estade): we should use a custom drag-drop handler so that we can |
| 349 // prefer URIs over plain text when both are available. | 349 // prefer URIs over plain text when both are available. |
| 350 gtk_drag_dest_set(home_->widget(), GTK_DEST_DEFAULT_ALL, | 350 gtk_drag_dest_set(home_->widget(), GTK_DEST_DEFAULT_ALL, |
| 351 NULL, 0, GDK_ACTION_COPY); | 351 NULL, 0, GDK_ACTION_COPY); |
| 352 dnd::SetDestTargetListFromCodeMask(home_->widget(), | 352 GtkDndUtil::SetDestTargetListFromCodeMask(home_->widget(), |
| 353 dnd::X_CHROME_TEXT_PLAIN | | 353 GtkDndUtil::X_CHROME_TEXT_PLAIN | |
| 354 dnd::X_CHROME_TEXT_URI_LIST); | 354 GtkDndUtil::X_CHROME_TEXT_URI_LIST); |
| 355 | 355 |
| 356 g_signal_connect(home_->widget(), "drag-data-received", | 356 g_signal_connect(home_->widget(), "drag-data-received", |
| 357 G_CALLBACK(OnDragDataReceived), this); | 357 G_CALLBACK(OnDragDataReceived), this); |
| 358 } | 358 } |
| 359 | 359 |
| 360 // static | 360 // static |
| 361 gboolean BrowserToolbarGtk::OnToolbarExpose(GtkWidget* widget, | 361 gboolean BrowserToolbarGtk::OnToolbarExpose(GtkWidget* widget, |
| 362 GdkEventExpose* e, | 362 GdkEventExpose* e, |
| 363 BrowserToolbarGtk* toolbar) { | 363 BrowserToolbarGtk* toolbar) { |
| 364 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); | 364 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 menu->Popup(button, reinterpret_cast<GdkEvent*>(event)); | 416 menu->Popup(button, reinterpret_cast<GdkEvent*>(event)); |
| 417 | 417 |
| 418 return TRUE; | 418 return TRUE; |
| 419 } | 419 } |
| 420 | 420 |
| 421 // static | 421 // static |
| 422 void BrowserToolbarGtk::OnDragDataReceived(GtkWidget* widget, | 422 void BrowserToolbarGtk::OnDragDataReceived(GtkWidget* widget, |
| 423 GdkDragContext* drag_context, gint x, gint y, | 423 GdkDragContext* drag_context, gint x, gint y, |
| 424 GtkSelectionData* data, guint info, guint time, | 424 GtkSelectionData* data, guint info, guint time, |
| 425 BrowserToolbarGtk* toolbar) { | 425 BrowserToolbarGtk* toolbar) { |
| 426 if (info != dnd::X_CHROME_TEXT_PLAIN) { | 426 if (info != GtkDndUtil::X_CHROME_TEXT_PLAIN) { |
| 427 NOTIMPLEMENTED() << "Only support plain text drops for now, sorry!"; | 427 NOTIMPLEMENTED() << "Only support plain text drops for now, sorry!"; |
| 428 return; | 428 return; |
| 429 } | 429 } |
| 430 | 430 |
| 431 GURL url(reinterpret_cast<char*>(data->data)); | 431 GURL url(reinterpret_cast<char*>(data->data)); |
| 432 if (!url.is_valid()) { | 432 if (!url.is_valid()) |
| 433 // FIXME: remove this | |
| 434 NOTIMPLEMENTED() << "invalid url: " << url.spec(); | |
| 435 return; | 433 return; |
| 436 } | |
| 437 | 434 |
| 438 bool url_is_newtab = url.spec() == chrome::kChromeUINewTabURL; | 435 bool url_is_newtab = url.spec() == chrome::kChromeUINewTabURL; |
| 439 toolbar->profile_->GetPrefs()->SetBoolean(prefs::kHomePageIsNewTabPage, | 436 toolbar->profile_->GetPrefs()->SetBoolean(prefs::kHomePageIsNewTabPage, |
| 440 url_is_newtab); | 437 url_is_newtab); |
| 441 if (!url_is_newtab) { | 438 if (!url_is_newtab) { |
| 442 toolbar->profile_->GetPrefs()->SetString(prefs::kHomePage, | 439 toolbar->profile_->GetPrefs()->SetString(prefs::kHomePage, |
| 443 UTF8ToWide(url.spec())); | 440 UTF8ToWide(url.spec())); |
| 444 } | 441 } |
| 445 } | 442 } |
| 446 | 443 |
| 447 void BrowserToolbarGtk::InitNineBox() { | 444 void BrowserToolbarGtk::InitNineBox() { |
| 448 // TODO(estade): use |profile_|? | 445 // TODO(estade): use |profile_|? |
| 449 background_ninebox_.reset(new NineBox( | 446 background_ninebox_.reset(new NineBox( |
| 450 browser_->profile()->GetThemeProvider(), | 447 browser_->profile()->GetThemeProvider(), |
| 451 0, IDR_THEME_TOOLBAR, 0, 0, 0, 0, 0, 0, 0)); | 448 0, IDR_THEME_TOOLBAR, 0, 0, 0, 0, 0, 0, 0)); |
| 452 } | 449 } |
| OLD | NEW |