summaryrefslogtreecommitdiffstats
path: root/chrome/views
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-12 00:21:28 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-12 00:21:28 +0000
commit401513c474b3520fe784c03e068a15fc6655d6e1 (patch)
tree9d5368feb8f3a668ec4523e90bc9694bcfc3a9d3 /chrome/views
parenta8e9b16e3e3f944d0eaf7f91e5cc96a7b2c914d3 (diff)
downloadchromium_src-401513c474b3520fe784c03e068a15fc6655d6e1.zip
chromium_src-401513c474b3520fe784c03e068a15fc6655d6e1.tar.gz
chromium_src-401513c474b3520fe784c03e068a15fc6655d6e1.tar.bz2
Moving the storing/restoring of the focus from TabContents to WebContentsView. This makes TabContents less dependent on views.
This requires few contortions with DOMUIs (NTP, history and downloads tab) as they still need to set the initial focus specifically. BUG=None TEST=Run the interactive tests. Review URL: http://codereview.chromium.org/39269 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11501 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views')
-rw-r--r--chrome/views/view_storage.cc19
-rw-r--r--chrome/views/view_storage.h9
2 files changed, 4 insertions, 24 deletions
diff --git a/chrome/views/view_storage.cc b/chrome/views/view_storage.cc
index bc5849c..42396b8 100644
--- a/chrome/views/view_storage.cc
+++ b/chrome/views/view_storage.cc
@@ -11,8 +11,6 @@
namespace views {
-ViewStorage* ViewStorage::shared_instance_ = NULL;
-
// This struct contains the information to locate a specific view.
// Locating a view is not always straight-forward as a view can be a floating
// view, or the child of a floating view. Floating views are frequently deleted
@@ -36,19 +34,7 @@ struct ViewLocationInfo {
// static
ViewStorage* ViewStorage::GetSharedInstance() {
- if (shared_instance_)
- return shared_instance_;
-
- shared_instance_ = new ViewStorage();
- return shared_instance_;
-}
-
-// static
-void ViewStorage::DeleteSharedInstance() {
- if (!shared_instance_)
- return;
- delete shared_instance_;
- shared_instance_ = NULL;
+ return Singleton<ViewStorage>::get();
}
ViewStorage::ViewStorage() : view_storage_next_id_(0) {
@@ -57,9 +43,6 @@ ViewStorage::ViewStorage() : view_storage_next_id_(0) {
}
ViewStorage::~ViewStorage() {
- NotificationService::current()->RemoveObserver(
- this, NotificationType::VIEW_REMOVED, NotificationService::AllSources());
-
STLDeleteContainerPairSecondPointers(id_to_view_location_.begin(),
id_to_view_location_.end());
diff --git a/chrome/views/view_storage.h b/chrome/views/view_storage.h
index a965158..8b17474 100644
--- a/chrome/views/view_storage.h
+++ b/chrome/views/view_storage.h
@@ -5,6 +5,7 @@
#ifndef CHROME_VIEWS_VIEW_STORAGE_H_
#define CHROME_VIEWS_VIEW_STORAGE_H_
+#include "base/singleton.h"
#include "chrome/common/notification_observer.h"
#include "chrome/views/view.h"
@@ -31,9 +32,6 @@ class ViewStorage : public NotificationObserver {
// It is guaranted to be non NULL.
static ViewStorage* GetSharedInstance();
- // Deletes the global instance of the ViewStorage.
- static void DeleteSharedInstance();
-
// Returns a unique storage id that can be used to store/retrieve views.
int CreateStorageID();
@@ -47,6 +45,8 @@ class ViewStorage : public NotificationObserver {
void RemoveView(int storage_id);
private:
+ friend struct DefaultSingletonTraits<ViewStorage>;
+
ViewStorage();
~ViewStorage();
@@ -69,9 +69,6 @@ class ViewStorage : public NotificationObserver {
// Association View to id, used to speed up view notification removal.
std::map<View*, std::vector<int>*> view_to_ids_;
- // The singleton instance.
- static ViewStorage* shared_instance_;
-
DISALLOW_COPY_AND_ASSIGN(ViewStorage);
};