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

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

Issue 407483002: Show post-install UI when ephemeral apps are promoted to installed apps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@install_guard
Patch Set: Created 6 years, 5 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
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/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/extensions/sandboxed_unpacker.h" 17 #include "chrome/browser/extensions/sandboxed_unpacker.h"
18 #include "chrome/browser/extensions/webstore_startup_installer.h" 18 #include "chrome/browser/extensions/webstore_startup_installer.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/extensions/chrome_extensions_client.h" 21 #include "chrome/common/extensions/chrome_extensions_client.h"
22 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
24 #include "extensions/common/extension.h" 24 #include "extensions/common/extension.h"
25 #include "ipc/ipc_message.h" 25 #include "ipc/ipc_message.h"
26 26
27 #if defined(OS_WIN)
28 #include "apps/app_window.h"
29 #include "apps/app_window_registry.h"
30 #include "extensions/browser/extension_registry.h"
31 #endif
32
27 using content::BrowserThread; 33 using content::BrowserThread;
28 34
29 namespace { 35 namespace {
30 36
31 void PrintPackExtensionMessage(const std::string& message) { 37 void PrintPackExtensionMessage(const std::string& message) {
32 printf("%s\n", message.c_str()); 38 printf("%s\n", message.c_str());
33 } 39 }
34 40
41 // On Windows, the jumplist action for installing an ephemeral app has to use
tmdiep 2014/07/18 06:37:31 Note: Windows jumplists only allow you to execute
42 // the --install-from-webstore command line arg to initiate an install.
43 scoped_refptr<extensions::WebstoreStandaloneInstaller>
44 CreateEphemeralAppInstaller(
45 Profile* profile,
46 const std::string& app_id,
47 extensions::WebstoreStandaloneInstaller::Callback callback) {
48 scoped_refptr<extensions::WebstoreStandaloneInstaller> installer;
49
50 #if defined(OS_WIN)
51 using extensions::ExtensionRegistry;
52 ExtensionRegistry* registry = ExtensionRegistry::Get(profile);
53 DCHECK(registry);
54 if (!registry->GetExtensionById(app_id, ExtensionRegistry::EVERYTHING))
55 return installer;
56
57 apps::AppWindowRegistry* app_window_registry =
58 apps::AppWindowRegistry::Get(profile);
59 DCHECK(app_window_registry);
60 apps::AppWindow* app_window =
61 app_window_registry->GetCurrentAppWindowForApp(app_id);
62 if (!app_window)
63 return installer;
64
65 installer = new extensions::WebstoreInstallWithPrompt(
66 app_id, profile, app_window->GetNativeWindow(), callback);
67 #endif
68
69 return installer;
70 }
71
35 } // namespace 72 } // namespace
36 73
37 namespace extensions { 74 namespace extensions {
38 75
39 StartupHelper::StartupHelper() : pack_job_succeeded_(false) { 76 StartupHelper::StartupHelper() : pack_job_succeeded_(false) {
40 ExtensionsClient::Set(ChromeExtensionsClient::GetInstance()); 77 ExtensionsClient::Set(ChromeExtensionsClient::GetInstance());
41 } 78 }
42 79
43 void StartupHelper::OnPackSuccess( 80 void StartupHelper::OnPackSuccess(
44 const base::FilePath& crx_path, 81 const base::FilePath& crx_path,
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 void AppInstallHelper::BeginInstall( 273 void AppInstallHelper::BeginInstall(
237 Profile* profile, 274 Profile* profile,
238 const std::string& id, 275 const std::string& id,
239 bool show_prompt, 276 bool show_prompt,
240 DoneCallback done_callback) { 277 DoneCallback done_callback) {
241 done_callback_ = done_callback; 278 done_callback_ = done_callback;
242 279
243 WebstoreStandaloneInstaller::Callback callback = 280 WebstoreStandaloneInstaller::Callback callback =
244 base::Bind(&AppInstallHelper::OnAppInstallComplete, 281 base::Bind(&AppInstallHelper::OnAppInstallComplete,
245 base::Unretained(this)); 282 base::Unretained(this));
246 installer_ = new WebstoreStartupInstaller( 283
247 id, 284 installer_ = CreateEphemeralAppInstaller(profile, id, callback);
248 profile, 285 if (!installer_.get()) {
249 show_prompt, 286 installer_ =
250 callback); 287 new WebstoreStartupInstaller(id, profile, show_prompt, callback);
288 }
251 installer_->BeginInstall(); 289 installer_->BeginInstall();
252 } 290 }
253 291
254 void AppInstallHelper::OnAppInstallComplete(bool success, 292 void AppInstallHelper::OnAppInstallComplete(bool success,
255 const std::string& error) { 293 const std::string& error) {
256 success_ = success; 294 success_ = success;
257 error_= error; 295 error_= error;
258 done_callback_.Run(); 296 done_callback_.Run();
259 } 297 }
260 298
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 } 352 }
315 return id; 353 return id;
316 } 354 }
317 355
318 StartupHelper::~StartupHelper() { 356 StartupHelper::~StartupHelper() {
319 if (pack_job_.get()) 357 if (pack_job_.get())
320 pack_job_->ClearClient(); 358 pack_job_->ClearClient();
321 } 359 }
322 360
323 } // namespace extensions 361 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698