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

Side by Side Diff: chrome/browser/ui/cocoa/content_exceptions_window_controller.mm

Issue 5574001: Move ContentSettingsDetails and Pattern out of HostContentSettingsMap as separate classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser/content_settings
Patch Set: updates Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_exceptions_window_controller.h" 5 #import "chrome/browser/ui/cocoa/content_exceptions_window_controller.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/l10n_util_mac.h" 8 #include "app/l10n_util_mac.h"
9 #include "app/table_model_observer.h" 9 #include "app/table_model_observer.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 - (NSString*)stringForObjectValue:(id)object { 42 - (NSString*)stringForObjectValue:(id)object {
43 if (![object isKindOfClass:[NSString class]]) 43 if (![object isKindOfClass:[NSString class]])
44 return nil; 44 return nil;
45 return object; 45 return object;
46 } 46 }
47 47
48 - (BOOL)getObjectValue:(id*)object 48 - (BOOL)getObjectValue:(id*)object
49 forString:(NSString*)string 49 forString:(NSString*)string
50 errorDescription:(NSString**)error { 50 errorDescription:(NSString**)error {
51 if ([string length]) { 51 if ([string length]) {
52 if (HostContentSettingsMap::Pattern( 52 if (ContentSettingsPattern(
53 base::SysNSStringToUTF8(string)).IsValid()) { 53 base::SysNSStringToUTF8(string)).IsValid()) {
54 *object = string; 54 *object = string;
55 return YES; 55 return YES;
56 } 56 }
57 } 57 }
58 if (error) 58 if (error)
59 *error = @"Invalid pattern"; 59 *error = @"Invalid pattern";
60 return NO; 60 return NO;
61 } 61 }
62 62
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 288 }
289 289
290 - (IBAction)addException:(id)sender { 290 - (IBAction)addException:(id)sender {
291 if (newException_.get()) { 291 if (newException_.get()) {
292 // The invariant is that |newException_| is non-NULL exactly if the pattern 292 // The invariant is that |newException_| is non-NULL exactly if the pattern
293 // of a new exception is currently being edited - so there's nothing to do 293 // of a new exception is currently being edited - so there's nothing to do
294 // in that case. 294 // in that case.
295 return; 295 return;
296 } 296 }
297 newException_.reset(new HostContentSettingsMap::PatternSettingPair); 297 newException_.reset(new HostContentSettingsMap::PatternSettingPair);
298 newException_->first = HostContentSettingsMap::Pattern( 298 newException_->first = ContentSettingsPattern(
299 l10n_util::GetStringUTF8(IDS_EXCEPTIONS_SAMPLE_PATTERN)); 299 l10n_util::GetStringUTF8(IDS_EXCEPTIONS_SAMPLE_PATTERN));
300 newException_->second = CONTENT_SETTING_BLOCK; 300 newException_->second = CONTENT_SETTING_BLOCK;
301 [tableView_ reloadData]; 301 [tableView_ reloadData];
302 302
303 [self adjustEditingButtons]; 303 [self adjustEditingButtons];
304 int index = model_->RowCount(); 304 int index = model_->RowCount();
305 NSIndexSet* selectedSet = [NSIndexSet indexSetWithIndex:index]; 305 NSIndexSet* selectedSet = [NSIndexSet indexSetWithIndex:index];
306 [tableView_ selectRowIndexes:selectedSet byExtendingSelection:NO]; 306 [tableView_ selectRowIndexes:selectedSet byExtendingSelection:NO];
307 [tableView_ editColumn:0 row:index withEvent:nil select:YES]; 307 [tableView_ editColumn:0 row:index withEvent:nil select:YES];
308 } 308 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 HostContentSettingsMap::PatternSettingPair originalEntry = 411 HostContentSettingsMap::PatternSettingPair originalEntry =
412 isNewRow ? *newException_ : model_->entry_at(row); 412 isNewRow ? *newException_ : model_->entry_at(row);
413 HostContentSettingsMap::PatternSettingPair entry = originalEntry; 413 HostContentSettingsMap::PatternSettingPair entry = originalEntry;
414 bool isOtr = 414 bool isOtr =
415 isNewRow ? 0 : model_->entry_is_off_the_record(row); 415 isNewRow ? 0 : model_->entry_is_off_the_record(row);
416 bool wasOtr = isOtr; 416 bool wasOtr = isOtr;
417 417
418 // Modify it. 418 // Modify it.
419 NSString* identifier = [tableColumn identifier]; 419 NSString* identifier = [tableColumn identifier];
420 if ([identifier isEqualToString:@"pattern"]) { 420 if ([identifier isEqualToString:@"pattern"]) {
421 entry.first = HostContentSettingsMap::Pattern( 421 entry.first = ContentSettingsPattern(base::SysNSStringToUTF8(object));
422 base::SysNSStringToUTF8(object));
423 } 422 }
424 if ([identifier isEqualToString:@"action"]) { 423 if ([identifier isEqualToString:@"action"]) {
425 int index = [object intValue]; 424 int index = [object intValue];
426 entry.second = popup_model_->SettingForIndex(index); 425 entry.second = popup_model_->SettingForIndex(index);
427 } 426 }
428 if ([identifier isEqualToString:@"otr"]) { 427 if ([identifier isEqualToString:@"otr"]) {
429 isOtr = [object intValue] != 0; 428 isOtr = [object intValue] != 0;
430 } 429 }
431 430
432 // Commit modification, if any. 431 // Commit modification, if any.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 480
482 // The model caches its data, meaning we need to recreate it on every change. 481 // The model caches its data, meaning we need to recreate it on every change.
483 model_.reset(new ContentExceptionsTableModel( 482 model_.reset(new ContentExceptionsTableModel(
484 settingsMap_, otrSettingsMap_, settingsType_)); 483 settingsMap_, otrSettingsMap_, settingsType_));
485 484
486 [tableView_ reloadData]; 485 [tableView_ reloadData];
487 [self adjustEditingButtons]; 486 [self adjustEditingButtons];
488 } 487 }
489 488
490 @end 489 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698