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

Side by Side Diff: chrome/browser/ui/website_settings/permission_menu_model.cc

Issue 819183002: Plugin Power Saver: Fix DETECT in WebsiteSettingsUI omnibox dropdown. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0210-plugin-power-saver-fix-website-settings-plugin-ask-backportable
Patch Set: fix mac stuff Created 5 years, 12 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 unified diff | Download patch
OLDNEW
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/ui/website_settings/permission_menu_model.h" 5 #include "chrome/browser/ui/website_settings/permission_menu_model.h"
6 6
7 #include "chrome/grit/generated_resources.h" 7 #include "chrome/grit/generated_resources.h"
8 #include "ui/base/l10n/l10n_util.h" 8 #include "ui/base/l10n/l10n_util.h"
9 9
10 PermissionMenuModel::PermissionMenuModel( 10 PermissionMenuModel::PermissionMenuModel(
11 const GURL& url, 11 const GURL& url,
12 const WebsiteSettingsUI::PermissionInfo& info, 12 const WebsiteSettingsUI::PermissionInfo& info,
13 const ChangeCallback& callback) 13 const ChangeCallback& callback)
14 : ui::SimpleMenuModel(this), permission_(info), callback_(callback) { 14 : ui::SimpleMenuModel(this), permission_(info), callback_(callback) {
15 DCHECK(!callback_.is_null()); 15 DCHECK(!callback_.is_null());
16 base::string16 label; 16 base::string16 label;
17 switch (permission_.default_setting) { 17 switch (permission_.default_setting) {
18 case CONTENT_SETTING_ALLOW: 18 case CONTENT_SETTING_ALLOW:
19 label = l10n_util::GetStringUTF16( 19 label = l10n_util::GetStringUTF16(
20 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ALLOW); 20 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ALLOW);
21 break; 21 break;
22 case CONTENT_SETTING_BLOCK: 22 case CONTENT_SETTING_BLOCK:
23 label = l10n_util::GetStringUTF16( 23 label = l10n_util::GetStringUTF16(
24 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK); 24 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK);
25 break; 25 break;
26 case CONTENT_SETTING_ASK: 26 case CONTENT_SETTING_ASK:
27 // For Plugins, ASK is obsolete. Show as BLOCK to reflect actual behavior.
27 label = l10n_util::GetStringUTF16( 28 label = l10n_util::GetStringUTF16(
28 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK); 29 permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS
30 ? IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK
31 : IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK);
29 break; 32 break;
30 case CONTENT_SETTING_DETECT_IMPORTANT_CONTENT: 33 case CONTENT_SETTING_DETECT_IMPORTANT_CONTENT:
31 label = l10n_util::GetStringUTF16( 34 label = l10n_util::GetStringUTF16(
32 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_DETECT_IMPORTANT_CONTENT); 35 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_DETECT_IMPORTANT_CONTENT);
33 break; 36 break;
34 case CONTENT_SETTING_NUM_SETTINGS: 37 case CONTENT_SETTING_NUM_SETTINGS:
35 NOTREACHED(); 38 NOTREACHED();
36 default: 39 default:
37 break; 40 break;
38 } 41 }
39 AddCheckItem(CONTENT_SETTING_DEFAULT, label); 42 AddCheckItem(CONTENT_SETTING_DEFAULT, label);
40 43
41 // Media only support CONTENTE_SETTTING_ALLOW for https. 44 // Media only support CONTENTE_SETTTING_ALLOW for https.
42 if (permission_.type != CONTENT_SETTINGS_TYPE_MEDIASTREAM || 45 if (permission_.type != CONTENT_SETTINGS_TYPE_MEDIASTREAM ||
43 url.SchemeIsSecure()) { 46 url.SchemeIsSecure()) {
44 label = l10n_util::GetStringUTF16( 47 label = l10n_util::GetStringUTF16(
45 IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW); 48 IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW);
46 AddCheckItem(CONTENT_SETTING_ALLOW, label); 49 AddCheckItem(CONTENT_SETTING_ALLOW, label);
47 } 50 }
48 51
49 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS) { 52 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS) {
50 label = l10n_util::GetStringUTF16( 53 label = l10n_util::GetStringUTF16(
51 IDS_WEBSITE_SETTINGS_MENU_ITEM_ASK); 54 IDS_WEBSITE_SETTINGS_MENU_ITEM_DETECT_IMPORTANT_CONTENT);
52 AddCheckItem(CONTENT_SETTING_ASK, label); 55 AddCheckItem(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, label);
53 } 56 }
54 57
55 if (permission_.type != CONTENT_SETTINGS_TYPE_FULLSCREEN) { 58 if (permission_.type != CONTENT_SETTINGS_TYPE_FULLSCREEN) {
56 label = l10n_util::GetStringUTF16( 59 label = l10n_util::GetStringUTF16(
57 IDS_WEBSITE_SETTINGS_MENU_ITEM_BLOCK); 60 IDS_WEBSITE_SETTINGS_MENU_ITEM_BLOCK);
58 AddCheckItem(CONTENT_SETTING_BLOCK, label); 61 AddCheckItem(CONTENT_SETTING_BLOCK, label);
59 } 62 }
60 } 63 }
61 64
62 PermissionMenuModel::PermissionMenuModel(const GURL& url, 65 PermissionMenuModel::PermissionMenuModel(const GURL& url,
63 ContentSetting setting, 66 ContentSetting setting,
64 const ChangeCallback& callback) 67 const ChangeCallback& callback)
65 : ui::SimpleMenuModel(this), callback_(callback) { 68 : ui::SimpleMenuModel(this), callback_(callback) {
66 DCHECK(setting == CONTENT_SETTING_ALLOW || setting == CONTENT_SETTING_BLOCK); 69 DCHECK(setting == CONTENT_SETTING_ALLOW || setting == CONTENT_SETTING_BLOCK);
67 permission_.type = CONTENT_SETTINGS_TYPE_DEFAULT; 70 permission_.type = CONTENT_SETTINGS_TYPE_DEFAULT;
68 permission_.setting = setting; 71 permission_.setting = setting;
69 permission_.default_setting = CONTENT_SETTING_NUM_SETTINGS; 72 permission_.default_setting = CONTENT_SETTING_NUM_SETTINGS;
70 AddCheckItem(CONTENT_SETTING_ALLOW, 73 AddCheckItem(CONTENT_SETTING_ALLOW,
71 l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW)); 74 l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW));
72 AddCheckItem(CONTENT_SETTING_BLOCK, 75 AddCheckItem(CONTENT_SETTING_BLOCK,
73 l10n_util::GetStringUTF16(IDS_PERMISSION_DENY)); 76 l10n_util::GetStringUTF16(IDS_PERMISSION_DENY));
74 } 77 }
75 78
76 PermissionMenuModel::~PermissionMenuModel() {} 79 PermissionMenuModel::~PermissionMenuModel() {}
77 80
78 bool PermissionMenuModel::IsCommandIdChecked(int command_id) const { 81 bool PermissionMenuModel::IsCommandIdChecked(int command_id) const {
82 // For Plugins, ASK is obsolete. Show as BLOCK to reflect actual behavior.
83 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS &&
84 permission_.setting == CONTENT_SETTING_ASK &&
85 command_id == CONTENT_SETTING_BLOCK) {
86 return true;
87 }
79 return permission_.setting == command_id; 88 return permission_.setting == command_id;
80 } 89 }
81 90
82 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { 91 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const {
83 return true; 92 return true;
84 } 93 }
85 94
86 bool PermissionMenuModel::GetAcceleratorForCommandId( 95 bool PermissionMenuModel::GetAcceleratorForCommandId(
87 int command_id, 96 int command_id,
88 ui::Accelerator* accelerator) { 97 ui::Accelerator* accelerator) {
89 // Accelerators are not supported. 98 // Accelerators are not supported.
90 return false; 99 return false;
91 } 100 }
92 101
93 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { 102 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) {
94 permission_.setting = static_cast<ContentSetting>(command_id); 103 permission_.setting = static_cast<ContentSetting>(command_id);
95 callback_.Run(permission_); 104 callback_.Run(permission_);
96 } 105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698