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

Unified Diff: mojo/examples/embedded_app/embedded_app.cc

Issue 489493004: Update view manager to support content handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blah to the blizzah Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: mojo/examples/embedded_app/embedded_app.cc
diff --git a/mojo/examples/embedded_app/embedded_app.cc b/mojo/examples/embedded_app/embedded_app.cc
index c81c905db13e5b0acae6167269e6b5e37a65f8b9..906b904aa767781b1501af99c9a220c0b680133a 100644
--- a/mojo/examples/embedded_app/embedded_app.cc
+++ b/mojo/examples/embedded_app/embedded_app.cc
@@ -25,21 +25,13 @@
namespace mojo {
namespace examples {
-class EmbeddedApp;
-class NavigatorImpl : public InterfaceImpl<Navigator> {
- public:
- explicit NavigatorImpl(EmbeddedApp* app) : app_(app) {}
+const SkColor kColors[] = { SK_ColorYELLOW,
+ SK_ColorRED,
+ SK_ColorGREEN,
+ SK_ColorMAGENTA };
- private:
- virtual void Navigate(
- uint32 view_id,
- NavigationDetailsPtr navigation_details,
- ResponseDetailsPtr response_details) OVERRIDE;
-
- EmbeddedApp* app_;
- DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
-};
+class EmbeddedApp;
class EmbeddedApp
: public ApplicationDelegate,
@@ -47,18 +39,11 @@ class EmbeddedApp
public ViewObserver {
public:
EmbeddedApp()
- : navigator_factory_(this),
- view_manager_(NULL),
- view_manager_client_factory_(this) {
+ : view_manager_client_factory_(this) {
url::AddStandardScheme("mojo");
}
virtual ~EmbeddedApp() {}
- void SetViewColor(uint32 view_id, SkColor color) {
- pending_view_colors_[view_id] = color;
- ProcessPendingViewColor(view_id);
- }
-
private:
// Overridden from ApplicationDelegate:
@@ -72,7 +57,6 @@ class EmbeddedApp
virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
MOJO_OVERRIDE {
connection->AddService(&view_manager_client_factory_);
- connection->AddService(&navigator_factory_);
return true;
}
@@ -83,7 +67,7 @@ class EmbeddedApp
scoped_ptr<ServiceProvider> imported_services) OVERRIDE {
root->AddObserver(this);
roots_[root->id()] = root;
- ProcessPendingViewColor(root->id());
+ root->SetColor(kColors[next_color_++ % arraysize(kColors)]);
}
virtual void OnViewManagerDisconnected(ViewManager* view_manager) OVERRIDE {
base::MessageLoop::current()->Quit();
@@ -106,53 +90,17 @@ class EmbeddedApp
}
}
- void ProcessPendingViewColor(uint32 view_id) {
- RootMap::iterator root = roots_.find(view_id);
- if (root == roots_.end())
- return;
-
- PendingViewColors::iterator color = pending_view_colors_.find(view_id);
- if (color == pending_view_colors_.end())
- return;
-
- root->second->SetColor(color->second);
- pending_view_colors_.erase(color);
- }
-
- InterfaceFactoryImplWithContext<NavigatorImpl, EmbeddedApp>
- navigator_factory_;
-
- ViewManager* view_manager_;
NavigatorHostPtr navigator_host_;
ViewManagerClientFactory view_manager_client_factory_;
typedef std::map<Id, View*> RootMap;
RootMap roots_;
- // We can receive navigations for views we don't have yet.
- typedef std::map<uint32, SkColor> PendingViewColors;
- PendingViewColors pending_view_colors_;
+ int next_color_;
DISALLOW_COPY_AND_ASSIGN(EmbeddedApp);
};
-void NavigatorImpl::Navigate(uint32 view_id,
- NavigationDetailsPtr navigation_details,
- ResponseDetailsPtr response_details) {
- GURL url(navigation_details->request->url.To<std::string>());
- if (!url.is_valid()) {
- LOG(ERROR) << "URL is invalid.";
- return;
- }
- // TODO(aa): Verify new URL is same origin as current origin.
- SkColor color = 0x00;
- if (!base::HexStringToUInt(url.path().substr(1), &color)) {
- LOG(ERROR) << "Invalid URL, path not convertible to integer";
- return;
- }
- app_->SetViewColor(view_id, color);
-}
-
} // namespace examples
} // namespace mojo
« no previous file with comments | « mojo/examples/content_handler_demo/content_handler_demo.cc ('k') | mojo/examples/nesting_app/nesting_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698