| 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/macros.h" | 7 #include "base/macros.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/context_menu_matcher.h" | 10 #include "chrome/browser/extensions/context_menu_matcher.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "extensions/browser/extension_registry.h" | 36 #include "extensions/browser/extension_registry.h" |
| 37 #include "extensions/browser/extension_system.h" | 37 #include "extensions/browser/extension_system.h" |
| 38 #include "extensions/browser/management_policy.h" | 38 #include "extensions/browser/management_policy.h" |
| 39 #include "extensions/browser/uninstall_reason.h" | 39 #include "extensions/browser/uninstall_reason.h" |
| 40 #include "extensions/common/extension.h" | 40 #include "extensions/common/extension.h" |
| 41 #include "extensions/common/feature_switch.h" | 41 #include "extensions/common/feature_switch.h" |
| 42 #include "extensions/common/manifest_handlers/options_page_info.h" | 42 #include "extensions/common/manifest_handlers/options_page_info.h" |
| 43 #include "extensions/common/manifest_url_handlers.h" | 43 #include "extensions/common/manifest_url_handlers.h" |
| 44 #include "ui/base/l10n/l10n_util.h" | 44 #include "ui/base/l10n/l10n_util.h" |
| 45 #include "ui/base/resource/resource_bundle.h" | 45 #include "ui/base/resource/resource_bundle.h" |
| 46 #include "ui/gfx/color_palette.h" |
| 46 #include "ui/gfx/image/image.h" | 47 #include "ui/gfx/image/image.h" |
| 48 #include "ui/gfx/paint_vector_icon.h" |
| 49 #include "ui/gfx/vector_icons_public.h" |
| 47 | 50 |
| 48 namespace extensions { | 51 namespace extensions { |
| 49 | 52 |
| 50 namespace { | 53 namespace { |
| 51 | 54 |
| 52 // Returns true if the given |item| is of the given |type|. | 55 // Returns true if the given |item| is of the given |type|. |
| 53 bool MenuItemMatchesAction(ExtensionContextMenuModel::ActionType type, | 56 bool MenuItemMatchesAction(ExtensionContextMenuModel::ActionType type, |
| 54 const MenuItem* item) { | 57 const MenuItem* item) { |
| 55 if (type == ExtensionContextMenuModel::NO_ACTION) | 58 if (type == ExtensionContextMenuModel::NO_ACTION) |
| 56 return false; | 59 return false; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 323 |
| 321 if (!is_component_) { | 324 if (!is_component_) { |
| 322 bool is_required_by_policy = | 325 bool is_required_by_policy = |
| 323 IsExtensionRequiredByPolicy(extension, profile_); | 326 IsExtensionRequiredByPolicy(extension, profile_); |
| 324 int message_id = is_required_by_policy ? | 327 int message_id = is_required_by_policy ? |
| 325 IDS_EXTENSIONS_INSTALLED_BY_ADMIN : IDS_EXTENSIONS_UNINSTALL; | 328 IDS_EXTENSIONS_INSTALLED_BY_ADMIN : IDS_EXTENSIONS_UNINSTALL; |
| 326 AddItem(UNINSTALL, l10n_util::GetStringUTF16(message_id)); | 329 AddItem(UNINSTALL, l10n_util::GetStringUTF16(message_id)); |
| 327 if (is_required_by_policy) { | 330 if (is_required_by_policy) { |
| 328 int uninstall_index = GetIndexOfCommandId(UNINSTALL); | 331 int uninstall_index = GetIndexOfCommandId(UNINSTALL); |
| 329 SetIcon(uninstall_index, | 332 SetIcon(uninstall_index, |
| 330 ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 333 gfx::Image(gfx::CreateVectorIcon(gfx::VectorIconId::BUSINESS, 16, |
| 331 IDR_OMNIBOX_HTTPS_POLICY_WARNING)); | 334 gfx::kChromeIconGrey))); |
| 332 } | 335 } |
| 333 } | 336 } |
| 334 | 337 |
| 335 // Add a toggle visibility (show/hide) if the extension icon is shown on the | 338 // Add a toggle visibility (show/hide) if the extension icon is shown on the |
| 336 // toolbar. | 339 // toolbar. |
| 337 int visibility_string_id = | 340 int visibility_string_id = |
| 338 GetVisibilityStringId(profile_, extension, button_visibility); | 341 GetVisibilityStringId(profile_, extension, button_visibility); |
| 339 if (visibility_string_id != -1) | 342 if (visibility_string_id != -1) |
| 340 AddItemWithStringId(TOGGLE_VISIBILITY, visibility_string_id); | 343 AddItemWithStringId(TOGGLE_VISIBILITY, visibility_string_id); |
| 341 | 344 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 if (runner && runner->WantsToRun(extension)) | 460 if (runner && runner->WantsToRun(extension)) |
| 458 runner->RunBlockedActions(extension); | 461 runner->RunBlockedActions(extension); |
| 459 } | 462 } |
| 460 } | 463 } |
| 461 | 464 |
| 462 content::WebContents* ExtensionContextMenuModel::GetActiveWebContents() const { | 465 content::WebContents* ExtensionContextMenuModel::GetActiveWebContents() const { |
| 463 return browser_->tab_strip_model()->GetActiveWebContents(); | 466 return browser_->tab_strip_model()->GetActiveWebContents(); |
| 464 } | 467 } |
| 465 | 468 |
| 466 } // namespace extensions | 469 } // namespace extensions |
| OLD | NEW |