| OLD | NEW | 
|    1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2010 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/wrench_menu_model.h" |    5 #include "chrome/browser/wrench_menu_model.h" | 
|    6  |    6  | 
|    7 #include <algorithm> |    7 #include <algorithm> | 
|    8 #include <cmath> |    8 #include <cmath> | 
|    9  |    9  | 
|   10 #include "app/l10n_util.h" |   10 #include "app/l10n_util.h" | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
|   37  |   37  | 
|   38 #if defined(OS_LINUX) |   38 #if defined(OS_LINUX) | 
|   39 #include <gtk/gtk.h> |   39 #include <gtk/gtk.h> | 
|   40 #include "chrome/browser/gtk/gtk_util.h" |   40 #include "chrome/browser/gtk/gtk_util.h" | 
|   41 #endif |   41 #endif | 
|   42  |   42  | 
|   43 #if defined(OS_MACOSX) |   43 #if defined(OS_MACOSX) | 
|   44 #include "chrome/browser/browser_window.h" |   44 #include "chrome/browser/browser_window.h" | 
|   45 #endif |   45 #endif | 
|   46  |   46  | 
 |   47 #if defined(OS_CHROMEOS) | 
 |   48 #include "chrome/browser/chromeos/cros/cros_library.h" | 
 |   49 #include "chrome/browser/chromeos/cros/update_library.h" | 
 |   50 #endif | 
 |   51  | 
|   47 //////////////////////////////////////////////////////////////////////////////// |   52 //////////////////////////////////////////////////////////////////////////////// | 
|   48 // EncodingMenuModel |   53 // EncodingMenuModel | 
|   49  |   54  | 
|   50 EncodingMenuModel::EncodingMenuModel(Browser* browser) |   55 EncodingMenuModel::EncodingMenuModel(Browser* browser) | 
|   51     : ALLOW_THIS_IN_INITIALIZER_LIST(menus::SimpleMenuModel(this)), |   56     : ALLOW_THIS_IN_INITIALIZER_LIST(menus::SimpleMenuModel(this)), | 
|   52       browser_(browser) { |   57       browser_(browser) { | 
|   53   Build(); |   58   Build(); | 
|   54 } |   59 } | 
|   55  |   60  | 
|   56 EncodingMenuModel::~EncodingMenuModel() { |   61 EncodingMenuModel::~EncodingMenuModel() { | 
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  251   // but accelerator should work. |  256   // but accelerator should work. | 
|  252   if (command_id == IDC_NEW_WINDOW && |  257   if (command_id == IDC_NEW_WINDOW && | 
|  253       CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) |  258       CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) | 
|  254     return false; |  259     return false; | 
|  255 #endif |  260 #endif | 
|  256  |  261  | 
|  257   return browser_->command_updater()->IsCommandEnabled(command_id); |  262   return browser_->command_updater()->IsCommandEnabled(command_id); | 
|  258 } |  263 } | 
|  259  |  264  | 
|  260 bool WrenchMenuModel::IsCommandIdVisible(int command_id) const { |  265 bool WrenchMenuModel::IsCommandIdVisible(int command_id) const { | 
|  261   if (command_id == IDC_UPGRADE_DIALOG) |  266   if (command_id == IDC_UPGRADE_DIALOG) { | 
 |  267 #if defined(OS_CHROMEOS) | 
 |  268     return (chromeos::CrosLibrary::Get()->GetUpdateLibrary()->status().status | 
 |  269             == chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT); | 
 |  270 #else | 
|  262     return Singleton<UpgradeDetector>::get()->notify_upgrade(); |  271     return Singleton<UpgradeDetector>::get()->notify_upgrade(); | 
 |  272 #endif | 
 |  273   } | 
|  263   return true; |  274   return true; | 
|  264 } |  275 } | 
|  265  |  276  | 
|  266 bool WrenchMenuModel::GetAcceleratorForCommandId( |  277 bool WrenchMenuModel::GetAcceleratorForCommandId( | 
|  267       int command_id, |  278       int command_id, | 
|  268       menus::Accelerator* accelerator) { |  279       menus::Accelerator* accelerator) { | 
|  269   return provider_->GetAcceleratorForCommandId(command_id, accelerator); |  280   return provider_->GetAcceleratorForCommandId(command_id, accelerator); | 
|  270 } |  281 } | 
|  271  |  282  | 
|  272 void WrenchMenuModel::TabSelectedAt(TabContents* old_contents, |  283 void WrenchMenuModel::TabSelectedAt(TabContents* old_contents, | 
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  376     string16 preferences = gtk_util::GetStockPreferencesMenuLabel(); |  387     string16 preferences = gtk_util::GetStockPreferencesMenuLabel(); | 
|  377     if (!preferences.empty()) |  388     if (!preferences.empty()) | 
|  378       AddItem(IDC_OPTIONS, preferences); |  389       AddItem(IDC_OPTIONS, preferences); | 
|  379     else |  390     else | 
|  380       AddItemWithStringId(IDC_OPTIONS, IDS_OPTIONS); |  391       AddItemWithStringId(IDC_OPTIONS, IDS_OPTIONS); | 
|  381 #else |  392 #else | 
|  382     AddItemWithStringId(IDC_OPTIONS, IDS_OPTIONS); |  393     AddItemWithStringId(IDC_OPTIONS, IDS_OPTIONS); | 
|  383 #endif |  394 #endif | 
|  384   } |  395   } | 
|  385  |  396  | 
 |  397 #if defined(OS_CHROMEOS) | 
 |  398   const string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME); | 
 |  399 #else | 
 |  400   const string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 
 |  401 #endif | 
