OLD | NEW |
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/ui/extensions/application_launch.h" | 5 #include "chrome/browser/ui/extensions/application_launch.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "apps/launcher.h" | 9 #include "apps/launcher.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 chrome::HostDesktopType desktop_type, | 65 chrome::HostDesktopType desktop_type, |
66 const std::string& extension_id, | 66 const std::string& extension_id, |
67 const base::Closure& callback) | 67 const base::Closure& callback) |
68 : service_(service), | 68 : service_(service), |
69 profile_(profile), | 69 profile_(profile), |
70 desktop_type_(desktop_type), | 70 desktop_type_(desktop_type), |
71 extension_id_(extension_id), | 71 extension_id_(extension_id), |
72 callback_(callback) { | 72 callback_(callback) { |
73 } | 73 } |
74 | 74 |
75 virtual ~EnableViaAppListFlow() { | 75 ~EnableViaAppListFlow() override {} |
76 } | |
77 | 76 |
78 void Run() { | 77 void Run() { |
79 DCHECK(!service_->IsExtensionEnabled(extension_id_)); | 78 DCHECK(!service_->IsExtensionEnabled(extension_id_)); |
80 flow_.reset(new ExtensionEnableFlow(profile_, extension_id_, this)); | 79 flow_.reset(new ExtensionEnableFlow(profile_, extension_id_, this)); |
81 flow_->StartForCurrentlyNonexistentWindow( | 80 flow_->StartForCurrentlyNonexistentWindow( |
82 base::Bind(&EnableViaAppListFlow::ShowAppList, base::Unretained(this))); | 81 base::Bind(&EnableViaAppListFlow::ShowAppList, base::Unretained(this))); |
83 } | 82 } |
84 | 83 |
85 private: | 84 private: |
86 gfx::NativeWindow ShowAppList() { | 85 gfx::NativeWindow ShowAppList() { |
87 AppListService* app_list_service = AppListService::Get(desktop_type_); | 86 AppListService* app_list_service = AppListService::Get(desktop_type_); |
88 app_list_service->Show(); | 87 app_list_service->Show(); |
89 return app_list_service->GetAppListWindow(); | 88 return app_list_service->GetAppListWindow(); |
90 } | 89 } |
91 | 90 |
92 // ExtensionEnableFlowDelegate overrides. | 91 // ExtensionEnableFlowDelegate overrides. |
93 virtual void ExtensionEnableFlowFinished() override { | 92 void ExtensionEnableFlowFinished() override { |
94 const Extension* extension = | 93 const Extension* extension = |
95 service_->GetExtensionById(extension_id_, false); | 94 service_->GetExtensionById(extension_id_, false); |
96 if (!extension) | 95 if (!extension) |
97 return; | 96 return; |
98 callback_.Run(); | 97 callback_.Run(); |
99 delete this; | 98 delete this; |
100 } | 99 } |
101 | 100 |
102 virtual void ExtensionEnableFlowAborted(bool user_initiated) override { | 101 void ExtensionEnableFlowAborted(bool user_initiated) override { delete this; } |
103 delete this; | |
104 } | |
105 | 102 |
106 ExtensionService* service_; | 103 ExtensionService* service_; |
107 Profile* profile_; | 104 Profile* profile_; |
108 chrome::HostDesktopType desktop_type_; | 105 chrome::HostDesktopType desktop_type_; |
109 std::string extension_id_; | 106 std::string extension_id_; |
110 base::Closure callback_; | 107 base::Closure callback_; |
111 scoped_ptr<ExtensionEnableFlow> flow_; | 108 scoped_ptr<ExtensionEnableFlow> flow_; |
112 | 109 |
113 DISALLOW_COPY_AND_ASSIGN(EnableViaAppListFlow); | 110 DISALLOW_COPY_AND_ASSIGN(EnableViaAppListFlow); |
114 }; | 111 }; |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 | 453 |
457 // For extensions lacking launch urls, determine a reasonable fallback. | 454 // For extensions lacking launch urls, determine a reasonable fallback. |
458 if (!url.is_valid()) { | 455 if (!url.is_valid()) { |
459 url = extensions::OptionsPageInfo::GetOptionsPage(extension); | 456 url = extensions::OptionsPageInfo::GetOptionsPage(extension); |
460 if (!url.is_valid()) | 457 if (!url.is_valid()) |
461 url = GURL(chrome::kChromeUIExtensionsURL); | 458 url = GURL(chrome::kChromeUIExtensionsURL); |
462 } | 459 } |
463 | 460 |
464 return url; | 461 return url; |
465 } | 462 } |
OLD | NEW |