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

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 5560007: Don't update icon of chrome app shortcuts from the favicon of the hosted URL. (Closed)
Patch Set: Rev commnets Created 10 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 | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_init.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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <shellapi.h> 8 #include <shellapi.h>
9 #include <windows.h> 9 #include <windows.h>
10 #endif // OS_WIN 10 #endif // OS_WIN
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 Profile* profile, 518 Profile* profile,
519 const Extension* extension, 519 const Extension* extension,
520 extension_misc::LaunchContainer container, 520 extension_misc::LaunchContainer container,
521 TabContents* existing_tab) { 521 TabContents* existing_tab) {
522 TabContents* tab = NULL; 522 TabContents* tab = NULL;
523 523
524 UMA_HISTOGRAM_ENUMERATION("Extensions.AppLaunchContainer", container, 100); 524 UMA_HISTOGRAM_ENUMERATION("Extensions.AppLaunchContainer", container, 100);
525 525
526 switch (container) { 526 switch (container) {
527 case extension_misc::LAUNCH_WINDOW: 527 case extension_misc::LAUNCH_WINDOW:
528 tab = Browser::OpenApplicationWindow(profile, 528 // TODO(skerner): Setting |extension| to NULL is odd.
529 extension->GetFullLaunchURL()); 529 // Not doing so triggers some vestigial extensions app window
530 // behavior that leads to crashes. This sort of window is no
531 // longer supported, and its remains need to be cleaned up.
532 // crbug/65630 tracks this cleanup.
533 tab = Browser::OpenApplicationWindow(profile, NULL, container,
534 extension->GetFullLaunchURL(),
535 NULL);
530 break; 536 break;
531 case extension_misc::LAUNCH_PANEL: 537 case extension_misc::LAUNCH_PANEL:
532 tab = Browser::OpenApplicationWindow(profile, extension, container, 538 tab = Browser::OpenApplicationWindow(profile, extension, container,
533 GURL()); 539 GURL(), NULL);
534 break; 540 break;
535 case extension_misc::LAUNCH_TAB: { 541 case extension_misc::LAUNCH_TAB: {
536 tab = Browser::OpenApplicationTab(profile, extension, existing_tab); 542 tab = Browser::OpenApplicationTab(profile, extension, existing_tab);
537 break; 543 break;
538 } 544 }
539 default: 545 default:
540 NOTREACHED(); 546 NOTREACHED();
541 break; 547 break;
542 } 548 }
543 return tab; 549 return tab;
544 } 550 }
545 551
546 // static 552 // static
547 TabContents* Browser::OpenApplicationWindow( 553 TabContents* Browser::OpenApplicationWindow(
548 Profile* profile, 554 Profile* profile,
549 const Extension* extension, 555 const Extension* extension,
550 extension_misc::LaunchContainer container, 556 extension_misc::LaunchContainer container,
551 const GURL& url_input) { 557 const GURL& url_input,
558 Browser** app_browser) {
552 GURL url; 559 GURL url;
553 if (!url_input.is_empty()) { 560 if (!url_input.is_empty()) {
554 if (extension) 561 if (extension)
555 DCHECK(extension->web_extent().ContainsURL(url_input)); 562 DCHECK(extension->web_extent().ContainsURL(url_input));
556 url = url_input; 563 url = url_input;
557 } else { 564 } else {
558 DCHECK(extension); 565 DCHECK(extension);
559 url = extension->GetFullLaunchURL(); 566 url = extension->GetFullLaunchURL();
560 } 567 }
561 568
562 // TODO(erikkay) this can't be correct for extensions 569 // TODO(erikkay) this can't be correct for extensions
563 std::string app_name = web_app::GenerateApplicationNameFromURL(url); 570 std::string app_name = web_app::GenerateApplicationNameFromURL(url);
564 RegisterAppPrefs(app_name); 571 RegisterAppPrefs(app_name);
565 572
566 bool as_panel = extension && (container == extension_misc::LAUNCH_PANEL); 573 bool as_panel = extension && (container == extension_misc::LAUNCH_PANEL);
567 Browser* browser = Browser::CreateForApp(app_name, extension, profile, 574 Browser* browser = Browser::CreateForApp(app_name, extension, profile,
568 as_panel); 575 as_panel);
576 if (app_browser)
577 *app_browser = browser;
578
569 TabContentsWrapper* wrapper = 579 TabContentsWrapper* wrapper =
570 browser->AddSelectedTabWithURL(url, PageTransition::START_PAGE); 580 browser->AddSelectedTabWithURL(url, PageTransition::START_PAGE);
571 TabContents* contents = wrapper->tab_contents(); 581 TabContents* contents = wrapper->tab_contents();
572 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 582 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
573 contents->render_view_host()->SyncRendererPrefs(); 583 contents->render_view_host()->SyncRendererPrefs();
574 browser->window()->Show(); 584 browser->window()->Show();
575 585
576 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial 586 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial
577 // focus explicitly. 587 // focus explicitly.
578 contents->view()->SetInitialFocus(); 588 contents->view()->SetInitialFocus();
589 return contents;
590 }
579 591
580 if (!as_panel) { 592 TabContents* Browser::OpenAppShortcutWindow(Profile* profile,
593 const GURL& url,
594 bool update_shortcut) {
595 Browser* app_browser;
596 TabContents* tab = OpenApplicationWindow(
597 profile,
598 NULL, // this is a URL app. No extension.
599 extension_misc::LAUNCH_WINDOW,
600 url,
601 &app_browser);
602
603 if (!tab)
604 return NULL;
605
606 if (update_shortcut) {
581 // Set UPDATE_SHORTCUT as the pending web app action. This action is picked 607 // Set UPDATE_SHORTCUT as the pending web app action. This action is picked
582 // up in LoadingStateChanged to schedule a GetApplicationInfo. And when 608 // up in LoadingStateChanged to schedule a GetApplicationInfo. And when
583 // the web app info is available, TabContents notifies Browser via 609 // the web app info is available, TabContents notifies Browser via
584 // OnDidGetApplicationInfo, which calls 610 // OnDidGetApplicationInfo, which calls
585 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as 611 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as
586 // pending web app action. 612 // pending web app action.
587 browser->pending_web_app_action_ = UPDATE_SHORTCUT; 613 app_browser->pending_web_app_action_ = UPDATE_SHORTCUT;
588 } 614 }
589 615 return tab;
590 return contents;
591 } 616 }
592 617
593 // static 618 // static
594 TabContents* Browser::OpenApplicationWindow(Profile* profile, const GURL& url) {
595 return OpenApplicationWindow(profile, NULL, extension_misc::LAUNCH_WINDOW,
596 url);
597 }
598
599 // static
600 TabContents* Browser::OpenApplicationTab(Profile* profile, 619 TabContents* Browser::OpenApplicationTab(Profile* profile,
601 const Extension* extension, 620 const Extension* extension,
602 TabContents* existing_tab) { 621 TabContents* existing_tab) {
603 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); 622 Browser* browser = BrowserList::GetLastActiveWithProfile(profile);
604 TabContents* contents = NULL; 623 TabContents* contents = NULL;
605 if (!browser || browser->type() != Browser::TYPE_NORMAL) 624 if (!browser || browser->type() != Browser::TYPE_NORMAL)
606 return contents; 625 return contents;
607 626
608 // Check the prefs for overridden mode. 627 // Check the prefs for overridden mode.
609 ExtensionsService* extensions_service = profile->GetExtensionsService(); 628 ExtensionsService* extensions_service = profile->GetExtensionsService();
(...skipping 3532 matching lines...) Expand 10 before | Expand all | Expand 10 after
4142 NOTREACHED(); 4161 NOTREACHED();
4143 return false; 4162 return false;
4144 } 4163 }
4145 4164
4146 void Browser::CreateInstantIfNecessary() { 4165 void Browser::CreateInstantIfNecessary() {
4147 if (type() == TYPE_NORMAL && InstantController::IsEnabled(profile()) && 4166 if (type() == TYPE_NORMAL && InstantController::IsEnabled(profile()) &&
4148 !profile()->IsOffTheRecord()) { 4167 !profile()->IsOffTheRecord()) {
4149 instant_.reset(new InstantController(profile_, this)); 4168 instant_.reset(new InstantController(profile_, this));
4150 } 4169 }
4151 } 4170 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698