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

Side by Side Diff: chrome/browser/web_applications/web_app.cc

Issue 777543002: Create hosted app shims on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unnecessary forward declaration Created 6 years 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/web_applications/web_app.h" 5 #include "chrome/browser/web_applications/web_app.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/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/i18n/file_util_icu.h" 10 #include "base/i18n/file_util_icu.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/extensions/extension_ui_util.h" 16 #include "chrome/browser/extensions/extension_ui_util.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/profiles/profile_manager.h"
17 #include "chrome/common/chrome_constants.h" 19 #include "chrome/common/chrome_constants.h"
18 #include "chrome/common/chrome_version_info.h" 20 #include "chrome/common/chrome_version_info.h"
19 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 21 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
20 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
21 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
22 #include "extensions/browser/extension_registry.h" 24 #include "extensions/browser/extension_registry.h"
23 #include "extensions/browser/image_loader.h" 25 #include "extensions/browser/image_loader.h"
24 #include "extensions/common/constants.h" 26 #include "extensions/common/constants.h"
25 #include "extensions/common/extension.h" 27 #include "extensions/common/extension.h"
26 #include "extensions/common/extension_set.h" 28 #include "extensions/common/extension_set.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 263
262 void GetShortcutInfoForApp(const extensions::Extension* extension, 264 void GetShortcutInfoForApp(const extensions::Extension* extension,
263 Profile* profile, 265 Profile* profile,
264 const ShortcutInfoCallback& callback) { 266 const ShortcutInfoCallback& callback) {
265 GetInfoForApp( 267 GetInfoForApp(
266 extension, profile, base::Bind(&IgnoreFileHandlersInfo, callback)); 268 extension, profile, base::Bind(&IgnoreFileHandlersInfo, callback));
267 } 269 }
268 270
269 bool ShouldCreateShortcutFor(Profile* profile, 271 bool ShouldCreateShortcutFor(Profile* profile,
270 const extensions::Extension* extension) { 272 const extensions::Extension* extension) {
271 return extension->is_platform_app() && 273 return (extension->is_platform_app() || extension->is_hosted_app()) &&
jackhou1 2014/12/04 06:37:11 You'll need to #if-def this to just Mac. I just ch
mitchellj 2014/12/04 22:48:40 Done.
272 extension->location() != extensions::Manifest::COMPONENT && 274 extension->location() != extensions::Manifest::COMPONENT &&
273 extensions::ui_util::CanDisplayInAppLauncher(extension, profile); 275 extensions::ui_util::CanDisplayInAppLauncher(extension, profile);
274 } 276 }
275 277
276 base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path, 278 base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path,
277 const std::string& extension_id, 279 const std::string& extension_id,
278 const GURL& url) { 280 const GURL& url) {
279 DCHECK(!profile_path.empty()); 281 DCHECK(!profile_path.empty());
280 base::FilePath app_data_dir(profile_path.Append(chrome::kWebAppDirname)); 282 base::FilePath app_data_dir(profile_path.Append(chrome::kWebAppDirname));
281 283
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 return app_name.substr(prefix.length()); 338 return app_name.substr(prefix.length());
337 } 339 }
338 340
339 void CreateShortcutsWithInfo( 341 void CreateShortcutsWithInfo(
340 ShortcutCreationReason reason, 342 ShortcutCreationReason reason,
341 const ShortcutLocations& locations, 343 const ShortcutLocations& locations,
342 const ShortcutInfo& shortcut_info, 344 const ShortcutInfo& shortcut_info,
343 const extensions::FileHandlersInfo& file_handlers_info) { 345 const extensions::FileHandlersInfo& file_handlers_info) {
344 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 346 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
345 347
348 // It's possible for the extension to be deleted before we get here.
349 // For example, creating a hosted app from a website. Double check that
350 // it still exists.
351 Profile* profile = g_browser_process->profile_manager()->GetProfileByPath(
352 shortcut_info.profile_path);
353 if (!profile)
354 return;
355
356 extensions::ExtensionRegistry* registry =
357 extensions::ExtensionRegistry::Get(profile);
358 const extensions::Extension* extension = registry->GetExtensionById(
359 shortcut_info.extension_id, extensions::ExtensionRegistry::ENABLED);
360 if (!extension)
361 return;
362
346 BrowserThread::PostTask( 363 BrowserThread::PostTask(
347 BrowserThread::FILE, 364 BrowserThread::FILE,
348 FROM_HERE, 365 FROM_HERE,
349 base::Bind(base::IgnoreResult(&internals::CreatePlatformShortcuts), 366 base::Bind(base::IgnoreResult(&internals::CreatePlatformShortcuts),
350 GetShortcutDataDir(shortcut_info), 367 GetShortcutDataDir(shortcut_info),
351 shortcut_info, 368 shortcut_info,
352 file_handlers_info, 369 file_handlers_info,
353 locations, 370 locations,
354 reason)); 371 reason));
355 } 372 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 443
427 #if defined(OS_LINUX) 444 #if defined(OS_LINUX)
428 std::string GetWMClassFromAppName(std::string app_name) { 445 std::string GetWMClassFromAppName(std::string app_name) {
429 base::i18n::ReplaceIllegalCharactersInPath(&app_name, '_'); 446 base::i18n::ReplaceIllegalCharactersInPath(&app_name, '_');
430 base::TrimString(app_name, "_", &app_name); 447 base::TrimString(app_name, "_", &app_name);
431 return app_name; 448 return app_name;
432 } 449 }
433 #endif 450 #endif
434 451
435 } // namespace web_app 452 } // namespace web_app
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698