Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / password_manager_internals / password_manager_internals_ui.h
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.
4
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_
7
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"
11
12 class PasswordManagerInternalsUI
13     : public content::WebUIController,
14       public content::WebContentsObserver,
15       public password_manager::PasswordManagerLogger {
16  public:
17   explicit PasswordManagerInternalsUI(content::WebUI* web_ui);
18   virtual ~PasswordManagerInternalsUI();
19
20   // WebContentsObserver implementation.
21   virtual void DidStopLoading(
22       content::RenderViewHost* render_view_host) OVERRIDE;
23
24   // PasswordManagerLogger implementation.
25   virtual void LogSavePasswordProgress(const std::string& text) OVERRIDE;
26
27  private:
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.
33   };
34
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);
41
42   // Helper used by LogSavePasswordProgress, actually sends |text| to the
43   // internals page.
44   void LogInternal(const std::string& text);
45
46   // Whether the observed WebContents did stop loading.
47   bool did_stop_loading_;
48
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_;
52
53   DISALLOW_COPY_AND_ASSIGN(PasswordManagerInternalsUI);
54 };
55
56 #endif  // CHROME_BROWSER_UI_WEBUI_PASSWORD_MANAGER_INTERNALS_PASSWORD_MANAGER_INTERNALS_UI_H_