OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/extension_context_menu_model.h" | 5 #include "chrome/browser/extensions/extension_context_menu_model.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/extensions/active_script_controller.h" | 10 #include "chrome/browser/extensions/active_script_controller.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 return true; | 68 return true; |
69 | 69 |
70 return false; | 70 return false; |
71 } | 71 } |
72 | 72 |
73 // Returns the id for the visibility command for the given |extension|, or -1 | 73 // Returns the id for the visibility command for the given |extension|, or -1 |
74 // if none should be shown. | 74 // if none should be shown. |
75 int GetVisibilityStringId(Profile* profile, const Extension* extension) { | 75 int GetVisibilityStringId(Profile* profile, const Extension* extension) { |
76 DCHECK(profile); | 76 DCHECK(profile); |
77 int string_id = -1; | 77 int string_id = -1; |
78 if (!extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()) { | |
79 // Without the toolbar redesign, we only show the visibility toggle for | 78 // Without the toolbar redesign, we only show the visibility toggle for |
80 // browser actions, and only give the option to hide. | 79 // browser actions, and only give the option to hide. |
81 if (extensions::ExtensionActionManager::Get(profile)->GetBrowserAction( | 80 if (extensions::ExtensionActionManager::Get(profile)->GetBrowserAction( |
82 *extension)) { | 81 *extension)) { |
83 string_id = IDS_EXTENSIONS_HIDE_BUTTON; | 82 string_id = IDS_EXTENSIONS_HIDE_BUTTON; |
84 } | 83 } |
85 } else { | 84 else { |
86 // With the redesign, we display "show" or "hide" based on the icon's | 85 // With the redesign, we display "show" or "hide" based on the icon's |
87 // visibility. | 86 // visibility. |
88 bool visible = ExtensionActionAPI::GetBrowserActionVisibility( | 87 bool visible = ExtensionActionAPI::GetBrowserActionVisibility( |
89 ExtensionPrefs::Get(profile), extension->id()); | 88 ExtensionPrefs::Get(profile), extension->id()); |
90 string_id = | 89 string_id = |
91 visible ? IDS_EXTENSIONS_HIDE_BUTTON : IDS_EXTENSIONS_SHOW_BUTTON; | 90 visible ? IDS_EXTENSIONS_HIDE_BUTTON : IDS_EXTENSIONS_SHOW_BUTTON; |
92 } | 91 } |
93 return string_id; | 92 return string_id; |
94 } | 93 } |
95 | 94 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 extension_items_count_ = 0; | 318 extension_items_count_ = 0; |
320 extension_items_->AppendExtensionItems(MenuItem::ExtensionKey(extension_id_), | 319 extension_items_->AppendExtensionItems(MenuItem::ExtensionKey(extension_id_), |
321 base::string16(), | 320 base::string16(), |
322 &extension_items_count_, | 321 &extension_items_count_, |
323 true); // is_action_menu | 322 true); // is_action_menu |
324 } | 323 } |
325 | 324 |
326 content::WebContents* ExtensionContextMenuModel::GetActiveWebContents() const { | 325 content::WebContents* ExtensionContextMenuModel::GetActiveWebContents() const { |
327 return browser_->tab_strip_model()->GetActiveWebContents(); | 326 return browser_->tab_strip_model()->GetActiveWebContents(); |
328 } | 327 } |
OLD | NEW |