1 // Copyright 2014 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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_PASSWORD_MANAGER_INTERNALS_PASSWORD_MANAGER_INTERNALS_UI_H_
6 #define CHROME_BROWSER_UI_WEBUI_PASSWORD_MANAGER_INTERNALS_PASSWORD_MANAGER_INTERNALS_UI_H_
8 #include "components/password_manager/core/browser/password_manager_logger.h"
9 #include "content/public/browser/web_contents_observer.h"
10 #include "content/public/browser/web_ui_controller.h"
12 class PasswordManagerInternalsUI
13 : public content::WebUIController,
14 public content::WebContentsObserver,
15 public password_manager::PasswordManagerLogger {
17 explicit PasswordManagerInternalsUI(content::WebUI* web_ui);
18 virtual ~PasswordManagerInternalsUI();
20 // WebContentsObserver implementation.
21 virtual void DidStopLoading(
22 content::RenderViewHost* render_view_host) OVERRIDE;
24 // PasswordManagerLogger implementation.
25 virtual void LogSavePasswordProgress(const std::string& text) OVERRIDE;
28 // These types describe which kinds of notifications
29 // PasswordManagerInternalsUI can send to PasswordManagerClient.
30 enum ClientNotificationType {
31 PAGE_OPENED, // Send when the page gets opened.
32 PAGE_CLOSED // Send when the page gets closed.
35 // This acts on all PasswordManagerClient instances of the current profile
36 // based on |notification_type|:
37 // PAGE_OPENED -- |this| is set as clients' PasswordManagerLogger
38 // PAGE_CLOSED -- PasswordManagerLogger is reset for clients
39 void NotifyAllPasswordManagerClients(
40 ClientNotificationType notification_type);
42 // Helper used by LogSavePasswordProgress, actually sends |text| to the
44 void LogInternal(const std::string& text);
46 // Whether the observed WebContents did stop loading.
47 bool did_stop_loading_;
49 // Stores the logs here until |did_stop_loading_| becomes true. At that point
50 // all stored logs are displayed and any new are displayed directly.
51 std::string log_buffer_;
53 DISALLOW_COPY_AND_ASSIGN(PasswordManagerInternalsUI);
56 #endif // CHROME_BROWSER_UI_WEBUI_PASSWORD_MANAGER_INTERNALS_PASSWORD_MANAGER_INTERNALS_UI_H_