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

Side by Side Diff: chrome/browser/ui/views/extensions/bookmark_app_bubble_view.cc

Issue 804883002: Highlight newly installed bookmark apps on non-ash desktops. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: No else after return 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
« no previous file with comments | « no previous file | no next file » | 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/ui/views/extensions/bookmark_app_bubble_view.h" 5 #include "chrome/browser/ui/views/extensions/bookmark_app_bubble_view.h"
6 6
7 #include "base/strings/string16.h" 7 #include "base/strings/string16.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/extensions/app_icon_loader_impl.h" 10 #include "chrome/browser/extensions/app_icon_loader_impl.h"
10 #include "chrome/browser/extensions/bookmark_app_helper.h" 11 #include "chrome/browser/extensions/bookmark_app_helper.h"
11 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/launch_util.h" 13 #include "chrome/browser/extensions/launch_util.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/app_list/app_list_service.h"
16 #include "chrome/browser/ui/app_list/app_list_util.h"
17 #include "chrome/browser/ui/browser_navigator.h"
18 #include "chrome/browser/ui/host_desktop.h"
14 #include "chrome/common/extensions/extension_constants.h" 19 #include "chrome/common/extensions/extension_constants.h"
20 #include "chrome/common/url_constants.h"
15 #include "chrome/grit/generated_resources.h" 21 #include "chrome/grit/generated_resources.h"
22 #include "content/public/browser/notification_service.h"
23 #include "content/public/browser/web_contents.h"
16 #include "extensions/browser/extension_prefs.h" 24 #include "extensions/browser/extension_prefs.h"
17 #include "extensions/browser/extension_registry.h" 25 #include "extensions/browser/extension_registry.h"
18 #include "extensions/browser/extension_system.h" 26 #include "extensions/browser/extension_system.h"
19 #include "extensions/browser/pref_names.h" 27 #include "extensions/browser/pref_names.h"
20 #include "extensions/browser/uninstall_reason.h" 28 #include "extensions/browser/uninstall_reason.h"
21 #include "extensions/common/constants.h" 29 #include "extensions/common/constants.h"
22 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
23 #include "ui/base/resource/resource_bundle.h" 31 #include "ui/base/resource/resource_bundle.h"
24 #include "ui/events/keycodes/keyboard_codes.h" 32 #include "ui/events/keycodes/keyboard_codes.h"
25 #include "ui/views/controls/button/checkbox.h" 33 #include "ui/views/controls/button/checkbox.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 : extensions::LAUNCH_TYPE_WINDOW; 266 : extensions::LAUNCH_TYPE_WINDOW;
259 profile_->GetPrefs()->SetInteger( 267 profile_->GetPrefs()->SetInteger(
260 extensions::pref_names::kBookmarkAppCreationLaunchType, launch_type); 268 extensions::pref_names::kBookmarkAppCreationLaunchType, launch_type);
261 extensions::SetLaunchType(GetExtensionService(profile_), 269 extensions::SetLaunchType(GetExtensionService(profile_),
262 extension_id_, 270 extension_id_,
263 launch_type); 271 launch_type);
264 272
265 const extensions::Extension* extension = 273 const extensions::Extension* extension =
266 extensions::ExtensionRegistry::Get(profile_)->GetExtensionById( 274 extensions::ExtensionRegistry::Get(profile_)->GetExtensionById(
267 extension_id_, extensions::ExtensionRegistry::EVERYTHING); 275 extension_id_, extensions::ExtensionRegistry::EVERYTHING);
268 if (extension && base::UTF8ToUTF16(extension->name()) == title_tf_->text()) 276
277 if (!extension)
269 return; 278 return;
270 279
271 // Reinstall the app with an updated name. 280 if (base::UTF8ToUTF16(extension->name()) != title_tf_->text()) {
272 WebApplicationInfo install_info(web_app_info_); 281 // Reinstall the app with an updated name.
273 install_info.title = title_tf_->text(); 282 WebApplicationInfo install_info(web_app_info_);
283 install_info.title = title_tf_->text();
274 284
275 extensions::CreateOrUpdateBookmarkApp(GetExtensionService(profile_), 285 extensions::CreateOrUpdateBookmarkApp(GetExtensionService(profile_),
276 &install_info); 286 &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
287 }
288
289 // Show the newly installed app in the app launcher or chrome://apps. Don't
290 // do this on ash, as the icon will have been added to the shelf.
291 chrome::HostDesktopType desktop =
292 chrome::GetHostDesktopTypeForNativeWindow(GetWidget()->GetNativeWindow());
293 if (desktop == chrome::HOST_DESKTOP_TYPE_ASH)
294 return;
295
296 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
297 if (IsAppLauncherEnabled()) {
298 AppListService::Get(desktop)
299 ->ShowForAppInstall(current_profile, extension->id(), false);
300 return;
301 }
302
303 std::string app_id = extension->id();
304 chrome::NavigateParams params(current_profile,
305 GURL(chrome::kChromeUIAppsURL),
306 ui::PAGE_TRANSITION_LINK);
307 params.disposition = NEW_FOREGROUND_TAB;
308 chrome::Navigate(&params);
309
310 content::NotificationService::current()->Notify(
311 chrome::NOTIFICATION_APP_INSTALLED_TO_NTP,
312 content::Source<content::WebContents>(params.target_contents),
313 content::Details<const std::string>(&app_id));
277 } 314 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698