Home | History | Annotate | Download | only in google_apis
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_GOOGLE_APIS_GDATA_CONTACTS_REQUESTS_H_
      6 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_CONTACTS_REQUESTS_H_
      7 
      8 #include <string>
      9 
     10 #include "chrome/browser/google_apis/base_requests.h"
     11 
     12 namespace google_apis {
     13 
     14 //========================== GetContactGroupsRequest =========================
     15 
     16 // This class fetches a JSON feed containing a user's contact groups.
     17 class GetContactGroupsRequest : public GetDataRequest {
     18  public:
     19   GetContactGroupsRequest(RequestSender* runner,
     20                           const GetDataCallback& callback);
     21   virtual ~GetContactGroupsRequest();
     22 
     23   void set_feed_url_for_testing(const GURL& url) {
     24     feed_url_for_testing_ = url;
     25   }
     26 
     27  protected:
     28   // Overridden from GetDataRequest.
     29   virtual GURL GetURL() const OVERRIDE;
     30 
     31  private:
     32   // If non-empty, URL of the feed to fetch.
     33   GURL feed_url_for_testing_;
     34 
     35   DISALLOW_COPY_AND_ASSIGN(GetContactGroupsRequest);
     36 };
     37 
     38 //============================ GetContactsRequest ============================
     39 
     40 // This class fetches a JSON feed containing a user's contacts.
     41 class GetContactsRequest : public GetDataRequest {
     42  public:
     43   GetContactsRequest(RequestSender* runner,
     44                      const std::string& group_id,
     45                      const base::Time& min_update_time,
     46                      const GetDataCallback& callback);
     47   virtual ~GetContactsRequest();
     48 
     49   void set_feed_url_for_testing(const GURL& url) {
     50     feed_url_for_testing_ = url;
     51   }
     52 
     53  protected:
     54   // Overridden from GetDataRequest.
     55   virtual GURL GetURL() const OVERRIDE;
     56 
     57  private:
     58   // If non-empty, URL of the feed to fetch.
     59   GURL feed_url_for_testing_;
     60 
     61   // If non-empty, contains the ID of the group whose contacts should be
     62   // returned.  Group IDs generally look like this:
     63   // http://www.google.com/m8/feeds/groups/user%40gmail.com/base/6
     64   std::string group_id_;
     65 
     66   // If is_null() is false, contains a minimum last-updated time that will be
     67   // used to filter contacts.
     68   base::Time min_update_time_;
     69 
     70   DISALLOW_COPY_AND_ASSIGN(GetContactsRequest);
     71 };
     72 
     73 //========================== GetContactPhotoRequest ==========================
     74 
     75 // This class fetches a contact's photo.
     76 class GetContactPhotoRequest : public UrlFetchRequestBase {
     77  public:
     78   GetContactPhotoRequest(RequestSender* runner,
     79                          const GURL& photo_url,
     80                          const GetContentCallback& callback);
     81   virtual ~GetContactPhotoRequest();
     82 
     83  protected:
     84   // Overridden from UrlFetchRequestBase.
     85   virtual GURL GetURL() const OVERRIDE;
     86   virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE;
     87   virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE;
     88 
     89  private:
     90   // Location of the photo to fetch.
     91   GURL photo_url_;
     92 
     93   // Callback to which the photo data is passed.
     94   GetContentCallback callback_;
     95 
     96   DISALLOW_COPY_AND_ASSIGN(GetContactPhotoRequest);
     97 };
     98 
     99 }  // namespace google_apis
    100 
    101 #endif  // CHROME_BROWSER_GOOGLE_APIS_GDATA_CONTACTS_REQUESTS_H_
    102