Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(485)

Side by Side Diff: ios/web/webui/web_ui_ios_data_source_impl.h

Issue 1110213002: Upstream most of the iOS WebUI support in ios/web/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 IOS_WEB_WEBUI_WEB_UI_IOS_DATA_SOURCE_IMPL_H_
6 #define IOS_WEB_WEBUI_WEB_UI_IOS_DATA_SOURCE_IMPL_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/compiler_specific.h"
14 #include "base/values.h"
15 #include "ios/web/public/url_data_source_ios.h"
16 #include "ios/web/public/web_ui_ios_data_source.h"
17 #include "ios/web/webui/url_data_manager_ios.h"
18 #include "ios/web/webui/url_data_source_ios_impl.h"
19
20 namespace web {
21
22 class WebUIIOSDataSourceImpl : public URLDataSourceIOSImpl,
23 public WebUIIOSDataSource {
24 public:
25 // WebUIIOSDataSource implementation:
26 void AddString(const std::string& name, const base::string16& value) override;
27 void AddString(const std::string& name, const std::string& value) override;
28 void AddLocalizedString(const std::string& name, int ids) override;
29 void AddBoolean(const std::string& name, bool value) override;
30 void SetJsonPath(const std::string& path) override;
31 void AddResourcePath(const std::string& path, int resource_id) override;
32 void SetDefaultResource(int resource_id) override;
33 void DisableDenyXFrameOptions() override;
34
35 protected:
36 ~WebUIIOSDataSourceImpl() override;
37
38 // Completes a request by sending our dictionary of localized strings.
39 void SendLocalizedStringsAsJSON(
40 const URLDataSourceIOS::GotDataCallback& callback);
41
42 // Completes a request by sending the file specified by |idr|.
43 void SendFromResourceBundle(const URLDataSourceIOS::GotDataCallback& callback,
44 int idr);
45
46 private:
47 class InternalDataSource;
48 friend class InternalDataSource;
49 friend class WebUIIOSDataSourceTest;
50 friend class WebUIIOSDataSource;
51
52 explicit WebUIIOSDataSourceImpl(const std::string& source_name);
53
54 // Methods that match URLDataSource which are called by
55 // InternalDataSource.
56 std::string GetSource() const;
57 std::string GetMimeType(const std::string& path) const;
58 void StartDataRequest(const std::string& path,
59 const URLDataSourceIOS::GotDataCallback& callback);
60
61 void disable_set_font_strings_for_testing() {
62 disable_set_font_strings_ = true;
63 }
64
65 // The name of this source.
66 // E.g., for favicons, this could be "favicon", which results in paths for
67 // specific resources like "favicon/34" getting sent to this source.
68 std::string source_name_;
69 int default_resource_;
70 std::string json_path_;
71 std::map<std::string, int> path_to_idr_map_;
72 base::DictionaryValue localized_strings_;
73 bool deny_xframe_options_;
74 bool disable_set_font_strings_;
75 bool replace_existing_source_;
76
77 DISALLOW_COPY_AND_ASSIGN(WebUIIOSDataSourceImpl);
78 };
79
80 } // web
81
82 #endif // IOS_WEB_WEBUI_WEB_UI_IOS_DATA_SOURCE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698