OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/bookmark_app_helper.h" | 5 #include "chrome/browser/extensions/bookmark_app_helper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cctype> | 9 #include <cctype> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "chrome/browser/banners/app_banner_settings_helper.h" | 16 #include "chrome/browser/banners/app_banner_settings_helper.h" |
17 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" | 17 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" |
18 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_delegate.h" | 18 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_delegate.h" |
19 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
20 #include "chrome/browser/extensions/crx_installer.h" | 20 #include "chrome/browser/extensions/crx_installer.h" |
21 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
22 #include "chrome/browser/extensions/favicon_downloader.h" | 22 #include "chrome/browser/extensions/favicon_downloader.h" |
23 #include "chrome/browser/extensions/launch_util.h" | 23 #include "chrome/browser/extensions/launch_util.h" |
24 #include "chrome/browser/extensions/tab_helper.h" | 24 #include "chrome/browser/extensions/tab_helper.h" |
25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/ui/app_list/app_list_service.h" | 26 #include "chrome/browser/ui/app_list/app_list_service.h" |
27 #include "chrome/browser/ui/app_list/app_list_util.h" | 27 #include "chrome/browser/ui/app_list/app_list_util.h" |
| 28 #include "chrome/browser/ui/browser_dialogs.h" |
28 #include "chrome/browser/ui/browser_finder.h" | 29 #include "chrome/browser/ui/browser_finder.h" |
29 #include "chrome/browser/ui/browser_window.h" | 30 #include "chrome/browser/ui/browser_window.h" |
30 #include "chrome/browser/web_applications/web_app.h" | 31 #include "chrome/browser/web_applications/web_app.h" |
31 #include "chrome/browser/webshare/share_target_pref_helper.h" | 32 #include "chrome/browser/webshare/share_target_pref_helper.h" |
32 #include "chrome/common/extensions/extension_constants.h" | 33 #include "chrome/common/extensions/extension_constants.h" |
33 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 34 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
34 #include "chrome/common/origin_trials/chrome_origin_trial_policy.h" | 35 #include "chrome/common/origin_trials/chrome_origin_trial_policy.h" |
35 #include "chrome/common/url_constants.h" | 36 #include "chrome/common/url_constants.h" |
36 #include "chrome/grit/platform_locale_settings.h" | 37 #include "chrome/grit/platform_locale_settings.h" |
37 #include "components/prefs/pref_service.h" | 38 #include "components/prefs/pref_service.h" |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 OnBubbleCompleted(true, web_app_info_); | 661 OnBubbleCompleted(true, web_app_info_); |
661 return; | 662 return; |
662 } | 663 } |
663 | 664 |
664 Browser* browser = chrome::FindBrowserWithWebContents(contents_); | 665 Browser* browser = chrome::FindBrowserWithWebContents(contents_); |
665 if (!browser) { | 666 if (!browser) { |
666 // The browser can be null in tests. | 667 // The browser can be null in tests. |
667 OnBubbleCompleted(true, web_app_info_); | 668 OnBubbleCompleted(true, web_app_info_); |
668 return; | 669 return; |
669 } | 670 } |
670 browser->window()->ShowBookmarkAppBubble( | 671 chrome::ShowBookmarkAppDialog( |
671 web_app_info_, base::Bind(&BookmarkAppHelper::OnBubbleCompleted, | 672 browser->window()->GetNativeWindow(), web_app_info_, |
672 weak_factory_.GetWeakPtr())); | 673 base::Bind(&BookmarkAppHelper::OnBubbleCompleted, |
| 674 weak_factory_.GetWeakPtr())); |
673 } | 675 } |
674 | 676 |
675 void BookmarkAppHelper::OnBubbleCompleted( | 677 void BookmarkAppHelper::OnBubbleCompleted( |
676 bool user_accepted, | 678 bool user_accepted, |
677 const WebApplicationInfo& web_app_info) { | 679 const WebApplicationInfo& web_app_info) { |
678 if (user_accepted) { | 680 if (user_accepted) { |
679 web_app_info_ = web_app_info; | 681 web_app_info_ = web_app_info; |
680 crx_installer_->InstallWebApp(web_app_info_); | 682 crx_installer_->InstallWebApp(web_app_info_); |
681 } else { | 683 } else { |
682 callback_.Run(nullptr, web_app_info_); | 684 callback_.Run(nullptr, web_app_info_); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); | 817 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); |
816 } | 818 } |
817 | 819 |
818 bool IsValidBookmarkAppUrl(const GURL& url) { | 820 bool IsValidBookmarkAppUrl(const GURL& url) { |
819 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); | 821 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); |
820 origin_only_pattern.SetMatchAllURLs(true); | 822 origin_only_pattern.SetMatchAllURLs(true); |
821 return url.is_valid() && origin_only_pattern.MatchesURL(url); | 823 return url.is_valid() && origin_only_pattern.MatchesURL(url); |
822 } | 824 } |
823 | 825 |
824 } // namespace extensions | 826 } // namespace extensions |
OLD | NEW |