OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/toolbar/wrench_menu_model.h" | 5 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/task_manager/task_manager.h" | 22 #include "chrome/browser/task_manager/task_manager.h" |
23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
24 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
25 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" | 25 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" |
26 #include "chrome/browser/upgrade_detector.h" | 26 #include "chrome/browser/upgrade_detector.h" |
27 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
30 #include "chrome/common/profiling.h" | 30 #include "chrome/common/profiling.h" |
31 #include "content/browser/tab_contents/tab_contents.h" | 31 #include "content/browser/tab_contents/tab_contents.h" |
| 32 #include "content/common/content_notification_types.h" |
32 #include "content/common/notification_service.h" | 33 #include "content/common/notification_service.h" |
33 #include "content/common/notification_source.h" | 34 #include "content/common/notification_source.h" |
34 #include "content/common/notification_type.h" | |
35 #include "grit/chromium_strings.h" | 35 #include "grit/chromium_strings.h" |
36 #include "grit/generated_resources.h" | 36 #include "grit/generated_resources.h" |
37 #include "grit/theme_resources.h" | 37 #include "grit/theme_resources.h" |
38 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
39 #include "ui/base/models/button_menu_item_model.h" | 39 #include "ui/base/models/button_menu_item_model.h" |
40 #include "ui/base/resource/resource_bundle.h" | 40 #include "ui/base/resource/resource_bundle.h" |
41 | 41 |
42 #if defined(TOOLKIT_USES_GTK) | 42 #if defined(TOOLKIT_USES_GTK) |
43 #include <gtk/gtk.h> | 43 #include <gtk/gtk.h> |
44 #include "chrome/browser/ui/gtk/gtk_util.h" | 44 #include "chrome/browser/ui/gtk/gtk_util.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 Browser* browser) | 215 Browser* browser) |
216 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), | 216 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), |
217 provider_(provider), | 217 provider_(provider), |
218 browser_(browser), | 218 browser_(browser), |
219 tabstrip_model_(browser_->tabstrip_model()) { | 219 tabstrip_model_(browser_->tabstrip_model()) { |
220 Build(); | 220 Build(); |
221 UpdateZoomControls(); | 221 UpdateZoomControls(); |
222 | 222 |
223 tabstrip_model_->AddObserver(this); | 223 tabstrip_model_->AddObserver(this); |
224 | 224 |
225 registrar_.Add(this, NotificationType::ZOOM_LEVEL_CHANGED, | 225 registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED, |
226 Source<HostZoomMap>(browser_->profile()->GetHostZoomMap())); | 226 Source<HostZoomMap>(browser_->profile()->GetHostZoomMap())); |
227 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, | 227 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
228 NotificationService::AllSources()); | 228 NotificationService::AllSources()); |
229 } | 229 } |
230 | 230 |
231 WrenchMenuModel::~WrenchMenuModel() { | 231 WrenchMenuModel::~WrenchMenuModel() { |
232 if (tabstrip_model_) | 232 if (tabstrip_model_) |
233 tabstrip_model_->RemoveObserver(this); | 233 tabstrip_model_->RemoveObserver(this); |
234 } | 234 } |
235 | 235 |
236 bool WrenchMenuModel::DoesCommandIdDismissMenu(int command_id) const { | 236 bool WrenchMenuModel::DoesCommandIdDismissMenu(int command_id) const { |
237 return command_id != IDC_ZOOM_MINUS && command_id != IDC_ZOOM_PLUS; | 237 return command_id != IDC_ZOOM_MINUS && command_id != IDC_ZOOM_PLUS; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 UpdateZoomControls(); | 368 UpdateZoomControls(); |
369 } | 369 } |
370 | 370 |
371 void WrenchMenuModel::TabStripModelDeleted() { | 371 void WrenchMenuModel::TabStripModelDeleted() { |
372 // During views shutdown, the tabstrip model/browser is deleted first, while | 372 // During views shutdown, the tabstrip model/browser is deleted first, while |
373 // it is the opposite in gtk land. | 373 // it is the opposite in gtk land. |
374 tabstrip_model_->RemoveObserver(this); | 374 tabstrip_model_->RemoveObserver(this); |
375 tabstrip_model_ = NULL; | 375 tabstrip_model_ = NULL; |
376 } | 376 } |
377 | 377 |
378 void WrenchMenuModel::Observe(NotificationType type, | 378 void WrenchMenuModel::Observe(int type, |
379 const NotificationSource& source, | 379 const NotificationSource& source, |
380 const NotificationDetails& details) { | 380 const NotificationDetails& details) { |
381 switch (type.value) { | 381 switch (type) { |
382 case NotificationType::ZOOM_LEVEL_CHANGED: | 382 case content::NOTIFICATION_ZOOM_LEVEL_CHANGED: |
383 case NotificationType::NAV_ENTRY_COMMITTED: | 383 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: |
384 UpdateZoomControls(); | 384 UpdateZoomControls(); |
385 break; | 385 break; |
386 default: | 386 default: |
387 NOTREACHED(); | 387 NOTREACHED(); |
388 } | 388 } |
389 } | 389 } |
390 | 390 |
391 // For testing. | 391 // For testing. |
392 WrenchMenuModel::WrenchMenuModel() | 392 WrenchMenuModel::WrenchMenuModel() |
393 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), | 393 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 &enable_increment, &enable_decrement); | 544 &enable_increment, &enable_decrement); |
545 } | 545 } |
546 zoom_label_ = l10n_util::GetStringFUTF16( | 546 zoom_label_ = l10n_util::GetStringFUTF16( |
547 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 547 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
548 } | 548 } |
549 | 549 |
550 string16 WrenchMenuModel::GetSyncMenuLabel() const { | 550 string16 WrenchMenuModel::GetSyncMenuLabel() const { |
551 return sync_ui_util::GetSyncMenuLabel( | 551 return sync_ui_util::GetSyncMenuLabel( |
552 browser_->profile()->GetOriginalProfile()->GetProfileSyncService()); | 552 browser_->profile()->GetOriginalProfile()->GetProfileSyncService()); |
553 } | 553 } |
OLD | NEW |