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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/google_now/google_now_service.h
diff --git a/chrome/browser/ui/google_now/google_now_service.h b/chrome/browser/ui/google_now/google_now_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..eb6459a237b7f5270292c57c1c5778184776bb53
--- /dev/null
+++ b/chrome/browser/ui/google_now/google_now_service.h
@@ -0,0 +1,76 @@
+// Copyright (c) 2012 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.
+
+#ifndef CHROME_BROWSER_UI_GOOGLE_NOW_GOOGLE_NOW_SERVICE_H_
+#define CHROME_BROWSER_UI_GOOGLE_NOW_GOOGLE_NOW_SERVICE_H_
+
+#include "base/timer.h"
+#include "chrome/browser/profiles/profile_keyed_service.h"
+
+class Profile;
+
+namespace base {
+class TimeDelta;
+}
+
+namespace content {
+struct Geoposition;
+}
+
+namespace net {
+class URLRequest;
+}
+
+// The Google Now service gets Google Now cards from the server and shows them
+// as Chrome notifications.
+// The service performs periodic updating of Google Now cards.
+// Each updating of the cards consists of 3 steps:
+// 1. Obtaining the location of the machine (asynchronous);
+// 2. Making a server request (asynchronous);
+// 3. Showing the cards as notifications.
+class GoogleNowService : public ProfileKeyedService {
+ public:
+ // Must call Init after construction.
+ explicit GoogleNowService(Profile* profile);
+ virtual ~GoogleNowService();
+ void Init();
+
+ private:
+ // Parsed response from the server.
+ struct ServerResponse;
+
+ // Returns true if Google Now integration is enabled for the profile.
+ bool IsGoogleNowEnabled() const;
+ // Gets new cards from the server and shows them as notifications.
+ void UpdateCards();
+
+ // Schedules next cards update after the specified delay.
+ void StartWaitingForNextUpdate(base::TimeDelta delay);
+ void OnWaitingForNextUpdateEnds();
+
+ // Starts obtaining location of the machine.
+ void StartObtainingGeolocation();
+ void OnLocationObtained(const content::Geoposition& position);
+
+ // Starts downloading cards from the server.
+ void StartServerRequest(const content::Geoposition& position);
+ void OnServerRequestCompleted(net::URLRequest* request, int num_bytes);
+
+ // Parses server response. Returns true if the parsing was successful.
+ static bool ParseServerResponse(const net::URLRequest* request,
+ int num_bytes,
+ ServerResponse* server_response);
+
+ // Shows Google Now cards as notifications.
+ void ShowNotifications(const ServerResponse& server_response);
+
+ // The profile.
+ Profile* const profile_;
+ // Timer to schedule next cards update.
+ base::OneShotTimer<GoogleNowService> next_update_timer_;
+
+ DISALLOW_COPY_AND_ASSIGN(GoogleNowService);
+};
+
+#endif // CHROME_BROWSER_UI_GOOGLE_NOW_GOOGLE_NOW_SERVICE_H_
« 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