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/chromeos/status_area_view.h" | 5 #include "chrome/browser/chromeos/status_area_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/gfx/canvas.h" | 9 #include "app/gfx/canvas.h" |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // These extra command IDs must be unique when combined with the options, | 45 // These extra command IDs must be unique when combined with the options, |
46 // so we just pick up the numbering where that stops. | 46 // so we just pick up the numbering where that stops. |
47 enum OtherCommands { | 47 enum OtherCommands { |
48 CREATE_NEW_WINDOW = StatusAreaView::OPEN_TABS_ON_RIGHT + 1, | 48 CREATE_NEW_WINDOW = StatusAreaView::OPEN_TABS_ON_RIGHT + 1, |
49 }; | 49 }; |
50 | 50 |
51 explicit OptionsMenuModel(Browser* browser, | 51 explicit OptionsMenuModel(Browser* browser, |
52 views::SimpleMenuModel::Delegate* delegate) | 52 views::SimpleMenuModel::Delegate* delegate) |
53 : SimpleMenuModel(this), | 53 : SimpleMenuModel(this), |
54 browser_(browser) { | 54 browser_(browser) { |
| 55 #if defined(TOOLKIT_VIEWS) |
| 56 AddItemWithStringId(IDC_COMPACT_NAVBAR, IDS_COMPACT_NAVBAR); |
| 57 #else |
55 AddItem(static_cast<int>(CREATE_NEW_WINDOW), | 58 AddItem(static_cast<int>(CREATE_NEW_WINDOW), |
56 ASCIIToUTF16("New window")); | 59 ASCIIToUTF16("New window")); |
57 | 60 #endif |
58 AddSeparator(); | 61 AddSeparator(); |
59 | 62 |
60 AddItem(static_cast<int>(StatusAreaView::OPEN_TABS_ON_LEFT), | 63 AddItem(static_cast<int>(StatusAreaView::OPEN_TABS_ON_LEFT), |
61 ASCIIToUTF16("Open tabs on left")); | 64 ASCIIToUTF16("Open tabs on left")); |
62 AddItem(static_cast<int>(StatusAreaView::OPEN_TABS_CLOBBER), | 65 AddItem(static_cast<int>(StatusAreaView::OPEN_TABS_CLOBBER), |
63 ASCIIToUTF16("Open tabs clobber")); | 66 ASCIIToUTF16("Open tabs clobber")); |
64 AddItem(static_cast<int>(StatusAreaView::OPEN_TABS_ON_RIGHT), | 67 AddItem(static_cast<int>(StatusAreaView::OPEN_TABS_ON_RIGHT), |
65 ASCIIToUTF16("Open tabs on right")); | 68 ASCIIToUTF16("Open tabs on right")); |
66 } | 69 } |
67 virtual ~OptionsMenuModel() { | 70 virtual ~OptionsMenuModel() { |
68 } | 71 } |
69 | 72 |
70 // SimpleMenuModel::Delegate implementation. | 73 // SimpleMenuModel::Delegate implementation. |
71 virtual bool IsCommandIdChecked(int command_id) const { | 74 virtual bool IsCommandIdChecked(int command_id) const { |
72 return StatusAreaView::GetOpenTabsMode() == command_id; | 75 return StatusAreaView::GetOpenTabsMode() == command_id; |
73 } | 76 } |
74 virtual bool IsCommandIdEnabled(int command_id) const { | 77 virtual bool IsCommandIdEnabled(int command_id) const { |
75 return true; | 78 return true; |
76 } | 79 } |
77 virtual bool GetAcceleratorForCommandId( | 80 virtual bool GetAcceleratorForCommandId( |
78 int command_id, | 81 int command_id, |
79 views::Accelerator* accelerator) { | 82 views::Accelerator* accelerator) { |
80 return false; | 83 return false; |
81 } | 84 } |
82 virtual void ExecuteCommand(int command_id) { | 85 virtual void ExecuteCommand(int command_id) { |
83 switch (command_id) { | 86 switch (command_id) { |
| 87 #if defined(TOOLKIT_VIEWS) |
| 88 case IDC_COMPACT_NAVBAR: |
| 89 browser_->ExecuteCommand(command_id); |
| 90 break; |
| 91 #else |
84 case CREATE_NEW_WINDOW: | 92 case CREATE_NEW_WINDOW: |
85 #if defined(TOOLKIT_VIEWS) | |
86 // TODO(oshima): Implement accelerator to enable/disable | |
87 // compact nav bar. | |
88 #else | |
89 // Reach into the GTK browser window and enable the flag to create the | 93 // Reach into the GTK browser window and enable the flag to create the |
90 // next window as a compact nav one. | 94 // next window as a compact nav one. |
91 // TODO(brettw) this is an evil hack, and is here so this can be tested. | 95 // TODO(brettw) this is an evil hack, and is here so this can be tested. |
92 // Remove it eventually. | 96 // Remove it eventually. |
93 static_cast<BrowserWindowGtk*>(browser_->window())-> | 97 static_cast<BrowserWindowGtk*>(browser_->window())-> |
94 set_next_window_should_use_compact_nav(); | 98 set_next_window_should_use_compact_nav(); |
95 browser_->ExecuteCommand(IDC_NEW_WINDOW); | 99 browser_->ExecuteCommand(IDC_NEW_WINDOW); |
| 100 break; |
96 #endif | 101 #endif |
97 break; | |
98 case StatusAreaView::OPEN_TABS_ON_LEFT: | 102 case StatusAreaView::OPEN_TABS_ON_LEFT: |
99 case StatusAreaView::OPEN_TABS_CLOBBER: | 103 case StatusAreaView::OPEN_TABS_CLOBBER: |
100 case StatusAreaView::OPEN_TABS_ON_RIGHT: | 104 case StatusAreaView::OPEN_TABS_ON_RIGHT: |
101 StatusAreaView::SetOpenTabsMode( | 105 StatusAreaView::SetOpenTabsMode( |
102 static_cast<StatusAreaView::OpenTabsMode>(command_id)); | 106 static_cast<StatusAreaView::OpenTabsMode>(command_id)); |
103 break; | 107 break; |
104 default: | 108 default: |
105 NOTREACHED(); | 109 NOTREACHED(); |
106 } | 110 } |
107 } | 111 } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 } | 281 } |
278 | 282 |
279 void StatusAreaView::ExecuteCommand(int command_id) { | 283 void StatusAreaView::ExecuteCommand(int command_id) { |
280 browser_->ExecuteCommand(command_id); | 284 browser_->ExecuteCommand(command_id); |
281 } | 285 } |
282 | 286 |
283 void StatusAreaView::RunMenu(views::View* source, const gfx::Point& pt) { | 287 void StatusAreaView::RunMenu(views::View* source, const gfx::Point& pt) { |
284 CreateAppMenu(); | 288 CreateAppMenu(); |
285 app_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); | 289 app_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); |
286 } | 290 } |
OLD | NEW |