|  386   // On Mac, there is no About item. |  402   // On Mac, there is no About item. | 
|  387   if (browser_defaults::kShowAboutMenuItem) { |  403   if (browser_defaults::kShowAboutMenuItem) { | 
|  388     AddItem(IDC_ABOUT, l10n_util::GetStringFUTF16( |  404     AddItem(IDC_ABOUT, l10n_util::GetStringFUTF16( | 
|  389         IDS_ABOUT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |  405         IDS_ABOUT, product_name)); | 
|  390   } |  406   } | 
|  391  |  407  | 
|  392   AddItem(IDC_UPGRADE_DIALOG, l10n_util::GetStringFUTF16( |  408   AddItem(IDC_UPGRADE_DIALOG, l10n_util::GetStringFUTF16( | 
|  393       IDS_UPDATE_NOW, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |  409       IDS_UPDATE_NOW, product_name)); | 
|  394   ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |  410   ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 
|  395   SetIcon(GetIndexOfCommandId(IDC_UPGRADE_DIALOG), |  411   SetIcon(GetIndexOfCommandId(IDC_UPGRADE_DIALOG), | 
|  396           *rb.GetBitmapNamed(IDR_UPDATE_AVAILABLE)); |  412           *rb.GetBitmapNamed(IDR_UPDATE_AVAILABLE)); | 
|  397  |  413  | 
|  398   AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE); |  414   AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE); | 
|  399   if (browser_defaults::kShowExitMenuItem) { |  415   if (browser_defaults::kShowExitMenuItem) { | 
|  400     AddSeparator(); |  416     AddSeparator(); | 
|  401 #if defined(OS_CHROMEOS) |  417 #if defined(OS_CHROMEOS) | 
|  402     if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { |  418     if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { | 
|  403       AddItemWithStringId(IDC_EXIT, IDS_EXIT_GUEST_MODE); |  419       AddItemWithStringId(IDC_EXIT, IDS_EXIT_GUEST_MODE); | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  435         &enable_increment, &enable_decrement); |  451         &enable_increment, &enable_decrement); | 
|  436   } |  452   } | 
|  437   zoom_label_ = l10n_util::GetStringFUTF16( |  453   zoom_label_ = l10n_util::GetStringFUTF16( | 
|  438       IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |  454       IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 
|  439 } |  455 } | 
|  440  |  456  | 
|  441 string16 WrenchMenuModel::GetSyncMenuLabel() const { |  457 string16 WrenchMenuModel::GetSyncMenuLabel() const { | 
|  442   return sync_ui_util::GetSyncMenuLabel( |  458   return sync_ui_util::GetSyncMenuLabel( | 
|  443       browser_->profile()->GetOriginalProfile()->GetProfileSyncService()); |  459       browser_->profile()->GetOriginalProfile()->GetProfileSyncService()); | 
|  444 } |  460 } | 
| OLD | NEW |