| 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" |
| 11 #include "app/theme_provider.h" | 11 #include "app/theme_provider.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "chrome/app/chrome_dll_resource.h" | 13 #include "chrome/app/chrome_dll_resource.h" |
| 14 #include "chrome/browser/browser.h" | 14 #include "chrome/browser/browser.h" |
| 15 #include "chrome/browser/browser_window.h" | 15 #include "chrome/browser/browser_window.h" |
| 16 #include "chrome/browser/chromeos/clock_menu_button.h" | 16 #include "chrome/browser/chromeos/clock_menu_button.h" |
| 17 #include "chrome/browser/chromeos/network_menu_button.h" | 17 #include "chrome/browser/chromeos/network_menu_button.h" |
| 18 #include "chrome/browser/chromeos/power_menu_button.h" | 18 #include "chrome/browser/chromeos/power_menu_button.h" |
| 19 #include "chrome/browser/chromeos/status_area_button.h" | 19 #include "chrome/browser/chromeos/status_area_button.h" |
| 20 #if !defined(TOOLKIT_VIEWS) | 20 #if !defined(TOOLKIT_VIEWS) |
| 21 #include "chrome/browser/gtk/browser_window_gtk.h" | 21 #include "chrome/browser/gtk/browser_window_gtk.h" |
| 22 #else | 22 #else |
| 23 #include "chrome/browser/views/frame/browser_view.h" | 23 #include "chrome/browser/views/frame/browser_view.h" |
| 24 #endif | 24 #endif |
| 25 #include "chrome/browser/profile.h" | 25 #include "chrome/browser/profile.h" |
| 26 #include "chrome/common/pref_names.h" |
| 26 #include "grit/chromium_strings.h" | 27 #include "grit/chromium_strings.h" |
| 27 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
| 28 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" |
| 29 #include "views/controls/menu/menu.h" | 30 #include "views/controls/menu/menu.h" |
| 30 #include "views/controls/menu/simple_menu_model.h" | 31 #include "views/controls/menu/simple_menu_model.h" |
| 31 | 32 |
| 32 namespace chromeos { | 33 namespace chromeos { |
| 33 | 34 |
| 34 // Number of pixels to pad on the left border. | 35 // Number of pixels to pad on the left border. |
| 35 const int kLeftBorder = 1; | 36 const int kLeftBorder = 1; |
| 36 // Number of pixels to separate the clock from the next item on the right. | 37 // Number of pixels to separate the clock from the next item on the right. |
| 37 const int kClockSeparation = 4; | 38 const int kClockSeparation = 4; |
| 38 | 39 |
| 39 // BrowserWindowGtk tiles its image with this offset | 40 // BrowserWindowGtk tiles its image with this offset |
| 40 const int kCustomFrameBackgroundVerticalOffset = 15; | 41 const int kCustomFrameBackgroundVerticalOffset = 15; |
| 41 | 42 |
| 42 class OptionsMenuModel : public views::SimpleMenuModel, | 43 class OptionsMenuModel : public views::SimpleMenuModel, |
| 43 public views::SimpleMenuModel::Delegate { | 44 public views::SimpleMenuModel::Delegate { |
| 44 public: | 45 public: |
| 45 // These extra command IDs must be unique when combined with the options, | 46 // These extra command IDs must be unique when combined with the options, |
| 46 // so we just pick up the numbering where that stops. | 47 // so we just pick up the numbering where that stops. |
| 47 enum OtherCommands { | 48 enum OtherCommands { |
| 48 CREATE_NEW_WINDOW = StatusAreaView::OPEN_TABS_ON_RIGHT + 1, | 49 CREATE_NEW_WINDOW = StatusAreaView::OPEN_TABS_ON_RIGHT + 1, |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 explicit OptionsMenuModel(Browser* browser, | 52 explicit OptionsMenuModel(Browser* browser) |
| 52 views::SimpleMenuModel::Delegate* delegate) | |
| 53 : SimpleMenuModel(this), | 53 : SimpleMenuModel(this), |
| 54 browser_(browser) { | 54 browser_(browser) { |
| 55 #if defined(TOOLKIT_VIEWS) | 55 #if defined(TOOLKIT_VIEWS) |
| 56 AddItemWithStringId(IDC_COMPACT_NAVBAR, IDS_COMPACT_NAVBAR); | 56 AddItemWithStringId(IDC_COMPACT_NAVBAR, IDS_COMPACT_NAVBAR); |
| 57 #else | 57 #else |
| 58 AddItem(static_cast<int>(CREATE_NEW_WINDOW), | 58 AddItem(static_cast<int>(CREATE_NEW_WINDOW), |
| 59 ASCIIToUTF16("New window")); | 59 ASCIIToUTF16("New window")); |
| 60 #endif | 60 #endif |
| 61 AddSeparator(); | 61 AddSeparator(); |
| 62 | 62 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 228 |
| 229 // static | 229 // static |
| 230 void StatusAreaView::SetOpenTabsMode(OpenTabsMode mode) { | 230 void StatusAreaView::SetOpenTabsMode(OpenTabsMode mode) { |
| 231 open_tabs_mode_ = mode; | 231 open_tabs_mode_ = mode; |
| 232 } | 232 } |
| 233 | 233 |
| 234 void StatusAreaView::CreateAppMenu() { | 234 void StatusAreaView::CreateAppMenu() { |
| 235 if (app_menu_contents_.get()) | 235 if (app_menu_contents_.get()) |
| 236 return; | 236 return; |
| 237 | 237 |
| 238 options_menu_contents_.reset(new OptionsMenuModel(browser_, this)); | 238 options_menu_contents_.reset(new OptionsMenuModel(browser_)); |
| 239 | 239 |
| 240 app_menu_contents_.reset(new views::SimpleMenuModel(this)); | 240 app_menu_contents_.reset(new views::SimpleMenuModel(this)); |
| 241 app_menu_contents_->AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); | 241 app_menu_contents_->AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); |
| 242 app_menu_contents_->AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); | 242 app_menu_contents_->AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); |
| 243 app_menu_contents_->AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, | 243 app_menu_contents_->AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, |
| 244 IDS_NEW_INCOGNITO_WINDOW); | 244 IDS_NEW_INCOGNITO_WINDOW); |
| 245 app_menu_contents_->AddSeparator(); | 245 app_menu_contents_->AddSeparator(); |
| 246 app_menu_contents_->AddCheckItemWithStringId(IDC_SHOW_BOOKMARK_BAR, | 246 app_menu_contents_->AddCheckItemWithStringId(IDC_SHOW_BOOKMARK_BAR, |
| 247 IDS_SHOW_BOOKMARK_BAR); | 247 IDS_SHOW_BOOKMARK_BAR); |
| 248 app_menu_contents_->AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN); | 248 app_menu_contents_->AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 270 app_menu_contents_->AddItem(IDC_ABOUT, | 270 app_menu_contents_->AddItem(IDC_ABOUT, |
| 271 l10n_util::GetStringFUTF16( | 271 l10n_util::GetStringFUTF16( |
| 272 IDS_ABOUT, | 272 IDS_ABOUT, |
| 273 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 273 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
| 274 app_menu_contents_->AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE); | 274 app_menu_contents_->AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE); |
| 275 | 275 |
| 276 app_menu_menu_.reset(new views::Menu2(app_menu_contents_.get())); | 276 app_menu_menu_.reset(new views::Menu2(app_menu_contents_.get())); |
| 277 } | 277 } |
| 278 | 278 |
| 279 bool StatusAreaView::IsCommandIdChecked(int command_id) const { | 279 bool StatusAreaView::IsCommandIdChecked(int command_id) const { |
| 280 if (command_id == IDC_SHOW_BOOKMARK_BAR) |
| 281 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); |
| 280 return false; | 282 return false; |
| 281 } | 283 } |
| 282 | 284 |
| 283 bool StatusAreaView::IsCommandIdEnabled(int command_id) const { | 285 bool StatusAreaView::IsCommandIdEnabled(int command_id) const { |
| 284 if (command_id == IDC_RESTORE_TAB) | 286 if (command_id == IDC_RESTORE_TAB) |
| 285 return browser_->CanRestoreTab(); | 287 return browser_->CanRestoreTab(); |
| 286 return browser_->command_updater()->IsCommandEnabled(command_id); | 288 return browser_->command_updater()->IsCommandEnabled(command_id); |
| 287 } | 289 } |
| 288 | 290 |
| 289 bool StatusAreaView::GetAcceleratorForCommandId( | 291 bool StatusAreaView::GetAcceleratorForCommandId( |
| 290 int command_id, | 292 int command_id, |
| 291 views::Accelerator* accelerator) { | 293 views::Accelerator* accelerator) { |
| 292 return false; | 294 return false; |
| 293 } | 295 } |
| 294 | 296 |
| 295 void StatusAreaView::ExecuteCommand(int command_id) { | 297 void StatusAreaView::ExecuteCommand(int command_id) { |
| 296 browser_->ExecuteCommand(command_id); | 298 browser_->ExecuteCommand(command_id); |
| 297 } | 299 } |
| 298 | 300 |
| 299 void StatusAreaView::RunMenu(views::View* source, const gfx::Point& pt) { | 301 void StatusAreaView::RunMenu(views::View* source, const gfx::Point& pt) { |
| 300 CreateAppMenu(); | 302 CreateAppMenu(); |
| 301 app_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); | 303 app_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); |
| 302 } | 304 } |
| 303 | 305 |
| 304 } // namespace chromeos | 306 } // namespace chromeos |
| OLD | NEW |