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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #if defined(TOOLKIT_USES_GTK) | 50 #if defined(TOOLKIT_USES_GTK) |
51 #include <gtk/gtk.h> | 51 #include <gtk/gtk.h> |
52 #include "chrome/browser/ui/gtk/gtk_util.h" | 52 #include "chrome/browser/ui/gtk/gtk_util.h" |
53 #endif | 53 #endif |
54 | 54 |
55 #if defined(OS_WIN) | 55 #if defined(OS_WIN) |
56 #include "chrome/browser/enumerate_modules_model_win.h" | 56 #include "chrome/browser/enumerate_modules_model_win.h" |
57 #endif | 57 #endif |
58 | 58 |
59 using content::UserMetricsAction; | 59 using content::UserMetricsAction; |
| 60 using content::WebContents; |
60 | 61 |
61 //////////////////////////////////////////////////////////////////////////////// | 62 //////////////////////////////////////////////////////////////////////////////// |
62 // EncodingMenuModel | 63 // EncodingMenuModel |
63 | 64 |
64 EncodingMenuModel::EncodingMenuModel(Browser* browser) | 65 EncodingMenuModel::EncodingMenuModel(Browser* browser) |
65 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), | 66 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), |
66 browser_(browser) { | 67 browser_(browser) { |
67 Build(); | 68 Build(); |
68 } | 69 } |
69 | 70 |
(...skipping 21 matching lines...) Expand all Loading... |
91 // Use the id of the first radio command as the id of the group. | 92 // Use the id of the first radio command as the id of the group. |
92 if (group_id <= 0) | 93 if (group_id <= 0) |
93 group_id = id; | 94 group_id = id; |
94 AddRadioItem(id, label, group_id); | 95 AddRadioItem(id, label, group_id); |
95 } | 96 } |
96 } | 97 } |
97 } | 98 } |
98 } | 99 } |
99 | 100 |
100 bool EncodingMenuModel::IsCommandIdChecked(int command_id) const { | 101 bool EncodingMenuModel::IsCommandIdChecked(int command_id) const { |
101 TabContents* current_tab = browser_->GetSelectedTabContents(); | 102 WebContents* current_tab = browser_->GetSelectedWebContents(); |
102 if (!current_tab) | 103 if (!current_tab) |
103 return false; | 104 return false; |
104 EncodingMenuController controller; | 105 EncodingMenuController controller; |
105 return controller.IsItemChecked(browser_->profile(), | 106 return controller.IsItemChecked(browser_->profile(), |
106 current_tab->GetEncoding(), command_id); | 107 current_tab->GetEncoding(), command_id); |
107 } | 108 } |
108 | 109 |
109 bool EncodingMenuModel::IsCommandIdEnabled(int command_id) const { | 110 bool EncodingMenuModel::IsCommandIdEnabled(int command_id) const { |
110 bool enabled = browser_->command_updater()->IsCommandEnabled(command_id); | 111 bool enabled = browser_->command_updater()->IsCommandEnabled(command_id); |
111 // Special handling for the contents of the Encoding submenu. On Mac OS, | 112 // Special handling for the contents of the Encoding submenu. On Mac OS, |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 // you change the order you'll need to update wrench_menu as well. | 584 // you change the order you'll need to update wrench_menu as well. |
584 AddItemWithStringId(IDC_ZOOM_MINUS, IDS_ZOOM_MINUS); | 585 AddItemWithStringId(IDC_ZOOM_MINUS, IDS_ZOOM_MINUS); |
585 AddItemWithStringId(IDC_ZOOM_PLUS, IDS_ZOOM_PLUS); | 586 AddItemWithStringId(IDC_ZOOM_PLUS, IDS_ZOOM_PLUS); |
586 AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN); | 587 AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN); |
587 } | 588 } |
588 | 589 |
589 void WrenchMenuModel::UpdateZoomControls() { | 590 void WrenchMenuModel::UpdateZoomControls() { |
590 bool enable_increment = false; | 591 bool enable_increment = false; |
591 bool enable_decrement = false; | 592 bool enable_decrement = false; |
592 int zoom_percent = 100; | 593 int zoom_percent = 100; |
593 if (browser_->GetSelectedTabContents()) { | 594 if (browser_->GetSelectedWebContents()) { |
594 zoom_percent = browser_->GetSelectedTabContents()->GetZoomPercent( | 595 zoom_percent = browser_->GetSelectedWebContents()->GetZoomPercent( |
595 &enable_increment, &enable_decrement); | 596 &enable_increment, &enable_decrement); |
596 } | 597 } |
597 zoom_label_ = l10n_util::GetStringFUTF16( | 598 zoom_label_ = l10n_util::GetStringFUTF16( |
598 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 599 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
599 } | 600 } |
600 | 601 |
601 string16 WrenchMenuModel::GetSyncMenuLabel() const { | 602 string16 WrenchMenuModel::GetSyncMenuLabel() const { |
602 return sync_ui_util::GetSyncMenuLabel( | 603 return sync_ui_util::GetSyncMenuLabel( |
603 browser_->profile()->GetOriginalProfile()->GetProfileSyncService()); | 604 browser_->profile()->GetOriginalProfile()->GetProfileSyncService()); |
604 } | 605 } |
OLD | NEW |