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

Side by Side Diff: chrome/browser/ui/google_now/google_now_service.h

Issue 11412291: Creating a skeleton for Google Now for Chrome implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Final sky's comments. Created 8 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
(Empty)
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_UI_GOOGLE_NOW_GOOGLE_NOW_SERVICE_H_
6 #define CHROME_BROWSER_UI_GOOGLE_NOW_GOOGLE_NOW_SERVICE_H_
7
8 #include "base/timer.h"
9 #include "chrome/browser/profiles/profile_keyed_service.h"
10
11 class Profile;
12
13 namespace base {
14 class TimeDelta;
15 }
16
17 namespace content {
18 struct Geoposition;
19 }
20
21 namespace net {
22 class URLRequest;
23 }
24
25 // The Google Now service gets Google Now cards from the server and shows them
26 // as Chrome notifications.
27 // The service performs periodic updating of Google Now cards.
28 // Each updating of the cards consists of 3 steps:
29 // 1. Obtaining the location of the machine (asynchronous);
30 // 2. Making a server request (asynchronous);
31 // 3. Showing the cards as notifications.
32 class GoogleNowService : public ProfileKeyedService {
33 public:
34 // Must call Init after construction.
35 explicit GoogleNowService(Profile* profile);
36 virtual ~GoogleNowService();
37 void Init();
38
39 private:
40 // Parsed response from the server.
41 struct ServerResponse;
42
43 // Returns true if Google Now integration is enabled for the profile.
44 bool IsGoogleNowEnabled() const;
45 // Gets new cards from the server and shows them as notifications.
46 void UpdateCards();
47
48 // Schedules next cards update after the specified delay.
49 void StartWaitingForNextUpdate(base::TimeDelta delay);
50 void OnWaitingForNextUpdateEnds();
51
52 // Starts obtaining location of the machine.
53 void StartObtainingGeolocation();
54 void OnLocationObtained(const content::Geoposition& position);
55
56 // Starts downloading cards from the server.
57 void StartServerRequest(const content::Geoposition& position);
58 void OnServerRequestCompleted(net::URLRequest* request, int num_bytes);
59
60 // Parses server response. Returns true if the parsing was successful.
61 static bool ParseServerResponse(const net::URLRequest* request,
62 int num_bytes,
63 ServerResponse* server_response);
64
65 // Shows Google Now cards as notifications.
66 void ShowNotifications(const ServerResponse& server_response);
67
68 // The profile.
69 Profile* const profile_;
70 // Timer to schedule next cards update.
71 base::OneShotTimer<GoogleNowService> next_update_timer_;
72
73 DISALLOW_COPY_AND_ASSIGN(GoogleNowService);
74 };
75
76 #endif // CHROME_BROWSER_UI_GOOGLE_NOW_GOOGLE_NOW_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | chrome/browser/ui/google_now/google_now_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698