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

Side by Side Diff: chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm

Issue 10584042: Bring up a content settings icon for ungestured registerProtocolHandler call. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge Created 8 years, 5 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 | Annotate | Revision Log
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 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h " 5 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h "
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/content_settings/host_content_settings_map.h" 11 #include "chrome/browser/content_settings/host_content_settings_map.h"
12 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" 12 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
13 #import "chrome/browser/ui/cocoa/hyperlink_button_cell.h" 13 #import "chrome/browser/ui/cocoa/hyperlink_button_cell.h"
14 #import "chrome/browser/ui/cocoa/info_bubble_view.h" 14 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
15 #import "chrome/browser/ui/cocoa/l10n_util.h" 15 #import "chrome/browser/ui/cocoa/l10n_util.h"
16 #include "content/public/browser/plugin_service.h" 16 #include "content/public/browser/plugin_service.h"
17 #include "grit/generated_resources.h" 17 #include "grit/generated_resources.h"
18 #include "skia/ext/skia_utils_mac.h" 18 #include "skia/ext/skia_utils_mac.h"
19 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" 19 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
20 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
21 21
22 using content::PluginService; 22 using content::PluginService;
23 23
24 namespace { 24 namespace {
25 25
26 // Must match the tag of the unblock radio button in the xib files.
27 const int kAllowTag = 1;
28
29 // Must match the tag of the block radio button in the xib files.
30 const int kBlockTag = 2;
31
32 // Height of one link in the popup list. 26 // Height of one link in the popup list.
33 const int kLinkHeight = 16; 27 const int kLinkHeight = 16;
34 28
35 // Space between two popup links. 29 // Space between two popup links.
36 const int kLinkPadding = 4; 30 const int kLinkPadding = 4;
37 31
38 // Space taken in total by one popup link. 32 // Space taken in total by one popup link.
39 const int kLinkLineHeight = kLinkHeight + kLinkPadding; 33 const int kLinkLineHeight = kLinkHeight + kLinkPadding;
40 34
41 // Space between popup list and surrounding UI elements. 35 // Space between popup list and surrounding UI elements.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 case CONTENT_SETTINGS_TYPE_JAVASCRIPT: 124 case CONTENT_SETTINGS_TYPE_JAVASCRIPT:
131 nibPath = @"ContentBlockedJavaScript"; break; 125 nibPath = @"ContentBlockedJavaScript"; break;
132 case CONTENT_SETTINGS_TYPE_PLUGINS: 126 case CONTENT_SETTINGS_TYPE_PLUGINS:
133 nibPath = @"ContentBlockedPlugins"; break; 127 nibPath = @"ContentBlockedPlugins"; break;
134 case CONTENT_SETTINGS_TYPE_POPUPS: 128 case CONTENT_SETTINGS_TYPE_POPUPS:
135 nibPath = @"ContentBlockedPopups"; break; 129 nibPath = @"ContentBlockedPopups"; break;
136 case CONTENT_SETTINGS_TYPE_GEOLOCATION: 130 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
137 nibPath = @"ContentBlockedGeolocation"; break; 131 nibPath = @"ContentBlockedGeolocation"; break;
138 case CONTENT_SETTINGS_TYPE_MIXEDSCRIPT: 132 case CONTENT_SETTINGS_TYPE_MIXEDSCRIPT:
139 nibPath = @"ContentBlockedMixedScript"; break; 133 nibPath = @"ContentBlockedMixedScript"; break;
134 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS:
135 nibPath = @"ContentProtocolHandlers"; break;
140 default: 136 default:
141 NOTREACHED(); 137 NOTREACHED();
142 } 138 }
143 if ((self = [super initWithWindowNibPath:nibPath 139 if ((self = [super initWithWindowNibPath:nibPath
144 parentWindow:parentWindow 140 parentWindow:parentWindow
145 anchoredAt:anchoredAt])) { 141 anchoredAt:anchoredAt])) {
146 contentSettingBubbleModel_.reset(model.release()); 142 contentSettingBubbleModel_.reset(model.release());
147 [self showWindow:nil]; 143 [self showWindow:nil];
148 } 144 }
149 return self; 145 return self;
(...skipping 12 matching lines...) Expand all
162 sizeToFitFixedWidthTextField:titleLabel_]; 158 sizeToFitFixedWidthTextField:titleLabel_];
163 NSRect windowFrame = [[self window] frame]; 159 NSRect windowFrame = [[self window] frame];
164 windowFrame.size.height += deltaY; 160 windowFrame.size.height += deltaY;
165 [[self window] setFrame:windowFrame display:NO]; 161 [[self window] setFrame:windowFrame display:NO];
166 NSRect titleFrame = [titleLabel_ frame]; 162 NSRect titleFrame = [titleLabel_ frame];
167 titleFrame.origin.y -= deltaY; 163 titleFrame.origin.y -= deltaY;
168 [titleLabel_ setFrame:titleFrame]; 164 [titleLabel_ setFrame:titleFrame];
169 } 165 }
170 166
171 - (void)initializeRadioGroup { 167 - (void)initializeRadioGroup {
172 // Configure the radio group. For now, only deal with the 168 // NOTE! Tags in the xib files must match the order of the radio buttons
173 // strictly needed case of group containing 2 radio buttons. 169 // passed in the radio_group and be 1-based, not 0-based.
174 const ContentSettingBubbleModel::RadioGroup& radio_group = 170 const ContentSettingBubbleModel::RadioGroup& radio_group =
175 contentSettingBubbleModel_->bubble_content().radio_group; 171 contentSettingBubbleModel_->bubble_content().radio_group;
176 172
177 // Select appropriate radio button. 173 // Select appropriate radio button.
178 [allowBlockRadioGroup_ selectCellWithTag: 174 [allowBlockRadioGroup_ selectCellWithTag: radio_group.default_item + 1];
179 radio_group.default_item == 0 ? kAllowTag : kBlockTag];
180 175
181 const ContentSettingBubbleModel::RadioItems& radio_items = 176 const ContentSettingBubbleModel::RadioItems& radio_items =
182 radio_group.radio_items; 177 radio_group.radio_items;
183 DCHECK_EQ(2u, radio_items.size()) << "Only 2 radio items per group supported"; 178 for (size_t ii = 0; ii < radio_group.radio_items.size(); ++ii) {
184 // Set radio group labels from model. 179 NSCell* radioCell = [allowBlockRadioGroup_ cellWithTag: ii + 1];
185 NSCell* radioCell = [allowBlockRadioGroup_ cellWithTag:kAllowTag]; 180 [radioCell setTitle:base::SysUTF8ToNSString(radio_items[ii])];
186 [radioCell setTitle:base::SysUTF8ToNSString(radio_items[0])]; 181 }
187
188 radioCell = [allowBlockRadioGroup_ cellWithTag:kBlockTag];
189 [radioCell setTitle:base::SysUTF8ToNSString(radio_items[1])];
190 182
191 // Layout radio group labels post-localization. 183 // Layout radio group labels post-localization.
192 [GTMUILocalizerAndLayoutTweaker 184 [GTMUILocalizerAndLayoutTweaker
193 wrapRadioGroupForWidth:allowBlockRadioGroup_]; 185 wrapRadioGroupForWidth:allowBlockRadioGroup_];
194 CGFloat radioDeltaY = [GTMUILocalizerAndLayoutTweaker 186 CGFloat radioDeltaY = [GTMUILocalizerAndLayoutTweaker
195 sizeToFitView:allowBlockRadioGroup_].height; 187 sizeToFitView:allowBlockRadioGroup_].height;
196 NSRect windowFrame = [[self window] frame]; 188 NSRect windowFrame = [[self window] frame];
197 windowFrame.size.height += radioDeltaY; 189 windowFrame.size.height += radioDeltaY;
198 [[self window] setFrame:windowFrame display:NO]; 190 [[self window] setFrame:windowFrame display:NO];
199 } 191 }
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 // Adapt window size to bottom buttons. Do this before all other layouting. 431 // Adapt window size to bottom buttons. Do this before all other layouting.
440 [self sizeToFitManageDoneButtons]; 432 [self sizeToFitManageDoneButtons];
441 433
442 [self initializeTitle]; 434 [self initializeTitle];
443 435
444 ContentSettingsType type = contentSettingBubbleModel_->content_type(); 436 ContentSettingsType type = contentSettingBubbleModel_->content_type();
445 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) { 437 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
446 [self sizeToFitLoadButton]; 438 [self sizeToFitLoadButton];
447 [self initializeBlockedPluginsList]; 439 [self initializeBlockedPluginsList];
448 } 440 }
441
449 if (allowBlockRadioGroup_) // not bound in cookie bubble xib 442 if (allowBlockRadioGroup_) // not bound in cookie bubble xib
450 [self initializeRadioGroup]; 443 [self initializeRadioGroup];
451 444
452 if (type == CONTENT_SETTINGS_TYPE_POPUPS) 445 if (type == CONTENT_SETTINGS_TYPE_POPUPS)
453 [self initializePopupList]; 446 [self initializePopupList];
454 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) 447 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION)
455 [self initializeGeoLists]; 448 [self initializeGeoLists];
456 } 449 }
457 450
458 /////////////////////////////////////////////////////////////////////////////// 451 ///////////////////////////////////////////////////////////////////////////////
459 // Actual application logic 452 // Actual application logic
460 453
461 - (IBAction)allowBlockToggled:(id)sender { 454 - (IBAction)allowBlockToggled:(id)sender {
462 NSButtonCell *selectedCell = [sender selectedCell]; 455 NSButtonCell *selectedCell = [sender selectedCell];
463 contentSettingBubbleModel_->OnRadioClicked( 456 contentSettingBubbleModel_->OnRadioClicked([selectedCell tag] - 1);
464 [selectedCell tag] == kAllowTag ? 0 : 1);
465 } 457 }
466 458
467 - (void)popupLinkClicked:(id)sender { 459 - (void)popupLinkClicked:(id)sender {
468 content_setting_bubble::PopupLinks::iterator i(popupLinks_.find(sender)); 460 content_setting_bubble::PopupLinks::iterator i(popupLinks_.find(sender));
469 DCHECK(i != popupLinks_.end()); 461 DCHECK(i != popupLinks_.end());
470 contentSettingBubbleModel_->OnPopupClicked(i->second); 462 contentSettingBubbleModel_->OnPopupClicked(i->second);
471 } 463 }
472 464
473 - (void)clearGeolocationForCurrentHost:(id)sender { 465 - (void)clearGeolocationForCurrentHost:(id)sender {
474 contentSettingBubbleModel_->OnCustomLinkClicked(); 466 contentSettingBubbleModel_->OnCustomLinkClicked();
(...skipping 16 matching lines...) Expand all
491 483
492 - (IBAction)manageBlocking:(id)sender { 484 - (IBAction)manageBlocking:(id)sender {
493 contentSettingBubbleModel_->OnManageLinkClicked(); 485 contentSettingBubbleModel_->OnManageLinkClicked();
494 } 486 }
495 487
496 - (IBAction)closeBubble:(id)sender { 488 - (IBAction)closeBubble:(id)sender {
497 [self close]; 489 [self close];
498 } 490 }
499 491
500 @end // ContentSettingBubbleController 492 @end // ContentSettingBubbleController
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698