OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/chromeos/sim_unlock_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/sim_unlock_ui.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 } // namespace | 73 } // namespace |
74 | 74 |
75 namespace chromeos { | 75 namespace chromeos { |
76 | 76 |
77 class SimUnlockUIHTMLSource : public content::URLDataSource { | 77 class SimUnlockUIHTMLSource : public content::URLDataSource { |
78 public: | 78 public: |
79 SimUnlockUIHTMLSource(); | 79 SimUnlockUIHTMLSource(); |
80 | 80 |
81 // content::URLDataSource implementation. | 81 // content::URLDataSource implementation. |
82 virtual std::string GetSource() const override; | 82 std::string GetSource() const override; |
83 virtual void StartDataRequest( | 83 void StartDataRequest( |
84 const std::string& path, | 84 const std::string& path, |
85 int render_process_id, | 85 int render_process_id, |
86 int render_frame_id, | 86 int render_frame_id, |
87 const content::URLDataSource::GotDataCallback& callback) override; | 87 const content::URLDataSource::GotDataCallback& callback) override; |
88 virtual std::string GetMimeType(const std::string&) const override { | 88 std::string GetMimeType(const std::string&) const override { |
89 return "text/html"; | 89 return "text/html"; |
90 } | 90 } |
91 virtual bool ShouldAddContentSecurityPolicy() const override { | 91 bool ShouldAddContentSecurityPolicy() const override { return false; } |
92 return false; | |
93 } | |
94 | 92 |
95 private: | 93 private: |
96 virtual ~SimUnlockUIHTMLSource() {} | 94 ~SimUnlockUIHTMLSource() override {} |
97 | 95 |
98 std::string service_path_; | 96 std::string service_path_; |
99 DISALLOW_COPY_AND_ASSIGN(SimUnlockUIHTMLSource); | 97 DISALLOW_COPY_AND_ASSIGN(SimUnlockUIHTMLSource); |
100 }; | 98 }; |
101 | 99 |
102 // The handler for Javascript messages related to the "sim-unlock" view. | 100 // The handler for Javascript messages related to the "sim-unlock" view. |
103 class SimUnlockHandler : public WebUIMessageHandler, | 101 class SimUnlockHandler : public WebUIMessageHandler, |
104 public base::SupportsWeakPtr<SimUnlockHandler>, | 102 public base::SupportsWeakPtr<SimUnlockHandler>, |
105 public NetworkStateHandlerObserver { | 103 public NetworkStateHandlerObserver { |
106 public: | 104 public: |
107 SimUnlockHandler(); | 105 SimUnlockHandler(); |
108 virtual ~SimUnlockHandler(); | 106 ~SimUnlockHandler() override; |
109 | 107 |
110 // WebUIMessageHandler implementation. | 108 // WebUIMessageHandler implementation. |
111 virtual void RegisterMessages() override; | 109 void RegisterMessages() override; |
112 | 110 |
113 // NetworkStateHandlerObserver implementation. | 111 // NetworkStateHandlerObserver implementation. |
114 virtual void DeviceListChanged() override; | 112 void DeviceListChanged() override; |
115 | 113 |
116 private: | 114 private: |
117 // Should keep this state enum in sync with similar one in JS code. | 115 // Should keep this state enum in sync with similar one in JS code. |
118 // SIM_NOT_LOCKED_ASK_PIN - SIM card is not locked but we ask user | 116 // SIM_NOT_LOCKED_ASK_PIN - SIM card is not locked but we ask user |
119 // for PIN input because PinRequired preference change was requested. | 117 // for PIN input because PinRequired preference change was requested. |
120 // SIM_NOT_LOCKED_CHANGE_PIN - SIM card is not locked, ask user for old PIN | 118 // SIM_NOT_LOCKED_CHANGE_PIN - SIM card is not locked, ask user for old PIN |
121 // and new PIN to change it. | 119 // and new PIN to change it. |
122 typedef enum SimUnlockState { | 120 typedef enum SimUnlockState { |
123 SIM_UNLOCK_LOADING = -1, | 121 SIM_UNLOCK_LOADING = -1, |
124 SIM_ABSENT_NOT_LOCKED = 0, | 122 SIM_ABSENT_NOT_LOCKED = 0, |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 SimUnlockHandler* handler = new SimUnlockHandler(); | 757 SimUnlockHandler* handler = new SimUnlockHandler(); |
760 web_ui->AddMessageHandler(handler); | 758 web_ui->AddMessageHandler(handler); |
761 SimUnlockUIHTMLSource* html_source = new SimUnlockUIHTMLSource(); | 759 SimUnlockUIHTMLSource* html_source = new SimUnlockUIHTMLSource(); |
762 | 760 |
763 // Set up the chrome://sim-unlock/ source. | 761 // Set up the chrome://sim-unlock/ source. |
764 Profile* profile = Profile::FromWebUI(web_ui); | 762 Profile* profile = Profile::FromWebUI(web_ui); |
765 content::URLDataSource::Add(profile, html_source); | 763 content::URLDataSource::Add(profile, html_source); |
766 } | 764 } |
767 | 765 |
768 } // namespace chromeos | 766 } // namespace chromeos |
OLD | NEW |