| 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_toolbar_gtk.h" | 5 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #include <X11/XF86keysym.h> | 9 #include <X11/XF86keysym.h> |
| 10 | 10 |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 if (accelerator_gtk) | 361 if (accelerator_gtk) |
| 362 *accelerator = *accelerator_gtk; | 362 *accelerator = *accelerator_gtk; |
| 363 return !!accelerator_gtk; | 363 return !!accelerator_gtk; |
| 364 } | 364 } |
| 365 | 365 |
| 366 // content::NotificationObserver ----------------------------------------------- | 366 // content::NotificationObserver ----------------------------------------------- |
| 367 | 367 |
| 368 void BrowserToolbarGtk::Observe(int type, | 368 void BrowserToolbarGtk::Observe(int type, |
| 369 const content::NotificationSource& source, | 369 const content::NotificationSource& source, |
| 370 const content::NotificationDetails& details) { | 370 const content::NotificationDetails& details) { |
| 371 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 371 if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { |
| 372 NotifyPrefChanged(content::Details<std::string>(details).ptr()); | |
| 373 } else if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { | |
| 374 // Update the spacing around the menu buttons | 372 // Update the spacing around the menu buttons |
| 375 bool use_gtk = theme_service_->UsingNativeTheme(); | 373 bool use_gtk = theme_service_->UsingNativeTheme(); |
| 376 int border = use_gtk ? 0 : 2; | 374 int border = use_gtk ? 0 : 2; |
| 377 gtk_container_set_border_width( | 375 gtk_container_set_border_width( |
| 378 GTK_CONTAINER(wrench_menu_button_->widget()), border); | 376 GTK_CONTAINER(wrench_menu_button_->widget()), border); |
| 379 | 377 |
| 380 // Force the height of the toolbar so we get the right amount of padding | 378 // Force the height of the toolbar so we get the right amount of padding |
| 381 // above and below the location bar. We always force the size of the widgets | 379 // above and below the location bar. We always force the size of the widgets |
| 382 // to either side of the location box, but we only force the location box | 380 // to either side of the location box, but we only force the location box |
| 383 // size in chrome-theme mode because that's the only time we try to control | 381 // size in chrome-theme mode because that's the only time we try to control |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 wrench_menu_model_->UpdateZoomControls(); | 417 wrench_menu_model_->UpdateZoomControls(); |
| 420 | 418 |
| 421 // If our zoom level changed, we need to tell the menu to update its state, | 419 // If our zoom level changed, we need to tell the menu to update its state, |
| 422 // since the menu could still be open. | 420 // since the menu could still be open. |
| 423 wrench_menu_->UpdateMenu(); | 421 wrench_menu_->UpdateMenu(); |
| 424 } else { | 422 } else { |
| 425 NOTREACHED(); | 423 NOTREACHED(); |
| 426 } | 424 } |
| 427 } | 425 } |
| 428 | 426 |
| 427 void BrowserToolbarGtk::OnPreferenceChanged(PrefServiceBase* service, |
| 428 const std::string& pref_name) { |
| 429 NotifyPrefChanged(pref_name); |
| 430 } |
| 431 |
| 429 // BrowserToolbarGtk, public --------------------------------------------------- | 432 // BrowserToolbarGtk, public --------------------------------------------------- |
| 430 | 433 |
| 431 void BrowserToolbarGtk::UpdateWebContents(WebContents* contents, | 434 void BrowserToolbarGtk::UpdateWebContents(WebContents* contents, |
| 432 bool should_restore_state) { | 435 bool should_restore_state) { |
| 433 location_bar_->Update(should_restore_state ? contents : NULL); | 436 location_bar_->Update(should_restore_state ? contents : NULL); |
| 434 | 437 |
| 435 if (actions_toolbar_.get()) | 438 if (actions_toolbar_.get()) |
| 436 actions_toolbar_->Update(); | 439 actions_toolbar_->Update(); |
| 437 } | 440 } |
| 438 | 441 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 if (!url.is_valid()) | 646 if (!url.is_valid()) |
| 644 return; | 647 return; |
| 645 | 648 |
| 646 bool url_is_newtab = url.SchemeIs(chrome::kChromeUIScheme) && | 649 bool url_is_newtab = url.SchemeIs(chrome::kChromeUIScheme) && |
| 647 url.host() == chrome::kChromeUINewTabHost; | 650 url.host() == chrome::kChromeUINewTabHost; |
| 648 home_page_is_new_tab_page_.SetValue(url_is_newtab); | 651 home_page_is_new_tab_page_.SetValue(url_is_newtab); |
| 649 if (!url_is_newtab) | 652 if (!url_is_newtab) |
| 650 home_page_.SetValue(url.spec()); | 653 home_page_.SetValue(url.spec()); |
| 651 } | 654 } |
| 652 | 655 |
| 653 void BrowserToolbarGtk::NotifyPrefChanged(const std::string* pref) { | 656 void BrowserToolbarGtk::NotifyPrefChanged(const std::string& pref) { |
| 654 if (!pref || *pref == prefs::kShowHomeButton) { | 657 if (pref == prefs::kShowHomeButton) { |
| 655 bool visible = show_home_button_.GetValue() && !ShouldOnlyShowLocation(); | 658 bool visible = show_home_button_.GetValue() && !ShouldOnlyShowLocation(); |
| 656 gtk_widget_set_visible(home_->widget(), visible); | 659 gtk_widget_set_visible(home_->widget(), visible); |
| 657 } | 660 } |
| 658 | 661 |
| 659 if (!pref || | 662 if (pref == prefs::kHomePage || |
| 660 *pref == prefs::kHomePage || | 663 pref == prefs::kHomePageIsNewTabPage) |
| 661 *pref == prefs::kHomePageIsNewTabPage) | |
| 662 SetUpDragForHomeButton(!home_page_.IsManaged() && | 664 SetUpDragForHomeButton(!home_page_.IsManaged() && |
| 663 !home_page_is_new_tab_page_.IsManaged()); | 665 !home_page_is_new_tab_page_.IsManaged()); |
| 664 } | 666 } |
| 665 | 667 |
| 666 bool BrowserToolbarGtk::ShouldOnlyShowLocation() const { | 668 bool BrowserToolbarGtk::ShouldOnlyShowLocation() const { |
| 667 // If we're a popup window, only show the location bar (omnibox). | 669 // If we're a popup window, only show the location bar (omnibox). |
| 668 return !browser_->is_type_tabbed(); | 670 return !browser_->is_type_tabbed(); |
| 669 } | 671 } |
| 670 | 672 |
| 671 void BrowserToolbarGtk::RebuildWrenchMenu() { | 673 void BrowserToolbarGtk::RebuildWrenchMenu() { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 698 const gfx::ImageSkia* badge = theme_service_->GetImageSkiaNamed(resource_id); | 700 const gfx::ImageSkia* badge = theme_service_->GetImageSkiaNamed(resource_id); |
| 699 gfx::CanvasSkiaPaint canvas(expose, false); | 701 gfx::CanvasSkiaPaint canvas(expose, false); |
| 700 int x_offset = base::i18n::IsRTL() ? 0 : allocation.width - badge->width(); | 702 int x_offset = base::i18n::IsRTL() ? 0 : allocation.width - badge->width(); |
| 701 int y_offset = 0; | 703 int y_offset = 0; |
| 702 canvas.DrawImageInt(*badge, | 704 canvas.DrawImageInt(*badge, |
| 703 allocation.x + x_offset, | 705 allocation.x + x_offset, |
| 704 allocation.y + y_offset); | 706 allocation.y + y_offset); |
| 705 | 707 |
| 706 return FALSE; | 708 return FALSE; |
| 707 } | 709 } |
| OLD | NEW |