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

Unified Diff: chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h

Issue 23903011: Modify devices page to match the latest mocks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix browser test Created 7 years, 3 months 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
Index: chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h
diff --git a/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h b/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h
index 3beb0299da5762fda93932ef08f1bf4f468c208b..3538efcf543868aed9bae132d400630023483abc 100644
--- a/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h
+++ b/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h
@@ -9,7 +9,9 @@
#include <string>
#include <vector>
+#include "base/cancelable_callback.h"
#include "chrome/browser/local_discovery/cloud_print_account_manager.h"
+#include "chrome/browser/local_discovery/cloud_print_printer_list.h"
#include "chrome/browser/local_discovery/privet_confirm_api_flow.h"
#include "chrome/browser/local_discovery/privet_constants.h"
#include "chrome/browser/local_discovery/privet_device_lister.h"
@@ -28,7 +30,8 @@ namespace local_discovery {
// into the Javascript to update the page.
class LocalDiscoveryUIHandler : public content::WebUIMessageHandler,
public PrivetRegisterOperation::Delegate,
- public PrivetDeviceLister::Delegate {
+ public PrivetDeviceLister::Delegate,
+ public CloudPrintPrinterList::Delegate {
public:
class Factory {
public:
@@ -73,11 +76,15 @@ class LocalDiscoveryUIHandler : public content::WebUIMessageHandler,
const DeviceDescription& description) OVERRIDE;
virtual void DeviceRemoved(const std::string& name) OVERRIDE;
+ // CloudPrintPrinterList::Delegate implementation.
+ virtual void OnCloudPrintPrinterListReady() OVERRIDE;
+
+ virtual void OnCloudPrintPrinterListUnavailable() OVERRIDE;
+
private:
- // Message handlers:
- // For registering a device.
- void HandleRegisterDevice(const base::ListValue* args);
+ typedef std::map<std::string, DeviceDescription> DeviceDescriptionMap;
+ // Message handlers:
// For when the page is ready to recieve device notifications.
void HandleStart(const base::ListValue* args);
@@ -85,30 +92,26 @@ class LocalDiscoveryUIHandler : public content::WebUIMessageHandler,
void HandleIsVisible(const base::ListValue* args);
// For when a user choice is made.
- void HandleChooseUser(const base::ListValue* args);
+ void HandleRegisterDevice(const base::ListValue* args);
// For when a cancelation is made.
void HandleCancelRegistration(const base::ListValue* args);
+ // For requesting the printer list.
+ void HandleRequestPrinterList(const base::ListValue* args);
+
+ // For opening URLs (relative to the Google Cloud Print base URL) in a new
+ // tab.
+ void HandleOpenCloudPrintURL(const base::ListValue* args);
+
// For when the IP address of the printer has been resolved for registration.
void StartRegisterHTTP(
- const std::string& user,
scoped_ptr<PrivetHTTPClient> http_client);
// For when the confirm operation on the cloudprint server has finished
// executing.
void OnConfirmDone(CloudPrintBaseApiFlow::Status status);
- // For when the cloud print account list is resolved.
- void OnCloudPrintAccountsResolved(const std::vector<std::string>& accounts,
- const std::string& xsrf_token);
-
- // For when XSRF token is received for a secondary account.
- void OnXSRFTokenForSecondaryAccount(
- const GURL& automated_claim_url,
- const std::vector<std::string>& accounts,
- const std::string& xsrf_token);
-
// Signal to the web interface an error has ocurred while registering.
void SendRegisterError();
@@ -121,24 +124,23 @@ class LocalDiscoveryUIHandler : public content::WebUIMessageHandler,
// Get the sync account email.
std::string GetSyncAccount();
- // Get the base cloud print URL for a given device.
- const std::string& GetCloudPrintBaseUrl(const std::string& device_name);
-
- // Start the confirm flow for a cookie based authentication.
- void StartCookieConfirmFlow(
- int user_index,
- const std::string& xsrf_token,
- const GURL& automatic_claim_url);
+ // Get the base cloud print URL.
+ std::string GetCloudPrintBaseUrl();
// Reset and cancel the current registration.
void ResetCurrentRegistration();
+ scoped_ptr<base::DictionaryValue> CreatePrinterInfo(
+ const CloudPrintPrinterList::PrinterDetails& description);
+
+ // Announcement hasn't been sent for a certain time after registration
+ // finished. Consider it failed.
+ // TODO(noamsml): Re-resolve service first.
+ void OnAnnouncementTimeoutReached();
+
// The current HTTP client (used for the current operation).
scoped_ptr<PrivetHTTPClient> current_http_client_;
- // Device currently registering.
- std::string current_register_device_;
-
// The current register operation. Only one allowed at any time.
scoped_ptr<PrivetRegisterOperation> current_register_operation_;
@@ -158,20 +160,20 @@ class LocalDiscoveryUIHandler : public content::WebUIMessageHandler,
scoped_ptr<PrivetHTTPAsynchronousFactory::Resolution> privet_resolution_;
// A map of current device descriptions provided by the PrivetDeviceLister.
- std::map<std::string, DeviceDescription> device_descriptions_;
+ DeviceDescriptionMap device_descriptions_;
// Whether or not the page is marked as visible.
bool is_visible_;
- // Cloud print account manager to enumerate accounts and get XSRF token.
- scoped_ptr<CloudPrintAccountManager> cloud_print_account_manager_;
+ // Device whose state must be updated to "registered" to complete
+ // registration.
+ std::string new_register_device_;
- // XSRF token.
- std::string xsrf_token_for_primary_user_;
+ // List of printers from cloud print.
+ scoped_ptr<CloudPrintPrinterList> cloud_print_printer_list_;
- // Current user index (for multi-login), or kAccountIndexUseOAuth2 for sync
- // credentials.
- int current_register_user_index_;
+ // Announcement timeout for registration.
+ base::CancelableCallback<void()> registration_announce_timeout_;
DISALLOW_COPY_AND_ASSIGN(LocalDiscoveryUIHandler);
};

Powered by Google App Engine
This is Rietveld 408576698