summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-22 09:54:02 +0000
committersanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-22 09:54:02 +0000
commit2469a22063c3539147f55fe899a8dabc12901c01 (patch)
treec5bd5091c6b89ad6609d04224827cfcb231ab576
parent8c49df9f7873a5673364f1f40675e87a24885c81 (diff)
downloadchromium_src-2469a22063c3539147f55fe899a8dabc12901c01.zip
chromium_src-2469a22063c3539147f55fe899a8dabc12901c01.tar.gz
chromium_src-2469a22063c3539147f55fe899a8dabc12901c01.tar.bz2
Switched the cloud print login from a WebUI local dialog to a web-based scheme.
BUG=None TEST=Test cloud print login. Review URL: http://codereview.chromium.org/7342036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93595 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc1
-rw-r--r--chrome/browser/printing/cloud_print/cloud_print_proxy_service.h2
-rw-r--r--chrome/browser/printing/cloud_print/cloud_print_url.cc15
-rw-r--r--chrome/browser/printing/cloud_print/cloud_print_url.h3
-rw-r--r--chrome/browser/ui/webui/options/advanced_options_handler.cc9
-rw-r--r--chrome/service/cloud_print/cloud_print_proxy.cc4
6 files changed, 30 insertions, 4 deletions
diff --git a/chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc b/chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc
index 86dc073..1c05372 100644
--- a/chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc
+++ b/chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc
@@ -199,6 +199,7 @@ void CloudPrintProxyService::DisableCloudPrintProxy() {
void CloudPrintProxyService::ProxyInfoCallback(
const cloud_print::CloudPrintProxyInfo& proxy_info) {
+ proxy_id_ = proxy_info.proxy_id;
profile_->GetPrefs()->SetString(
prefs::kCloudPrintEmail,
proxy_info.enabled ? proxy_info.email : std::string());
diff --git a/chrome/browser/printing/cloud_print/cloud_print_proxy_service.h b/chrome/browser/printing/cloud_print/cloud_print_proxy_service.h
index 5afd93a..26df678 100644
--- a/chrome/browser/printing/cloud_print/cloud_print_proxy_service.h
+++ b/chrome/browser/printing/cloud_print/cloud_print_proxy_service.h
@@ -44,6 +44,7 @@ class CloudPrintProxyService
void RefreshStatusFromService();
bool ShowTokenExpiredNotification();
+ std::string proxy_id() const { return proxy_id_; }
// CloudPrintSetupHandler::Delegate implementation.
virtual void OnCloudPrintSetupClosed();
@@ -56,6 +57,7 @@ class CloudPrintProxyService
Profile* profile_;
scoped_refptr<TokenExpiredNotificationDelegate> token_expired_delegate_;
scoped_ptr<CloudPrintSetupHandler> cloud_print_setup_handler_;
+ std::string proxy_id_;
// Methods that send an IPC to the service.
void RefreshCloudPrintProxyStatus();
diff --git a/chrome/browser/printing/cloud_print/cloud_print_url.cc b/chrome/browser/printing/cloud_print/cloud_print_url.cc
index b6f8f02..209fe86 100644
--- a/chrome/browser/printing/cloud_print/cloud_print_url.cc
+++ b/chrome/browser/printing/cloud_print/cloud_print_url.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/logging.h"
+#include "base/stringprintf.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
@@ -66,6 +67,20 @@ GURL CloudPrintURL::GetCloudPrintServiceManageURL() {
return cloud_print_manage_url;
}
+GURL CloudPrintURL::GetCloudPrintServiceEnableURL(
+ const std::string& proxy_id) {
+ GURL cloud_print_service_url = GetCloudPrintServiceURL();
+ std::string path(cloud_print_service_url.path() +
+ "/enable_chrome_connector/enable.html");
+ GURL::Replacements replacements;
+ replacements.SetPathStr(path);
+ std::string query = StringPrintf("proxy=%s", proxy_id.c_str());
+ replacements.SetQueryStr(query);
+ GURL cloud_print_enable_url = cloud_print_service_url.ReplaceComponents(
+ replacements);
+ return cloud_print_enable_url;
+}
+
GURL CloudPrintURL::GetCloudPrintLearnMoreURL() {
GURL cloud_print_learn_more_url(kLearnMoreURL);
return cloud_print_learn_more_url;
diff --git a/chrome/browser/printing/cloud_print/cloud_print_url.h b/chrome/browser/printing/cloud_print/cloud_print_url.h
index 55780b2..27ea76f 100644
--- a/chrome/browser/printing/cloud_print/cloud_print_url.h
+++ b/chrome/browser/printing/cloud_print/cloud_print_url.h
@@ -6,6 +6,8 @@
#define CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_URL_H_
#pragma once
+#include <string>
+
class GURL;
class Profile;
@@ -17,6 +19,7 @@ class CloudPrintURL {
GURL GetCloudPrintServiceURL();
GURL GetCloudPrintServiceDialogURL();
GURL GetCloudPrintServiceManageURL();
+ GURL GetCloudPrintServiceEnableURL(const std::string& proxy_id);
// These aren't derived from the service, but it makes sense to keep all the
// URLs together, and this gives the unit tests access for testing.
diff --git a/chrome/browser/ui/webui/options/advanced_options_handler.cc b/chrome/browser/ui/webui/options/advanced_options_handler.cc
index c58fa42..3b4834e 100644
--- a/chrome/browser/ui/webui/options/advanced_options_handler.cc
+++ b/chrome/browser/ui/webui/options/advanced_options_handler.cc
@@ -482,10 +482,11 @@ void AdvancedOptionsHandler::ShowCloudPrintManagePage(const ListValue* args) {
#if !defined(OS_CHROMEOS)
void AdvancedOptionsHandler::ShowCloudPrintSetupDialog(const ListValue* args) {
UserMetricsRecordAction(UserMetricsAction("Options_EnableCloudPrintProxy"));
- cloud_print_setup_handler_.reset(new CloudPrintSetupHandler(this));
- CloudPrintSetupFlow::OpenDialog(
- web_ui_->GetProfile(), cloud_print_setup_handler_->AsWeakPtr(),
- web_ui_->tab_contents()->GetDialogRootWindow());
+ // Open the connector enable page in the current tab.
+ web_ui_->tab_contents()->OpenURL(
+ CloudPrintURL(web_ui_->GetProfile()).GetCloudPrintServiceEnableURL(
+ web_ui_->GetProfile()->GetCloudPrintProxyService()->proxy_id()),
+ GURL(), CURRENT_TAB, PageTransition::LINK);
}
void AdvancedOptionsHandler::HandleDisableCloudPrintProxy(
diff --git a/chrome/service/cloud_print/cloud_print_proxy.cc b/chrome/service/cloud_print/cloud_print_proxy.cc
index 2e02aa3..802a973 100644
--- a/chrome/service/cloud_print/cloud_print_proxy.cc
+++ b/chrome/service/cloud_print/cloud_print_proxy.cc
@@ -181,6 +181,10 @@ void CloudPrintProxy::GetProxyInfo(cloud_print::CloudPrintProxyInfo* info) {
if (enabled_)
info->email = user_email();
info->proxy_id = proxy_id_;
+ // If the Cloud Print service is not enabled, we may need to read the old
+ // value of proxy_id from prefs.
+ if (info->proxy_id.empty())
+ service_prefs_->GetString(prefs::kCloudPrintProxyId, &info->proxy_id);
}
// Notification methods from the backend. Called on UI thread.