summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-18 18:31:50 +0000
committerskerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-18 18:31:50 +0000
commit1b810530a418a711c68d6e7b4417b326f555b2d1 (patch)
treed91c43e9bb35bb14908c9bd46b70537294b6a7f3
parent4e9eba0d0848269269e45e7f2dcf04b9f4686d0f (diff)
downloadchromium_src-1b810530a418a711c68d6e7b4417b326f555b2d1.zip
chromium_src-1b810530a418a711c68d6e7b4417b326f555b2d1.tar.gz
chromium_src-1b810530a418a711c68d6e7b4417b326f555b2d1.tar.bz2
Add "open as window" menu item to NTP app menu.
BUG=59697 TEST=BrowserTest.OpenAppWindowLikeNtp,SessionRestoreUITest.RestoreAfterClosing* Review URL: http://codereview.chromium.org/5019005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66646 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd4
-rw-r--r--chrome/browser/background_application_list_model.cc5
-rw-r--r--chrome/browser/browser_browsertest.cc36
-rw-r--r--chrome/browser/dom_ui/app_launcher_handler.cc24
-rw-r--r--chrome/browser/dom_ui/ntp_resource_cache.cc2
-rw-r--r--chrome/browser/extensions/extension_dom_ui.cc7
-rw-r--r--chrome/browser/extensions/extension_prefs.cc16
-rw-r--r--chrome/browser/extensions/extension_prefs.h3
-rw-r--r--chrome/browser/extensions/extension_process_manager.cc14
-rw-r--r--chrome/browser/extensions/extension_startup_browsertest.cc3
-rw-r--r--chrome/browser/extensions/extension_toolbar_model.cc5
-rw-r--r--chrome/browser/extensions/extensions_service.cc7
-rw-r--r--chrome/browser/extensions/extensions_service.h7
-rw-r--r--chrome/browser/resources/new_new_tab.html4
-rw-r--r--chrome/browser/resources/ntp/apps.js13
-rw-r--r--chrome/browser/sessions/session_restore.cc54
-rw-r--r--chrome/browser/tab_contents/render_view_host_delegate_helper.cc5
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc10
-rw-r--r--chrome/browser/ui/browser.cc8
-rw-r--r--chrome/browser/ui/browser.h5
-rw-r--r--chrome/browser/ui/browser_init.cc11
21 files changed, 120 insertions, 123 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 3cc690e..978d213 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -7394,6 +7394,10 @@ Keep your key file in a safe place. You will need it to create new versions of y
desc="Text for the button that opens the app in a regular tab.">
Open as regular tab
</message>
+ <message name="IDS_APP_CONTEXT_MENU_OPEN_WINDOW"
+ desc="Text for the button that opens the app in an app window.">
+ Open as window
+ </message>
<message name="IDS_APP_CONTEXT_MENU_OPEN_FULLSCREEN"
desc="Text for the button that opens the app full screen.">
Open full screen
diff --git a/chrome/browser/background_application_list_model.cc b/chrome/browser/background_application_list_model.cc
index 63f2b94..f94b07e 100644
--- a/chrome/browser/background_application_list_model.cc
+++ b/chrome/browser/background_application_list_model.cc
@@ -239,9 +239,7 @@ void BackgroundApplicationListModel::Observe(
Update();
return;
}
- ExtensionsService* service = profile_->GetExtensionsService();
- if (!service || !service->is_ready())
- return;
+
switch (type.value) {
case NotificationType::EXTENSION_LOADED:
OnExtensionLoaded(Details<Extension>(details).ptr());
@@ -286,7 +284,6 @@ void BackgroundApplicationListModel::RemoveObserver(Observer* observer) {
// each observer.
void BackgroundApplicationListModel::Update() {
ExtensionsService* service = profile_->GetExtensionsService();
- DCHECK(service->is_ready());
// Discover current background applications, compare with previous list, which
// is consistently sorted, and notify observers if they differ.
diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc
index 2cfc68e..b306ec1 100644
--- a/chrome/browser/browser_browsertest.cc
+++ b/chrome/browser/browser_browsertest.cc
@@ -573,6 +573,42 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, CloseWithAppMenuOpen) {
new RunCloseWithAppMenuTask(browser()));
}
+#if !defined(OS_MACOSX)
+IN_PROC_BROWSER_TEST_F(BrowserTest, OpenAppWindowLikeNtp) {
+ ASSERT_TRUE(test_server()->Start());
+
+ // Load an app
+ host_resolver()->AddRule("www.example.com", "127.0.0.1");
+ ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/")));
+ const Extension* extension_app = GetExtension();
+
+ // Launch it in a window, as AppLauncherHandler::HandleLaunchApp() would.
+ TabContents* app_window = Browser::OpenApplication(
+ browser()->profile(), extension_app, extension_misc::LAUNCH_WINDOW, NULL);
+ ASSERT_TRUE(app_window);
+
+ // Apps launched in a window from the NTP do not have extension_app set in
+ // tab contents.
+ EXPECT_FALSE(app_window->extension_app());
+ EXPECT_EQ(extension_app->GetFullLaunchURL(), app_window->GetURL());
+
+ // The launch should have created a new browser.
+ ASSERT_EQ(2u, BrowserList::GetBrowserCount(browser()->profile()));
+
+ // Find the new browser.
+ Browser* new_browser = NULL;
+ for (BrowserList::const_iterator i = BrowserList::begin();
+ i != BrowserList::end() && !new_browser; ++i) {
+ if (*i != browser())
+ new_browser = *i;
+ }
+ ASSERT_TRUE(new_browser);
+ ASSERT_TRUE(new_browser != browser());
+
+ EXPECT_EQ(Browser::TYPE_APP, new_browser->type());
+}
+#endif // !defined(OS_MACOSX)
+
// TODO(ben): this test was never enabled. It has bit-rotted since being added.
// It originally lived in browser_unittest.cc, but has been moved here to make
// room for real browser unit tests.
diff --git a/chrome/browser/dom_ui/app_launcher_handler.cc b/chrome/browser/dom_ui/app_launcher_handler.cc
index 77e3ee0..e57dfdc 100644
--- a/chrome/browser/dom_ui/app_launcher_handler.cc
+++ b/chrome/browser/dom_ui/app_launcher_handler.cc
@@ -190,6 +190,14 @@ void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) {
bool showLauncher =
CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppLauncher);
dictionary->SetBoolean("showLauncher", showLauncher);
+
+#if defined(OS_MACOSX)
+ // App windows are not yet implemented on mac.
+ bool disable_app_window_launch = true;
+#else
+ bool disable_app_window_launch = false;
+#endif
+ dictionary->SetBoolean("disableAppWindowLaunch", disable_app_window_launch);
}
void AppLauncherHandler::HandleGetApps(const ListValue* args) {
@@ -248,8 +256,18 @@ void AppLauncherHandler::HandleLaunchApp(const ListValue* args) {
old_contents = browser->GetSelectedTabContents();
AnimateAppIcon(extension, rect);
+
+ extension_misc::LaunchContainer launch_container =
+ extension->launch_container();
+ ExtensionPrefs::LaunchType prefs_launch_type =
+ extensions_service_->extension_prefs()->GetLaunchType(extension_id);
+
+ // If the user chose to open in a window, change the container type.
+ if (prefs_launch_type == ExtensionPrefs::LAUNCH_WINDOW)
+ launch_container = extension_misc::LAUNCH_WINDOW;
+
TabContents* new_contents = Browser::OpenApplication(
- profile, extension, extension->launch_container(), old_contents);
+ profile, extension, launch_container, old_contents);
if (new_contents != old_contents && browser->tab_count() > 1)
browser->CloseTabContents(old_contents);
@@ -310,7 +328,7 @@ void AppLauncherHandler::HandleHideAppsPromo(const ListValue* args) {
extensions_service_->default_apps()->SetPromoHidden();
}
-//static
+// static
void AppLauncherHandler::RecordWebStoreLaunch(bool promo_active) {
if (!promo_active) return;
@@ -319,7 +337,7 @@ void AppLauncherHandler::RecordWebStoreLaunch(bool promo_active) {
extension_misc::PROMO_BUCKET_BOUNDARY);
}
-//static
+// static
void AppLauncherHandler::RecordAppLaunch(bool promo_active) {
// TODO(jstritar): record app launches that occur when the promo is not
// active using a different histogram.
diff --git a/chrome/browser/dom_ui/ntp_resource_cache.cc b/chrome/browser/dom_ui/ntp_resource_cache.cc
index 7d0a5d4..859c666 100644
--- a/chrome/browser/dom_ui/ntp_resource_cache.cc
+++ b/chrome/browser/dom_ui/ntp_resource_cache.cc
@@ -310,6 +310,8 @@ void NTPResourceCache::CreateNewTabHTML() {
l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_OPEN_PINNED));
localized_strings.SetString("applaunchtyperegular",
l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_OPEN_REGULAR));
+ localized_strings.SetString("applaunchtypewindow",
+ l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_OPEN_WINDOW));
localized_strings.SetString("applaunchtypefullscreen",
l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_OPEN_FULLSCREEN));
localized_strings.SetString("web_store_title",
diff --git a/chrome/browser/extensions/extension_dom_ui.cc b/chrome/browser/extensions/extension_dom_ui.cc
index c0522f0..faaa74b 100644
--- a/chrome/browser/extensions/extension_dom_ui.cc
+++ b/chrome/browser/extensions/extension_dom_ui.cc
@@ -243,13 +243,6 @@ bool ExtensionDOMUI::HandleChromeURLOverride(GURL* url, Profile* profile) {
return false;
ExtensionsService* service = profile->GetExtensionsService();
- if (!service->is_ready()) {
- // TODO(erikkay) So far, it looks like extensions load before the new tab
- // page. I don't know if we have anything that enforces this, so add this
- // check for safety.
- NOTREACHED() << "Chrome URL override requested before extensions loaded";
- return false;
- }
size_t i = 0;
while (i < url_list->GetSize()) {
diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc
index 3c789b0..26e601f0 100644
--- a/chrome/browser/extensions/extension_prefs.cc
+++ b/chrome/browser/extensions/extension_prefs.cc
@@ -452,12 +452,22 @@ void ExtensionPrefs::SetAllowFileAccess(const std::string& extension_id,
ExtensionPrefs::LaunchType ExtensionPrefs::GetLaunchType(
const std::string& extension_id) {
int value;
- if (ReadExtensionPrefInteger(extension_id, kPrefLaunchType, &value) && (
- value == LAUNCH_PINNED ||
+ if (ReadExtensionPrefInteger(extension_id, kPrefLaunchType, &value) &&
+ (value == LAUNCH_PINNED ||
value == LAUNCH_REGULAR ||
- value == LAUNCH_FULLSCREEN)) {
+ value == LAUNCH_FULLSCREEN ||
+ value == LAUNCH_WINDOW)) {
+
+#if defined(OS_MACOSX)
+ // App windows are not yet supported on mac. Pref sync could make
+ // the launch type LAUNCH_WINDOW, even if there is no UI to set it
+ // on mac.
+ if (value == LAUNCH_WINDOW)
+ return LAUNCH_REGULAR;
+#endif
return static_cast<LaunchType>(value);
}
+
return LAUNCH_REGULAR;
}
diff --git a/chrome/browser/extensions/extension_prefs.h b/chrome/browser/extensions/extension_prefs.h
index 298d03c..ad8e9c8 100644
--- a/chrome/browser/extensions/extension_prefs.h
+++ b/chrome/browser/extensions/extension_prefs.h
@@ -35,7 +35,8 @@ class ExtensionPrefs {
enum LaunchType {
LAUNCH_PINNED,
LAUNCH_REGULAR,
- LAUNCH_FULLSCREEN
+ LAUNCH_FULLSCREEN,
+ LAUNCH_WINDOW
};
explicit ExtensionPrefs(PrefService* prefs, const FilePath& root_dir_);
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index 8fd5538..3aec736 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -279,18 +279,15 @@ void ExtensionProcessManager::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
switch (type.value) {
- case NotificationType::EXTENSIONS_READY:
+ case NotificationType::EXTENSIONS_READY: {
CreateBackgroundHosts(this,
Source<Profile>(source).ptr()->GetExtensionsService()->extensions());
break;
+ }
case NotificationType::EXTENSION_LOADED: {
- ExtensionsService* service =
- Source<Profile>(source).ptr()->GetExtensionsService();
- if (service->is_ready()) {
- const Extension* extension = Details<const Extension>(details).ptr();
- ::CreateBackgroundHost(this, extension);
- }
+ const Extension* extension = Details<const Extension>(details).ptr();
+ ::CreateBackgroundHost(this, extension);
break;
}
@@ -454,8 +451,7 @@ void IncognitoExtensionProcessManager::Observe(
if (browser->profile() == browsing_instance_->profile()) {
ExtensionsService* service =
browsing_instance_->profile()->GetExtensionsService();
- if (service && service->is_ready())
- CreateBackgroundHosts(this, service->extensions());
+ CreateBackgroundHosts(this, service->extensions());
}
break;
}
diff --git a/chrome/browser/extensions/extension_startup_browsertest.cc b/chrome/browser/extensions/extension_startup_browsertest.cc
index 1b15ce0..a5561ef 100644
--- a/chrome/browser/extensions/extension_startup_browsertest.cc
+++ b/chrome/browser/extensions/extension_startup_browsertest.cc
@@ -84,9 +84,6 @@ class ExtensionStartupTestBase : public InProcessBrowserTest {
void WaitForServicesToStart(int num_expected_extensions,
bool expect_extensions_enabled) {
ExtensionsService* service = browser()->profile()->GetExtensionsService();
- if (!service->is_ready())
- ui_test_utils::WaitForNotification(NotificationType::EXTENSIONS_READY);
- ASSERT_TRUE(service->is_ready());
// Count the number of non-component extensions.
int found_extensions = 0;
diff --git a/chrome/browser/extensions/extension_toolbar_model.cc b/chrome/browser/extensions/extension_toolbar_model.cc
index 9b36825..7d31043 100644
--- a/chrome/browser/extensions/extension_toolbar_model.cc
+++ b/chrome/browser/extensions/extension_toolbar_model.cc
@@ -90,9 +90,6 @@ void ExtensionToolbarModel::Observe(NotificationType type,
return;
}
- if (!service_->is_ready())
- return;
-
const Extension* extension = Details<const Extension>(details).ptr();
if (type == NotificationType::EXTENSION_LOADED) {
AddExtension(extension);
@@ -151,8 +148,6 @@ void ExtensionToolbarModel::RemoveExtension(const Extension* extension) {
// 2. Create a vector of extensions that did not have a pref value.
// 3. Remove holes from the sorted vector and append the unsorted vector.
void ExtensionToolbarModel::InitializeExtensionList() {
- DCHECK(service_->is_ready());
-
std::vector<std::string> pref_order = service_->extension_prefs()->
GetToolbarOrder();
// Items that have a pref for their position.
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index e8f39aa..13fee46 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -538,7 +538,7 @@ ExtensionsService::ExtensionsService(Profile* profile,
install_directory_(install_directory),
extensions_enabled_(true),
show_extensions_prompts_(true),
- ready_(false),
+ init_done_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(toolbar_model_(this)),
default_apps_(profile->GetPrefs()),
event_routers_initialized_(false) {
@@ -608,7 +608,7 @@ void ExtensionsService::InitEventRouters() {
void ExtensionsService::Init() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(!ready_);
+ DCHECK(!init_done_); // Can't redo init.
DCHECK_EQ(extensions_.size(), 0u);
// Hack: we need to ensure the ResourceDispatcherHost is ready before we load
@@ -623,6 +623,8 @@ void ExtensionsService::Init() {
// TODO(erikkay) this should probably be deferred as well.
GarbageCollectExtensions();
+
+ init_done_ = true;
}
void ExtensionsService::InstallExtension(const FilePath& extension_path) {
@@ -1473,7 +1475,6 @@ void ExtensionsService::GarbageCollectExtensions() {
}
void ExtensionsService::OnLoadedInstalledExtensions() {
- ready_ = true;
if (updater_.get()) {
updater_->Start();
}
diff --git a/chrome/browser/extensions/extensions_service.h b/chrome/browser/extensions/extensions_service.h
index d3fd80b..11e4b1c8 100644
--- a/chrome/browser/extensions/extensions_service.h
+++ b/chrome/browser/extensions/extensions_service.h
@@ -381,9 +381,6 @@ class ExtensionsService
ExtensionPrefs* extension_prefs() { return extension_prefs_.get(); }
- // Whether the extension service is ready.
- bool is_ready() { return ready_; }
-
// Note that this may return NULL if autoupdate is not turned on.
ExtensionUpdater* updater() { return updater_.get(); }
@@ -508,8 +505,8 @@ class ExtensionsService
// Used by dispatchers to limit API quota for individual extensions.
ExtensionsQuotaService quota_service_;
- // Is the service ready to go?
- bool ready_;
+ // Record that Init() has been called.
+ bool init_done_;
// Our extension updater, if updates are turned on.
scoped_refptr<ExtensionUpdater> updater_;
diff --git a/chrome/browser/resources/new_new_tab.html b/chrome/browser/resources/new_new_tab.html
index 001c378..23ea917 100644
--- a/chrome/browser/resources/new_new_tab.html
+++ b/chrome/browser/resources/new_new_tab.html
@@ -236,6 +236,8 @@ if ('mode' in hashParams) {
launch-type="0">
<command id="apps-launch-type-regular" i18n-values=".label:applaunchtyperegular"
launch-type="1">
+<command id="apps-launch-type-window"
+ i18n-values=".label:applaunchtypewindow" launch-type="3">
<command id="apps-launch-type-fullscreen"
i18n-values=".label:applaunchtypefullscreen" launch-type="2">
@@ -244,6 +246,8 @@ if ('mode' in hashParams) {
<hr>
<button command="#apps-launch-type-regular" launch-type="1"></button>
<button command="#apps-launch-type-pinned" launch-type="0"></button>
+ <button id="apps-launch-type-window-menu-item"
+ command="#apps-launch-type-window" launch-type="3"></button>
<button command="#apps-launch-type-fullscreen" launch-type="2"></button>
<hr>
<button command="#apps-options-command"></button>
diff --git a/chrome/browser/resources/ntp/apps.js b/chrome/browser/resources/ntp/apps.js
index 7069231..2e4a92c 100644
--- a/chrome/browser/resources/ntp/apps.js
+++ b/chrome/browser/resources/ntp/apps.js
@@ -21,6 +21,10 @@ function getAppsCallback(data) {
var appsPromoPing = PING_WEBSTORE_LAUNCH_PREFIX + '+' + data.showPromo;
var webStoreEntry;
+ // Hide the app window menu option on platforms that do not support it.
+ $('apps-launch-type-window-menu-item').style.display =
+ (data.disableAppWindowLaunch ? 'none' : 'inline');
+
appsMiniview.textContent = '';
appsSectionContent.textContent = '';
@@ -150,10 +154,11 @@ var apps = (function() {
var LaunchType = {
LAUNCH_PINNED: 0,
LAUNCH_REGULAR: 1,
- LAUNCH_FULLSCREEN: 2
+ LAUNCH_FULLSCREEN: 2,
+ LAUNCH_WINDOW: 3
};
- // Keep in sync with LaunchContainer in extension.h
+ // Keep in sync with LaunchContainer in extension_constants.h
var LaunchContainer = {
LAUNCH_WINDOW: 0,
LAUNCH_PANEL: 1,
@@ -184,7 +189,8 @@ var apps = (function() {
// Update the commands related to the launch type.
var launchTypeIds = ['apps-launch-type-pinned',
'apps-launch-type-regular',
- 'apps-launch-type-fullscreen'];
+ 'apps-launch-type-fullscreen',
+ 'apps-launch-type-window'];
launchTypeIds.forEach(function(id) {
var command = $(id);
command.disabled = isPanel;
@@ -215,6 +221,7 @@ var apps = (function() {
case 'apps-launch-type-pinned':
case 'apps-launch-type-regular':
case 'apps-launch-type-fullscreen':
+ case 'apps-launch-type-window':
chrome.send('setLaunchType',
[currentApp['id'], e.command.getAttribute('launch-type')]);
break;
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc
index 6f38e51..3417215 100644
--- a/chrome/browser/sessions/session_restore.cc
+++ b/chrome/browser/sessions/session_restore.cc
@@ -272,8 +272,7 @@ class SessionRestoreImpl : public NotificationObserver {
synchronous_(synchronous),
clobber_existing_window_(clobber_existing_window),
always_create_tabbed_browser_(always_create_tabbed_browser),
- urls_to_open_(urls_to_open),
- waiting_for_extension_service_(false) {
+ urls_to_open_(urls_to_open) {
}
void Restore() {
@@ -339,19 +338,6 @@ class SessionRestoreImpl : public NotificationObserver {
delete this;
return;
- case NotificationType::EXTENSIONS_READY: {
- if (!waiting_for_extension_service_)
- return;
-
- waiting_for_extension_service_ = false;
- if (synchronous_) {
- MessageLoop::current()->Quit();
- return;
- }
- ProcessSessionWindows(&windows_);
- return;
- }
-
default:
NOTREACHED();
break;
@@ -396,18 +382,6 @@ class SessionRestoreImpl : public NotificationObserver {
void OnGotSession(SessionService::Handle handle,
std::vector<SessionWindow*>* windows) {
- if (HasExtensionApps(*windows) && profile_->GetExtensionsService() &&
- !profile_->GetExtensionsService()->is_ready()) {
- // At least one tab is an app tab and the extension service hasn't
- // finished loading. Wait to continue processing until the extensions
- // service finishes loading.
- registrar_.Add(this, NotificationType::EXTENSIONS_READY,
- Source<Profile>(profile_));
- windows_.swap(*windows);
- waiting_for_extension_service_ = true;
- return;
- }
-
if (synchronous_) {
// See comment above windows_ as to why we don't process immediately.
windows_.swap(*windows);
@@ -418,28 +392,6 @@ class SessionRestoreImpl : public NotificationObserver {
ProcessSessionWindows(windows);
}
- // Returns true if any tab in |windows| has an application extension id.
- bool HasExtensionApps(const std::vector<SessionWindow*>& windows) {
- for (std::vector<SessionWindow*>::const_iterator i = windows.begin();
- i != windows.end(); ++i) {
- if (HasExtensionApps((*i)->tabs))
- return true;
- }
-
- return false;
- }
-
- // Returns true if any tab in |tabs| has an application extension id.
- bool HasExtensionApps(const std::vector<SessionTab*>& tabs) {
- for (std::vector<SessionTab*>::const_iterator i = tabs.begin();
- i != tabs.end(); ++i) {
- if (!(*i)->extension_app_id.empty())
- return true;
- }
-
- return false;
- }
-
void ProcessSessionWindows(std::vector<SessionWindow*>* windows) {
if (windows->empty()) {
// Restore was unsuccessful.
@@ -601,10 +553,6 @@ class SessionRestoreImpl : public NotificationObserver {
// windows when the nested message loop exits.
std::vector<SessionWindow*> windows_;
- // If true, indicates at least one tab has an application extension id and
- // we're waiting for the extension service to finish loading.
- bool waiting_for_extension_service_;
-
NotificationRegistrar registrar_;
};
diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc
index 8c8754d..75b6ddc 100644
--- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc
+++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc
@@ -39,10 +39,7 @@ RenderViewHostDelegateViewHelper::MaybeCreateBackgroundContents(
const string16& frame_name) {
ExtensionsService* extensions_service = profile->GetExtensionsService();
- if (!opener_url.is_valid() ||
- frame_name.empty() ||
- !extensions_service ||
- !extensions_service->is_ready())
+ if (!opener_url.is_valid() || frame_name.empty())
return NULL;
const Extension* extension =
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 5f091ee..979b40b 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -598,12 +598,10 @@ void TabContents::SetExtensionAppById(const std::string& extension_app_id) {
return;
ExtensionsService* extension_service = profile()->GetExtensionsService();
- if (extension_service && extension_service->is_ready()) {
- const Extension* extension =
- extension_service->GetExtensionById(extension_app_id, false);
- if (extension)
- SetExtensionApp(extension);
- }
+ const Extension* extension =
+ extension_service->GetExtensionById(extension_app_id, false);
+ if (extension)
+ SetExtensionApp(extension);
}
SkBitmap* TabContents::GetExtensionAppIcon() {
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 2f02b64..29d7dd0 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -498,8 +498,6 @@ TabContents* Browser::OpenApplication(Profile* profile,
const std::string& app_id,
TabContents* existing_tab) {
ExtensionsService* extensions_service = profile->GetExtensionsService();
- if (!extensions_service->is_ready())
- return NULL;
// If the extension with |app_id| could't be found, most likely because it
// was uninstalled.
@@ -522,9 +520,11 @@ TabContents* Browser::OpenApplication(
UMA_HISTOGRAM_ENUMERATION("Extensions.AppLaunchContainer", container, 100);
- // The app is not yet open. Load it.
switch (container) {
case extension_misc::LAUNCH_WINDOW:
+ tab = Browser::OpenApplicationWindow(profile,
+ extension->GetFullLaunchURL());
+ break;
case extension_misc::LAUNCH_PANEL:
tab = Browser::OpenApplicationWindow(profile, extension, container,
GURL());
@@ -588,7 +588,7 @@ TabContents* Browser::OpenApplicationWindow(
}
// static
-TabContents* Browser::OpenApplicationWindow(Profile* profile, GURL& url) {
+TabContents* Browser::OpenApplicationWindow(Profile* profile, const GURL& url) {
return OpenApplicationWindow(profile, NULL, extension_misc::LAUNCH_WINDOW,
url);
}
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index b70049b..901137f 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -250,8 +250,9 @@ class Browser : public TabHandlerDelegate,
extension_misc::LaunchContainer container,
const GURL& url);
- // Open an application for |extension| in a new application window or panel.
- static TabContents* OpenApplicationWindow(Profile* profile, GURL& url);
+ // Open an application in a new application window. Used to implement
+ // app shortcuts.
+ static TabContents* OpenApplicationWindow(Profile* profile, const GURL& url);
// Open an application for |extension| in a new application tab, or
// |existing_tab| if not NULL. Returns NULL if there are no appropriate
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc
index 9085033..439f31f 100644
--- a/chrome/browser/ui/browser_init.cc
+++ b/chrome/browser/ui/browser_init.cc
@@ -605,14 +605,9 @@ bool BrowserInit::LaunchWithProfile::OpenApplicationWindow(Profile* profile) {
if (!IsAppLaunch(&url_string, &app_id))
return false;
- // http://crbug.com/37548
- // TODO(rafaelw): There are two legitimate cases where the extensions
- // service could not be ready at this point which need to be handled:
- // 1) The locale has changed and the manifests stored in the preferences
- // need to be relocalized.
- // 2) An externally installed extension will be found and installed.
- // Note that this can also fail if the app_id is simply invalid.
- // TODO(rafaelw): Do something reasonable here. Pop up a warning panel?
+ // This can fail if the app_id is invalid. It can also fail if the
+ // extension is external, and has not yet been installed.
+ // TODO(skerner): Do something reasonable here. Pop up a warning panel?
// Open an URL to the gallery page of the extension id?
if (!app_id.empty())
return Browser::OpenApplication(profile, app_id, NULL) != NULL;