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

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

Issue 2612493002: Prevent app banners from displaying after desktop add to shelf. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | chrome/browser/extensions/bookmark_app_helper_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "build/build_config.h" 15 #include "build/build_config.h"
16 #include "chrome/browser/banners/app_banner_settings_helper.h"
15 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" 17 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h"
16 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_delegate.h" 18 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_delegate.h"
17 #include "chrome/browser/chrome_notification_types.h" 19 #include "chrome/browser/chrome_notification_types.h"
18 #include "chrome/browser/extensions/crx_installer.h" 20 #include "chrome/browser/extensions/crx_installer.h"
19 #include "chrome/browser/extensions/extension_service.h" 21 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/extensions/favicon_downloader.h" 22 #include "chrome/browser/extensions/favicon_downloader.h"
21 #include "chrome/browser/extensions/launch_util.h" 23 #include "chrome/browser/extensions/launch_util.h"
22 #include "chrome/browser/extensions/tab_helper.h" 24 #include "chrome/browser/extensions/tab_helper.h"
23 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/ui/app_list/app_list_service.h" 26 #include "chrome/browser/ui/app_list/app_list_service.h"
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 685
684 // Set the launcher type for the app. 686 // Set the launcher type for the app.
685 extensions::SetLaunchType(profile_, extension->id(), launch_type); 687 extensions::SetLaunchType(profile_, extension->id(), launch_type);
686 688
687 if (!contents_) { 689 if (!contents_) {
688 // The web contents can be null in tests. 690 // The web contents can be null in tests.
689 callback_.Run(extension, web_app_info_); 691 callback_.Run(extension, web_app_info_);
690 return; 692 return;
691 } 693 }
692 694
695 // Record an app banner added to homescreen event to ensure banners are not
696 // shown for this app.
697 AppBannerSettingsHelper::RecordBannerEvent(
698 contents_, web_app_info_.app_url, web_app_info_.app_url.spec(),
699 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN,
700 base::Time::Now());
701
693 Browser* browser = chrome::FindBrowserWithWebContents(contents_); 702 Browser* browser = chrome::FindBrowserWithWebContents(contents_);
694 if (!browser) { 703 if (!browser) {
695 // The browser can be null in tests. 704 // The browser can be null in tests.
696 callback_.Run(extension, web_app_info_); 705 callback_.Run(extension, web_app_info_);
697 return; 706 return;
698 } 707 }
699 708
700 #if !defined(USE_ASH) 709 #if !defined(USE_ASH)
701 // Pin the app to the relevant launcher depending on the OS. 710 // Pin the app to the relevant launcher depending on the OS.
702 Profile* current_profile = profile_->GetOriginalProfile(); 711 Profile* current_profile = profile_->GetOriginalProfile();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); 808 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback));
800 } 809 }
801 810
802 bool IsValidBookmarkAppUrl(const GURL& url) { 811 bool IsValidBookmarkAppUrl(const GURL& url) {
803 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); 812 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes);
804 origin_only_pattern.SetMatchAllURLs(true); 813 origin_only_pattern.SetMatchAllURLs(true);
805 return url.is_valid() && origin_only_pattern.MatchesURL(url); 814 return url.is_valid() && origin_only_pattern.MatchesURL(url);
806 } 815 }
807 816
808 } // namespace extensions 817 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/bookmark_app_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698