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