summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chrome_to_mobile_service.h
diff options
context:
space:
mode:
authormsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-30 04:36:28 +0000
committermsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-30 04:36:28 +0000
commita220bbdc3779ade5acbe222131e35291a5f95d06 (patch)
treedb3fb42fb86d91288fc2a64979f93fb26edca2e7 /chrome/browser/chrome_to_mobile_service.h
parente013858e413435be2ce7d5a53d32b3cffdc4182b (diff)
downloadchromium_src-a220bbdc3779ade5acbe222131e35291a5f95d06.zip
chromium_src-a220bbdc3779ade5acbe222131e35291a5f95d06.tar.gz
chromium_src-a220bbdc3779ade5acbe222131e35291a5f95d06.tar.bz2
Revert 129779 - Limit Chrome To Mobile cloud print access; refinements etc.
Check the user's account info before contacting cloud print. Only ping cloud print for users of that service. Make ChromeToMobileService a RefcountedProfileKeyedService. Add and check |temp_dir_valid_| on GenerateSnapshot. Fix a JSON DictionaryValue leak from ParseResponseJSON use. Make |mobiles_| a ScopedVector of DeepCopy DictionaryValues. Call new ChromeToMobileService::HasDevices for encapsulation. Call RequestMobileListUpdate from bubbles, not their callers. Mock RequestMobileListUpdate so tests do not send requests. Store the service, not the profile, as a bubble class member. Skip IsSyncAccessible on updates (the first check suffices). Auto-close on Mac via performSelector, not PostDelayedTask. cancelPreviousPerformRequestsWithTarget on windowWillClose. Call OnChanged after UpdateChromeToMobileEnabled for Mac. (the icon wasn't showing up immediately on Release builds) BUG=102709,118691 TEST=Less cloud print traffic. No apparent behavior changes. Review URL: https://chromiumcodereview.appspot.com/9863054 TBR=msw@chromium.org Review URL: https://chromiumcodereview.appspot.com/9950011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129785 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chrome_to_mobile_service.h')
-rw-r--r--chrome/browser/chrome_to_mobile_service.h30
1 files changed, 7 insertions, 23 deletions
diff --git a/chrome/browser/chrome_to_mobile_service.h b/chrome/browser/chrome_to_mobile_service.h
index cb90590..c8348d6 100644
--- a/chrome/browser/chrome_to_mobile_service.h
+++ b/chrome/browser/chrome_to_mobile_service.h
@@ -11,12 +11,11 @@
#include <vector>
#include "base/file_util.h"
-#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_temp_dir.h"
#include "base/string16.h"
#include "base/timer.h"
-#include "chrome/browser/profiles/refcounted_profile_keyed_service.h"
+#include "chrome/browser/profiles/profile_keyed_service.h"
#include "chrome/common/net/gaia/oauth2_access_token_consumer.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@@ -34,7 +33,8 @@ class DictionaryValue;
// ChromeToMobileService connects to the cloud print service to enumerate
// compatible mobiles owned by its profile and send URLs and MHTML snapshots.
-class ChromeToMobileService : public RefcountedProfileKeyedService,
+// The mobile list updates regularly, and explicitly by RequestMobileListUpdate.
+class ChromeToMobileService : public ProfileKeyedService,
public content::URLFetcherDelegate,
public content::NotificationObserver,
public OAuth2AccessTokenConsumer {
@@ -78,15 +78,11 @@ class ChromeToMobileService : public RefcountedProfileKeyedService,
explicit ChromeToMobileService(Profile* profile);
virtual ~ChromeToMobileService();
- // Returns true if the service has found any registered mobile devices.
- bool HasDevices();
-
// Get the list of mobile devices.
- const std::vector<base::DictionaryValue*>& mobiles();
+ const std::vector<base::DictionaryValue*>& mobiles() { return mobiles_; }
// Request an updated mobile device list, request auth first if needed.
- // Virtual for unit test mocking.
- virtual void RequestMobileListUpdate();
+ void RequestMobileListUpdate();
// Callback with an MHTML snapshot of the profile's selected WebContents.
// Virtual for unit test mocking.
@@ -98,9 +94,6 @@ class ChromeToMobileService : public RefcountedProfileKeyedService,
const FilePath& snapshot,
base::WeakPtr<Observer> observer);
- // RefcountedProfileKeyedService method.
- virtual void ShutdownOnUIThread() OVERRIDE;
-
// content::URLFetcherDelegate method.
virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE;
@@ -126,13 +119,9 @@ class ChromeToMobileService : public RefcountedProfileKeyedService,
// Virtual for unit test mocking.
virtual void RefreshAccessToken();
- // Request account information to limit cloud print access to existing users.
- void RequestAccountInfo();
-
// Send the cloud print URLFetcher search request.
void RequestSearch();
- void HandleAccountInfoResponse();
void HandleSearchResponse();
void HandleSubmitResponse(const content::URLFetcher* source);
@@ -146,11 +135,10 @@ class ChromeToMobileService : public RefcountedProfileKeyedService,
std::string access_token_;
// The list of mobile devices retrieved from the cloud print service.
- ScopedVector<base::DictionaryValue> mobiles_;
+ std::vector<base::DictionaryValue*> mobiles_;
- // The temporary directory for MHTML snapshot files and its validity flag.
+ // The temporary directory for MHTML snapshot files.
ScopedTempDir temp_dir_;
- bool temp_dir_valid_;
// Map URLFetchers to observers for reporting OnSendComplete.
typedef std::map<const content::URLFetcher*, base::WeakPtr<Observer> >
@@ -161,10 +149,6 @@ class ChromeToMobileService : public RefcountedProfileKeyedService,
scoped_ptr<OAuth2AccessTokenFetcher> access_token_fetcher_;
base::OneShotTimer<ChromeToMobileService> auth_retry_timer_;
- // The pending account information request and the cloud print access flag.
- scoped_ptr<content::URLFetcher> account_info_request_;
- bool cloud_print_accessible_;
-
// The pending mobile device search request; and the time of the last request.
scoped_ptr<content::URLFetcher> search_request_;
base::TimeTicks previous_search_time_;