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

Side by Side Diff: chrome/browser/extensions/startup_helper.cc

Issue 10907104: Support an --install-from-webstore command line switch (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: updated comment Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/startup_helper.h" 5 #include "chrome/browser/extensions/startup_helper.h"
6 6
7 #include "base/bind.h"
7 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop.h"
8 #include "base/string_util.h" 10 #include "base/string_util.h"
9 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
10 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/webstore_inline_installer.h"
12 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "content/public/browser/web_contents.h"
18 #include "ipc/ipc_message.h"
14 19
15 namespace { 20 namespace {
16 21
17 void PrintPackExtensionMessage(const std::string& message) { 22 void PrintPackExtensionMessage(const std::string& message) {
18 base::StringPrintf("%s\n", message.c_str()); 23 base::StringPrintf("%s\n", message.c_str());
19 } 24 }
20 25
21 } // namespace 26 } // namespace
22 27
23 namespace extensions { 28 namespace extensions {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 ExtensionService* extension_service = profile->GetExtensionService(); 74 ExtensionService* extension_service = profile->GetExtensionService();
70 if (!extension_service) 75 if (!extension_service)
71 return false; 76 return false;
72 77
73 std::string extension_id = cmd_line.GetSwitchValueASCII( 78 std::string extension_id = cmd_line.GetSwitchValueASCII(
74 switches::kUninstallExtension); 79 switches::kUninstallExtension);
75 return ExtensionService::UninstallExtensionHelper(extension_service, 80 return ExtensionService::UninstallExtensionHelper(extension_service,
76 extension_id); 81 extension_id);
77 } 82 }
78 83
84 namespace {
85
86 class AppInstallHelper {
87 public:
88 AppInstallHelper();
89 virtual ~AppInstallHelper();
90
91 WebstoreInlineInstaller::Callback Callback();
92 void OnAppInstallComplete(bool success, const std::string& error);
93 };
94
95 AppInstallHelper::AppInstallHelper() {}
96
97 AppInstallHelper::~AppInstallHelper() {}
98
99 WebstoreInlineInstaller::Callback AppInstallHelper::Callback() {
100 return base::Bind(&AppInstallHelper::OnAppInstallComplete,
Mihai Parparita -not on Chrome 2012/09/07 22:01:36 Why not do this inline in te WebstoreInlineInstall
asargent_no_longer_on_chrome 2012/09/14 23:24:35 Done.
101 base::Unretained(this));
102 }
103 void AppInstallHelper::OnAppInstallComplete(bool success,
104 const std::string& error) {
Mihai Parparita -not on Chrome 2012/09/07 22:01:36 It would be nice to somehow propagate this error b
asargent_no_longer_on_chrome 2012/09/14 23:24:35 Done.
105 MessageLoop::current()->Quit();
106 }
107
108 } // namespace
109
110 bool StartupHelper::InstallAppFromID(const std::string& id, Profile* profile) {
111 scoped_ptr<content::WebContents> web_contents(
Mihai Parparita -not on Chrome 2012/09/07 22:01:36 Add a TODO about removing the need for this WebCon
asargent_no_longer_on_chrome 2012/09/14 23:24:35 Done.
112 content::WebContents::Create(profile, NULL, MSG_ROUTING_NONE, NULL));
113
114 AppInstallHelper helper;
115 scoped_refptr<WebstoreInlineInstaller> installer(
116 new WebstoreInlineInstaller(
117 web_contents.get(), id, false, GURL(), helper.Callback()));
118 installer->BeginInstall();
119
120 MessageLoop::current()->Run();
121 return false;
122 }
123
79 StartupHelper::~StartupHelper() { 124 StartupHelper::~StartupHelper() {
80 if (pack_job_.get()) 125 if (pack_job_.get())
81 pack_job_->ClearClient(); 126 pack_job_->ClearClient();
82 } 127 }
83 128
84 } // namespace extensions 129 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698