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

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

Issue 5582002: Move:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/tab_contents_wrapper.h ('k') | chrome/browser/tab_menu_model.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/tab_contents_wrapper.h"
6
7 #include "base/singleton.h"
8 #include "chrome/browser/password_manager/password_manager.h"
9 #include "chrome/browser/password_manager_delegate_impl.h"
10 #include "chrome/browser/tab_contents/tab_contents.h"
11
12 ////////////////////////////////////////////////////////////////////////////////
13 // TabContentsWrapper, public:
14
15 TabContentsWrapper::TabContentsWrapper(TabContents* contents)
16 : tab_contents_(contents) {
17 DCHECK(contents);
18 // Stash this in the property bag so it can be retrieved without having to
19 // go to a Browser.
20 property_accessor()->SetProperty(contents->property_bag(), this);
21
22 // Needed so that we initialize the password manager on first navigation.
23 tab_contents()->AddNavigationObserver(this);
24 }
25
26 TabContentsWrapper::~TabContentsWrapper() {
27 // Unregister observers (TabContents outlives supporting objects).
28 tab_contents()->RemoveNavigationObserver(password_manager_.get());
29 }
30
31 PropertyAccessor<TabContentsWrapper*>* TabContentsWrapper::property_accessor() {
32 return Singleton< PropertyAccessor<TabContentsWrapper*> >::get();
33 }
34
35 TabContentsWrapper* TabContentsWrapper::Clone() {
36 TabContents* new_contents = tab_contents()->Clone();
37 TabContentsWrapper* new_wrapper = new TabContentsWrapper(new_contents);
38 // Instantiate the passowrd manager if it has been instantiated here.
39 if (password_manager_.get())
40 new_wrapper->GetPasswordManager();
41 return new_wrapper;
42 }
43
44 PasswordManager* TabContentsWrapper::GetPasswordManager() {
45 if (!password_manager_.get()) {
46 // Create the delegate then create the manager.
47 password_manager_delegate_.reset(
48 new PasswordManagerDelegateImpl(tab_contents()));
49 password_manager_.reset(
50 new PasswordManager(password_manager_delegate_.get()));
51 // Register the manager to receive navigation notifications.
52 tab_contents()->AddNavigationObserver(password_manager_.get());
53 }
54 return password_manager_.get();
55 }
56
57 ////////////////////////////////////////////////////////////////////////////////
58 // TabContentsWrapper, WebNavigationObserver implementation:
59
60 void TabContentsWrapper::NavigateToPendingEntry() {
61 GetPasswordManager();
62 tab_contents()->RemoveNavigationObserver(this);
63 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents_wrapper.h ('k') | chrome/browser/tab_menu_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698