OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/webui/uber/uber_ui.h" | |
6 | |
7 #include "base/stl_util.h" | |
8 #include "chrome/browser/profiles/profile.h" | |
9 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | |
10 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | |
11 #include "chrome/browser/ui/webui/options/options_ui.h" | |
12 #include "chrome/common/url_constants.h" | |
13 #include "content/browser/tab_contents/tab_contents.h" | |
14 #include "grit/browser_resources.h" | |
15 | |
16 namespace { | |
17 | |
18 ChromeWebUIDataSource* CreateUberHTMLSource() { | |
19 ChromeWebUIDataSource* source = | |
20 new ChromeWebUIDataSource(chrome::kChromeUIUberHost); | |
21 | |
22 source->set_json_path("strings.js"); | |
23 source->add_resource_path("uber.js", IDR_UBER_JS); | |
24 source->set_default_resource(IDR_UBER_HTML); | |
25 return source; | |
26 } | |
27 | |
28 } // namespace | |
29 | |
30 UberUI::UberUI(TabContents* contents) : ChromeWebUI(contents) { | |
31 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); | |
32 profile->GetChromeURLDataManager()->AddDataSource(CreateUberHTMLSource()); | |
33 | |
34 ChromeWebUI* options = new OptionsUI(contents); | |
35 options->set_frame_xpath("//iframe[@id='settings']"); | |
arv (Not doing code reviews)
2011/12/09 06:47:44
Why xpath and not CSS selector?
| |
36 sub_uis_.push_back(options); | |
37 } | |
38 | |
39 UberUI::~UberUI() { | |
40 STLDeleteElements(&sub_uis_); | |
James Hawkins
2011/12/10 03:03:13
Use a ScopedVector.
Evan Stade
2011/12/13 00:15:27
Done.
| |
41 } | |
42 | |
43 void UberUI::RenderViewCreated(RenderViewHost* render_view_host) { | |
44 for (size_t i = 0; i < sub_uis_.size(); i++) { | |
45 sub_uis_[i]->RenderViewCreated(render_view_host); | |
46 } | |
47 | |
48 ChromeWebUI::RenderViewCreated(render_view_host); | |
49 } | |
50 | |
51 void UberUI::RenderViewReused(RenderViewHost* render_view_host) { | |
52 for (size_t i = 0; i < sub_uis_.size(); i++) { | |
53 sub_uis_[i]->RenderViewReused(render_view_host); | |
54 } | |
55 | |
56 ChromeWebUI::RenderViewReused(render_view_host); | |
57 } | |
58 | |
59 void UberUI::DidBecomeActiveForReusedRenderView() OVERRIDE { | |
60 for (size_t i = 0; i < sub_uis_.size(); i++) { | |
61 sub_uis_[i]->DidBecomeActiveForReusedRenderView(); | |
62 } | |
63 | |
64 ChromeWebUI::DidBecomeActiveForReusedRenderView(); | |
65 } | |
66 | |
67 void UberUI::OnWebUISend(const GURL& source_url, | |
68 const std::string& message, | |
69 const ListValue& args) { | |
70 for (size_t i = 0; i < sub_uis_.size(); i++) { | |
71 sub_uis_[i]->OnWebUISend(source_url, message, args); | |
72 } | |
73 | |
74 ChromeWebUI::OnWebUISend(source_url, message, args); | |
75 } | |
76 | |
77 /* | |
James Hawkins
2011/12/10 03:03:13
Remove?
Evan Stade
2011/12/13 00:15:27
Done.
| |
78 void UberUI::CallJavascriptFunction(const std::string& function_name, | |
79 const base::Value& arg) { | |
80 base::StringValue id_value(function_name); | |
81 WebUI::CallJavascriptFunction("postFunction", id_value, arg); | |
82 } | |
83 */ | |
OLD | NEW |