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

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

Issue 169443007: Always use the app icon as the taskbar icon for windowed streamlined hosted apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: maintain logic in the non-app-window case Created 6 years, 10 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 | 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 (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/extensions/tab_helper.h" 5 #include "chrome/browser/extensions/tab_helper.h"
6 6
7 #include "base/command_line.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
8 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/extensions/activity_log/activity_log.h" 12 #include "chrome/browser/extensions/activity_log/activity_log.h"
12 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" 13 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h"
13 #include "chrome/browser/extensions/api/declarative_content/content_rules_regist ry.h" 14 #include "chrome/browser/extensions/api/declarative_content/content_rules_regist ry.h"
14 #include "chrome/browser/extensions/crx_installer.h" 15 #include "chrome/browser/extensions/crx_installer.h"
15 #include "chrome/browser/extensions/error_console/error_console.h" 16 #include "chrome/browser/extensions/error_console/error_console.h"
16 #include "chrome/browser/extensions/extension_action.h" 17 #include "chrome/browser/extensions/extension_action.h"
(...skipping 10 matching lines...) Expand all
27 #include "chrome/browser/sessions/session_id.h" 28 #include "chrome/browser/sessions/session_id.h"
28 #include "chrome/browser/sessions/session_tab_helper.h" 29 #include "chrome/browser/sessions/session_tab_helper.h"
29 #include "chrome/browser/shell_integration.h" 30 #include "chrome/browser/shell_integration.h"
30 #include "chrome/browser/ui/browser_commands.h" 31 #include "chrome/browser/ui/browser_commands.h"
31 #include "chrome/browser/ui/browser_dialogs.h" 32 #include "chrome/browser/ui/browser_dialogs.h"
32 #include "chrome/browser/ui/browser_finder.h" 33 #include "chrome/browser/ui/browser_finder.h"
33 #include "chrome/browser/ui/browser_window.h" 34 #include "chrome/browser/ui/browser_window.h"
34 #include "chrome/browser/ui/host_desktop.h" 35 #include "chrome/browser/ui/host_desktop.h"
35 #include "chrome/browser/ui/web_applications/web_app_ui.h" 36 #include "chrome/browser/ui/web_applications/web_app_ui.h"
36 #include "chrome/browser/web_applications/web_app.h" 37 #include "chrome/browser/web_applications/web_app.h"
38 #include "chrome/common/chrome_switches.h"
37 #include "chrome/common/extensions/extension_constants.h" 39 #include "chrome/common/extensions/extension_constants.h"
38 #include "chrome/common/extensions/extension_icon_set.h" 40 #include "chrome/common/extensions/extension_icon_set.h"
39 #include "chrome/common/extensions/extension_messages.h" 41 #include "chrome/common/extensions/extension_messages.h"
40 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 42 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
41 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" 43 #include "chrome/common/extensions/manifest_handlers/icons_handler.h"
42 #include "chrome/common/render_messages.h" 44 #include "chrome/common/render_messages.h"
43 #include "chrome/common/url_constants.h" 45 #include "chrome/common/url_constants.h"
44 #include "content/public/browser/invalidate_type.h" 46 #include "content/public/browser/invalidate_type.h"
45 #include "content/public/browser/navigation_controller.h" 47 #include "content/public/browser/navigation_controller.h"
46 #include "content/public/browser/navigation_details.h" 48 #include "content/public/browser/navigation_details.h"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 #if defined(OS_MACOSX) 291 #if defined(OS_MACOSX)
290 return false; 292 return false;
291 #else 293 #else
292 return web_app::IsValidUrl(web_contents()->GetURL()) && 294 return web_app::IsValidUrl(web_contents()->GetURL()) &&
293 pending_web_app_action_ == NONE; 295 pending_web_app_action_ == NONE;
294 #endif 296 #endif
295 } 297 }
296 298
297 void TabHelper::SetExtensionApp(const Extension* extension) { 299 void TabHelper::SetExtensionApp(const Extension* extension) {
298 DCHECK(!extension || AppLaunchInfo::GetFullLaunchURL(extension).is_valid()); 300 DCHECK(!extension || AppLaunchInfo::GetFullLaunchURL(extension).is_valid());
301 if (extension_app_ == extension)
302 return;
303
299 extension_app_ = extension; 304 extension_app_ = extension;
300 305
301 UpdateExtensionAppIcon(extension_app_); 306 UpdateExtensionAppIcon(extension_app_);
302 307
303 content::NotificationService::current()->Notify( 308 content::NotificationService::current()->Notify(
304 chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED, 309 chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED,
305 content::Source<TabHelper>(this), 310 content::Source<TabHelper>(this),
306 content::NotificationService::NoDetails()); 311 content::NotificationService::NoDetails());
307 } 312 }
308 313
(...skipping 30 matching lines...) Expand all
339 DidNavigateMainFrame(web_contents(), details, params); 344 DidNavigateMainFrame(web_contents(), details, params);
340 } 345 }
341 #endif // defined(ENABLE_EXTENSIONS) 346 #endif // defined(ENABLE_EXTENSIONS)
342 347
343 Profile* profile = 348 Profile* profile =
344 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 349 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
345 ExtensionService* service = profile->GetExtensionService(); 350 ExtensionService* service = profile->GetExtensionService();
346 if (!service) 351 if (!service)
347 return; 352 return;
348 353
349 UpdateExtensionAppIcon(service->GetInstalledExtensionByUrl(params.url)); 354 if (CommandLine::ForCurrentProcess()->HasSwitch(
355 switches::kEnableStreamlinedHostedApps)) {
356 #if !defined(OS_ANDROID)
357 Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
358 if (browser && browser->is_app()) {
359 SetExtensionApp(service->GetInstalledExtension(
360 web_app::GetExtensionIdFromApplicationName(browser->app_name())));
361 } else {
362 UpdateExtensionAppIcon(service->GetInstalledExtensionByUrl(params.url));
363 }
364 #endif
365 } else {
366 UpdateExtensionAppIcon(service->GetInstalledExtensionByUrl(params.url));
367 }
350 368
351 if (details.is_in_page) 369 if (details.is_in_page)
352 return; 370 return;
353 371
354 ExtensionActionManager* extension_action_manager = 372 ExtensionActionManager* extension_action_manager =
355 ExtensionActionManager::Get(profile); 373 ExtensionActionManager::Get(profile);
356 for (ExtensionSet::const_iterator it = service->extensions()->begin(); 374 for (ExtensionSet::const_iterator it = service->extensions()->begin();
357 it != service->extensions()->end(); ++it) { 375 it != service->extensions()->end(); ++it) {
358 ExtensionAction* browser_action = 376 ExtensionAction* browser_action =
359 extension_action_manager->GetBrowserAction(*it->get()); 377 extension_action_manager->GetBrowserAction(*it->get());
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 } 780 }
763 } 781 }
764 782
765 void TabHelper::SetTabId(RenderViewHost* render_view_host) { 783 void TabHelper::SetTabId(RenderViewHost* render_view_host) {
766 render_view_host->Send( 784 render_view_host->Send(
767 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), 785 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(),
768 SessionID::IdForTab(web_contents()))); 786 SessionID::IdForTab(web_contents())));
769 } 787 }
770 788
771 } // namespace extensions 789 } // namespace extensions
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