summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-02 19:30:19 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-02 19:30:19 +0000
commit6a3ec231b4a982787a4a1a5fd672bb974ce98bca (patch)
treea63406d0cb3012ed4ab677598d4f2de9329e9f5a /chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
parent1ffacfd8a743eb9d375080db95d900166758551c (diff)
downloadchromium_src-6a3ec231b4a982787a4a1a5fd672bb974ce98bca.zip
chromium_src-6a3ec231b4a982787a4a1a5fd672bb974ce98bca.tar.gz
chromium_src-6a3ec231b4a982787a4a1a5fd672bb974ce98bca.tar.bz2
Move:
tab_menu_model->ui/tabs tab_contents_wrapper->ui/tab_contents view_ids.h->ui status_bubble.h->ui options*->ui/options show_options_url*->ui/options location_bar*->ui/omnibox input_window*->ui browser_uitests->ui/tests BUG=none TEST=none TBR=brettw Review URL: http://codereview.chromium.org/5582002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68047 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/tab_contents/tab_contents_wrapper.cc')
-rw-r--r--chrome/browser/ui/tab_contents/tab_contents_wrapper.cc63
1 files changed, 63 insertions, 0 deletions
diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
new file mode 100644
index 0000000..0adec32
--- /dev/null
+++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+
+#include "base/singleton.h"
+#include "chrome/browser/password_manager/password_manager.h"
+#include "chrome/browser/password_manager_delegate_impl.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// TabContentsWrapper, public:
+
+TabContentsWrapper::TabContentsWrapper(TabContents* contents)
+ : tab_contents_(contents) {
+ DCHECK(contents);
+ // Stash this in the property bag so it can be retrieved without having to
+ // go to a Browser.
+ property_accessor()->SetProperty(contents->property_bag(), this);
+
+ // Needed so that we initialize the password manager on first navigation.
+ tab_contents()->AddNavigationObserver(this);
+}
+
+TabContentsWrapper::~TabContentsWrapper() {
+ // Unregister observers (TabContents outlives supporting objects).
+ tab_contents()->RemoveNavigationObserver(password_manager_.get());
+}
+
+PropertyAccessor<TabContentsWrapper*>* TabContentsWrapper::property_accessor() {
+ return Singleton< PropertyAccessor<TabContentsWrapper*> >::get();
+}
+
+TabContentsWrapper* TabContentsWrapper::Clone() {
+ TabContents* new_contents = tab_contents()->Clone();
+ TabContentsWrapper* new_wrapper = new TabContentsWrapper(new_contents);
+ // Instantiate the passowrd manager if it has been instantiated here.
+ if (password_manager_.get())
+ new_wrapper->GetPasswordManager();
+ return new_wrapper;
+}
+
+PasswordManager* TabContentsWrapper::GetPasswordManager() {
+ if (!password_manager_.get()) {
+ // Create the delegate then create the manager.
+ password_manager_delegate_.reset(
+ new PasswordManagerDelegateImpl(tab_contents()));
+ password_manager_.reset(
+ new PasswordManager(password_manager_delegate_.get()));
+ // Register the manager to receive navigation notifications.
+ tab_contents()->AddNavigationObserver(password_manager_.get());
+ }
+ return password_manager_.get();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// TabContentsWrapper, WebNavigationObserver implementation:
+
+void TabContentsWrapper::NavigateToPendingEntry() {
+ GetPasswordManager();
+ tab_contents()->RemoveNavigationObserver(this);
+}