Skip to content

Commit

Permalink
Derive the manage URL from the cloud print root in prefs.
Browse files Browse the repository at this point in the history
Allows for different cloud print service providers.

BUG=56850
TEST=Use the Manage button in the cloud print section of advanced prefs.

Review URL: http://codereview.chromium.org/3602003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61239 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
scottbyer@google.com committed Oct 1, 2010
1 parent 545252a commit 7f71e75
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
10 changes: 10 additions & 0 deletions chrome/browser/printing/cloud_print/cloud_print_url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,13 @@ GURL CloudPrintURL::GetCloudPrintServiceDialogURL() {
replacements);
return cloud_print_dialog_url;
}

GURL CloudPrintURL::GetCloudPrintServiceManageURL() {
GURL cloud_print_service_url = GetCloudPrintServiceURL();
std::string path(cloud_print_service_url.path() + "/manage.html");
GURL::Replacements replacements;
replacements.SetPathStr(path);
GURL cloud_print_manage_url = cloud_print_service_url.ReplaceComponents(
replacements);
return cloud_print_manage_url;
}
1 change: 1 addition & 0 deletions chrome/browser/printing/cloud_print/cloud_print_url.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class CloudPrintURL {

GURL GetCloudPrintServiceURL();
GURL GetCloudPrintServiceDialogURL();
GURL GetCloudPrintServiceManageURL();

private:
void RegisterPreferences();
Expand Down
9 changes: 9 additions & 0 deletions chrome/browser/printing/print_dialog_cloud_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,15 @@ TEST_F(CloudPrintURLTest, CheckDefaultURLs) {
EXPECT_THAT(dialog_url, HasSubstr("/client/"));
EXPECT_THAT(dialog_url, Not(HasSubstr("cloudprint/cloudprint")));
EXPECT_THAT(dialog_url, HasSubstr("/dialog.html"));

std::string manage_url =
CloudPrintURL(profile_.get()).
GetCloudPrintServiceManageURL().spec();
EXPECT_THAT(manage_url, HasSubstr("www.google.com"));
EXPECT_THAT(manage_url, HasSubstr("/cloudprint/"));
EXPECT_THAT(manage_url, Not(HasSubstr("/client/")));
EXPECT_THAT(manage_url, Not(HasSubstr("cloudprint/cloudprint")));
EXPECT_THAT(manage_url, HasSubstr("/manage"));
}

// Testing for CloudPrintDataSender needs a mock DOMUI.
Expand Down
5 changes: 2 additions & 3 deletions chrome/browser/views/options/advanced_contents_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/pref_set_observer.h"
#include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h"
#include "chrome/browser/printing/cloud_print/cloud_print_url.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
Expand Down Expand Up @@ -1441,9 +1442,7 @@ void CloudPrintProxySection::ButtonPressed(views::Button* sender,
// Open a new browser window for the management tab. The browser
// will go away when the user closes that tab.
Browser* browser = Browser::Create(profile());
// FIXME(scottbyer): Refactor Cloud Print URL creation.
// http://code.google.com/p/chromium/issues/detail?id=56850
browser->OpenURL(GURL("https://www.google.com/cloudprint/manage.html"),
browser->OpenURL(CloudPrintURL(profile()).GetCloudPrintServiceManageURL(),
GURL(), NEW_WINDOW, PageTransition::LINK);
}
}
Expand Down

0 comments on commit 7f71e75

Please sign in to comment.