diff options
Diffstat (limited to 'chrome/browser/extensions')
-rwxr-xr-x | chrome/browser/extensions/extension_view.cc | 7 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service.cc | 47 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service.h | 4 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service_unittest.cc | 16 |
4 files changed, 41 insertions, 33 deletions
diff --git a/chrome/browser/extensions/extension_view.cc b/chrome/browser/extensions/extension_view.cc index 5678e08..3f602d0 100755 --- a/chrome/browser/extensions/extension_view.cc +++ b/chrome/browser/extensions/extension_view.cc @@ -50,7 +50,7 @@ void ExtensionView::DidChangeBounds(const gfx::Rect& previous, void ExtensionView::ShowIfCompletelyLoaded() { // We wait to show the ExtensionView until it has loaded and our parent has // given us a background. These can happen in different orders. - if (host_->did_stop_loading() && render_view_host()->view() && + if (!IsVisible() && host_->did_stop_loading() && render_view_host()->view() && !render_view_host()->view()->background().empty()) { SetVisible(true); DidContentsPreferredWidthChange(pending_preferred_width_); @@ -71,7 +71,7 @@ void ExtensionView::DidContentsPreferredWidthChange(const int pref_width) { // Size changes will not be honored by lower layers while we are hidden. if (!IsVisible()) { pending_preferred_width_ = pref_width; - } else if (pref_width > 0) { + } else if (pref_width > 0 && pref_width != GetPreferredSize().width()) { set_preferred_size(gfx::Size(pref_width, height())); SizeToPreferredSize(); @@ -81,9 +81,8 @@ void ExtensionView::DidContentsPreferredWidthChange(const int pref_width) { // containment hierarchy. if (GetParent() != NULL && GetParent()->GetParent() != NULL) { GetParent()->GetParent()->Layout(); + GetParent()->GetParent()->SchedulePaint(); } - - SchedulePaint(); } } diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index 38fb703..5e9c221 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -13,6 +13,8 @@ #include "base/thread.h" #include "base/values.h" #include "net/base/file_stream.h" +#include "chrome/browser/browser.h" +#include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browsing_instance.h" #include "chrome/browser/extensions/extension.h" @@ -27,8 +29,7 @@ #include "chrome/common/json_value_serializer.h" #include "chrome/common/notification_service.h" #include "chrome/common/unzip.h" - -#include "chrome/browser/browser_list.h" +#include "chrome/common/url_constants.h" #if defined(OS_WIN) #include "base/registry.h" @@ -190,13 +191,22 @@ void ExtensionsService::OnExtensionsLoaded(ExtensionList* new_extensions) { delete new_extensions; } -void ExtensionsService::OnExtensionInstalled(FilePath path, bool update) { +void ExtensionsService::OnExtensionInstalled(Extension* extension, + bool update) { NotificationService::current()->Notify( NotificationType::EXTENSION_INSTALLED, NotificationService::AllSources(), - Details<FilePath>(&path)); - - // TODO(erikkay): Update UI if appropriate. + Details<Extension>(extension)); + + // We open the NTP if the extension has a toolstrip and the bookmark bar is + // detached. We noticed that people got confused if something didn't obviously + // happen when installing an extension. + Browser* browser = BrowserList::GetLastActive(); + if (browser && browser->window() && + !browser->window()->IsBookmarkBarVisible() && + !extension->toolstrips().empty()) + browser->AddTabWithURL(GURL(chrome::kChromeUINewTabURL), GURL(), + PageTransition::LINK, true, -1, NULL); } ExtensionView* ExtensionsService::CreateView(Extension* extension, @@ -755,24 +765,23 @@ void ExtensionsServiceBackend::ReportExtensionInstallError( void ExtensionsServiceBackend::ReportExtensionInstalled( const FilePath& path, bool update) { + // After it's installed, load it right away with the same settings. + Extension* extension = LoadExtensionCurrentVersion(path); + CHECK(extension); + frontend_->GetMessageLoop()->PostTask(FROM_HERE, NewRunnableMethod( frontend_, &ExtensionsServiceFrontendInterface::OnExtensionInstalled, - path, + extension, update)); - // After it's installed, load it right away with the same settings. - LOG(INFO) << "Loading extension " << path.value(); - Extension* extension = LoadExtensionCurrentVersion(path); - if (extension) { - // Only one extension, but ReportExtensionsLoaded can handle multiple, - // so we need to construct a list. - scoped_ptr<ExtensionList> extensions(new ExtensionList); - extensions->push_back(extension); - LOG(INFO) << "Done."; - // Hand off ownership of the loaded extensions to the frontend. - ReportExtensionsLoaded(extensions.release()); - } + // Only one extension, but ReportExtensionsLoaded can handle multiple, + // so we need to construct a list. + scoped_ptr<ExtensionList> extensions(new ExtensionList); + extensions->push_back(extension); + LOG(INFO) << "Done."; + // Hand off ownership of the loaded extensions to the frontend. + ReportExtensionsLoaded(extensions.release()); } // Some extensions will autoupdate themselves externally from Chrome. These diff --git a/chrome/browser/extensions/extensions_service.h b/chrome/browser/extensions/extensions_service.h index d876f34..4bf2323 100644 --- a/chrome/browser/extensions/extensions_service.h +++ b/chrome/browser/extensions/extensions_service.h @@ -53,7 +53,7 @@ class ExtensionsServiceFrontendInterface // Called with results from InstallExtension(). // |is_update| is true if the installation was an update to an existing // installed extension rather than a new installation. - virtual void OnExtensionInstalled(FilePath path, bool is_update) = 0; + virtual void OnExtensionInstalled(Extension* extension, bool is_update) = 0; }; @@ -76,7 +76,7 @@ class ExtensionsService : public ExtensionsServiceFrontendInterface { virtual void InstallExtension(const FilePath& extension_path); virtual void LoadExtension(const FilePath& extension_path); virtual void OnExtensionsLoaded(ExtensionList* extensions); - virtual void OnExtensionInstalled(FilePath path, bool is_update); + virtual void OnExtensionInstalled(Extension* extension, bool is_update); // Creates a new ExtensionView, grouping it in the appropriate SiteInstance // (and therefore process) based on the URL and profile. diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc index b4a81c5..d66ea0b 100644 --- a/chrome/browser/extensions/extensions_service_unittest.cc +++ b/chrome/browser/extensions/extensions_service_unittest.cc @@ -68,8 +68,8 @@ class ExtensionsServiceTestFrontend return &extensions_; } - std::vector<FilePath>* installed() { - return &installed_; + Extension* installed() { + return installed_; } // ExtensionsServiceFrontendInterface @@ -92,8 +92,8 @@ class ExtensionsServiceTestFrontend std::stable_sort(extensions_.begin(), extensions_.end(), ExtensionsOrder()); } - virtual void OnExtensionInstalled(FilePath path, bool is_update) { - installed_.push_back(path); + virtual void OnExtensionInstalled(Extension* extension, bool is_update) { + installed_ = extension; } void TestInstallExtension(const FilePath& path, @@ -105,18 +105,18 @@ class ExtensionsServiceTestFrontend message_loop_.RunAllPending(); std::vector<std::string> errors = GetErrors(); if (should_succeed) { - EXPECT_EQ(1u, installed_.size()) << path.value(); + EXPECT_TRUE(installed_) << path.value(); EXPECT_EQ(0u, errors.size()) << path.value(); for (std::vector<std::string>::iterator err = errors.begin(); err != errors.end(); ++err) { LOG(ERROR) << *err; } } else { - EXPECT_EQ(0u, installed_.size()) << path.value(); + EXPECT_FALSE(installed_) << path.value(); EXPECT_EQ(1u, errors.size()) << path.value(); } - installed_.clear(); + installed_ = NULL; ExtensionErrorReporter::GetInstance()->ClearErrors(); } @@ -124,7 +124,7 @@ class ExtensionsServiceTestFrontend private: MessageLoop message_loop_; ExtensionList extensions_; - std::vector<FilePath> installed_; + Extension* installed_; }; // make the test a PlatformTest to setup autorelease pools properly on mac |