Logo Search packages:      
Sourcecode: chromium-browser version File versions  Download package


// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.


#import <Cocoa/Cocoa.h>

#include <vector>
#include "base/scoped_nsobject.h"
#include "googleurl/src/gurl.h"

class Profile;

// The model for the "custom home pages" table in preferences. Contains a list
// of CustomHomePageEntry objects. This is intended to be used with Cocoa
// bindings.
// The supported binding is |customHomePages|, a to-many relationship which
// can be observed with an array controller.

@interface CustomHomePagesModel : NSObject {
  scoped_nsobject<NSArray> entries_;
  Profile* profile_;  // weak, used for loading favicons

// Initialize with |profile|, which must not be NULL. The profile is used for
// loading favicons for urls.
- (id)initWithProfile:(Profile*)profile;

// Get/set the urls the model currently contains as a group. Only one change
// notification will be sent.
- (std::vector<GURL>)URLs;
- (void)setURLs:(const std::vector<GURL>&)urls;

// Validates the set of URLs stored in the model. The user may have input bad
// data. This function removes invalid entries from the model, which will result
// in anyone observing being updated.
- (void)validateURLs;

// For binding |customHomePages| to a mutable array controller.
- (NSUInteger)countOfCustomHomePages;
- (id)objectInCustomHomePagesAtIndex:(NSUInteger)index;
- (void)insertObject:(id)object inCustomHomePagesAtIndex:(NSUInteger)index;
- (void)removeObjectFromCustomHomePagesAtIndex:(NSUInteger)index;

@interface CustomHomePagesModel(InternalOrTestingAPI)

// Clears the URL string at the specified index. This constitutes bad data. The
// validator should scrub the entry from the list the next time it is run.
- (void) setURLStringEmptyAt:(NSUInteger)index;


// A notification that fires when the URL of one of the entries changes.
// Prevents interested parties from having to observe all model objects in order
// to persist changes to a single entry. Changes to the number of items in the
// model can be observed by watching |customHomePages| via KVO so an additional
// notification is not sent.
extern NSString* const kHomepageEntryChangedNotification;


Generated by  Doxygen 1.6.0   Back to index