Chromium Code Reviews| Index: chrome/browser/ui/webui/password_manager_internals/password_manager_internals_ui.cc |
| diff --git a/chrome/browser/ui/webui/password_manager_internals/password_manager_internals_ui.cc b/chrome/browser/ui/webui/password_manager_internals/password_manager_internals_ui.cc |
| index 34d46112af75a041f980bb3165e77da57f15c7f6..aa0994ef65ba79a99e93ac01028722bb1adb7af0 100644 |
| --- a/chrome/browser/ui/webui/password_manager_internals/password_manager_internals_ui.cc |
| +++ b/chrome/browser/ui/webui/password_manager_internals/password_manager_internals_ui.cc |
| @@ -7,26 +7,18 @@ |
| #include <algorithm> |
| #include <set> |
| -#include "base/strings/string16.h" |
| -#include "base/strings/stringprintf.h" |
| -#include "base/strings/utf_string_conversions.h" |
| #include "base/values.h" |
| -#include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| #include "chrome/browser/profiles/profile.h" |
| -#include "chrome/browser/ui/android/tab_model/tab_model.h" |
| -#include "chrome/browser/ui/android/tab_model/tab_model_list.h" |
| -#include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" |
| #include "chrome/common/url_constants.h" |
| -#include "content/public/browser/browser_context.h" |
| -#include "content/public/browser/render_view_host.h" |
| -#include "content/public/browser/web_contents.h" |
| +#include "components/password_manager/content/browser/password_manager_internals_service_factory.h" |
| +#include "components/password_manager/core/browser/password_manager_internals_service.h" |
| #include "content/public/browser/web_ui.h" |
| #include "content/public/browser/web_ui_data_source.h" |
| #include "grit/password_manager_internals_resources.h" |
| #include "net/base/escape.h" |
| -using content::BrowserContext; |
| -using content::WebContents; |
| +using password_manager::PasswordManagerInternalsService; |
| +using password_manager::PasswordManagerInternalsServiceFactory; |
| namespace { |
| @@ -42,16 +34,6 @@ content::WebUIDataSource* CreatePasswordManagerInternalsHTMLSource() { |
| return source; |
| } |
| -void InsertWebContentsIfProfileMatches( |
| - WebContents* web_contents, |
| - const Profile* profile_to_match, |
| - std::set<WebContents*>* set_of_web_contents) { |
| - if (static_cast<const BrowserContext*>(profile_to_match) == |
| - web_contents->GetBrowserContext()) { |
| - set_of_web_contents->insert(web_contents); |
| - } |
| -} |
| - |
| } // namespace |
| PasswordManagerInternalsUI::PasswordManagerInternalsUI(content::WebUI* web_ui) |
| @@ -61,11 +43,19 @@ PasswordManagerInternalsUI::PasswordManagerInternalsUI(content::WebUI* web_ui) |
| // Set up the chrome://password-manager-internals/ source. |
| content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
| CreatePasswordManagerInternalsHTMLSource()); |
| - NotifyAllPasswordManagerClients(PAGE_OPENED); |
| + PasswordManagerInternalsService* service = |
| + PasswordManagerInternalsServiceFactory::GetForBrowserContext( |
| + Profile::FromWebUI(web_ui)); |
| + if (service) |
| + log_buffer_.append(service->RegisterReceiver(this)); |
|
Ilya Sherman
2014/05/13 04:32:18
Hmm, why do you need a log buffer? Couldn't you j
vabr (Chromium)
2014/05/13 09:27:11
Good idea, done.
I don't think any more bookkeepin
|
| } |
| PasswordManagerInternalsUI::~PasswordManagerInternalsUI() { |
| - NotifyAllPasswordManagerClients(PAGE_CLOSED); |
| + PasswordManagerInternalsService* service = |
| + PasswordManagerInternalsServiceFactory::GetForBrowserContext( |
| + Profile::FromWebUI(web_ui())); |
| + if (service) |
| + service->UnregisterReceiver(this); |
| } |
| void PasswordManagerInternalsUI::DidStopLoading( |
| @@ -92,42 +82,3 @@ void PasswordManagerInternalsUI::LogInternal(const std::string& text) { |
| web_ui()->CallJavascriptFunction("addSavePasswordProgressLog", |
| text_string_value); |
| } |
| - |
| -void PasswordManagerInternalsUI::NotifyAllPasswordManagerClients( |
| - ClientNotificationType notification_type) { |
| - // First, find all the WebContents objects of the current profile. |
| - Profile* current_profile = Profile::FromWebUI(web_ui()); |
| - std::set<WebContents*> profile_web_contents; |
| -#if defined(OS_ANDROID) |
| - for (TabModelList::const_iterator iter = TabModelList::begin(); |
| - iter != TabModelList::end(); |
| - ++iter) { |
| - TabModel* model = *iter; |
| - for (int i = 0; i < model->GetTabCount(); ++i) { |
| - InsertWebContentsIfProfileMatches( |
| - model->GetWebContentsAt(i), current_profile, &profile_web_contents); |
| - } |
| - } |
| -#else |
| - for (TabContentsIterator iter; !iter.done(); iter.Next()) { |
| - InsertWebContentsIfProfileMatches( |
| - *iter, current_profile, &profile_web_contents); |
| - } |
| -#endif |
| - |
| - // Now get the corresponding PasswordManagerClients, and attach/detach |this|. |
| - for (std::set<WebContents*>::iterator it = profile_web_contents.begin(); |
| - it != profile_web_contents.end(); |
| - ++it) { |
| - ChromePasswordManagerClient* client = |
| - ChromePasswordManagerClient::FromWebContents(*it); |
| - switch (notification_type) { |
| - case PAGE_OPENED: |
| - client->SetLogger(this); |
| - break; |
| - case PAGE_CLOSED: |
| - client->SetLogger(NULL); |
| - break; |
| - } |
| - } |
| -} |