Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: chrome/browser/ui/gtk/browser_toolbar_gtk.cc

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head for commit Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/gtk/browser_toolbar_gtk.h ('k') | chrome/browser/ui/gtk/browser_window_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 gtk_widget_show(event_box_); 243 gtk_widget_show(event_box_);
244 gtk_widget_show(alignment_); 244 gtk_widget_show(alignment_);
245 gtk_widget_show(toolbar_); 245 gtk_widget_show(toolbar_);
246 gtk_widget_show_all(location_hbox_); 246 gtk_widget_show_all(location_hbox_);
247 gtk_widget_hide(reload_->widget()); 247 gtk_widget_hide(reload_->widget());
248 } else { 248 } else {
249 gtk_widget_show_all(event_box_); 249 gtk_widget_show_all(event_box_);
250 if (actions_toolbar_->button_count() == 0) 250 if (actions_toolbar_->button_count() == 0)
251 gtk_widget_hide(actions_toolbar_->widget()); 251 gtk_widget_hide(actions_toolbar_->widget());
252 } 252 }
253
253 // Initialize pref-dependent UI state. 254 // Initialize pref-dependent UI state.
254 NotifyPrefChanged(NULL); 255 NotifyPrefChanged(NULL);
255 256
256 // Because the above does a recursive show all on all widgets we need to 257 // Because the above does a recursive show all on all widgets we need to
257 // update the icon visibility to hide them. 258 // update the icon visibility to hide them.
258 location_bar_->UpdateContentSettingsIcons(); 259 location_bar_->UpdateContentSettingsIcons();
259 260
260 SetViewIDs(); 261 SetViewIDs();
261 theme_service_->InitThemesFor(this); 262 theme_service_->InitThemesFor(this);
262 } 263 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 if (accelerator_gtk) 362 if (accelerator_gtk)
362 *accelerator = *accelerator_gtk; 363 *accelerator = *accelerator_gtk;
363 return !!accelerator_gtk; 364 return !!accelerator_gtk;
364 } 365 }
365 366
366 // content::NotificationObserver ----------------------------------------------- 367 // content::NotificationObserver -----------------------------------------------
367 368
368 void BrowserToolbarGtk::Observe(int type, 369 void BrowserToolbarGtk::Observe(int type,
369 const content::NotificationSource& source, 370 const content::NotificationSource& source,
370 const content::NotificationDetails& details) { 371 const content::NotificationDetails& details) {
371 if (type == chrome::NOTIFICATION_PREF_CHANGED) { 372 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 373 // Update the spacing around the menu buttons
375 bool use_gtk = theme_service_->UsingNativeTheme(); 374 bool use_gtk = theme_service_->UsingNativeTheme();
376 int border = use_gtk ? 0 : 2; 375 int border = use_gtk ? 0 : 2;
377 gtk_container_set_border_width( 376 gtk_container_set_border_width(
378 GTK_CONTAINER(wrench_menu_button_->widget()), border); 377 GTK_CONTAINER(wrench_menu_button_->widget()), border);
379 378
380 // Force the height of the toolbar so we get the right amount of padding 379 // 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 380 // 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 381 // 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 382 // 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
419 wrench_menu_model_->UpdateZoomControls(); 418 wrench_menu_model_->UpdateZoomControls();
420 419
421 // If our zoom level changed, we need to tell the menu to update its state, 420 // If our zoom level changed, we need to tell the menu to update its state,
422 // since the menu could still be open. 421 // since the menu could still be open.
423 wrench_menu_->UpdateMenu(); 422 wrench_menu_->UpdateMenu();
424 } else { 423 } else {
425 NOTREACHED(); 424 NOTREACHED();
426 } 425 }
427 } 426 }
428 427
428 void BrowserToolbarGtk::OnPreferenceChanged(PrefServiceBase* service,
429 const std::string& pref_name) {
430 NotifyPrefChanged(&pref_name);
431 }
432
429 // BrowserToolbarGtk, public --------------------------------------------------- 433 // BrowserToolbarGtk, public ---------------------------------------------------
430 434
431 void BrowserToolbarGtk::UpdateWebContents(WebContents* contents, 435 void BrowserToolbarGtk::UpdateWebContents(WebContents* contents,
432 bool should_restore_state) { 436 bool should_restore_state) {
433 location_bar_->Update(should_restore_state ? contents : NULL); 437 location_bar_->Update(should_restore_state ? contents : NULL);
434 438
435 if (actions_toolbar_.get()) 439 if (actions_toolbar_.get())
436 actions_toolbar_->Update(); 440 actions_toolbar_->Update();
437 } 441 }
438 442
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 const gfx::ImageSkia* badge = theme_service_->GetImageSkiaNamed(resource_id); 702 const gfx::ImageSkia* badge = theme_service_->GetImageSkiaNamed(resource_id);
699 gfx::CanvasSkiaPaint canvas(expose, false); 703 gfx::CanvasSkiaPaint canvas(expose, false);
700 int x_offset = base::i18n::IsRTL() ? 0 : allocation.width - badge->width(); 704 int x_offset = base::i18n::IsRTL() ? 0 : allocation.width - badge->width();
701 int y_offset = 0; 705 int y_offset = 0;
702 canvas.DrawImageInt(*badge, 706 canvas.DrawImageInt(*badge,
703 allocation.x + x_offset, 707 allocation.x + x_offset,
704 allocation.y + y_offset); 708 allocation.y + y_offset);
705 709
706 return FALSE; 710 return FALSE;
707 } 711 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/browser_toolbar_gtk.h ('k') | chrome/browser/ui/gtk/browser_window_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698