Index: chrome/browser/ui/views/extensions/bookmark_app_bubble_view.cc |
diff --git a/chrome/browser/ui/views/extensions/bookmark_app_bubble_view.cc b/chrome/browser/ui/views/extensions/bookmark_app_bubble_view.cc |
index 566b751172edf87f9be942d55e686ab3e014d4a7..3e1b73dddf429ab576391b058b5a2ce8270bbfd8 100644 |
--- a/chrome/browser/ui/views/extensions/bookmark_app_bubble_view.cc |
+++ b/chrome/browser/ui/views/extensions/bookmark_app_bubble_view.cc |
@@ -6,13 +6,21 @@ |
#include "base/strings/string16.h" |
#include "base/strings/utf_string_conversions.h" |
+#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/extensions/app_icon_loader_impl.h" |
#include "chrome/browser/extensions/bookmark_app_helper.h" |
#include "chrome/browser/extensions/extension_service.h" |
#include "chrome/browser/extensions/launch_util.h" |
#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/ui/app_list/app_list_service.h" |
+#include "chrome/browser/ui/app_list/app_list_util.h" |
+#include "chrome/browser/ui/browser_navigator.h" |
+#include "chrome/browser/ui/host_desktop.h" |
#include "chrome/common/extensions/extension_constants.h" |
+#include "chrome/common/url_constants.h" |
#include "chrome/grit/generated_resources.h" |
+#include "content/public/browser/notification_service.h" |
+#include "content/public/browser/web_contents.h" |
#include "extensions/browser/extension_prefs.h" |
#include "extensions/browser/extension_registry.h" |
#include "extensions/browser/extension_system.h" |
@@ -265,13 +273,42 @@ void BookmarkAppBubbleView::ApplyEdits() { |
const extensions::Extension* extension = |
extensions::ExtensionRegistry::Get(profile_)->GetExtensionById( |
extension_id_, extensions::ExtensionRegistry::EVERYTHING); |
- if (extension && base::UTF8ToUTF16(extension->name()) == title_tf_->text()) |
+ |
+ if (!extension) |
+ return; |
+ |
+ if (base::UTF8ToUTF16(extension->name()) != title_tf_->text()) { |
+ // Reinstall the app with an updated name. |
+ WebApplicationInfo install_info(web_app_info_); |
+ install_info.title = title_tf_->text(); |
+ |
+ extensions::CreateOrUpdateBookmarkApp(GetExtensionService(profile_), |
+ &install_info); |
calamity
2014/12/15 03:38:09
Hmm. Doesn't this happen asynchronously? I guess i
benwells
2014/12/15 05:02:47
Good point. It was unsafe before, I've made it saf
|
+ } |
+ |
+ // Show the newly installed app in the app launcher or chrome://apps. Don't |
+ // do this on ash, as the icon will have been added to the shelf. |
+ chrome::HostDesktopType desktop = |
+ chrome::GetHostDesktopTypeForNativeWindow(GetWidget()->GetNativeWindow()); |
+ if (desktop == chrome::HOST_DESKTOP_TYPE_ASH) |
return; |
- // Reinstall the app with an updated name. |
- WebApplicationInfo install_info(web_app_info_); |
- install_info.title = title_tf_->text(); |
+ Profile* current_profile = profile_->GetOriginalProfile(); |
calamity
2014/12/15 03:38:09
Is this for dealing with incognito profiles? Shoul
benwells
2014/12/15 05:02:47
You can add bookmark apps in incognito, but they a
|
+ if (IsAppLauncherEnabled()) { |
+ AppListService::Get(desktop) |
+ ->ShowForAppInstall(current_profile, extension->id(), false); |
+ return; |
+ } |
- extensions::CreateOrUpdateBookmarkApp(GetExtensionService(profile_), |
- &install_info); |
+ std::string app_id = extension->id(); |
+ chrome::NavigateParams params(current_profile, |
+ GURL(chrome::kChromeUIAppsURL), |
+ ui::PAGE_TRANSITION_LINK); |
+ params.disposition = NEW_FOREGROUND_TAB; |
+ chrome::Navigate(¶ms); |
+ |
+ content::NotificationService::current()->Notify( |
+ chrome::NOTIFICATION_APP_INSTALLED_TO_NTP, |
+ content::Source<content::WebContents>(params.target_contents), |
+ content::Details<const std::string>(&app_id)); |
} |