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

Side by Side Diff: athena/extensions/chrome/extensions_delegate_impl.cc

Issue 863033002: Delete athena/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "athena/extensions/public/extensions_delegate.h"
6
7 #include "athena/extensions/chrome/athena_chrome_app_window_client.h"
8 #include "athena/extensions/chrome/athena_extension_install_ui.h"
9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/extension_util.h"
13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/extensions/app_launch_params.h"
15 #include "chrome/browser/ui/extensions/application_launch.h"
16 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
17 #include "extensions/browser/extension_registry.h"
18 #include "extensions/browser/extension_system.h"
19 #include "extensions/common/constants.h"
20 #include "extensions/common/extension_set.h"
21 #include "extensions/common/extension_urls.h"
22 #include "net/base/url_util.h"
23 #include "ui/base/window_open_disposition.h"
24
25 namespace athena {
26 namespace {
27
28 class ChromeExtensionsDelegate : public ExtensionsDelegate {
29 public:
30 explicit ChromeExtensionsDelegate(content::BrowserContext* context)
31 : extension_service_(
32 extensions::ExtensionSystem::Get(context)->extension_service()) {
33 extensions::AppWindowClient::Set(&app_window_client_);
34 }
35
36 ~ChromeExtensionsDelegate() override {
37 extensions::AppWindowClient::Set(nullptr);
38 }
39
40 private:
41 // ExtensionsDelegate:
42 content::BrowserContext* GetBrowserContext() const override {
43 return extension_service_->GetBrowserContext();
44 }
45 const extensions::ExtensionSet& GetInstalledExtensions() override {
46 return extensions::ExtensionRegistry::Get(GetBrowserContext())
47 ->enabled_extensions();
48 }
49 bool LaunchApp(const std::string& app_id) override {
50 // Check Running apps
51 content::BrowserContext* context = GetBrowserContext();
52 const extensions::Extension* extension =
53 extensions::ExtensionRegistry::Get(context)->GetExtensionById(
54 app_id, extensions::ExtensionRegistry::EVERYTHING);
55 DCHECK(extension);
56 if (!extension)
57 return false;
58
59 // TODO(oshima): Support installation/enabling process.
60 if (!extensions::util::IsAppLaunchableWithoutEnabling(app_id, context))
61 return false;
62
63 AppLaunchParams params(Profile::FromBrowserContext(context), extension,
64 CURRENT_TAB, chrome::HOST_DESKTOP_TYPE_ASH,
65 extensions::SOURCE_APP_LAUNCHER);
66 // TODO(oshima): rename HOST_DESTOP_TYPE_ASH to non native desktop.
67
68 if (app_id == extensions::kWebStoreAppId) {
69 std::string source_value =
70 std::string(extension_urls::kLaunchSourceAppList);
71 // Set an override URL to include the source.
72 GURL extension_url =
73 extensions::AppLaunchInfo::GetFullLaunchURL(extension);
74 params.override_url = net::AppendQueryParameter(
75 extension_url, extension_urls::kWebstoreSourceField, source_value);
76 }
77 params.container = extensions::LAUNCH_CONTAINER_WINDOW;
78
79 OpenApplication(params);
80 return true;
81 }
82
83 bool UnloadApp(const std::string& app_id) override {
84 // TODO(skuhne): Implement using extension service.
85 return false;
86 }
87
88 scoped_ptr<extensions::ExtensionInstallUI> CreateExtensionInstallUI()
89 override {
90 return scoped_ptr<extensions::ExtensionInstallUI>(
91 new AthenaExtensionInstallUI());
92 }
93
94 // ExtensionService for the browser context this is created for.
95 ExtensionService* extension_service_;
96
97 // Installed extensions.
98 extensions::ExtensionSet extensions_;
99
100 AthenaChromeAppWindowClient app_window_client_;
101
102 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsDelegate);
103 };
104
105 } // namespace
106
107 // static
108 void ExtensionsDelegate::CreateExtensionsDelegate(
109 content::BrowserContext* context) {
110 new ChromeExtensionsDelegate(context);
111 }
112
113 } // namespace athena
OLDNEW
« no previous file with comments | « athena/extensions/chrome/chrome_search_controller_factory.cc ('k') | athena/extensions/extension_app_model_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698