| 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/options2/options_ui2.h" | 5 #include "chrome/browser/ui/webui/options2/options_ui2.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 //////////////////////////////////////////////////////////////////////////////// | 104 //////////////////////////////////////////////////////////////////////////////// |
| 105 // | 105 // |
| 106 // OptionsUIHTMLSource | 106 // OptionsUIHTMLSource |
| 107 // | 107 // |
| 108 //////////////////////////////////////////////////////////////////////////////// | 108 //////////////////////////////////////////////////////////////////////////////// |
| 109 | 109 |
| 110 class OptionsUIHTMLSource : public ChromeURLDataManager::DataSource { | 110 class OptionsUIHTMLSource : public ChromeURLDataManager::DataSource { |
| 111 public: | 111 public: |
| 112 // The constructor takes over ownership of |localized_strings|. | 112 // The constructor takes over ownership of |localized_strings|. |
| 113 explicit OptionsUIHTMLSource(DictionaryValue* localized_strings); | 113 explicit OptionsUIHTMLSource(DictionaryValue* localized_strings); |
| 114 virtual ~OptionsUIHTMLSource(); | |
| 115 | 114 |
| 116 // Called when the network layer has requested a resource underneath | 115 // Called when the network layer has requested a resource underneath |
| 117 // the path we registered. | 116 // the path we registered. |
| 118 virtual void StartDataRequest(const std::string& path, | 117 virtual void StartDataRequest(const std::string& path, |
| 119 bool is_incognito, | 118 bool is_incognito, |
| 120 int request_id); | 119 int request_id); |
| 121 virtual std::string GetMimeType(const std::string&) const; | 120 virtual std::string GetMimeType(const std::string&) const; |
| 122 | 121 |
| 123 private: | 122 private: |
| 123 virtual ~OptionsUIHTMLSource(); |
| 124 |
| 124 // Localized strings collection. | 125 // Localized strings collection. |
| 125 scoped_ptr<DictionaryValue> localized_strings_; | 126 scoped_ptr<DictionaryValue> localized_strings_; |
| 126 | 127 |
| 127 DISALLOW_COPY_AND_ASSIGN(OptionsUIHTMLSource); | 128 DISALLOW_COPY_AND_ASSIGN(OptionsUIHTMLSource); |
| 128 }; | 129 }; |
| 129 | 130 |
| 130 OptionsUIHTMLSource::OptionsUIHTMLSource(DictionaryValue* localized_strings) | 131 OptionsUIHTMLSource::OptionsUIHTMLSource(DictionaryValue* localized_strings) |
| 131 : DataSource(chrome::kChromeUISettingsFrameHost, MessageLoop::current()) { | 132 : DataSource(chrome::kChromeUISettingsFrameHost, MessageLoop::current()) { |
| 132 DCHECK(localized_strings); | 133 DCHECK(localized_strings); |
| 133 localized_strings_.reset(localized_strings); | 134 localized_strings_.reset(localized_strings); |
| 134 } | 135 } |
| 135 | 136 |
| 136 OptionsUIHTMLSource::~OptionsUIHTMLSource() {} | |
| 137 | |
| 138 void OptionsUIHTMLSource::StartDataRequest(const std::string& path, | 137 void OptionsUIHTMLSource::StartDataRequest(const std::string& path, |
| 139 bool is_incognito, | 138 bool is_incognito, |
| 140 int request_id) { | 139 int request_id) { |
| 141 scoped_refptr<RefCountedMemory> response_bytes; | 140 scoped_refptr<RefCountedMemory> response_bytes; |
| 142 SetFontAndTextDirection(localized_strings_.get()); | 141 SetFontAndTextDirection(localized_strings_.get()); |
| 143 | 142 |
| 144 if (path == kLocalizedStringsFile) { | 143 if (path == kLocalizedStringsFile) { |
| 145 // Return dynamically-generated strings from memory. | 144 // Return dynamically-generated strings from memory. |
| 146 std::string strings_js; | 145 std::string strings_js; |
| 147 jstemplate_builder::AppendJsonJS(localized_strings_.get(), &strings_js); | 146 jstemplate_builder::AppendJsonJS(localized_strings_.get(), &strings_js); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 159 SendResponse(request_id, response_bytes); | 158 SendResponse(request_id, response_bytes); |
| 160 } | 159 } |
| 161 | 160 |
| 162 std::string OptionsUIHTMLSource::GetMimeType(const std::string& path) const { | 161 std::string OptionsUIHTMLSource::GetMimeType(const std::string& path) const { |
| 163 if (path == kLocalizedStringsFile || path == kOptionsBundleJsFile) | 162 if (path == kLocalizedStringsFile || path == kOptionsBundleJsFile) |
| 164 return "application/javascript"; | 163 return "application/javascript"; |
| 165 | 164 |
| 166 return "text/html"; | 165 return "text/html"; |
| 167 } | 166 } |
| 168 | 167 |
| 168 OptionsUIHTMLSource::~OptionsUIHTMLSource() {} |
| 169 |
| 169 //////////////////////////////////////////////////////////////////////////////// | 170 //////////////////////////////////////////////////////////////////////////////// |
| 170 // | 171 // |
| 171 // OptionsPageUIHandler | 172 // OptionsPageUIHandler |
| 172 // | 173 // |
| 173 //////////////////////////////////////////////////////////////////////////////// | 174 //////////////////////////////////////////////////////////////////////////////// |
| 174 | 175 |
| 175 OptionsPageUIHandler::OptionsPageUIHandler() { | 176 OptionsPageUIHandler::OptionsPageUIHandler() { |
| 176 } | 177 } |
| 177 | 178 |
| 178 OptionsPageUIHandler::~OptionsPageUIHandler() { | 179 OptionsPageUIHandler::~OptionsPageUIHandler() { |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 WideToASCII(CommandLine::ForCurrentProcess()->GetCommandLineString()); | 421 WideToASCII(CommandLine::ForCurrentProcess()->GetCommandLineString()); |
| 421 #else | 422 #else |
| 422 command_line_string = | 423 command_line_string = |
| 423 CommandLine::ForCurrentProcess()->GetCommandLineString(); | 424 CommandLine::ForCurrentProcess()->GetCommandLineString(); |
| 424 #endif | 425 #endif |
| 425 | 426 |
| 426 render_view_host->SetWebUIProperty("commandLineString", command_line_string); | 427 render_view_host->SetWebUIProperty("commandLineString", command_line_string); |
| 427 } | 428 } |
| 428 | 429 |
| 429 } // namespace options2 | 430 } // namespace options2 |
| OLD | NEW |