Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6071)

Unified Diff: chrome/browser/ui/toolbar/action_box_menu_model.cc

Issue 10887029: Only show chrome2mobile in action box if it is enabled (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/toolbar/action_box_menu_model.cc
diff --git a/chrome/browser/ui/toolbar/action_box_menu_model.cc b/chrome/browser/ui/toolbar/action_box_menu_model.cc
index 84af1e16ced4e9832bf9d18019a14123a8aac744..c58fd4d0fc2c007d81df3afa66686cadb0fdea66 100644
--- a/chrome/browser/ui/toolbar/action_box_menu_model.cc
+++ b/chrome/browser/ui/toolbar/action_box_menu_model.cc
@@ -6,8 +6,16 @@
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
+#include "chrome/browser/chrome_to_mobile_service.h"
+#include "chrome/browser/chrome_to_mobile_service_factory.h"
+#include "chrome/browser/command_updater.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/extension_toolbar_model.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "grit/generated_resources.h"
@@ -27,25 +35,27 @@ const int kFirstExtensionCommandId = 0xE000;
////////////////////////////////////////////////////////////////////////////////
// ActionBoxMenuModel
-ActionBoxMenuModel::ActionBoxMenuModel(Browser* browser,
- ExtensionService* extension_service)
+ActionBoxMenuModel::ActionBoxMenuModel(Browser* browser)
: ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)),
- browser_(browser),
- extension_service_(extension_service) {
+ browser_(browser) {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- InsertItemWithStringIdAt(0, IDC_CHROME_TO_MOBILE_PAGE,
- IDS_CHROME_TO_MOBILE_BUBBLE_TOOLTIP);
- SetIcon(0, rb.GetNativeImageNamed(IDR_MOBILE));
-
- TabContents* current_tab_contents = chrome::GetActiveTabContents(browser);
+ if (ChromeToMobileServiceFactory::GetForProfile(browser_->profile())->
+ HasMobiles()) {
msw 2012/08/31 17:15:36 nit: indent 4 more spaces.
+ AddItemWithStringId(IDC_CHROME_TO_MOBILE_PAGE,
+ IDS_CHROME_TO_MOBILE_BUBBLE_TOOLTIP);
+ SetIcon(GetIndexOfCommandId(IDC_CHROME_TO_MOBILE_PAGE),
+ rb.GetNativeImageNamed(IDR_MOBILE));
+ }
+ TabContents* current_tab_contents = chrome::GetActiveTabContents(browser_);
bool starred = current_tab_contents->bookmark_tab_helper()->is_starred();
- InsertItemWithStringIdAt(1, IDC_BOOKMARK_PAGE,
- starred ? IDS_TOOLTIP_STARRED : IDS_TOOLTIP_STAR);
- SetIcon(1, rb.GetNativeImageNamed(starred ? IDR_STAR_LIT : IDR_STAR));
+ AddItemWithStringId(IDC_BOOKMARK_PAGE,
+ starred ? IDS_TOOLTIP_STARRED : IDS_TOOLTIP_STAR);
+ SetIcon(GetIndexOfCommandId(IDC_BOOKMARK_PAGE),
+ rb.GetNativeImageNamed(starred ? IDR_STAR_LIT : IDR_STAR));
// Adds extensions to the model.
int command_id = kFirstExtensionCommandId;
- const extensions::ExtensionList& action_box_items = action_box_menu_items();
+ const extensions::ExtensionList& action_box_items = GetActionBoxMenuItems();
if (!action_box_items.empty()) {
AddSeparator(ui::NORMAL_SEPARATOR);
for (size_t i = 0; i < action_box_items.size(); ++i) {
@@ -75,8 +85,10 @@ const extensions::Extension* ActionBoxMenuModel::GetExtensionAt(int index) {
id_to_extension_id_map_.find(command_id);
if (it == id_to_extension_id_map_.end())
return NULL;
-
- return extension_service_->GetExtensionById(it->second, false);
+ ExtensionService* extension_service =
+ extensions::ExtensionSystem::Get(browser_->profile())->
+ extension_service();
+ return extension_service->GetExtensionById(it->second, false);
}
bool ActionBoxMenuModel::IsCommandIdChecked(int command_id) const {
@@ -98,6 +110,13 @@ void ActionBoxMenuModel::ExecuteCommand(int command_id) {
chrome::ExecuteCommand(browser_, command_id);
}
+const extensions::ExtensionList& ActionBoxMenuModel::GetActionBoxMenuItems() {
+ ExtensionService* extension_service =
+ extensions::ExtensionSystem::Get(browser_->profile())->
+ extension_service();
+ return extension_service->toolbar_model()->action_box_menu_items();
+}
+
void ActionBoxMenuModel::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
« no previous file with comments | « chrome/browser/ui/toolbar/action_box_menu_model.h ('k') | chrome/browser/ui/views/location_bar/action_box_button_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698