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/extensions/webstore_installer.h" | 5 #include "chrome/browser/extensions/webstore_installer.h" |
6 | 6 |
| 7 #include "base/command_line.h" |
| 8 #include "base/stringprintf.h" |
7 #include "base/string_util.h" | 9 #include "base/string_util.h" |
8 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/extensions/crx_installer.h" | 11 #include "chrome/browser/extensions/crx_installer.h" |
10 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/tabs/tab_strip_model.h" | 13 #include "chrome/browser/tabs/tab_strip_model.h" |
12 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
14 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
| 17 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
16 #include "chrome/common/extensions/extension_constants.h" | 19 #include "chrome/common/extensions/extension_constants.h" |
17 #include "content/browser/tab_contents/navigation_controller.h" | 20 #include "content/browser/tab_contents/navigation_controller.h" |
18 #include "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
19 #include "content/public/browser/notification_source.h" | 22 #include "content/public/browser/notification_source.h" |
20 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
21 #include "net/base/escape.h" | 24 #include "net/base/escape.h" |
22 | 25 |
23 namespace { | 26 namespace { |
24 | 27 |
25 const char kInvalidIdError[] = "Invalid id"; | 28 const char kInvalidIdError[] = "Invalid id"; |
26 const char kNoBrowserError[] = "No browser found"; | 29 const char kNoBrowserError[] = "No browser found"; |
27 | 30 |
28 const char kInlineInstallSource[] = "inline"; | 31 const char kInlineInstallSource[] = "inline"; |
29 const char kDefaultInstallSource[] = ""; | 32 const char kDefaultInstallSource[] = ""; |
30 | 33 |
31 GURL GetWebstoreInstallURL( | 34 GURL GetWebstoreInstallURL( |
32 const std::string& extension_id, const std::string& install_source) { | 35 const std::string& extension_id, const std::string& install_source) { |
| 36 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 37 if (cmd_line->HasSwitch(switches::kAppsGalleryDownloadURL)) { |
| 38 std::string download_url = |
| 39 cmd_line->GetSwitchValueASCII(switches::kAppsGalleryDownloadURL); |
| 40 return GURL(base::StringPrintf(download_url.c_str(), |
| 41 extension_id.c_str())); |
| 42 } |
33 std::vector<std::string> params; | 43 std::vector<std::string> params; |
34 params.push_back("id=" + extension_id); | 44 params.push_back("id=" + extension_id); |
35 if (!install_source.empty()) { | 45 if (!install_source.empty()) { |
36 params.push_back("installsource=" + install_source); | 46 params.push_back("installsource=" + install_source); |
37 } | 47 } |
38 params.push_back("lang=" + g_browser_process->GetApplicationLocale()); | 48 params.push_back("lang=" + g_browser_process->GetApplicationLocale()); |
39 params.push_back("uc"); | 49 params.push_back("uc"); |
40 std::string url_string = extension_urls::GetWebstoreUpdateUrl(true).spec(); | 50 std::string url_string = extension_urls::GetWebstoreUpdateUrl(true).spec(); |
41 | 51 |
42 GURL url(url_string + "?response=redirect&x=" + | 52 GURL url(url_string + "?response=redirect&x=" + |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 144 |
135 Release(); // Balanced in Start(). | 145 Release(); // Balanced in Start(). |
136 } | 146 } |
137 | 147 |
138 void WebstoreInstaller::ReportSuccess() { | 148 void WebstoreInstaller::ReportSuccess() { |
139 if (delegate_) | 149 if (delegate_) |
140 delegate_->OnExtensionInstallSuccess(id_); | 150 delegate_->OnExtensionInstallSuccess(id_); |
141 | 151 |
142 Release(); // Balanced in Start(). | 152 Release(); // Balanced in Start(). |
143 } | 153 } |
OLD | NEW |