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/uber/uber_ui.h" | 5 #include "chrome/browser/ui/webui/uber/uber_ui.h" |
6 | 6 |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 8 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
9 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 9 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
10 #include "chrome/browser/ui/webui/options2/options_ui.h" | 10 #include "chrome/browser/ui/webui/options/options_ui.h" |
11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
12 #include "content/browser/tab_contents/tab_contents.h" | 12 #include "content/browser/tab_contents/tab_contents.h" |
13 #include "grit/browser_resources.h" | 13 #include "grit/browser_resources.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 ChromeWebUIDataSource* CreateUberHTMLSource() { | 17 ChromeWebUIDataSource* CreateUberHTMLSource() { |
18 ChromeWebUIDataSource* source = | 18 ChromeWebUIDataSource* source = |
19 new ChromeWebUIDataSource(chrome::kChromeUIUberHost); | 19 new ChromeWebUIDataSource(chrome::kChromeUIUberHost); |
20 | 20 |
21 source->set_json_path("strings.js"); | 21 source->set_json_path("strings.js"); |
22 source->add_resource_path("uber.js", IDR_UBER_JS); | 22 source->add_resource_path("uber.js", IDR_UBER_JS); |
23 source->set_default_resource(IDR_UBER_HTML); | 23 source->set_default_resource(IDR_UBER_HTML); |
24 return source; | 24 return source; |
25 } | 25 } |
26 | 26 |
27 } // namespace | 27 } // namespace |
28 | 28 |
29 UberUI::UberUI(TabContents* contents) : ChromeWebUI(contents) { | 29 UberUI::UberUI(TabContents* contents) : ChromeWebUI(contents) { |
30 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); | 30 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); |
31 profile->GetChromeURLDataManager()->AddDataSource(CreateUberHTMLSource()); | 31 profile->GetChromeURLDataManager()->AddDataSource(CreateUberHTMLSource()); |
32 | 32 |
33 ChromeWebUI* options = new Options2UI(contents); | 33 ChromeWebUI* options = new OptionsUI(contents); |
34 options->set_frame_xpath("//iframe[@id='settings']"); | 34 options->set_frame_xpath("//iframe[@id='settings']"); |
35 sub_uis_.push_back(options); | 35 sub_uis_.push_back(options); |
36 } | 36 } |
37 | 37 |
38 UberUI::~UberUI() { | 38 UberUI::~UberUI() { |
39 } | 39 } |
40 | 40 |
41 void UberUI::RenderViewCreated(RenderViewHost* render_view_host) { | 41 void UberUI::RenderViewCreated(RenderViewHost* render_view_host) { |
42 for (size_t i = 0; i < sub_uis_.size(); i++) { | 42 for (size_t i = 0; i < sub_uis_.size(); i++) { |
43 sub_uis_[i]->RenderViewCreated(render_view_host); | 43 sub_uis_[i]->RenderViewCreated(render_view_host); |
(...skipping 22 matching lines...) Expand all Loading... |
66 const std::string& message, | 66 const std::string& message, |
67 const ListValue& args) { | 67 const ListValue& args) { |
68 // TODO(estade): This should only send the message to the appropriate | 68 // TODO(estade): This should only send the message to the appropriate |
69 // subpage (if any), not all of them. | 69 // subpage (if any), not all of them. |
70 for (size_t i = 0; i < sub_uis_.size(); i++) { | 70 for (size_t i = 0; i < sub_uis_.size(); i++) { |
71 sub_uis_[i]->OnWebUISend(source_url, message, args); | 71 sub_uis_[i]->OnWebUISend(source_url, message, args); |
72 } | 72 } |
73 | 73 |
74 ChromeWebUI::OnWebUISend(source_url, message, args); | 74 ChromeWebUI::OnWebUISend(source_url, message, args); |
75 } | 75 } |
OLD | NEW |