OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/proxy_settings_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/proxy_settings_ui.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/chromeos/webui/core_chromeos_options_handler.h" | 10 #include "chrome/browser/chromeos/webui/core_chromeos_options_handler.h" |
11 #include "chrome/browser/chromeos/webui/proxy_handler.h" | 11 #include "chrome/browser/chromeos/webui/proxy_handler.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
14 #include "chrome/common/jstemplate_builder.h" | 14 #include "chrome/common/jstemplate_builder.h" |
15 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
16 #include "content/browser/tab_contents/tab_contents.h" | 16 #include "content/browser/tab_contents/tab_contents.h" |
17 #include "grit/browser_resources.h" | 17 #include "grit/browser_resources.h" |
18 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 class ProxySettingsHTMLSource : public ChromeURLDataManager::DataSource { | 22 class ProxySettingsHTMLSource : public ChromeURLDataManager::DataSource { |
23 public: | 23 public: |
24 explicit ProxySettingsHTMLSource(DictionaryValue* localized_strings); | 24 explicit ProxySettingsHTMLSource(DictionaryValue* localized_strings); |
25 | 25 |
26 // Called when the network layer has requested a resource underneath | 26 // Called when the network layer has requested a resource underneath |
27 // the path we registered. | 27 // the path we registered. |
28 virtual void StartDataRequest(const std::string& path, | 28 virtual void StartDataRequest(const std::string& path, |
29 bool is_off_the_record, | 29 bool is_incognito, |
30 int request_id); | 30 int request_id); |
31 virtual std::string GetMimeType(const std::string&) const { | 31 virtual std::string GetMimeType(const std::string&) const { |
32 return "text/html"; | 32 return "text/html"; |
33 } | 33 } |
34 | 34 |
35 private: | 35 private: |
36 scoped_ptr<DictionaryValue> localized_strings_; | 36 scoped_ptr<DictionaryValue> localized_strings_; |
37 | 37 |
38 DISALLOW_COPY_AND_ASSIGN(ProxySettingsHTMLSource); | 38 DISALLOW_COPY_AND_ASSIGN(ProxySettingsHTMLSource); |
39 }; | 39 }; |
40 | 40 |
41 ProxySettingsHTMLSource::ProxySettingsHTMLSource( | 41 ProxySettingsHTMLSource::ProxySettingsHTMLSource( |
42 DictionaryValue* localized_strings) | 42 DictionaryValue* localized_strings) |
43 : DataSource(chrome::kChromeUIProxySettingsHost, MessageLoop::current()), | 43 : DataSource(chrome::kChromeUIProxySettingsHost, MessageLoop::current()), |
44 localized_strings_(localized_strings) { | 44 localized_strings_(localized_strings) { |
45 } | 45 } |
46 | 46 |
47 void ProxySettingsHTMLSource::StartDataRequest(const std::string& path, | 47 void ProxySettingsHTMLSource::StartDataRequest(const std::string& path, |
48 bool is_off_the_record, | 48 bool is_incognito, |
49 int request_id) { | 49 int request_id) { |
50 SetFontAndTextDirection(localized_strings_.get()); | 50 SetFontAndTextDirection(localized_strings_.get()); |
51 | 51 |
52 static const base::StringPiece html( | 52 static const base::StringPiece html( |
53 ResourceBundle::GetSharedInstance().GetRawDataResource( | 53 ResourceBundle::GetSharedInstance().GetRawDataResource( |
54 IDR_PROXY_SETTINGS_HTML)); | 54 IDR_PROXY_SETTINGS_HTML)); |
55 const std::string full_html = jstemplate_builder::GetI18nTemplateHtml( | 55 const std::string full_html = jstemplate_builder::GetI18nTemplateHtml( |
56 html, localized_strings_.get()); | 56 html, localized_strings_.get()); |
57 | 57 |
58 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); | 58 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 void ProxySettingsUI::InitializeHandlers() { | 97 void ProxySettingsUI::InitializeHandlers() { |
98 std::vector<WebUIMessageHandler*>::iterator iter; | 98 std::vector<WebUIMessageHandler*>::iterator iter; |
99 // Skip over the generic handler. | 99 // Skip over the generic handler. |
100 for (iter = handlers_.begin() + 1; iter != handlers_.end(); ++iter) { | 100 for (iter = handlers_.begin() + 1; iter != handlers_.end(); ++iter) { |
101 (static_cast<OptionsPageUIHandler*>(*iter))->Initialize(); | 101 (static_cast<OptionsPageUIHandler*>(*iter))->Initialize(); |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 } // namespace chromeos | 105 } // namespace chromeos |
OLD | NEW |