diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-19 19:53:56 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-19 19:53:56 +0000 |
commit | d2353452f11b73f763ea0be9f1a608d03cfddeac (patch) | |
tree | 909d363b7ace6f5ca757cf5099e1bae6f9f3f626 /content/browser | |
parent | 78c3d8db2b114b626562bba08f6a91f1ddac566f (diff) | |
download | chromium_src-d2353452f11b73f763ea0be9f1a608d03cfddeac.zip chromium_src-d2353452f11b73f763ea0be9f1a608d03cfddeac.tar.gz chromium_src-d2353452f11b73f763ea0be9f1a608d03cfddeac.tar.bz2 |
Rename WebUI to WebUIImpl.
BUG=98716
Review URL: https://chromiumcodereview.appspot.com/9150021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118337 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
-rw-r--r-- | content/browser/browser_url_handler.cc | 2 | ||||
-rw-r--r-- | content/browser/tab_contents/render_view_host_manager.cc | 4 | ||||
-rw-r--r-- | content/browser/tab_contents/render_view_host_manager.h | 14 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.cc | 14 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.h | 2 | ||||
-rw-r--r-- | content/browser/webui/generic_handler.cc | 2 | ||||
-rw-r--r-- | content/browser/webui/web_ui_impl.cc (renamed from content/browser/webui/web_ui.cc) | 82 | ||||
-rw-r--r-- | content/browser/webui/web_ui_impl.h (renamed from content/browser/webui/web_ui.h) | 16 | ||||
-rw-r--r-- | content/browser/webui/web_ui_message_handler_unittest.cc (renamed from content/browser/webui/web_ui_unittest.cc) | 41 |
9 files changed, 84 insertions, 93 deletions
diff --git a/content/browser/browser_url_handler.cc b/content/browser/browser_url_handler.cc index cf05366..c42024d 100644 --- a/content/browser/browser_url_handler.cc +++ b/content/browser/browser_url_handler.cc @@ -5,7 +5,7 @@ #include "content/browser/browser_url_handler.h" #include "base/string_util.h" -#include "content/browser/webui/web_ui.h" +#include "content/browser/webui/web_ui_impl.h" #include "content/public/browser/content_browser_client.h" #include "content/public/common/url_constants.h" #include "googleurl/src/gurl.h" diff --git a/content/browser/tab_contents/render_view_host_manager.cc b/content/browser/tab_contents/render_view_host_manager.cc index 4a968ed..f2ea2ae 100644 --- a/content/browser/tab_contents/render_view_host_manager.cc +++ b/content/browser/tab_contents/render_view_host_manager.cc @@ -15,7 +15,7 @@ #include "content/browser/site_instance.h" #include "content/browser/tab_contents/navigation_controller_impl.h" #include "content/browser/tab_contents/navigation_entry_impl.h" -#include "content/browser/webui/web_ui.h" +#include "content/browser/webui/web_ui_impl.h" #include "content/common/view_messages.h" #include "content/public/browser/content_browser_client.h" #include "content/public/browser/notification_service.h" @@ -216,7 +216,7 @@ void RenderViewHostManager::DidNavigateMainFrame( } } -void RenderViewHostManager::SetWebUIPostCommit(WebUI* web_ui) { +void RenderViewHostManager::SetWebUIPostCommit(WebUIImpl* web_ui) { DCHECK(!web_ui_.get()); web_ui_.reset(web_ui); } diff --git a/content/browser/tab_contents/render_view_host_manager.h b/content/browser/tab_contents/render_view_host_manager.h index 84eff55..ae15dca 100644 --- a/content/browser/tab_contents/render_view_host_manager.h +++ b/content/browser/tab_contents/render_view_host_manager.h @@ -19,7 +19,7 @@ class InterstitialPage; class NavigationControllerImpl; class RenderViewHost; class RenderWidgetHostView; -class WebUI; +class WebUIImpl; namespace content { class BrowserContext; @@ -68,7 +68,7 @@ class CONTENT_EXPORT RenderViewHostManager // Creates a WebUI object for the given URL if one applies. Ownership of the // returned pointer will be passed to the caller. If no WebUI applies, // returns NULL. - virtual WebUI* CreateWebUIForRenderManager(const GURL& url) = 0; + virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) = 0; // Returns the navigation entry of the current navigation, or NULL if there // is none. @@ -123,10 +123,10 @@ class CONTENT_EXPORT RenderViewHostManager } // Returns the current committed Web UI or NULL if none applies. - WebUI* web_ui() const { return web_ui_.get(); } + WebUIImpl* web_ui() const { return web_ui_.get(); } // Returns the Web UI for the pending navigation, or NULL of none applies. - WebUI* pending_web_ui() const { return pending_web_ui_.get(); } + WebUIImpl* pending_web_ui() const { return pending_web_ui_.get(); } // Called when we want to instruct the renderer to navigate to the given // navigation entry. It may create a new RenderViewHost or re-use an existing @@ -154,7 +154,7 @@ class CONTENT_EXPORT RenderViewHostManager // Set the WebUI after committing a page load. This is useful for navigations // initiated from a renderer, where we want to give the new renderer WebUI // privileges from the originating renderer. - void SetWebUIPostCommit(WebUI* web_ui); + void SetWebUIPostCommit(WebUIImpl* web_ui); // Called when a provisional load on the given renderer is aborted. void RendererAbortedProvisionalLoad(RenderViewHost* render_view_host); @@ -265,7 +265,7 @@ class CONTENT_EXPORT RenderViewHostManager // non-DOM-UI pages). This object is responsible for all communication with // a child RenderView instance. RenderViewHost* render_view_host_; - scoped_ptr<WebUI> web_ui_; + scoped_ptr<WebUIImpl> web_ui_; // A RenderViewHost used to load a cross-site page. This remains hidden // while a cross-site request is pending until it calls DidNavigate. It may @@ -277,7 +277,7 @@ class CONTENT_EXPORT RenderViewHostManager // the RVH won't be swapped, so the pending pointer will be unused, but there // will be a pending Web UI associated with the navigation. RenderViewHost* pending_render_view_host_; - scoped_ptr<WebUI> pending_web_ui_; + scoped_ptr<WebUIImpl> pending_web_ui_; // A map of site instance ID to swapped out RenderViewHosts. typedef base::hash_map<int32, RenderViewHost*> RenderViewHostMap; diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index be56eb2..1b6fe89 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -31,6 +31,7 @@ #include "content/browser/tab_contents/navigation_entry_impl.h" #include "content/browser/tab_contents/provisional_load_details.h" #include "content/browser/tab_contents/title_updated_details.h" +#include "content/browser/webui/web_ui_impl.h" #include "content/common/intents_messages.h" #include "content/common/view_messages.h" #include "content/public/browser/browser_context.h" @@ -122,6 +123,7 @@ using content::SSLStatus; using content::UserMetricsAction; using content::WebContents; using content::WebContentsObserver; +using content::WebUI; using content::WebUIController; namespace { @@ -304,8 +306,10 @@ RenderViewHostManager* TabContents::GetRenderManagerForTesting() { } bool TabContents::OnMessageReceived(const IPC::Message& message) { - if (GetWebUI() && static_cast<WebUI*>(GetWebUI())->OnMessageReceived(message)) + if (GetWebUI() && + static_cast<WebUIImpl*>(GetWebUI())->OnMessageReceived(message)) { return true; + } ObserverListBase<WebContentsObserver>::Iterator it(observers_); WebContentsObserver* observer; @@ -434,7 +438,7 @@ content::WebContentsView* TabContents::GetView() const { } content::WebUI* TabContents::CreateWebUI(const GURL& url) { - WebUI* web_ui = new WebUI(this); + WebUIImpl* web_ui = new WebUIImpl(this); WebUIController* controller = content::GetContentClient()->browser()->GetWebUIFactory()-> CreateWebUIForURL(web_ui, url); @@ -1481,7 +1485,7 @@ void TabContents::DidNavigateMainFramePostCommit( // that opened the window, as long as both renderers have the same // privileges. if (delegate_ && opener_web_ui_type_ == GetWebUITypeForCurrentState()) { - WebUI* web_ui = static_cast<WebUI*>(CreateWebUI(GetURL())); + WebUIImpl* web_ui = static_cast<WebUIImpl*>(CreateWebUI(GetURL())); // web_ui might be NULL if the URL refers to a non-existent extension. if (web_ui) { render_manager_.SetWebUIPostCommit(web_ui); @@ -2192,8 +2196,8 @@ NavigationControllerImpl& TabContents::GetControllerForRenderManager() { return GetControllerImpl(); } -WebUI* TabContents::CreateWebUIForRenderManager(const GURL& url) { - return static_cast<WebUI*>(CreateWebUI(url)); +WebUIImpl* TabContents::CreateWebUIForRenderManager(const GURL& url) { + return static_cast<WebUIImpl*>(CreateWebUI(url)); } NavigationEntry* diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index 65519d6..058e650 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -326,7 +326,7 @@ class CONTENT_EXPORT TabContents virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE; virtual void NotifySwappedFromRenderManager() OVERRIDE; virtual NavigationControllerImpl& GetControllerForRenderManager() OVERRIDE; - virtual WebUI* CreateWebUIForRenderManager(const GURL& url) OVERRIDE; + virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) OVERRIDE; virtual content::NavigationEntry* GetLastCommittedNavigationEntryForRenderManager() OVERRIDE; virtual bool FocusLocationBarByDefault() OVERRIDE; diff --git a/content/browser/webui/generic_handler.cc b/content/browser/webui/generic_handler.cc index 8d401ad..bcd0868 100644 --- a/content/browser/webui/generic_handler.cc +++ b/content/browser/webui/generic_handler.cc @@ -9,7 +9,7 @@ #include "base/logging.h" #include "base/values.h" #include "content/browser/disposition_utils.h" -#include "content/browser/webui/web_ui.h" +#include "content/browser/webui/web_ui_impl.h" #include "content/public/browser/web_contents.h" using content::OpenURLParams; diff --git a/content/browser/webui/web_ui.cc b/content/browser/webui/web_ui_impl.cc index 2ffd763..36e021d 100644 --- a/content/browser/webui/web_ui.cc +++ b/content/browser/webui/web_ui_impl.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/webui/web_ui.h" +#include "content/browser/webui/web_ui_impl.h" #include "base/command_line.h" #include "base/json/json_writer.h" @@ -47,7 +47,7 @@ string16 WebUI::GetJavascriptCall( } -WebUI::WebUI(WebContents* contents) +WebUIImpl::WebUIImpl(WebContents* contents) : hide_favicon_(false), focus_location_bar_by_default_(false), should_hide_url_(false), @@ -58,27 +58,27 @@ WebUI::WebUI(WebContents* contents) AddMessageHandler(new GenericHandler()); } -WebUI::~WebUI() { +WebUIImpl::~WebUIImpl() { // Delete the controller first, since it may also be keeping a pointer to some // of the handlers and can call them at destruction. controller_.reset(); STLDeleteContainerPointers(handlers_.begin(), handlers_.end()); } -// WebUI, public: ------------------------------------------------------------- +// WebUIImpl, public: ---------------------------------------------------------- -bool WebUI::OnMessageReceived(const IPC::Message& message) { +bool WebUIImpl::OnMessageReceived(const IPC::Message& message) { bool handled = true; - IPC_BEGIN_MESSAGE_MAP(WebUI, message) + IPC_BEGIN_MESSAGE_MAP(WebUIImpl, message) IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; } -void WebUI::OnWebUISend(const GURL& source_url, - const std::string& message, - const ListValue& args) { +void WebUIImpl::OnWebUISend(const GURL& source_url, + const std::string& message, + const ListValue& args) { if (!ChildProcessSecurityPolicy::GetInstance()-> HasWebUIBindings(web_contents_->GetRenderProcessHost()->GetID())) { NOTREACHED() << "Blocked unauthorized use of WebUIBindings."; @@ -97,7 +97,7 @@ void WebUI::OnWebUISend(const GURL& source_url, } } -void WebUI::RenderViewCreated(RenderViewHost* render_view_host) { +void WebUIImpl::RenderViewCreated(RenderViewHost* render_view_host) { controller_->RenderViewCreated(render_view_host); // Do not attempt to set the toolkit property if WebUI is not enabled, e.g., @@ -119,85 +119,85 @@ void WebUI::RenderViewCreated(RenderViewHost* render_view_host) { render_view_host->SetWebUIProperty("touchOptimized", "true"); } -WebContents* WebUI::GetWebContents() const { +WebContents* WebUIImpl::GetWebContents() const { return web_contents_; } -bool WebUI::ShouldHideFavicon() const { +bool WebUIImpl::ShouldHideFavicon() const { return hide_favicon_; } -void WebUI::HideFavicon() { +void WebUIImpl::HideFavicon() { hide_favicon_ = true; } -bool WebUI::ShouldFocusLocationBarByDefault() const { +bool WebUIImpl::ShouldFocusLocationBarByDefault() const { return focus_location_bar_by_default_; } -void WebUI::FocusLocationBarByDefault() { +void WebUIImpl::FocusLocationBarByDefault() { focus_location_bar_by_default_ = true; } -bool WebUI::ShouldHideURL() const { +bool WebUIImpl::ShouldHideURL() const { return should_hide_url_; } -void WebUI::HideURL() { +void WebUIImpl::HideURL() { should_hide_url_ = true; } -const string16& WebUI::GetOverriddenTitle() const { +const string16& WebUIImpl::GetOverriddenTitle() const { return overridden_title_; } -void WebUI::OverrideTitle(const string16& title) { +void WebUIImpl::OverrideTitle(const string16& title) { overridden_title_ = title; } -content::PageTransition WebUI::GetLinkTransitionType() const { +content::PageTransition WebUIImpl::GetLinkTransitionType() const { return link_transition_type_; } -void WebUI::SetLinkTransitionType(content::PageTransition type) { +void WebUIImpl::SetLinkTransitionType(content::PageTransition type) { link_transition_type_ = type; } -int WebUI::GetBindings() const { +int WebUIImpl::GetBindings() const { return bindings_; } -void WebUI::SetBindings(int bindings) { +void WebUIImpl::SetBindings(int bindings) { bindings_ = bindings; } -void WebUI::SetFrameXPath(const std::string& xpath) { +void WebUIImpl::SetFrameXPath(const std::string& xpath) { frame_xpath_ = xpath; } -WebUIController* WebUI::GetController() const { +WebUIController* WebUIImpl::GetController() const { return controller_.get(); } -void WebUI::SetController(WebUIController* controller) { +void WebUIImpl::SetController(WebUIController* controller) { controller_.reset(controller); } -void WebUI::CallJavascriptFunction(const std::string& function_name) { +void WebUIImpl::CallJavascriptFunction(const std::string& function_name) { DCHECK(IsStringASCII(function_name)); string16 javascript = ASCIIToUTF16(function_name + "();"); ExecuteJavascript(javascript); } -void WebUI::CallJavascriptFunction(const std::string& function_name, - const Value& arg) { +void WebUIImpl::CallJavascriptFunction(const std::string& function_name, + const Value& arg) { DCHECK(IsStringASCII(function_name)); std::vector<const Value*> args; args.push_back(&arg); ExecuteJavascript(GetJavascriptCall(function_name, args)); } -void WebUI::CallJavascriptFunction( +void WebUIImpl::CallJavascriptFunction( const std::string& function_name, const Value& arg1, const Value& arg2) { DCHECK(IsStringASCII(function_name)); @@ -207,7 +207,7 @@ void WebUI::CallJavascriptFunction( ExecuteJavascript(GetJavascriptCall(function_name, args)); } -void WebUI::CallJavascriptFunction( +void WebUIImpl::CallJavascriptFunction( const std::string& function_name, const Value& arg1, const Value& arg2, const Value& arg3) { DCHECK(IsStringASCII(function_name)); @@ -218,7 +218,7 @@ void WebUI::CallJavascriptFunction( ExecuteJavascript(GetJavascriptCall(function_name, args)); } -void WebUI::CallJavascriptFunction( +void WebUIImpl::CallJavascriptFunction( const std::string& function_name, const Value& arg1, const Value& arg2, @@ -233,34 +233,34 @@ void WebUI::CallJavascriptFunction( ExecuteJavascript(GetJavascriptCall(function_name, args)); } -void WebUI::CallJavascriptFunction( +void WebUIImpl::CallJavascriptFunction( const std::string& function_name, const std::vector<const Value*>& args) { DCHECK(IsStringASCII(function_name)); ExecuteJavascript(GetJavascriptCall(function_name, args)); } -void WebUI::RegisterMessageCallback(const std::string &message, - const MessageCallback& callback) { +void WebUIImpl::RegisterMessageCallback(const std::string &message, + const MessageCallback& callback) { message_callbacks_.insert(std::make_pair(message, callback)); } -void WebUI::ProcessWebUIMessage(const GURL& source_url, - const std::string& message, - const base::ListValue& args) { +void WebUIImpl::ProcessWebUIMessage(const GURL& source_url, + const std::string& message, + const base::ListValue& args) { OnWebUISend(source_url, message, args); } -// WebUI, protected: ---------------------------------------------------------- +// WebUIImpl, protected: ------------------------------------------------------- -void WebUI::AddMessageHandler(WebUIMessageHandler* handler) { +void WebUIImpl::AddMessageHandler(WebUIMessageHandler* handler) { DCHECK(!handler->web_ui()); handler->set_web_ui(this); handler->RegisterMessages(); handlers_.push_back(handler); } -void WebUI::ExecuteJavascript(const string16& javascript) { +void WebUIImpl::ExecuteJavascript(const string16& javascript) { web_contents_->GetRenderViewHost()->ExecuteJavascriptInWebFrame( ASCIIToUTF16(frame_xpath_), javascript); } diff --git a/content/browser/webui/web_ui.h b/content/browser/webui/web_ui_impl.h index 63a6dcb..eef3948 100644 --- a/content/browser/webui/web_ui.h +++ b/content/browser/webui/web_ui_impl.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_BROWSER_WEBUI_WEB_UI_H_ -#define CONTENT_BROWSER_WEBUI_WEB_UI_H_ +#ifndef CONTENT_BROWSER_WEBUI_WEB_UI_IMPL_H_ +#define CONTENT_BROWSER_WEBUI_WEB_UI_IMPL_H_ #pragma once #include <map> @@ -14,11 +14,11 @@ class RenderViewHost; -class CONTENT_EXPORT WebUI : public content::WebUI, - public IPC::Channel::Listener { +class CONTENT_EXPORT WebUIImpl : public content::WebUI, + public IPC::Channel::Listener { public: - explicit WebUI(content::WebContents* contents); - virtual ~WebUI(); + explicit WebUIImpl(content::WebContents* contents); + virtual ~WebUIImpl(); // Called by TabContents when the RenderView is first created. This is *not* // called for every page load because in some cases RenderViewHostManager will @@ -109,7 +109,7 @@ class CONTENT_EXPORT WebUI : public content::WebUI, scoped_ptr<content::WebUIController> controller_; - DISALLOW_COPY_AND_ASSIGN(WebUI); + DISALLOW_COPY_AND_ASSIGN(WebUIImpl); }; -#endif // CONTENT_BROWSER_WEBUI_WEB_UI_H_ +#endif // CONTENT_BROWSER_WEBUI_WEB_UI_IMPL_H_ diff --git a/content/browser/webui/web_ui_unittest.cc b/content/browser/webui/web_ui_message_handler_unittest.cc index 93e597f..23ff85c 100644 --- a/content/browser/webui/web_ui_unittest.cc +++ b/content/browser/webui/web_ui_message_handler_unittest.cc @@ -2,73 +2,60 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/webui/web_ui.h" +#include "content/public/browser/web_ui_message_handler.h" #include "base/string16.h" +#include "base/utf_string_conversions.h" #include "base/values.h" #include "testing/gtest/include/gtest/gtest.h" -class TestWebUIMessageHandler : public WebUIMessageHandler { - public: - TestWebUIMessageHandler() {} - virtual ~TestWebUIMessageHandler() {} - - protected: - virtual void RegisterMessages() {} - - private: - DISALLOW_COPY_AND_ASSIGN(TestWebUIMessageHandler); -}; +namespace content { TEST(WebUIMessageHandlerTest, ExtractIntegerValue) { - TestWebUIMessageHandler handler; - ListValue list; int value, zero_value = 0, neg_value = -1234, pos_value = 1234; list.Append(Value::CreateIntegerValue(zero_value)); - EXPECT_TRUE(handler.ExtractIntegerValue(&list, &value)); + EXPECT_TRUE(WebUIMessageHandler::ExtractIntegerValue(&list, &value)); EXPECT_EQ(value, zero_value); list.Clear(); list.Append(Value::CreateIntegerValue(neg_value)); - EXPECT_TRUE(handler.ExtractIntegerValue(&list, &value)); + EXPECT_TRUE(WebUIMessageHandler::ExtractIntegerValue(&list, &value)); EXPECT_EQ(value, neg_value); list.Clear(); list.Append(Value::CreateIntegerValue(pos_value)); - EXPECT_TRUE(handler.ExtractIntegerValue(&list, &value)); + EXPECT_TRUE(WebUIMessageHandler::ExtractIntegerValue(&list, &value)); EXPECT_EQ(value, pos_value); } TEST(WebUIMessageHandlerTest, ExtractDoubleValue) { - TestWebUIMessageHandler handler; - ListValue list; double value, zero_value = 0.0, neg_value = -1234.5, pos_value = 1234.5; list.Append(Value::CreateDoubleValue(zero_value)); - EXPECT_TRUE(handler.ExtractDoubleValue(&list, &value)); + EXPECT_TRUE(WebUIMessageHandler::ExtractDoubleValue(&list, &value)); EXPECT_EQ(value, zero_value); list.Clear(); list.Append(Value::CreateDoubleValue(neg_value)); - EXPECT_TRUE(handler.ExtractDoubleValue(&list, &value)); + EXPECT_TRUE(WebUIMessageHandler::ExtractDoubleValue(&list, &value)); EXPECT_EQ(value, neg_value); list.Clear(); list.Append(Value::CreateDoubleValue(pos_value)); - EXPECT_TRUE(handler.ExtractDoubleValue(&list, &value)); + EXPECT_TRUE(WebUIMessageHandler::ExtractDoubleValue(&list, &value)); EXPECT_EQ(value, pos_value); } TEST(WebUIMessageHandlerTest, ExtractStringValue) { - TestWebUIMessageHandler handler; - ListValue list; - string16 in_string = "The facts, though interesting, are irrelevant." - list.Append(Value::CreateStringValue(string)); - string16 out_string = handler.ExtractStringValue(&list); + string16 in_string(UTF8ToUTF16( + "The facts, though interesting, are irrelevant.")); + list.Append(Value::CreateStringValue(in_string)); + string16 out_string = WebUIMessageHandler::ExtractStringValue(&list); EXPECT_STREQ(in_string.c_str(), out_string.c_str()); } +} // namespace content |