OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" | 5 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "chrome/browser/google/google_util.h" | 10 #include "chrome/browser/google/google_util.h" |
11 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
16 | 16 |
17 const char kDefaultCloudPrintServiceURL[] = "https://www.google.com/cloudprint"; | 17 const char kDefaultCloudPrintServiceURL[] = "https://www.google.com/cloudprint"; |
18 const char kSigninURL[] = "https://www.google.com/accounts/ServiceLogin?" | |
19 "service=cloudprint&continue=" | |
20 "https%3A%2F%2Fwww.google.com%2Fcloudprint"; | |
Scott Byer
2011/08/23 23:57:33
Should this be over-ridable in the prefs?
Albert Bodenhamer
2011/08/24 01:00:07
Done.
| |
21 | |
18 const char kLearnMoreURL[] = | 22 const char kLearnMoreURL[] = |
19 "https://www.google.com/support/cloudprint"; | 23 "https://www.google.com/support/cloudprint"; |
20 const char kTestPageURL[] = | 24 const char kTestPageURL[] = |
21 "http://www.google.com/landing/cloudprint/enable.html?print=true"; | 25 "http://www.google.com/landing/cloudprint/enable.html?print=true"; |
22 | 26 |
23 void CloudPrintURL::RegisterPreferences() { | 27 void CloudPrintURL::RegisterPreferences() { |
24 DCHECK(profile_); | 28 DCHECK(profile_); |
25 PrefService* pref_service = profile_->GetPrefs(); | 29 PrefService* pref_service = profile_->GetPrefs(); |
26 if (pref_service->FindPreference(prefs::kCloudPrintServiceURL)) | 30 if (pref_service->FindPreference(prefs::kCloudPrintServiceURL)) |
27 return; | 31 return; |
(...skipping 12 matching lines...) Expand all Loading... | |
40 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 44 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
41 GURL cloud_print_service_url = GURL(command_line.GetSwitchValueASCII( | 45 GURL cloud_print_service_url = GURL(command_line.GetSwitchValueASCII( |
42 switches::kCloudPrintServiceURL)); | 46 switches::kCloudPrintServiceURL)); |
43 if (cloud_print_service_url.is_empty()) { | 47 if (cloud_print_service_url.is_empty()) { |
44 cloud_print_service_url = GURL( | 48 cloud_print_service_url = GURL( |
45 profile_->GetPrefs()->GetString(prefs::kCloudPrintServiceURL)); | 49 profile_->GetPrefs()->GetString(prefs::kCloudPrintServiceURL)); |
46 } | 50 } |
47 return cloud_print_service_url; | 51 return cloud_print_service_url; |
48 } | 52 } |
49 | 53 |
54 GURL CloudPrintURL::GetCloudPrintSigninURL() { | |
55 GURL url(kSigninURL); | |
56 return google_util::AppendGoogleLocaleParam(url); | |
57 } | |
58 | |
50 GURL CloudPrintURL::GetCloudPrintServiceDialogURL() { | 59 GURL CloudPrintURL::GetCloudPrintServiceDialogURL() { |
51 GURL cloud_print_service_url = GetCloudPrintServiceURL(); | 60 GURL cloud_print_service_url = GetCloudPrintServiceURL(); |
52 std::string path(cloud_print_service_url.path() + "/client/dialog.html"); | 61 std::string path(cloud_print_service_url.path() + "/client/dialog.html"); |
53 GURL::Replacements replacements; | 62 GURL::Replacements replacements; |
54 replacements.SetPathStr(path); | 63 replacements.SetPathStr(path); |
55 GURL cloud_print_dialog_url = cloud_print_service_url.ReplaceComponents( | 64 GURL cloud_print_dialog_url = cloud_print_service_url.ReplaceComponents( |
56 replacements); | 65 replacements); |
57 return google_util::AppendGoogleLocaleParam(cloud_print_dialog_url); | 66 return google_util::AppendGoogleLocaleParam(cloud_print_dialog_url); |
58 } | 67 } |
59 | 68 |
(...skipping 23 matching lines...) Expand all Loading... | |
83 | 92 |
84 GURL CloudPrintURL::GetCloudPrintLearnMoreURL() { | 93 GURL CloudPrintURL::GetCloudPrintLearnMoreURL() { |
85 GURL cloud_print_learn_more_url(kLearnMoreURL); | 94 GURL cloud_print_learn_more_url(kLearnMoreURL); |
86 return cloud_print_learn_more_url; | 95 return cloud_print_learn_more_url; |
87 } | 96 } |
88 | 97 |
89 GURL CloudPrintURL::GetCloudPrintTestPageURL() { | 98 GURL CloudPrintURL::GetCloudPrintTestPageURL() { |
90 GURL cloud_print_learn_more_url(kTestPageURL); | 99 GURL cloud_print_learn_more_url(kTestPageURL); |
91 return cloud_print_learn_more_url; | 100 return cloud_print_learn_more_url; |
92 } | 101 } |
OLD | NEW |