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

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: png viewer works sorta 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
« no previous file with comments | « no previous file | mojo/examples/nesting_app/nesting_app.cc » ('j') | mojo/examples/png_viewer/png_viewer.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 fd5877336a195fd98a03075a4f1c59bd8ee17e51..dcf07d00ad43a531f0bc71a16bdfe244ec6e5488 100644
--- a/mojo/examples/embedded_app/embedded_app.cc
+++ b/mojo/examples/embedded_app/embedded_app.cc
@@ -23,21 +23,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,
@@ -45,18 +37,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:
@@ -70,7 +55,6 @@ class EmbeddedApp
virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
MOJO_OVERRIDE {
connection->AddService(&view_manager_client_factory_);
- connection->AddService(&navigator_factory_);
return true;
}
@@ -81,7 +65,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();
@@ -104,53 +88,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
// static
« no previous file with comments | « no previous file | mojo/examples/nesting_app/nesting_app.cc » ('j') | mojo/examples/png_viewer/png_viewer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698