diff --git a/DEPS b/DEPS
index 21e98e6..a79d852a 100644
--- a/DEPS
+++ b/DEPS
@@ -39,7 +39,7 @@
   # Three lines of non-changing comments so that
   # the commit queue can handle CLs rolling Skia
   # and whatever else without interference from each other.
-  'skia_revision': '964eec67760196585954203ba625e440607f7e92',
+  'skia_revision': 'ccce0e02576100e1baaab6b18d91acaff624753e',
   # Three lines of non-changing comments so that
   # the commit queue can handle CLs rolling V8
   # and whatever else without interference from each other.
@@ -179,7 +179,7 @@
     Var('chromium_git') + '/external/bidichecker/lib.git' + '@' + '97f2aa645b74c28c57eca56992235c79850fa9e0',
 
   'src/third_party/webgl/src':
-   Var('chromium_git') + '/external/khronosgroup/webgl.git' + '@' + '29258490ea902efba0cd3ef8200299b5c31d5d26',
+   Var('chromium_git') + '/external/khronosgroup/webgl.git' + '@' + '580ea2e50aa26d0ee44643bea68be827d6303967',
 
   'src/third_party/webdriver/pylib':
     Var('chromium_git') + '/external/selenium/py.git' + '@' + '5fd78261a75fe08d27ca4835fb6c5ce4b42275bd',
diff --git a/base/memory/shared_memory_handle_mac.cc b/base/memory/shared_memory_handle_mac.cc
index e8f772f..600d2bb 100644
--- a/base/memory/shared_memory_handle_mac.cc
+++ b/base/memory/shared_memory_handle_mac.cc
@@ -92,7 +92,9 @@
       kern_return_t kr = mach_port_mod_refs(mach_task_self(), memory_object_,
                                             MACH_PORT_RIGHT_SEND, 1);
       DCHECK_EQ(kr, KERN_SUCCESS);
-      return SharedMemoryHandle(*this);
+      SharedMemoryHandle handle(*this);
+      handle.SetOwnershipPassesToIPC(true);
+      return handle;
     }
   }
 }
diff --git a/base/memory/shared_memory_win.cc b/base/memory/shared_memory_win.cc
index 791db3f..d7545f7f 100644
--- a/base/memory/shared_memory_win.cc
+++ b/base/memory/shared_memory_win.cc
@@ -136,8 +136,11 @@
   BOOL success =
       ::DuplicateHandle(process, handle.GetHandle(), process, &duped_handle, 0,
                         FALSE, DUPLICATE_SAME_ACCESS);
-  if (success)
-    return SharedMemoryHandle(duped_handle, GetCurrentProcId());
+  if (success) {
+    base::SharedMemoryHandle handle(duped_handle, GetCurrentProcId());
+    handle.SetOwnershipPassesToIPC(true);
+    return handle;
+  }
   return SharedMemoryHandle();
 }
 
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 48a5e9a..4bb50bd 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -153,7 +153,7 @@
 #include "content/public/common/web_preferences.h"
 #include "device/devices_app/usb/public/interfaces/device_manager.mojom.h"
 #include "gin/v8_initializer.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "net/base/mime_util.h"
 #include "net/cookies/canonical_cookie.h"
 #include "net/cookies/cookie_options.h"
diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager.cc b/chrome/browser/chromeos/accessibility/accessibility_manager.cc
index b0a769c3..6da2f944 100644
--- a/chrome/browser/chromeos/accessibility/accessibility_manager.cc
+++ b/chrome/browser/chromeos/accessibility/accessibility_manager.cc
@@ -67,6 +67,7 @@
 #include "content/public/browser/web_ui.h"
 #include "content/public/common/content_switches.h"
 #include "extensions/browser/event_router.h"
+#include "extensions/browser/extension_api_frame_id_map.h"
 #include "extensions/browser/extension_registry.h"
 #include "extensions/browser/extension_system.h"
 #include "extensions/browser/file_reader.h"
@@ -127,20 +128,21 @@
     return;
   if (!extensions::TabHelper::FromWebContents(web_contents))
     extensions::TabHelper::CreateForWebContents(web_contents);
-  extensions::TabHelper::FromWebContents(web_contents)->script_executor()->
-      ExecuteScript(HostID(HostID::EXTENSIONS, extension_id),
-                    extensions::ScriptExecutor::JAVASCRIPT,
-                    code,
-                    extensions::ScriptExecutor::ALL_FRAMES,
-                    extensions::ScriptExecutor::DONT_MATCH_ABOUT_BLANK,
-                    extensions::UserScript::DOCUMENT_IDLE,
-                    extensions::ScriptExecutor::ISOLATED_WORLD,
-                    extensions::ScriptExecutor::DEFAULT_PROCESS,
-                    GURL(),  // No webview src.
-                    GURL(),  // No file url.
-                    false,  // Not user gesture.
-                    extensions::ScriptExecutor::NO_RESULT,
-                    extensions::ScriptExecutor::ExecuteScriptCallback());
+  extensions::TabHelper::FromWebContents(web_contents)
+      ->script_executor()
+      ->ExecuteScript(HostID(HostID::EXTENSIONS, extension_id),
+                      extensions::ScriptExecutor::JAVASCRIPT, code,
+                      extensions::ScriptExecutor::INCLUDE_SUB_FRAMES,
+                      extensions::ExtensionApiFrameIdMap::kTopFrameId,
+                      extensions::ScriptExecutor::DONT_MATCH_ABOUT_BLANK,
+                      extensions::UserScript::DOCUMENT_IDLE,
+                      extensions::ScriptExecutor::ISOLATED_WORLD,
+                      extensions::ScriptExecutor::DEFAULT_PROCESS,
+                      GURL(),  // No webview src.
+                      GURL(),  // No file url.
+                      false,   // Not user gesture.
+                      extensions::ScriptExecutor::NO_RESULT,
+                      extensions::ScriptExecutor::ExecuteScriptCallback());
 }
 
 // Helper class that directly loads an extension's content scripts into
diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc
index f7a1103..c9b67e1 100644
--- a/chrome/browser/extensions/api/tabs/tabs_api.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_api.cc
@@ -71,6 +71,7 @@
 #include "content/public/browser/web_contents.h"
 #include "content/public/common/url_constants.h"
 #include "extensions/browser/app_window/app_window.h"
+#include "extensions/browser/extension_api_frame_id_map.h"
 #include "extensions/browser/extension_function_dispatcher.h"
 #include "extensions/browser/extension_function_util.h"
 #include "extensions/browser/extension_host.h"
@@ -1359,10 +1360,10 @@
             net::UnescapeURLComponent(url.GetContent(),
                                       net::UnescapeRule::URL_SPECIAL_CHARS |
                                           net::UnescapeRule::SPACES),
-            ScriptExecutor::TOP_FRAME, ScriptExecutor::DONT_MATCH_ABOUT_BLANK,
-            UserScript::DOCUMENT_IDLE, ScriptExecutor::MAIN_WORLD,
-            ScriptExecutor::DEFAULT_PROCESS, GURL(), GURL(), user_gesture_,
-            ScriptExecutor::NO_RESULT,
+            ScriptExecutor::SINGLE_FRAME, ExtensionApiFrameIdMap::kTopFrameId,
+            ScriptExecutor::DONT_MATCH_ABOUT_BLANK, UserScript::DOCUMENT_IDLE,
+            ScriptExecutor::MAIN_WORLD, ScriptExecutor::DEFAULT_PROCESS, GURL(),
+            GURL(), user_gesture_, ScriptExecutor::NO_RESULT,
             base::Bind(&TabsUpdateFunction::OnExecuteCodeFinished, this));
 
     *is_async = true;
@@ -1898,13 +1899,45 @@
 
   CHECK(contents);
 
+  int frame_id = details_->frame_id ? *details_->frame_id
+                                    : ExtensionApiFrameIdMap::kTopFrameId;
+  content::RenderFrameHost* rfh =
+      ExtensionApiFrameIdMap::GetRenderFrameHostById(contents, frame_id);
+  if (!rfh) {
+    error_ = ErrorUtils::FormatErrorMessage(keys::kFrameNotFoundError,
+                                            base::IntToString(frame_id),
+                                            base::IntToString(execute_tab_id_));
+    return false;
+  }
+
+  // Content scripts declared in manifest.json can access frames at about:-URLs
+  // if the extension has permission to access the frame's origin, so also allow
+  // programmatic content scripts at about:-URLs for allowed origins.
+  GURL effective_document_url(rfh->GetLastCommittedURL());
+  bool is_about_url = effective_document_url.SchemeIs(url::kAboutScheme);
+  if (is_about_url && details_->match_about_blank &&
+      *details_->match_about_blank) {
+    effective_document_url = GURL(rfh->GetLastCommittedOrigin().Serialize());
+  }
+
+  if (!effective_document_url.is_valid()) {
+    // Unknown URL, e.g. because no load was committed yet. Allow for now, the
+    // renderer will check again and fail the injection if needed.
+    return true;
+  }
+
   // NOTE: This can give the wrong answer due to race conditions, but it is OK,
   // we check again in the renderer.
   if (!extension()->permissions_data()->CanAccessPage(
-          extension(),
-          contents->GetURL(),
-          execute_tab_id_,
-          &error_)) {
+          extension(), effective_document_url, execute_tab_id_, &error_)) {
+    if (is_about_url &&
+        extension()->permissions_data()->active_permissions().HasAPIPermission(
+            APIPermission::kTab)) {
+      error_ = ErrorUtils::FormatErrorMessage(
+          manifest_errors::kCannotAccessAboutUrl,
+          rfh->GetLastCommittedURL().spec(),
+          rfh->GetLastCommittedOrigin().Serialize());
+    }
     return false;
   }
 
diff --git a/chrome/browser/extensions/api/tabs/tabs_constants.cc b/chrome/browser/extensions/api/tabs/tabs_constants.cc
index 5a2a1c9..2903ee9c 100644
--- a/chrome/browser/extensions/api/tabs/tabs_constants.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_constants.cc
@@ -75,6 +75,7 @@
     "moved to and from normal windows.";
 const char kCanOnlyMoveTabsWithinSameProfileError[] = "Tabs can only be moved "
     "between windows in the same profile.";
+const char kFrameNotFoundError[] = "No frame with id * in tab *.";
 const char kNoCrashBrowserError[] =
     "I'm sorry. I'm afraid I can't do that.";
 const char kNoCurrentWindowError[] = "No current window";
diff --git a/chrome/browser/extensions/api/tabs/tabs_constants.h b/chrome/browser/extensions/api/tabs/tabs_constants.h
index df0064d..628f5ae 100644
--- a/chrome/browser/extensions/api/tabs/tabs_constants.h
+++ b/chrome/browser/extensions/api/tabs/tabs_constants.h
@@ -77,6 +77,7 @@
 
 // Error messages.
 extern const char kCannotZoomDisabledTabError[];
+extern const char kFrameNotFoundError[];
 extern const char kNoCrashBrowserError[];
 extern const char kNoCurrentWindowError[];
 extern const char kNoLastFocusedWindowError[];
diff --git a/chrome/browser/extensions/execute_script_apitest.cc b/chrome/browser/extensions/execute_script_apitest.cc
index 82f3eab..7f81895c 100644
--- a/chrome/browser/extensions/execute_script_apitest.cc
+++ b/chrome/browser/extensions/execute_script_apitest.cc
@@ -37,6 +37,12 @@
   ASSERT_TRUE(RunExtensionTest("executescript/in_frame")) << message_;
 }
 
+IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, ExecuteScriptByFrameId) {
+  SetupDelayedHostResolver();
+  ASSERT_TRUE(StartEmbeddedTestServer());
+  ASSERT_TRUE(RunExtensionTest("executescript/frame_id")) << message_;
+}
+
 // Fails often on Windows.
 // http://crbug.com/174715
 #if defined(OS_WIN)
diff --git a/chrome/browser/resources/chromeos/chromevox/chromevox.gni b/chrome/browser/resources/chromeos/chromevox/chromevox.gni
index f3bf9a6..7ea0495 100644
--- a/chrome/browser/resources/chromeos/chromevox/chromevox.gni
+++ b/chrome/browser/resources/chromeos/chromevox/chromevox.gni
@@ -18,8 +18,7 @@
                                 ],
                                 ".",
                                 "$closure_library_dir/../bin/build")
-jsbundler_modules +=
-    [ "//third_party/WebKit/Source/devtools/scripts/rjsmin.py" ]
+jsbundler_modules += [ "//third_party/WebKit/Source/build/scripts/rjsmin.py" ]
 
 # List of all modules that are included in one or more of the production
 # chromevox scripts.
diff --git a/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.css b/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.css
index 373bff38..98d8b8b4 100644
--- a/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.css
+++ b/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.css
@@ -17,7 +17,7 @@
 }
 
 #back-button-container {
-  -webkit-padding-end: 12px;
+  -webkit-padding-end: 4px;
 }
 
 #close-button {
diff --git a/chrome/browser/resources/media_router/elements/route_details/route_details.css b/chrome/browser/resources/media_router/elements/route_details/route_details.css
index 7b9411d..601c1dd 100644
--- a/chrome/browser/resources/media_router/elements/route_details/route_details.css
+++ b/chrome/browser/resources/media_router/elements/route_details/route_details.css
@@ -31,9 +31,11 @@
 }
 
 #route-information {
+  -webkit-padding-end: 26px;
   -webkit-padding-start: 44px;
   background-color: white;
   font-size: 1.2em;
+  line-height: 1.5em;
   margin-top: 16px;
   overflow: hidden;
 }
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h
index 9fcd262..27113dfc 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h
+++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h
@@ -6,6 +6,7 @@
 #define CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DIALOG_COCOA_H_
 
 #include "base/mac/scoped_nsobject.h"
+#include "base/memory/scoped_ptr.h"
 #include "base/memory/weak_ptr.h"
 #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
 #include "chrome/browser/ui/autofill/autofill_dialog_view.h"
@@ -64,7 +65,7 @@
   // Closes the sheet and ends the modal loop. Triggers cleanup sequence.
   void CloseNow();
 
-  std::unique_ptr<ConstrainedWindowMac> constrained_window_;
+  scoped_ptr<ConstrainedWindowMac> constrained_window_;
   base::scoped_nsobject<AutofillDialogWindowController> sheet_delegate_;
 
   // The delegate |this| queries for logic and state.
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm
index 1731bb3..4a80bbd 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm
+++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm
@@ -38,8 +38,8 @@
   base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
       [[CustomConstrainedWindowSheet alloc]
           initWithCustomWindow:[sheet_delegate_ window]]);
-  constrained_window_ =
-      CreateAndShowWebModalDialogMac(this, delegate_->GetWebContents(), sheet);
+  constrained_window_.reset(
+      new ConstrainedWindowMac(this, delegate_->GetWebContents(), sheet));
   [sheet_delegate_ show];
 }
 
diff --git a/chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.h b/chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.h
index e9358d3..64faef1 100644
--- a/chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.h
+++ b/chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.h
@@ -6,6 +6,7 @@
 #define CHROME_BROWSER_UI_COCOA_AUTOFILL_CARD_UNMASK_PROMPT_VIEW_BRIDGE_H_
 
 #include "base/mac/scoped_nsobject.h"
+#include "base/memory/scoped_ptr.h"
 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
 #include "components/autofill/core/browser/ui/card_unmask_prompt_view.h"
 
@@ -40,7 +41,7 @@
   void PerformClose();
 
  private:
-  std::unique_ptr<ConstrainedWindowMac> constrained_window_;
+  scoped_ptr<ConstrainedWindowMac> constrained_window_;
   base::scoped_nsobject<CardUnmaskPromptViewCocoa> view_controller_;
 
   // The controller |this| queries for logic and state.
diff --git a/chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.mm b/chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.mm
index b4f949e..2a9d770 100644
--- a/chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.mm
+++ b/chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.mm
@@ -87,8 +87,8 @@
   [window setContentView:[view_controller_ view]];
   base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
       [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window]);
-  constrained_window_ =
-      CreateAndShowWebModalDialogMac(this, web_contents_, sheet);
+  constrained_window_.reset(
+      new ConstrainedWindowMac(this, web_contents_, sheet));
 }
 
 void CardUnmaskPromptViewBridge::ControllerGone() {
diff --git a/chrome/browser/ui/cocoa/certificate_viewer_mac.h b/chrome/browser/ui/cocoa/certificate_viewer_mac.h
index 7990758..f33bef2d 100644
--- a/chrome/browser/ui/cocoa/certificate_viewer_mac.h
+++ b/chrome/browser/ui/cocoa/certificate_viewer_mac.h
@@ -24,7 +24,7 @@
   base::scoped_nsobject<NSArray> certificates_;
   scoped_ptr<SSLCertificateViewerCocoaBridge> observer_;
   base::scoped_nsobject<SFCertificatePanel> panel_;
-  std::unique_ptr<ConstrainedWindowMac> constrainedWindow_;
+  scoped_ptr<ConstrainedWindowMac> constrainedWindow_;
   base::scoped_nsobject<NSWindow> overlayWindow_;
   BOOL closePending_;
   // A copy of the sheet's frame used to restore on show.
diff --git a/chrome/browser/ui/cocoa/certificate_viewer_mac.mm b/chrome/browser/ui/cocoa/certificate_viewer_mac.mm
index 1adb0f1..5c41b94f 100644
--- a/chrome/browser/ui/cocoa/certificate_viewer_mac.mm
+++ b/chrome/browser/ui/cocoa/certificate_viewer_mac.mm
@@ -134,8 +134,8 @@
   panel_.reset([[SFCertificatePanel alloc] init]);
   [panel_ setPolicies:(id) policies.get()];
 
-  constrainedWindow_ =
-      CreateAndShowWebModalDialogMac(observer_.get(), webContents, self);
+  constrainedWindow_.reset(
+      new ConstrainedWindowMac(observer_.get(), webContents, self));
 }
 
 - (NSWindow*)overlayWindow {
@@ -189,10 +189,6 @@
   // NOOP
 }
 
-- (void)resizeWithNewSize:(NSSize)preferredSize {
-  // NOOP
-}
-
 - (NSWindow*)sheetWindow {
   return panel_;
 }
diff --git a/chrome/browser/ui/cocoa/constrained_web_dialog_delegate_mac.mm b/chrome/browser/ui/cocoa/constrained_web_dialog_delegate_mac.mm
index 5dc49ab..0ce4df8d 100644
--- a/chrome/browser/ui/cocoa/constrained_web_dialog_delegate_mac.mm
+++ b/chrome/browser/ui/cocoa/constrained_web_dialog_delegate_mac.mm
@@ -11,11 +11,7 @@
 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_window.h"
 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_web_dialog_sheet.h"
-#include "chrome/browser/ui/webui/chrome_web_contents_handler.h"
-#include "content/public/browser/render_view_host.h"
 #include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_observer.h"
-#include "ui/base/cocoa/window_size_constants.h"
 #include "ui/gfx/geometry/size.h"
 #include "ui/web_dialogs/web_dialog_delegate.h"
 #include "ui/web_dialogs/web_dialog_ui.h"
@@ -27,61 +23,19 @@
 
 namespace {
 
-class ConstrainedWebDialogDelegateMac;
-
-// This class is to trigger a resize to the dialog window when
-// ResizeDueToAutoResize() is invoked.
-class WebDialogWebContentsDelegateMac
-    : public ui::WebDialogWebContentsDelegate {
- public:
-  WebDialogWebContentsDelegateMac(content::BrowserContext* browser_context,
-                                  content::WebContentsObserver* observer,
-                                  ConstrainedWebDialogDelegateBase* delegate)
-      : ui::WebDialogWebContentsDelegate(browser_context,
-                                         new ChromeWebContentsHandler()),
-        observer_(observer),
-        delegate_(delegate) {
-  }
-  ~WebDialogWebContentsDelegateMac() override {}
-
-  void ResizeDueToAutoResize(content::WebContents* source,
-                             const gfx::Size& preferred_size) override {
-    if (!observer_->web_contents())
-      return;
-    delegate_->ResizeToGivenSize(preferred_size);
-  }
-
- private:
-  // These members must outlive the instance.
-  content::WebContentsObserver* const observer_;
-  ConstrainedWebDialogDelegateBase* delegate_;
-
-  DISALLOW_COPY_AND_ASSIGN(WebDialogWebContentsDelegateMac);
-};
-
 class ConstrainedWebDialogDelegateMac
     : public ConstrainedWebDialogDelegateBase {
  public:
   ConstrainedWebDialogDelegateMac(
       content::BrowserContext* browser_context,
-      WebDialogDelegate* delegate,
-      content::WebContentsObserver* observer)
-      : ConstrainedWebDialogDelegateBase(browser_context, delegate,
-          new WebDialogWebContentsDelegateMac(browser_context, observer,
-                                              this)) {}
+      WebDialogDelegate* delegate)
+      : ConstrainedWebDialogDelegateBase(browser_context, delegate, NULL) {}
 
   // WebDialogWebContentsDelegate interface.
   void CloseContents(WebContents* source) override {
     window_->CloseWebContentsModalDialog();
   }
 
-  // ConstrainedWebDialogDelegateBase:
-  void ResizeToGivenSize(const gfx::Size size) override {
-    NSSize updated_preferred_size = NSMakeSize(size.width(),
-                                               size.height());
-    [window_->sheet() resizeWithNewSize:updated_preferred_size];
-  }
-
   void set_window(ConstrainedWindowMac* window) { window_ = window; }
   ConstrainedWindowMac* window() const { return window_; }
 
@@ -96,16 +50,13 @@
 
 class ConstrainedWebDialogDelegateViewMac :
     public ConstrainedWindowMacDelegate,
-    public ConstrainedWebDialogDelegate,
-    public content::WebContentsObserver {
+    public ConstrainedWebDialogDelegate {
 
  public:
   ConstrainedWebDialogDelegateViewMac(
       content::BrowserContext* browser_context,
       WebDialogDelegate* delegate,
-      content::WebContents* web_contents,
-      const gfx::Size& min_size,
-      const gfx::Size& max_size);
+      content::WebContents* web_contents);
   ~ConstrainedWebDialogDelegateViewMac() override {}
 
   // ConstrainedWebDialogDelegate interface
@@ -124,37 +75,16 @@
   gfx::NativeWindow GetNativeDialog() override { return window_; }
   WebContents* GetWebContents() override { return impl_->GetWebContents(); }
   gfx::Size GetMinimumSize() const override {
-    return min_size_;
+    NOTIMPLEMENTED();
+    return gfx::Size();
   }
   gfx::Size GetMaximumSize() const override {
-    return max_size_;
+    NOTIMPLEMENTED();
+    return gfx::Size();
   }
   gfx::Size GetPreferredSize() const override {
-    gfx::Size size;
-    if (!impl_->closed_via_webui()) {
-      NSRect frame = [window_ frame];
-      size = gfx::Size(frame.size.width, frame.size.height);
-    }
-    return size;
-  }
-
-  // content::WebContentsObserver:
-  void RenderViewCreated(content::RenderViewHost* render_view_host) override {
-    if (IsDialogAutoResizable())
-      EnableAutoResize();
-  }
-  void RenderViewHostChanged(content::RenderViewHost* old_host,
-                             content::RenderViewHost* new_host) override {
-    if (IsDialogAutoResizable())
-      EnableAutoResize();
-  }
-  void DocumentOnLoadCompletedInMainFrame() override {
-    if (!IsDialogAutoResizable())
-      return;
-
-    EnableAutoResize();
-    if (GetWebContents())
-      constrained_window_->ShowWebContentsModalDialog();
+    NOTIMPLEMENTED();
+    return gfx::Size();
   }
 
   // ConstrainedWindowMacDelegate interface
@@ -165,53 +95,25 @@
   }
 
  private:
-  void EnableAutoResize() {
-    if (!GetWebContents())
-      return;
-
-    content::RenderViewHost* render_view_host =
-        GetWebContents()->GetRenderViewHost();
-    render_view_host->EnableAutoResize(min_size_, max_size_);
-  }
-
-  // Whether or not the dialog is autoresizable is determined based on whether
-  // |max_size_| was specified.
-  bool IsDialogAutoResizable() {
-    return !max_size_.IsEmpty();
-  }
-
   scoped_ptr<ConstrainedWebDialogDelegateMac> impl_;
-  std::unique_ptr<ConstrainedWindowMac> constrained_window_;
+  scoped_ptr<ConstrainedWindowMac> constrained_window_;
   base::scoped_nsobject<NSWindow> window_;
 
-  // Minimum and maximum sizes to determine dialog bounds for auto-resizing.
-  const gfx::Size min_size_;
-  const gfx::Size max_size_;
-
   DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateViewMac);
 };
 
 ConstrainedWebDialogDelegateViewMac::ConstrainedWebDialogDelegateViewMac(
     content::BrowserContext* browser_context,
     WebDialogDelegate* delegate,
-    content::WebContents* web_contents,
-    const gfx::Size& min_size,
-    const gfx::Size& max_size)
-    : content::WebContentsObserver(web_contents),
-      impl_(new ConstrainedWebDialogDelegateMac(browser_context, delegate,
-            this)),
-      min_size_(min_size),
-      max_size_(max_size) {
-  if (IsDialogAutoResizable())
-    Observe(GetWebContents());
-
+    content::WebContents* web_contents)
+    : impl_(new ConstrainedWebDialogDelegateMac(browser_context, delegate)) {
   // Create a window to hold web_contents in the constrained sheet:
   gfx::Size size;
   delegate->GetDialogSize(&size);
   NSRect frame = NSMakeRect(0, 0, size.width(), size.height());
 
-  window_.reset([[ConstrainedWindowCustomWindow alloc]
-                initWithContentRect:ui::kWindowSizeDeterminedLater]);
+  window_.reset(
+      [[ConstrainedWindowCustomWindow alloc] initWithContentRect:frame]);
   [GetWebContents()->GetNativeView() setFrame:frame];
   [GetWebContents()->GetNativeView() setAutoresizingMask:
       NSViewWidthSizable|NSViewHeightSizable];
@@ -220,14 +122,8 @@
   base::scoped_nsobject<WebDialogConstrainedWindowSheet> sheet(
       [[WebDialogConstrainedWindowSheet alloc] initWithCustomWindow:window_
                                                   webDialogDelegate:delegate]);
-
-  if (IsDialogAutoResizable()) {
-    constrained_window_ = CreateWebModalDialogMac(
-          this, web_contents, sheet);
-  } else {
-    constrained_window_ = CreateAndShowWebModalDialogMac(
-          this, web_contents, sheet);
-  }
+  constrained_window_.reset(new ConstrainedWindowMac(
+      this, web_contents, sheet));
 
   impl_->set_window(constrained_window_.get());
 }
@@ -239,23 +135,6 @@
   // Deleted when the dialog closes.
   ConstrainedWebDialogDelegateViewMac* constrained_delegate =
       new ConstrainedWebDialogDelegateViewMac(
-          browser_context, delegate, web_contents,
-          gfx::Size(), gfx::Size());
-  return constrained_delegate;
-}
-
-ConstrainedWebDialogDelegate* ShowConstrainedWebDialogWithAutoResize(
-    content::BrowserContext* browser_context,
-    WebDialogDelegate* delegate,
-    content::WebContents* web_contents,
-    const gfx::Size& min_size,
-    const gfx::Size& max_size) {
-  DCHECK(!min_size.IsEmpty());
-  DCHECK(!max_size.IsEmpty());
-  // Deleted when the dialog closes.
-  ConstrainedWebDialogDelegateViewMac* constrained_delegate =
-      new ConstrainedWebDialogDelegateViewMac(
-          browser_context, delegate, web_contents,
-          min_size, max_size);
+          browser_context, delegate, web_contents);
   return constrained_delegate;
 }
diff --git a/chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.mm b/chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.mm
index ab67fc6..aac59467 100644
--- a/chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.mm
+++ b/chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.mm
@@ -73,10 +73,6 @@
   [customWindow_ setFrameOrigin:origin];
 }
 
-- (void)resizeWithNewSize:(NSSize)size {
-  // NOOP
-}
-
 - (NSWindow*)sheetWindow {
   return customWindow_;
 }
diff --git a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h
index 3b60a39..e3d981e 100644
--- a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h
+++ b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h
@@ -7,9 +7,6 @@
 
 #import <Cocoa/Cocoa.h>
 
-#include "base/mac/scoped_nsobject.h"
-#include "components/web_modal/web_contents_modal_dialog_manager.h"
-
 namespace content {
 class WebContents;
 }
@@ -24,18 +21,6 @@
   virtual void OnConstrainedWindowClosed(ConstrainedWindowMac* window) = 0;
 };
 
-// Creates a ConstrainedWindowMac, shows the dialog, and returns it.
-std::unique_ptr<ConstrainedWindowMac> CreateAndShowWebModalDialogMac(
-    ConstrainedWindowMacDelegate* delegate,
-    content::WebContents* web_contents,
-    id<ConstrainedWindowSheet> sheet);
-
-// Creates a ConstrainedWindowMac and returns it.
-std::unique_ptr<ConstrainedWindowMac> CreateWebModalDialogMac(
-    ConstrainedWindowMacDelegate* delegate,
-    content::WebContents* web_contents,
-    id<ConstrainedWindowSheet> sheet);
-
 // Constrained window implementation for Mac.
 // Normally an instance of this class is owned by the delegate. The delegate
 // should delete the instance when the window is closed.
@@ -46,9 +31,6 @@
                        id<ConstrainedWindowSheet> sheet);
   ~ConstrainedWindowMac();
 
-  // Shows the constrained window.
-  void ShowWebContentsModalDialog();
-
   // Closes the constrained window.
   void CloseWebContentsModalDialog();
 
@@ -56,24 +38,13 @@
   void set_manager(SingleWebContentsDialogManagerCocoa* manager) {
     manager_ = manager;
   }
-  id<ConstrainedWindowSheet> sheet() const { return sheet_.get(); }
 
   // Called by |manager_| when the dialog is closing.
   void OnDialogClosing();
 
-  // Whether or not the dialog was shown. If the dialog is auto-resizable, it
-  // is hidden until its WebContents initially loads.
-  bool DialogWasShown();
-
-  // Gets the dialog manager for |web_contents_|.
-  web_modal::WebContentsModalDialogManager* GetDialogManager();
-
  private:
   ConstrainedWindowMacDelegate* delegate_;  // weak, owns us.
   SingleWebContentsDialogManagerCocoa* manager_;  // weak, owned by WCMDM.
-  content::WebContents* web_contents_;  // weak, owned by dialog initiator.
-  base::scoped_nsprotocol<id<ConstrainedWindowSheet>> sheet_;
-  scoped_ptr<SingleWebContentsDialogManagerCocoa> native_manager_;
 };
 
 #endif  // CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_MAC_
diff --git a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm
index 510402e8..16f755c 100644
--- a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm
+++ b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm
@@ -11,59 +11,35 @@
 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h"
 #import "chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.h"
 #include "components/guest_view/browser/guest_view_base.h"
+#include "components/web_modal/web_contents_modal_dialog_manager.h"
 #include "content/public/browser/browser_thread.h"
 
 using web_modal::WebContentsModalDialogManager;
 
-std::unique_ptr<ConstrainedWindowMac> CreateAndShowWebModalDialogMac(
-    ConstrainedWindowMacDelegate* delegate,
-    content::WebContents* web_contents,
-    id<ConstrainedWindowSheet> sheet) {
-  ConstrainedWindowMac* window =
-      new ConstrainedWindowMac(delegate, web_contents, sheet);
-  window->ShowWebContentsModalDialog();
-  return std::unique_ptr<ConstrainedWindowMac>(window);
-}
-
-std::unique_ptr<ConstrainedWindowMac> CreateWebModalDialogMac(
-    ConstrainedWindowMacDelegate* delegate,
-    content::WebContents* web_contents,
-    id<ConstrainedWindowSheet> sheet) {
-  return std::unique_ptr<ConstrainedWindowMac>(
-      new ConstrainedWindowMac(delegate, web_contents, sheet));
-}
-
 ConstrainedWindowMac::ConstrainedWindowMac(
     ConstrainedWindowMacDelegate* delegate,
     content::WebContents* web_contents,
     id<ConstrainedWindowSheet> sheet)
-    : delegate_(delegate),
-      sheet_([sheet retain]) {
+    : delegate_(delegate) {
   DCHECK(sheet);
 
   // |web_contents| may be embedded within a chain of nested GuestViews. If it
   // is, follow the chain of embedders to the outermost WebContents and use it.
-  web_contents_ =
+  web_contents =
       guest_view::GuestViewBase::GetTopLevelWebContents(web_contents);
 
-  native_manager_.reset(
-      new SingleWebContentsDialogManagerCocoa(this, sheet_.get(),
-                                              GetDialogManager()));
+  auto manager = WebContentsModalDialogManager::FromWebContents(web_contents);
+  scoped_ptr<SingleWebContentsDialogManagerCocoa> native_manager(
+      new SingleWebContentsDialogManagerCocoa(this, sheet, manager));
+  manager->ShowDialogWithManager([sheet sheetWindow],
+                                 std::move(native_manager));
 }
 
 ConstrainedWindowMac::~ConstrainedWindowMac() {
   CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
-  native_manager_.reset();
   DCHECK(!manager_);
 }
 
-void ConstrainedWindowMac::ShowWebContentsModalDialog() {
-  scoped_ptr<SingleWebContentsDialogManagerCocoa> dialog_manager;
-  dialog_manager.reset(native_manager_.release());
-  GetDialogManager()->ShowDialogWithManager(
-      [sheet_.get() sheetWindow], std::move(dialog_manager));
-}
-
 void ConstrainedWindowMac::CloseWebContentsModalDialog() {
   if (manager_)
     manager_->Close();
@@ -73,13 +49,3 @@
   if (delegate_)
     delegate_->OnConstrainedWindowClosed(this);
 }
-
-bool ConstrainedWindowMac::DialogWasShown() {
-  // If the dialog was shown, |native_manager_| would have been released.
-  return !native_manager_;
-}
-
-WebContentsModalDialogManager* ConstrainedWindowMac::GetDialogManager() {
-  DCHECK(web_contents_);
-  return WebContentsModalDialogManager::FromWebContents(web_contents_);
-}
diff --git a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac_browsertest.mm b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac_browsertest.mm
index d8ffb1e..8e6ceda 100644
--- a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac_browsertest.mm
+++ b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac_browsertest.mm
@@ -79,15 +79,14 @@
 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, ShowInInactiveTab) {
   // Show dialog in non active tab.
   NiceMock<ConstrainedWindowDelegateMock> delegate;
-  std::unique_ptr<ConstrainedWindowMac> dialog(
-      CreateAndShowWebModalDialogMac(&delegate, tab0_, sheet_));
+  ConstrainedWindowMac dialog(&delegate, tab0_, sheet_);
   EXPECT_EQ(0.0, [sheet_window_ alphaValue]);
 
   // Switch to inactive tab.
   browser()->tab_strip_model()->ActivateTabAt(0, true);
   EXPECT_EQ(1.0, [sheet_window_ alphaValue]);
 
-  dialog->CloseWebContentsModalDialog();
+  dialog.CloseWebContentsModalDialog();
 }
 
 // If a tab has never been shown then the associated tab view for the web
@@ -106,8 +105,7 @@
 
   // Show dialog and verify that it's not visible yet.
   NiceMock<ConstrainedWindowDelegateMock> delegate;
-  std::unique_ptr<ConstrainedWindowMac> dialog(
-      CreateAndShowWebModalDialogMac(&delegate, tab2, sheet_));
+  ConstrainedWindowMac dialog(&delegate, tab2, sheet_);
   EXPECT_FALSE([sheet_window_ isVisible]);
 
   // Activate the tab and verify that the constrained window is shown.
@@ -116,27 +114,25 @@
   EXPECT_TRUE([sheet_window_ isVisible]);
   EXPECT_EQ(1.0, [sheet_window_ alphaValue]);
 
-  dialog->CloseWebContentsModalDialog();
+  dialog.CloseWebContentsModalDialog();
 }
 
 // Test that adding a sheet disables tab dragging.
 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, TabDragging) {
   NiceMock<ConstrainedWindowDelegateMock> delegate;
-  std::unique_ptr<ConstrainedWindowMac> dialog(
-      CreateAndShowWebModalDialogMac(&delegate, tab1_, sheet_));
+  ConstrainedWindowMac dialog(&delegate, tab1_, sheet_);
 
   // Verify that the dialog disables dragging.
   EXPECT_TRUE([controller_ isTabDraggable:tab_view0_]);
   EXPECT_FALSE([controller_ isTabDraggable:tab_view1_]);
 
-  dialog->CloseWebContentsModalDialog();
+  dialog.CloseWebContentsModalDialog();
 }
 
 // Test that closing a browser window with a sheet works.
 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, BrowserWindowClose) {
   NiceMock<ConstrainedWindowDelegateMock> delegate;
-  std::unique_ptr<ConstrainedWindowMac> dialog(
-      CreateAndShowWebModalDialogMac(&delegate, tab1_, sheet_));
+  ConstrainedWindowMac dialog(&delegate, tab1_, sheet_);
   EXPECT_EQ(1.0, [sheet_window_ alphaValue]);
 
   // Close the browser window.
@@ -150,8 +146,7 @@
 // Test that closing a tab with a sheet works.
 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, TabClose) {
   NiceMock<ConstrainedWindowDelegateMock> delegate;
-  std::unique_ptr<ConstrainedWindowMac> dialog(
-      CreateAndShowWebModalDialogMac(&delegate, tab1_, sheet_));
+  ConstrainedWindowMac dialog(&delegate, tab1_, sheet_);
   EXPECT_EQ(1.0, [sheet_window_ alphaValue]);
 
   // Close the tab.
@@ -165,8 +160,7 @@
 // Test that the sheet is still visible after entering and exiting fullscreen.
 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, BrowserWindowFullscreen) {
   NiceMock<ConstrainedWindowDelegateMock> delegate;
-  std::unique_ptr<ConstrainedWindowMac> dialog(
-      CreateAndShowWebModalDialogMac(&delegate, tab1_, sheet_));
+  ConstrainedWindowMac dialog(&delegate, tab1_, sheet_);
   EXPECT_EQ(1.0, [sheet_window_ alphaValue]);
 
   // Toggle fullscreen twice: one for entering and one for exiting.
@@ -186,5 +180,5 @@
     EXPECT_EQ(1.0, [sheet_window_ alphaValue]);
   }
 
-  dialog->CloseWebContentsModalDialog();
+  dialog.CloseWebContentsModalDialog();
 }
diff --git a/chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h b/chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h
index cf24f7d..4549556 100644
--- a/chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h
+++ b/chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h
@@ -24,8 +24,6 @@
 
 - (void)updateSheetPosition;
 
-- (void)resizeWithNewSize:(NSSize)size;
-
 @property(readonly, nonatomic) NSWindow* sheetWindow;
 
 @end
diff --git a/chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller_unittest.mm b/chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller_unittest.mm
index 6566d21..05038cf 100644
--- a/chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller_unittest.mm
@@ -59,10 +59,6 @@
 - (void)updateSheetPosition {
 }
 
-- (void)resizeWithNewSize:(NSSize)size {
-  // NOOP
-}
-
 - (NSWindow*)sheetWindow {
   return [alert_ window];
 }
diff --git a/chrome/browser/ui/cocoa/constrained_window/constrained_window_web_dialog_sheet.mm b/chrome/browser/ui/cocoa/constrained_window/constrained_window_web_dialog_sheet.mm
index 6e7d3f19..3c71f00 100644
--- a/chrome/browser/ui/cocoa/constrained_window/constrained_window_web_dialog_sheet.mm
+++ b/chrome/browser/ui/cocoa/constrained_window/constrained_window_web_dialog_sheet.mm
@@ -27,14 +27,4 @@
   [super updateSheetPosition];
 }
 
-- (void)resizeWithNewSize:(NSSize)size {
-  [customWindow_ setContentSize:size];
-
-  // self's updateSheetPosition() sets |customWindow_|'s contentSize to a
-  // fixed dialog size. Here, we want to resize to |size| instead. Use
-  // super rather than self to bypass the setContentSize() call for the fixed
-  // size.
-  [super updateSheetPosition];
-}
-
 @end
diff --git a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h
index 55b55c9..e895491e 100644
--- a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h
+++ b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h
@@ -47,7 +47,7 @@
 
   content::NotificationRegistrar registrar_;
 
-  std::unique_ptr<ConstrainedWindowMac> window_;
+  scoped_ptr<ConstrainedWindowMac> window_;
 
   base::scoped_nsobject<CollectedCookiesWindowController> sheet_controller_;
 
diff --git a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm
index 7c85ffe8..679c212 100644
--- a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm
+++ b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm
@@ -66,7 +66,8 @@
   base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
       [[CustomConstrainedWindowSheet alloc]
           initWithCustomWindow:[sheet_controller_ window]]);
-  window_ = CreateAndShowWebModalDialogMac(this, web_contents, sheet);
+  window_.reset(new ConstrainedWindowMac(
+      this, web_contents, sheet));
 }
 
 CollectedCookiesMac::~CollectedCookiesMac() {
diff --git a/chrome/browser/ui/cocoa/extensions/device_permissions_dialog_controller.h b/chrome/browser/ui/cocoa/extensions/device_permissions_dialog_controller.h
index 19e5f3c..73e04f7 100644
--- a/chrome/browser/ui/cocoa/extensions/device_permissions_dialog_controller.h
+++ b/chrome/browser/ui/cocoa/extensions/device_permissions_dialog_controller.h
@@ -39,7 +39,7 @@
  private:
   scoped_refptr<extensions::DevicePermissionsPrompt::Prompt> prompt_;
   base::scoped_nsobject<DevicePermissionsViewController> view_controller_;
-  std::unique_ptr<ConstrainedWindowMac> constrained_window_;
+  scoped_ptr<ConstrainedWindowMac> constrained_window_;
 };
 
 #endif  // CHROME_BROWSER_UI_COCOA_EXTENSIONS_DEVICE_PERMISSIONS_DIALOG_CONTROLER_H_
diff --git a/chrome/browser/ui/cocoa/extensions/device_permissions_dialog_controller.mm b/chrome/browser/ui/cocoa/extensions/device_permissions_dialog_controller.mm
index 881aff0..6babaf28 100644
--- a/chrome/browser/ui/cocoa/extensions/device_permissions_dialog_controller.mm
+++ b/chrome/browser/ui/cocoa/extensions/device_permissions_dialog_controller.mm
@@ -33,8 +33,8 @@
 
   base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
       [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window]);
-  constrained_window_ =
-      CreateAndShowWebModalDialogMac(this, web_contents, sheet);
+  constrained_window_.reset(
+      new ConstrainedWindowMac(this, web_contents, sheet));
 }
 
 DevicePermissionsDialogController::~DevicePermissionsDialogController() {
diff --git a/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.h b/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.h
index 455062c6..26143ea 100644
--- a/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.h
+++ b/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.h
@@ -57,7 +57,7 @@
 
   ExtensionInstallPrompt::DoneCallback done_callback_;
   base::scoped_nsobject<ExtensionInstallViewController> view_controller_;
-  std::unique_ptr<ConstrainedWindowMac> constrained_window_;
+  scoped_ptr<ConstrainedWindowMac> constrained_window_;
   scoped_ptr<extensions::ExperienceSamplingEvent> sampling_event_;
 
   DISALLOW_COPY_AND_ASSIGN(ExtensionInstallDialogController);
diff --git a/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.mm b/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.mm
index 4685a25b..826a3bc 100644
--- a/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.mm
+++ b/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.mm
@@ -60,8 +60,8 @@
 
   base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
       [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window]);
-  constrained_window_ = CreateAndShowWebModalDialogMac(
-      this, show_params->GetParentWebContents(), sheet);
+  constrained_window_.reset(new ConstrainedWindowMac(
+      this, show_params->GetParentWebContents(), sheet));
 
   std::string event_name = ExperienceSamplingEvent::kExtensionInstallDialog;
   event_name.append(
diff --git a/chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.h b/chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.h
index 88f0080d..42252af9 100644
--- a/chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.h
+++ b/chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.h
@@ -70,7 +70,7 @@
   CGFloat CreateCheckboxSeparator(CGFloat y_pos, NSString* header);
 
   MediaGalleriesDialogController* controller_;  // weak
-  std::unique_ptr<ConstrainedWindowMac> window_;
+  scoped_ptr<ConstrainedWindowMac> window_;
 
   // The alert that the dialog is being displayed as.
   base::scoped_nsobject<ConstrainedWindowAlert> alert_;
diff --git a/chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.mm b/chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.mm
index 37b47da1..5dd8949 100644
--- a/chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.mm
+++ b/chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.mm
@@ -102,8 +102,8 @@
     base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
         [[CustomConstrainedWindowSheet alloc]
             initWithCustomWindow:[alert_ window]]);
-    window_ = CreateAndShowWebModalDialogMac(
-        this, controller->WebContents(), sheet);
+    window_.reset(new ConstrainedWindowMac(
+        this, controller->WebContents(), sheet));
   }
 }
 
diff --git a/chrome/browser/ui/cocoa/login_prompt_cocoa.mm b/chrome/browser/ui/cocoa/login_prompt_cocoa.mm
index 4d72782..2c24253b 100644
--- a/chrome/browser/ui/cocoa/login_prompt_cocoa.mm
+++ b/chrome/browser/ui/cocoa/login_prompt_cocoa.mm
@@ -80,8 +80,8 @@
     base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
         [[CustomConstrainedWindowSheet alloc]
             initWithCustomWindow:[sheet_controller_ window]]);
-    constrained_window_ = CreateAndShowWebModalDialogMac(
-        this, requesting_contents, sheet);
+    constrained_window_.reset(new ConstrainedWindowMac(
+        this, requesting_contents, sheet));
 
     NotifyAuthNeeded();
   }
@@ -126,7 +126,7 @@
   // The Cocoa controller of the GUI.
   base::scoped_nsobject<LoginHandlerSheet> sheet_controller_;
 
-  std::unique_ptr<ConstrainedWindowMac> constrained_window_;
+  scoped_ptr<ConstrainedWindowMac> constrained_window_;
 
   DISALLOW_COPY_AND_ASSIGN(LoginHandlerMac);
 };
diff --git a/chrome/browser/ui/cocoa/one_click_signin_dialog_controller.h b/chrome/browser/ui/cocoa/one_click_signin_dialog_controller.h
index b4f82d4..d56dfdd 100644
--- a/chrome/browser/ui/cocoa/one_click_signin_dialog_controller.h
+++ b/chrome/browser/ui/cocoa/one_click_signin_dialog_controller.h
@@ -8,6 +8,7 @@
 #import <Cocoa/Cocoa.h>
 
 #include "base/mac/scoped_nsobject.h"
+#include "base/memory/scoped_ptr.h"
 #include "chrome/browser/ui/browser_window.h"
 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
 
@@ -41,7 +42,7 @@
  private:
   void PerformClose();
 
-  std::unique_ptr<ConstrainedWindowMac> constrained_window_;
+  scoped_ptr<ConstrainedWindowMac> constrained_window_;
   base::scoped_nsobject<OneClickSigninViewController> view_controller_;
 };
 
diff --git a/chrome/browser/ui/cocoa/one_click_signin_dialog_controller.mm b/chrome/browser/ui/cocoa/one_click_signin_dialog_controller.mm
index a8f9a84..f0156f2 100644
--- a/chrome/browser/ui/cocoa/one_click_signin_dialog_controller.mm
+++ b/chrome/browser/ui/cocoa/one_click_signin_dialog_controller.mm
@@ -30,15 +30,15 @@
 
   base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
       [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window]);
-  constrained_window_ =
-      CreateAndShowWebModalDialogMac(this, web_contents, sheet);
+  constrained_window_.reset(new ConstrainedWindowMac(
+      this, web_contents, sheet));
 }
 
 OneClickSigninDialogController::~OneClickSigninDialogController() {
 }
 
 void OneClickSigninDialogController::OnConstrainedWindowClosed(
-  ConstrainedWindowMac* window) {
+    ConstrainedWindowMac* window) {
   [view_controller_ viewWillClose];
   base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
 }
diff --git a/chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.h b/chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.h
index 192f6ce0..6f27470 100644
--- a/chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.h
+++ b/chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.h
@@ -13,6 +13,7 @@
 #include "base/compiler_specific.h"
 #include "base/mac/scoped_nsobject.h"
 #include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
 #include "base/memory/weak_ptr.h"
 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
 #include "chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_view_controller.h"
@@ -59,7 +60,7 @@
   base::scoped_nsobject<ProfileSigninConfirmationViewController> controller_;
 
   // The constrained window that contains the dialog view.
-  std::unique_ptr<ConstrainedWindowMac> window_;
+  scoped_ptr<ConstrainedWindowMac> window_;
 
   DISALLOW_COPY_AND_ASSIGN(ProfileSigninConfirmationDialogCocoa);
 };
diff --git a/chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.mm b/chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.mm
index e600717..a46b4eb 100644
--- a/chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.mm
+++ b/chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.mm
@@ -59,7 +59,7 @@
   [[window contentView] addSubview:[controller_ view]];
   base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
       [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window]);
-  window_ = CreateAndShowWebModalDialogMac(this, web_contents, sheet);
+  window_.reset(new ConstrainedWindowMac(this, web_contents, sheet));
 }
 
 ProfileSigninConfirmationDialogCocoa::~ProfileSigninConfirmationDialogCocoa() {
diff --git a/chrome/browser/ui/cocoa/profiles/user_manager_mac.h b/chrome/browser/ui/cocoa/profiles/user_manager_mac.h
index d8346b8..dd1c1c6c 100644
--- a/chrome/browser/ui/cocoa/profiles/user_manager_mac.h
+++ b/chrome/browser/ui/cocoa/profiles/user_manager_mac.h
@@ -9,6 +9,7 @@
 
 #include "base/mac/scoped_nsobject.h"
 #include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/profiles/profile_window.h"
 
diff --git a/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm b/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm
index cdae282..48a02249 100644
--- a/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm
+++ b/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm
@@ -167,7 +167,7 @@
   std::string emailAddress_;
   content::WebContents* webContents_;
   scoped_ptr<ReauthDialogDelegate> webContentsDelegate_;
-  std::unique_ptr<ConstrainedWindowMac> constrained_window_;
+  scoped_ptr<ConstrainedWindowMac> constrained_window_;
   scoped_ptr<content::WebContents> reauthWebContents_;
 }
 - (id)initWithProfile:(Profile*)profile
@@ -203,9 +203,9 @@
     base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
        [[CustomConstrainedWindowSheet alloc]
            initWithCustomWindow:[self window]]);
-    constrained_window_ =
-        CreateAndShowWebModalDialogMac(
-            webContentsDelegate_.get(), webContents_, sheet);
+    constrained_window_.reset(
+       new ConstrainedWindowMac(
+          webContentsDelegate_.get(), webContents_, sheet));
 
     // The close button needs to call CloseWebContentsModalDialog() on the
     // constrained window isntead of just [window close] so grab a reference to
diff --git a/chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.mm b/chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.mm
index 1cbaec8..6b1d507 100644
--- a/chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.mm
+++ b/chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.mm
@@ -58,12 +58,8 @@
   [[ConstrainedWindowSheetController controllerForSheet:sheet_]
       closeSheet:sheet_];
   client_->set_manager(nullptr);
-
-  bool dialog_was_open = client_->DialogWasShown();
   client_->OnDialogClosing();      // |client_| might delete itself here.
-
-  if (dialog_was_open)
-    delegate_->WillClose(dialog());  // Deletes |this|.
+  delegate_->WillClose(dialog());  // Deletes |this|.
 }
 
 void SingleWebContentsDialogManagerCocoa::Focus() {
diff --git a/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.h b/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.h
index 4e3b307b..f1fe2e3 100644
--- a/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.h
+++ b/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.h
@@ -35,7 +35,7 @@
   // A C++ object to bridge SSLClientAuthObserver notifications to us.
   scoped_ptr<SSLClientAuthObserverCocoaBridge> observer_;
   base::scoped_nsobject<SFChooseIdentityPanel> panel_;
-  std::unique_ptr<ConstrainedWindowMac> constrainedWindow_;
+  scoped_ptr<ConstrainedWindowMac> constrainedWindow_;
   base::scoped_nsobject<NSWindow> overlayWindow_;
   BOOL closePending_;
   // A copy of the sheet's frame used to restore on show.
diff --git a/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm b/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm
index 4a06708..8c7d66d 100644
--- a/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm
+++ b/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm
@@ -179,8 +179,8 @@
     CFRelease(sslPolicy);
   }
 
-  constrainedWindow_ =
-      CreateAndShowWebModalDialogMac(observer_.get(), webContents, self);
+  constrainedWindow_.reset(
+      new ConstrainedWindowMac(observer_.get(), webContents, self));
   observer_->StartObserving();
 }
 
@@ -260,10 +260,6 @@
   // NOOP
 }
 
-- (void)resizeWithNewSize:(NSSize)size {
-  // NOOP
-}
-
 - (NSWindow*)sheetWindow {
   return panel_;
 }
diff --git a/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.h b/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.h
index c7e32951..1eed74f 100644
--- a/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.h
+++ b/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.h
@@ -48,7 +48,7 @@
 
   bool closing_;
 
-  std::unique_ptr<ConstrainedWindowMac> window_;
+  scoped_ptr<ConstrainedWindowMac> window_;
   scoped_ptr<TabModalConfirmDialogDelegate> delegate_;
   base::scoped_nsobject<ConstrainedWindowAlert> alert_;
   base::scoped_nsobject<TabModalConfirmDialogMacBridge> bridge_;
diff --git a/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.mm b/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.mm
index e0e7f547..6935ce1 100644
--- a/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.mm
+++ b/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.mm
@@ -94,7 +94,7 @@
   base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
       [[CustomConstrainedWindowSheet alloc]
           initWithCustomWindow:[alert_ window]]);
-  window_ = CreateAndShowWebModalDialogMac(this, web_contents, sheet);
+  window_.reset(new ConstrainedWindowMac(this, web_contents, sheet));
   delegate_->set_close_delegate(this);
 }
 
diff --git a/chrome/browser/ui/cocoa/web_contents_modal_dialog_manager_views_mac.mm b/chrome/browser/ui/cocoa/web_contents_modal_dialog_manager_views_mac.mm
index 31f057fa..1eefbd15 100644
--- a/chrome/browser/ui/cocoa/web_contents_modal_dialog_manager_views_mac.mm
+++ b/chrome/browser/ui/cocoa/web_contents_modal_dialog_manager_views_mac.mm
@@ -96,10 +96,6 @@
   [customWindow_ setFrameOrigin:origin];
 }
 
-- (void)resizeWithNewSize:(NSSize)size {
-  // NOOP
-}
-
 - (NSWindow*)sheetWindow {
   return customWindow_;
 }
diff --git a/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc
index db4c547..fd60a4b 100644
--- a/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc
+++ b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc
@@ -113,8 +113,3 @@
   NOTREACHED();
   return gfx::Size();
 }
-
-void ConstrainedWebDialogDelegateBase::ResizeToGivenSize(
-    const gfx::Size size) {
-  NOTREACHED();
-}
diff --git a/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h
index a43814a..fee4931 100644
--- a/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h
+++ b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h
@@ -24,8 +24,6 @@
     : public ConstrainedWebDialogDelegate,
       public ui::WebDialogWebContentsDelegate {
  public:
-  // |browser_context| and |delegate| must outlive |this| instance, whereas
-  // |this| will take ownership of |tab_delegate|.
   ConstrainedWebDialogDelegateBase(content::BrowserContext* browser_context,
                                    ui::WebDialogDelegate* delegate,
                                    WebDialogWebContentsDelegate* tab_delegate);
@@ -49,9 +47,6 @@
       content::WebContents* source,
       const content::NativeWebKeyboardEvent& event) override;
 
-  // Resize the dialog to the given size.
-  virtual void ResizeToGivenSize(const gfx::Size size);
-
  private:
   scoped_ptr<ui::WebDialogDelegate> web_dialog_delegate_;
 
diff --git a/chrome/browser/ui/webui/constrained_web_dialog_ui.h b/chrome/browser/ui/webui/constrained_web_dialog_ui.h
index 39cc74b..4f7159e5 100644
--- a/chrome/browser/ui/webui/constrained_web_dialog_ui.h
+++ b/chrome/browser/ui/webui/constrained_web_dialog_ui.h
@@ -51,8 +51,6 @@
   // Returns the maximum size for the dialog.
   virtual gfx::Size GetMaximumSize() const = 0;
 
-  // Returns the preferred size for the dialog, or an empty size if
-  // the dialog has been closed.
   virtual gfx::Size GetPreferredSize() const = 0;
 
  protected:
diff --git a/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc b/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc
index f7d39e55..fbdf04f8 100644
--- a/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc
@@ -26,6 +26,7 @@
 
 namespace {
 
+#if !defined(OS_MACOSX)
 static const char kTestDataURL[] = "data:text/html,<!doctype html>"
     "<body></body>"
     "<style>"
@@ -41,6 +42,7 @@
   return base::StringPrintf("window.document.body.style.width = %d + 'px';"
       "window.document.body.style.height = %d + 'px';", dimension, dimension);
 }
+#endif
 
 class ConstrainedWebDialogBrowserTestObserver
     : public content::WebContentsObserver {
@@ -145,6 +147,7 @@
   EXPECT_TRUE(observer.contents_destroyed());
 }
 
+#if !defined(OS_MACOSX)
 // Tests that dialog autoresizes based on web contents when autoresizing
 // is enabled.
 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest,
@@ -170,12 +173,6 @@
   gfx::Size min_size = gfx::Size(100, 100);
   gfx::Size max_size = gfx::Size(200, 200);
   gfx::Size initial_dialog_size;
-// OSX windows are initially created with non-empty dimensions. The
-// autoresizeable dialog's window dimensions are determined after initial
-// creation.
-#if defined(OS_MACOSX)
-  initial_dialog_size = gfx::Size(1, 1);
-#endif
   delegate->GetDialogSize(&initial_dialog_size);
 
   ConstrainedWebDialogDelegate* dialog_delegate =
@@ -189,6 +186,7 @@
   EXPECT_EQ(max_size, dialog_delegate->GetMaximumSize());
 
   // Check for initial sizing. Dialog was created as a 400x400 dialog.
+  EXPECT_EQ(gfx::Size(), web_contents->GetPreferredSize());
   ASSERT_EQ(initial_dialog_size, dialog_delegate->GetPreferredSize());
 
   observer.Wait();
@@ -252,6 +250,7 @@
   delegate->GetDialogSize(&initial_dialog_size);
 
   // Check for initial sizing. Dialog was created as a 400x400 dialog.
+  EXPECT_EQ(gfx::Size(), web_contents->GetPreferredSize());
   ASSERT_EQ(initial_dialog_size, dialog_delegate->GetPreferredSize());
 
   // Resize <body> to dimension smaller than dialog.
@@ -270,3 +269,4 @@
       initial_dialog_size,
       dialog_delegate)));
 }
+#endif  // !OS_MACOSX
diff --git a/chrome/test/data/extensions/api_test/executescript/basic/test.js b/chrome/test/data/extensions/api_test/executescript/basic/test.js
index 59375968..7185964 100644
--- a/chrome/test/data/extensions/api_test/executescript/basic/test.js
+++ b/chrome/test/data/extensions/api_test/executescript/basic/test.js
@@ -88,7 +88,13 @@
       },
 
       function executeJavaScriptCodeShouldFail() {
-        chrome.tabs.update(tabId, { url: testFailureUrl }, function() {
+        var doneListening =
+            chrome.test.listenForever(chrome.tabs.onUpdated, onUpdated);
+        chrome.tabs.update(tabId, {url: testFailureUrl});
+
+        function onUpdated(updatedTabId, changeInfo) {
+          if (updatedTabId !== tabId || changeInfo.url === testFailureUrl)
+            return;
           var script_file = {};
           script_file.code = "document.title = 'executeScript';";
           // The error message should contain the URL of the site for which it
@@ -97,7 +103,8 @@
               'Cannot access contents of url "' + testFailureUrl +
               '". Extension manifest must request permission to access this ' +
               'host.'));
-        });
+          doneListening();
+        }
       },
 
       function executeJavaScriptWithNoneValueShouldFail() {
diff --git a/chrome/test/data/extensions/api_test/executescript/frame_id/frame.html b/chrome/test/data/extensions/api_test/executescript/frame_id/frame.html
new file mode 100644
index 0000000..75a3b13
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/executescript/frame_id/frame.html
@@ -0,0 +1,3 @@
+Same-origin frame.
+
+<iframe src="nested.html"></iframe>
diff --git a/chrome/test/data/extensions/api_test/executescript/frame_id/frames.html b/chrome/test/data/extensions/api_test/executescript/frame_id/frames.html
new file mode 100644
index 0000000..886abb4
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/executescript/frame_id/frames.html
@@ -0,0 +1,11 @@
+<iframe srcdoc="same-origin srcdoc frame"></iframe>
+
+<!-- Unique origin about:blank -->
+<iframe sandbox="" src="about:blank"></iframe>
+
+<iframe src="frame.html"></iframe>
+
+<script>
+document.write('<iframe src="http://c.com:' + location.port +
+               '/empty.html"></iframe>');
+</script>
diff --git a/chrome/test/data/extensions/api_test/executescript/frame_id/manifest.json b/chrome/test/data/extensions/api_test/executescript/frame_id/manifest.json
new file mode 100644
index 0000000..7b46d7b
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/executescript/frame_id/manifest.json
@@ -0,0 +1,9 @@
+{
+  "version": "1",
+  "manifest_version": 2,
+  "name": "executeScript / insertCSS test by frameId",
+  "background": {
+    "scripts": ["test.js"]
+  },
+  "permissions": ["webNavigation", "tabs", "http://a.com/"]
+}
diff --git a/chrome/test/data/extensions/api_test/executescript/frame_id/nested.html b/chrome/test/data/extensions/api_test/executescript/frame_id/nested.html
new file mode 100644
index 0000000..b73bc1d
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/executescript/frame_id/nested.html
@@ -0,0 +1 @@
+Deeply nested frame.
diff --git a/chrome/test/data/extensions/api_test/executescript/frame_id/test.js b/chrome/test/data/extensions/api_test/executescript/frame_id/test.js
new file mode 100644
index 0000000..cfd38c71
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/executescript/frame_id/test.js
@@ -0,0 +1,383 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var pass = chrome.test.callbackPass;
+var fail = chrome.test.callbackFail;
+var assertEq = chrome.test.assertEq;
+var assertTrue = chrome.test.assertTrue;
+var relativePath = '/extensions/api_test/executescript/frame_id/frames.html';
+var testOrigin = 'http://a.com:PORT';
+var testUrl = 'http://a.com:PORT' + relativePath;
+
+var tabId;
+
+// Frame ID of every frame in this test, and the patterns of the frame URLs.
+// Frame IDs are lazily initialized (and constant thereafter).
+// All patterns are mutually exclusive.
+
+// Main frame.
+var ID_FRAME_TOP = 0;
+var R_FRAME_TOP = /frames\.html/;
+// Frame with (same-origin) about:srcdoc.
+var ID_FRAME_SRCDOC;
+var R_FRAME_SRCDOC = /about:srcdoc/;
+// Frame with (unique-origin) sandboxed about:blank.
+var ID_FRAME_UNREACHABLE;
+var R_FRAME_UNREACHABLE = /about:blank/;
+// Frame with same-origin page.
+var ID_FRAME_SECOND;
+var R_FRAME_SECOND = /frame\.html/;
+// Same-origin child frame of |frame_second|.
+var ID_FRAME_THIRD;
+var R_FRAME_THIRD = /nested\.html/;
+// Frame for which the extension does not have the right permissions.
+var ID_FRAME_NOPERMISSION;
+var R_FRAME_NOPERMISSION = /empty\.html/;
+
+function matchesAny(urls, regex) {
+  return urls.some(function(url) { return regex.test(url); });
+}
+
+var gCssCounter = 0;
+
+// Calls chrome.tabs.insertCSS and invokes the callback with a list of affected
+// URLs. This function assumes that the tab identified by |tabId| exists, and
+// that |injectDetails| is a valid argument for insertCSS.
+function insertCSS(tabId, injectDetails, callback) {
+  var marker = (++gCssCounter) + 'px';
+  injectDetails.code = 'body { min-width: ' + marker + ';}';
+  chrome.tabs.insertCSS(tabId, injectDetails, function() {
+    chrome.test.assertNoLastError();
+    chrome.tabs.executeScript(
+        tabId, {
+          code: '[getComputedStyle(document.body).minWidth, document.URL];',
+          allFrames: true,
+          matchAboutBlank: true
+        },
+        function(results) {
+          chrome.test.assertNoLastError();
+          results = getAffectedUrls(results);
+          callback(results);
+        });
+  });
+
+  // Selects the results from the frames whose CSS was changed by the insertCSS
+  // call, and returns the URLs of these frames.
+  function getAffectedUrls(results) {
+    return results.filter(function(result) {
+      return result && result[0] === marker;
+    }).map(function(result) {
+      return result[1];  // "document.URL"
+    });
+  }
+}
+
+chrome.test.getConfig(function(config) {
+  testOrigin = testOrigin.replace(/PORT/, config.testServer.port);
+  testUrl = testUrl.replace(/PORT/, config.testServer.port);
+  chrome.tabs.onUpdated.addListener(function(_, changeInfo, tab) {
+    if (changeInfo.status != 'complete' || tab.id !== tabId) {
+      return;
+    }
+
+    chrome.webNavigation.getAllFrames({tabId: tabId}, function(frames) {
+      function getFrameId(urlRegex) {
+        var filtered =
+            frames.filter(function(frame) { return urlRegex.test(frame.url); });
+        // Sanity check.
+        chrome.test.assertEq(1, filtered.length);
+        chrome.test.assertTrue(filtered[0].frameId > 0);
+        return filtered[0].frameId;
+      }
+
+      ID_FRAME_SRCDOC = getFrameId(R_FRAME_SRCDOC);
+      ID_FRAME_UNREACHABLE = getFrameId(R_FRAME_UNREACHABLE);
+      ID_FRAME_SECOND = getFrameId(R_FRAME_SECOND);
+      ID_FRAME_THIRD = getFrameId(R_FRAME_THIRD);
+      ID_FRAME_NOPERMISSION = getFrameId(R_FRAME_NOPERMISSION);
+
+      runTests(config);
+    });
+  });
+
+  chrome.tabs.create({url: testUrl}, function(tab) { tabId = tab.id; });
+});
+
+function runTests(config) {
+  // All of the following tests set the frameId parameter in the injection
+  // details.
+  chrome.test.runTests([
+    function executeScriptInTopFrame() {
+      chrome.tabs.executeScript(
+          tabId, {frameId: 0, code: 'document.URL'}, pass(function(results) {
+            assertEq(1, results.length);
+            assertTrue(matchesAny(results, R_FRAME_TOP));
+          }));
+    },
+
+    function executeScriptInTopFrameIncludingAllFrames() {
+      chrome.tabs.executeScript(
+          tabId, {
+            frameId: 0,
+            matchAboutBlank: true,
+            allFrames: true,
+            code: 'document.URL'
+          },
+          pass(function(results) {
+            assertEq(4, results.length);
+            assertTrue(matchesAny(results, R_FRAME_TOP));
+            assertTrue(matchesAny(results, R_FRAME_SRCDOC));
+            assertTrue(matchesAny(results, R_FRAME_SECOND));
+            assertTrue(matchesAny(results, R_FRAME_THIRD));
+          }));
+    },
+
+    function executeScriptInSrcdocFrame() {
+      chrome.tabs.executeScript(
+          tabId, {
+            frameId: ID_FRAME_SRCDOC,
+            matchAboutBlank: true,
+            code: 'document.URL'
+          },
+          pass(function(results) {
+            assertEq(1, results.length);
+            assertTrue(matchesAny(results, R_FRAME_SRCDOC));
+          }));
+    },
+
+    function executeScriptInSrcdocFrameWithoutMatchAboutBlank() {
+      // TODO(robwu): Why is the origin serialized as "about:blank" instead of
+      // "about:srcdoc"?
+      chrome.tabs.executeScript(
+          tabId, {frameId: ID_FRAME_SRCDOC, code: 'document.URL'},
+          fail(
+              'Cannot access "about:blank" at origin "' + testOrigin + '". ' +
+              'Extension must have permission to access the frame\'s origin, ' +
+              'and matchAboutBlank must be true.'));
+    },
+
+    function executeScriptInSrcdocFrameIncludingAllFrames() {
+      chrome.tabs.executeScript(
+          tabId, {
+            frameId: ID_FRAME_SRCDOC,
+            matchAboutBlank: true,
+            allFrames: true,
+            code: 'document.URL'
+          },
+          pass(function(results) {
+            assertEq(1, results.length);
+            assertTrue(matchesAny(results, R_FRAME_SRCDOC));
+          }));
+    },
+
+    function executeScriptInSandboxedFrame() {
+      chrome.tabs.executeScript(
+          tabId, {
+            frameId: ID_FRAME_UNREACHABLE,
+            matchAboutBlank: true,
+            code: 'document.URL'
+          },
+          fail(
+              'Cannot access "about:blank" at origin "null". Extension must ' +
+              'have permission to access the frame\'s origin, and ' +
+              'matchAboutBlank must be true.'));
+    },
+
+    function executeScriptInSubFrame() {
+      chrome.tabs.executeScript(
+          tabId, {frameId: ID_FRAME_SECOND, code: 'document.URL'},
+          pass(function(results) {
+            assertEq(1, results.length);
+            assertTrue(matchesAny(results, R_FRAME_SECOND));
+          }));
+    },
+
+    function executeScriptInSubFrameIncludingAllFrames() {
+      chrome.tabs.executeScript(
+          tabId,
+          {frameId: ID_FRAME_SECOND, allFrames: true, code: 'document.URL'},
+          pass(function(results) {
+            assertEq(2, results.length);
+            assertTrue(matchesAny(results, R_FRAME_SECOND));
+            assertTrue(matchesAny(results, R_FRAME_THIRD));
+          }));
+    },
+
+    function executeScriptInNestedFrame() {
+      chrome.tabs.executeScript(
+          tabId, {frameId: ID_FRAME_THIRD, code: 'document.URL'},
+          pass(function(results) {
+            assertEq(1, results.length);
+            assertTrue(matchesAny(results, R_FRAME_THIRD));
+          }));
+    },
+
+    function executeScriptInNestedFrameIncludingAllFrames() {
+      chrome.tabs.executeScript(
+          tabId,
+          {frameId: ID_FRAME_THIRD, allFrames: true, code: 'document.URL'},
+          pass(function(results) {
+            assertEq(1, results.length);
+            assertTrue(matchesAny(results, R_FRAME_THIRD));
+          }));
+    },
+
+    function executeScriptInFrameWithoutPermission() {
+      chrome.tabs.executeScript(
+          tabId, {frameId: ID_FRAME_NOPERMISSION, code: 'document.URL'},
+          fail(
+              'Cannot access contents of url "http://c.com:' +
+              config.testServer.port + '/empty.html". Extension manifest ' +
+              'must request permission to access this host.'));
+    },
+
+    function executeScriptWithNonExistentFrameId() {
+      chrome.tabs.executeScript(
+          tabId, {frameId: 999999999, code: 'document.URL'},
+          fail('No frame with id 999999999 in tab ' + tabId + '.'));
+    },
+
+    function executeScriptWithNegativeFrameId() {
+      try {
+        chrome.tabs.executeScript(
+            tabId, {frameId: -1, code: 'document.URL'}, function() {
+              chrome.test.fail(
+                  'executeScript should never have been executed!');
+            });
+      } catch (e) {
+        assertEq(
+            'Invalid value for argument 2. Property \'frameId\': ' +
+                'Value must not be less than 0.',
+            e.message);
+        chrome.test.succeed();
+      }
+    },
+
+    function insertCSSInTopFrame() {
+      insertCSS(tabId, {frameId: 0}, pass(function(results) {
+                  assertEq(1, results.length);
+                  assertTrue(matchesAny(results, R_FRAME_TOP));
+                }));
+    },
+
+    function insertCSSInTopFrameIncludingAllFrames() {
+      insertCSS(
+          tabId, {frameId: 0, matchAboutBlank: true, allFrames: true},
+          pass(function(results) {
+            assertEq(4, results.length);
+            assertTrue(matchesAny(results, R_FRAME_TOP));
+            assertTrue(matchesAny(results, R_FRAME_SRCDOC));
+            assertTrue(matchesAny(results, R_FRAME_SECOND));
+            assertTrue(matchesAny(results, R_FRAME_THIRD));
+          }));
+    },
+
+    function insertCSSInSrcdocFrame() {
+      insertCSS(
+          tabId, {frameId: ID_FRAME_SRCDOC, matchAboutBlank: true},
+          pass(function(results) {
+            assertEq(1, results.length);
+            assertTrue(matchesAny(results, R_FRAME_SRCDOC));
+          }));
+    },
+
+    function insertCSSInSrcdocFrameWithoutMatchAboutBlank() {
+      // TODO(robwu): Why is the origin serialized as "about:blank" instead of
+      // "about:srcdoc"?
+      chrome.tabs.insertCSS(
+          tabId, {frameId: ID_FRAME_SRCDOC, code: 'body{color:red;}'},
+          fail(
+              'Cannot access "about:blank" at origin "' + testOrigin + '". ' +
+              'Extension must have permission to access the frame\'s origin, ' +
+              'and matchAboutBlank must be true.'));
+    },
+
+    function insertCSSInSrcdocFrameIncludingAllFrames() {
+      insertCSS(
+          tabId,
+          {frameId: ID_FRAME_SRCDOC, matchAboutBlank: true, allFrames: true},
+          pass(function(results) {
+            assertEq(1, results.length);
+            assertTrue(matchesAny(results, R_FRAME_SRCDOC));
+          }));
+    },
+
+    function insertCSSInSandboxedFrame() {
+      chrome.tabs.insertCSS(
+          tabId, {
+            frameId: ID_FRAME_UNREACHABLE,
+            matchAboutBlank: true,
+            code: 'body{color:red}'
+          },
+          fail(
+              'Cannot access "about:blank" at origin "null". Extension must ' +
+              'have permission to access the frame\'s origin, and ' +
+              'matchAboutBlank must be true.'));
+    },
+
+    function insertCSSInSubFrame() {
+      insertCSS(tabId, {frameId: ID_FRAME_SECOND}, pass(function(results) {
+                  assertEq(1, results.length);
+                  assertTrue(matchesAny(results, R_FRAME_SECOND));
+                }));
+    },
+
+    function insertCSSInSubFrameIncludingAllFrames() {
+      insertCSS(
+          tabId, {frameId: ID_FRAME_SECOND, allFrames: true},
+          pass(function(results) {
+            assertEq(2, results.length);
+            assertTrue(matchesAny(results, R_FRAME_SECOND));
+            assertTrue(matchesAny(results, R_FRAME_THIRD));
+          }));
+    },
+
+    function insertCSSInNestedFrame() {
+      insertCSS(tabId, {frameId: ID_FRAME_THIRD}, pass(function(results) {
+                  assertEq(1, results.length);
+                  assertTrue(matchesAny(results, R_FRAME_THIRD));
+                }));
+    },
+
+    function insertCSSInNestedFrameIncludingAllFrames() {
+      insertCSS(
+          tabId, {frameId: ID_FRAME_THIRD, allFrames: true},
+          pass(function(results) {
+            assertEq(1, results.length);
+            assertTrue(matchesAny(results, R_FRAME_THIRD));
+          }));
+    },
+
+    function insertCSSInFrameWithoutPermission() {
+      chrome.tabs.insertCSS(
+          tabId, {frameId: ID_FRAME_NOPERMISSION, code: 'body{color:red}'},
+          fail(
+              'Cannot access contents of url "http://c.com:' +
+              config.testServer.port + '/empty.html". Extension manifest ' +
+              'must request permission to access this host.'));
+    },
+
+    function insertCSSWithNonExistentFrameId() {
+      chrome.tabs.insertCSS(
+          tabId, {frameId: 999999999, code: 'body{color:red}'},
+          fail('No frame with id 999999999 in tab ' + tabId + '.'));
+    },
+
+    function insertCSSWithNegativeFrameId() {
+      try {
+        chrome.tabs.insertCSS(
+            tabId, {frameId: -1, code: 'body{color:red}'}, function() {
+              chrome.test.fail('insertCSS should never have been executed!');
+            });
+      } catch (e) {
+        assertEq(
+            'Invalid value for argument 2. Property \'frameId\': ' +
+                'Value must not be less than 0.',
+            e.message);
+        chrome.test.succeed();
+      }
+    },
+
+  ]);
+}
diff --git a/chrome/test/data/extensions/api_test/executescript/navigation_race/test.js b/chrome/test/data/extensions/api_test/executescript/navigation_race/test.js
index 02bd14b..fb4f7e0 100644
--- a/chrome/test/data/extensions/api_test/executescript/navigation_race/test.js
+++ b/chrome/test/data/extensions/api_test/executescript/navigation_race/test.js
@@ -17,9 +17,10 @@
         // the script, so it's still showing a.com, where we don't have
         // permission to run it.
         if (chrome.runtime.lastError) {
-          chrome.test.assertTrue(
-              chrome.runtime.lastError.message.indexOf(
-                  'Cannot access contents of the page.') == 0);
+          chrome.test.assertLastError(
+              'Cannot access contents of url "' + urlA +
+              '". Extension manifest must request permission to access this ' +
+              'host.');
           chrome.test.notifyPass();
         } else {
           // If there were no errors, then the script did run, but it should
diff --git a/components/clipboard/clipboard_application_delegate.cc b/components/clipboard/clipboard_application_delegate.cc
index 9f3cde56..fe148c7 100644
--- a/components/clipboard/clipboard_application_delegate.cc
+++ b/components/clipboard/clipboard_application_delegate.cc
@@ -7,7 +7,7 @@
 #include <utility>
 
 #include "components/clipboard/clipboard_standalone_impl.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 
 namespace clipboard {
 
@@ -22,13 +22,13 @@
 }
 
 bool ClipboardApplicationDelegate::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+    mojo::Connection* connection) {
   connection->AddService(this);
   return true;
 }
 
 void ClipboardApplicationDelegate::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<mojo::Clipboard> request) {
   // TODO(erg): Write native implementations of the clipboard. For now, we
   // just build a clipboard which doesn't interact with the system.
diff --git a/components/clipboard/clipboard_application_delegate.h b/components/clipboard/clipboard_application_delegate.h
index 18b8b047..1184f9b 100644
--- a/components/clipboard/clipboard_application_delegate.h
+++ b/components/clipboard/clipboard_application_delegate.h
@@ -8,30 +8,25 @@
 #include "base/macros.h"
 #include "components/clipboard/public/interfaces/clipboard.mojom.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
-
-namespace mojo {
-class ApplicationConnection;
-}
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace clipboard {
 
 class ClipboardApplicationDelegate
-    : public mojo::ApplicationDelegate,
+    : public mojo::ShellClient,
       public mojo::InterfaceFactory<mojo::Clipboard> {
  public:
   ClipboardApplicationDelegate();
   ~ClipboardApplicationDelegate() override;
 
-  // mojo::ApplicationDelegate implementation.
+  // mojo::ShellClient implementation.
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   // mojo::InterfaceFactory<mojo::Clipboard> implementation.
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<mojo::Clipboard> request) override;
 
  private:
diff --git a/components/devtools_service/devtools_service_delegate.cc b/components/devtools_service/devtools_service_delegate.cc
index 5382703..d4384cc 100644
--- a/components/devtools_service/devtools_service_delegate.cc
+++ b/components/devtools_service/devtools_service_delegate.cc
@@ -10,7 +10,7 @@
 #include "components/devtools_service/devtools_registry_impl.h"
 #include "components/devtools_service/devtools_service.h"
 #include "mojo/common/url_type_converters.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 #include "url/gurl.h"
 
@@ -38,8 +38,7 @@
   service_.reset(new DevToolsService(shell));
 }
 
-bool DevToolsServiceDelegate::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+bool DevToolsServiceDelegate::AcceptConnection(mojo::Connection* connection) {
   connection->AddService<DevToolsRegistry>(this);
 
   // DevToolsCoordinator is a privileged interface and only allowed for the
@@ -54,13 +53,13 @@
 }
 
 void DevToolsServiceDelegate::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<DevToolsRegistry> request) {
   service_->registry()->BindToRegistryRequest(std::move(request));
 }
 
 void DevToolsServiceDelegate::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<DevToolsCoordinator> request) {
   service_->BindToCoordinatorRequest(std::move(request));
 }
diff --git a/components/devtools_service/devtools_service_delegate.h b/components/devtools_service/devtools_service_delegate.h
index a500a7f..5ae52f9 100644
--- a/components/devtools_service/devtools_service_delegate.h
+++ b/components/devtools_service/devtools_service_delegate.h
@@ -8,15 +8,15 @@
 #include "base/macros.h"
 #include "base/memory/scoped_ptr.h"
 #include "components/devtools_service/public/interfaces/devtools_service.mojom.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace devtools_service {
 
 class DevToolsService;
 
 class DevToolsServiceDelegate
-    : public mojo::ApplicationDelegate,
+    : public mojo::ShellClient,
       public mojo::InterfaceFactory<DevToolsRegistry>,
       public mojo::InterfaceFactory<DevToolsCoordinator> {
  public:
@@ -24,19 +24,18 @@
   ~DevToolsServiceDelegate() override;
 
  private:
-  // mojo::ApplicationDelegate implementation.
+  // mojo::Connection implementation.
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
   void Quit() override;
 
   // mojo::InterfaceFactory<DevToolsRegistry> implementation.
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<DevToolsRegistry> request) override;
 
   // mojo::InterfaceFactory<DevToolsCoordinator> implementation.
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<DevToolsCoordinator> request) override;
 
   scoped_ptr<DevToolsService> service_;
diff --git a/components/filesystem/file_system_app.cc b/components/filesystem/file_system_app.cc
index 855ece4..ec3887b 100644
--- a/components/filesystem/file_system_app.cc
+++ b/components/filesystem/file_system_app.cc
@@ -8,7 +8,7 @@
 
 #include "base/bind.h"
 #include "base/logging.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 
 namespace filesystem {
@@ -23,8 +23,7 @@
   tracing_.Initialize(shell, url);
 }
 
-bool FileSystemApp::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+bool FileSystemApp::AcceptConnection(mojo::Connection* connection) {
   connection->AddService<FileSystem>(this);
   return true;
 }
@@ -57,7 +56,7 @@
 }
 
 // |InterfaceFactory<Files>| implementation:
-void FileSystemApp::Create(mojo::ApplicationConnection* connection,
+void FileSystemApp::Create(mojo::Connection* connection,
                            mojo::InterfaceRequest<FileSystem> request) {
   new FileSystemImpl(this, connection, std::move(request));
 }
diff --git a/components/filesystem/file_system_app.h b/components/filesystem/file_system_app.h
index b8ef41c..44da313 100644
--- a/components/filesystem/file_system_app.h
+++ b/components/filesystem/file_system_app.h
@@ -10,8 +10,8 @@
 #include "components/filesystem/file_system_impl.h"
 #include "components/filesystem/public/interfaces/file_system.mojom.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace mojo {
 class Shell;
@@ -19,7 +19,7 @@
 
 namespace filesystem {
 
-class FileSystemApp : public mojo::ApplicationDelegate,
+class FileSystemApp : public mojo::ShellClient,
                       public mojo::InterfaceFactory<FileSystem> {
  public:
   FileSystemApp();
@@ -34,15 +34,14 @@
   // that we can QuitNow() once the last DirectoryImpl has closed itself.
   void OnDirectoryConnectionError(DirectoryImpl* directory);
 
-  // |ApplicationDelegate| override:
+  // |mojo::ShellClient| override:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
   bool ShellConnectionLost() override;
 
   // |InterfaceFactory<Files>| implementation:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<FileSystem> request) override;
 
   // Use a vector to work around map not letting us use FileSystemClientPtr as
diff --git a/components/filesystem/file_system_impl.cc b/components/filesystem/file_system_impl.cc
index 88de84c..785e6909 100644
--- a/components/filesystem/file_system_impl.cc
+++ b/components/filesystem/file_system_impl.cc
@@ -17,7 +17,7 @@
 #include "build/build_config.h"
 #include "components/filesystem/directory_impl.h"
 #include "components/filesystem/file_system_app.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "url/gurl.h"
 
 #if defined(OS_WIN)
@@ -46,7 +46,7 @@
 }  // namespace filesystem
 
 FileSystemImpl::FileSystemImpl(FileSystemApp* app,
-                               mojo::ApplicationConnection* connection,
+                               mojo::Connection* connection,
                                mojo::InterfaceRequest<FileSystem> request)
     : app_(app),
       remote_application_url_(connection->GetRemoteApplicationURL()),
diff --git a/components/filesystem/file_system_impl.h b/components/filesystem/file_system_impl.h
index 2cda44d..c3fae13a 100644
--- a/components/filesystem/file_system_impl.h
+++ b/components/filesystem/file_system_impl.h
@@ -15,7 +15,7 @@
 }
 
 namespace mojo {
-class ApplicationConnection;
+class Connection;
 }
 
 namespace filesystem {
@@ -24,7 +24,7 @@
 class FileSystemImpl : public FileSystem {
  public:
   FileSystemImpl(FileSystemApp* app,
-                 mojo::ApplicationConnection* connection,
+                 mojo::Connection* connection,
                  mojo::InterfaceRequest<FileSystem> request);
   ~FileSystemImpl() override;
 
diff --git a/components/font_service/font_service_app.cc b/components/font_service/font_service_app.cc
index 7618296..8636c7c 100644
--- a/components/font_service/font_service_app.cc
+++ b/components/font_service/font_service_app.cc
@@ -9,7 +9,7 @@
 #include "base/files/file.h"
 #include "base/files/file_path.h"
 #include "mojo/platform_handle/platform_handle_functions.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 
 static_assert(static_cast<uint32_t>(SkTypeface::kNormal) ==
                   static_cast<uint32_t>(font_service::TypefaceStyle::NORMAL),
@@ -63,13 +63,12 @@
   tracing_.Initialize(shell, url);
 }
 
-bool FontServiceApp::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+bool FontServiceApp::AcceptConnection(mojo::Connection* connection) {
   connection->AddService(this);
   return true;
 }
 
-void FontServiceApp::Create(mojo::ApplicationConnection* connection,
+void FontServiceApp::Create(mojo::Connection* connection,
                             mojo::InterfaceRequest<FontService> request) {
   bindings_.AddBinding(this, std::move(request));
 }
diff --git a/components/font_service/font_service_app.h b/components/font_service/font_service_app.h
index 914eb08..6c2aeea 100644
--- a/components/font_service/font_service_app.h
+++ b/components/font_service/font_service_app.h
@@ -11,13 +11,13 @@
 #include "components/font_service/public/interfaces/font_service.mojom.h"
 #include "mojo/common/weak_binding_set.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "skia/ext/skia_utils_base.h"
 
 namespace font_service {
 
-class FontServiceApp : public mojo::ApplicationDelegate,
+class FontServiceApp : public mojo::ShellClient,
                        public mojo::InterfaceFactory<FontService>,
                        public FontService {
  public:
@@ -25,14 +25,13 @@
   ~FontServiceApp() override;
 
  private:
-  // ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   // mojo::InterfaceFactory<FontService>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<FontService> request) override;
 
   // FontService:
diff --git a/components/html_viewer/ax_provider_apptest.cc b/components/html_viewer/ax_provider_apptest.cc
index d53d271..2ee55873 100644
--- a/components/html_viewer/ax_provider_apptest.cc
+++ b/components/html_viewer/ax_provider_apptest.cc
@@ -82,8 +82,8 @@
   ASSERT_TRUE(server.Start());
 
   // Connect to the URL through the mojo:html_viewer content handler.
-  scoped_ptr<ApplicationConnection> connection =
-      shell()->ConnectToApplication(server.GetURL("/test.html").spec());
+  scoped_ptr<Connection> connection =
+      shell()->Connect(server.GetURL("/test.html").spec());
 
   // Embed the html_viewer in a Window.
   mus::mojom::WindowTreeClientPtr tree_client;
diff --git a/components/html_viewer/blink_platform_impl.cc b/components/html_viewer/blink_platform_impl.cc
index 1f27e86..1a8d159 100644
--- a/components/html_viewer/blink_platform_impl.cc
+++ b/components/html_viewer/blink_platform_impl.cc
@@ -78,8 +78,8 @@
       main_thread_task_runner_(renderer_scheduler->DefaultTaskRunner()),
       main_thread_(renderer_scheduler->CreateMainThread()) {
   if (shell) {
-    scoped_ptr<mojo::ApplicationConnection> connection =
-        shell->ConnectToApplication("mojo:network_service");
+    scoped_ptr<mojo::Connection> connection =
+        shell->Connect("mojo:network_service");
     connection->ConnectToService(&web_socket_factory_);
     connection->ConnectToService(&url_loader_factory_);
 
diff --git a/components/html_viewer/blink_resource_constants.h b/components/html_viewer/blink_resource_constants.h
index cc12ca1..ac9f3d7 100644
--- a/components/html_viewer/blink_resource_constants.h
+++ b/components/html_viewer/blink_resource_constants.h
@@ -89,6 +89,8 @@
     {"xhtmlmp.css", IDR_UASTYLE_XHTMLMP_CSS},
     {"viewportAndroid.css", IDR_UASTYLE_VIEWPORT_ANDROID_CSS},
     {"InspectorOverlayPage.html", IDR_INSPECTOR_OVERLAY_PAGE_HTML},
+    {"InjectedScriptSource.js", IDR_INSPECTOR_INJECTED_SCRIPT_SOURCE_JS},
+    {"DebuggerScriptSource.js", IDR_INSPECTOR_DEBUGGER_SCRIPT_SOURCE_JS},
     {"DocumentExecCommand.js", IDR_PRIVATE_SCRIPT_DOCUMENTEXECCOMMAND_JS},
     {"DocumentXMLTreeViewer.css", IDR_PRIVATE_SCRIPT_DOCUMENTXMLTREEVIEWER_CSS},
     {"DocumentXMLTreeViewer.js", IDR_PRIVATE_SCRIPT_DOCUMENTXMLTREEVIEWER_JS},
diff --git a/components/html_viewer/html_document.cc b/components/html_viewer/html_document.cc
index fca5dd44..fdb4efd 100644
--- a/components/html_viewer/html_document.cc
+++ b/components/html_viewer/html_document.cc
@@ -28,7 +28,6 @@
 #include "mojo/converters/geometry/geometry_type_converters.h"
 #include "mojo/public/cpp/system/data_pipe.h"
 #include "mojo/shell/public/cpp/application_impl.h"
-#include "mojo/shell/public/cpp/connect.h"
 #include "mojo/shell/public/interfaces/shell.mojom.h"
 #include "third_party/WebKit/public/web/WebLocalFrame.h"
 #include "ui/gfx/geometry/dip_util.h"
@@ -95,7 +94,7 @@
 }
 
 HTMLDocument::HTMLDocument(mojo::Shell* html_document_shell,
-                           mojo::ApplicationConnection* connection,
+                           mojo::Connection* connection,
                            mojo::URLResponsePtr response,
                            GlobalState* global_state,
                            const DeleteCallback& delete_callback,
@@ -271,7 +270,7 @@
     delete this;
 }
 
-void HTMLDocument::Create(mojo::ApplicationConnection* connection,
+void HTMLDocument::Create(mojo::Connection* connection,
                           mojo::InterfaceRequest<AxProvider> request) {
   if (!did_finish_local_frame_load_) {
     // Cache AxProvider interface requests until the document finishes loading.
@@ -284,7 +283,7 @@
   }
 }
 
-void HTMLDocument::Create(mojo::ApplicationConnection* connection,
+void HTMLDocument::Create(mojo::Connection* connection,
                           mojo::InterfaceRequest<TestHTMLViewer> request) {
   CHECK(IsTestInterfaceEnabled());
   if (!did_finish_local_frame_load_) {
@@ -298,7 +297,7 @@
 }
 
 void HTMLDocument::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<web_view::mojom::FrameClient> request) {
   if (frame_) {
     DVLOG(1) << "Request for FrameClient after one already vended.";
@@ -308,7 +307,7 @@
 }
 
 void HTMLDocument::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<devtools_service::DevToolsAgent> request) {
   if (frame_) {
     if (frame_->devtools_agent())
@@ -319,7 +318,7 @@
 }
 
 void HTMLDocument::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) {
   DCHECK(!transferable_state_.window_tree_delegate_impl);
   transferable_state_.window_tree_delegate_impl.reset(
diff --git a/components/html_viewer/html_document.h b/components/html_viewer/html_document.h
index 453d2df..b24f2b3 100644
--- a/components/html_viewer/html_document.h
+++ b/components/html_viewer/html_document.h
@@ -64,7 +64,7 @@
   // |connection| the specific connection triggering this new instance.
   // |setup| is used to obtain init type state (such as resources).
   HTMLDocument(mojo::Shell* html_document_shell,
-               mojo::ApplicationConnection* connection,
+               mojo::Connection* connection,
                mojo::URLResponsePtr response,
                GlobalState* setup,
                const DeleteCallback& delete_callback,
@@ -119,31 +119,31 @@
   void OnFrameDestroyed() override;
 
   // mojo::InterfaceFactory<mojo::AxProvider>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<mojo::AxProvider> request) override;
 
   // mojo::InterfaceFactory<web_view::mojom::FrameClient>:
   void Create(
-      mojo::ApplicationConnection* connection,
+      mojo::Connection* connection,
       mojo::InterfaceRequest<web_view::mojom::FrameClient> request) override;
 
   // mojo::InterfaceFactory<TestHTMLViewer>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<TestHTMLViewer> request) override;
 
   // mojo::InterfaceFactory<devtools_service::DevToolsAgent>:
   void Create(
-      mojo::ApplicationConnection* connection,
+      mojo::Connection* connection,
       mojo::InterfaceRequest<devtools_service::DevToolsAgent> request) override;
 
   // mojo::InterfaceFactory<mus::WindowTreeClient>:
   void Create(
-      mojo::ApplicationConnection* connection,
+      mojo::Connection* connection,
       mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) override;
 
   scoped_ptr<mojo::AppRefCount> app_refcount_;
   mojo::Shell* html_document_shell_;
-  mojo::ApplicationConnection* connection_;
+  mojo::Connection* connection_;
 
   // HTMLDocument owns these pointers; binding requests after document load.
   std::set<AxProviderImpl*> ax_providers_;
diff --git a/components/html_viewer/html_document_application_delegate.cc b/components/html_viewer/html_document_application_delegate.cc
index 5da6b38e..e1208d2c 100644
--- a/components/html_viewer/html_document_application_delegate.cc
+++ b/components/html_viewer/html_document_application_delegate.cc
@@ -10,9 +10,7 @@
 #include "base/macros.h"
 #include "components/html_viewer/global_state.h"
 #include "components/html_viewer/html_document.h"
-#include "mojo/shell/public/cpp/application_connection.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
-#include "mojo/shell/public/cpp/connect.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace html_viewer {
 
@@ -25,7 +23,7 @@
   ServiceConnectorQueue() {}
   ~ServiceConnectorQueue() override {}
 
-  void PushRequestsTo(mojo::ApplicationConnection* connection) {
+  void PushRequestsTo(mojo::Connection* connection) {
     ScopedVector<Request> requests;
     requests_.swap(requests);
     for (Request* request : requests) {
@@ -41,7 +39,7 @@
   };
 
   // mojo::ServiceConnector:
-  void ConnectToService(mojo::ApplicationConnection* application_connection,
+  void ConnectToService(mojo::Connection* connection,
                         const std::string& interface_name,
                         mojo::ScopedMessagePipeHandle handle) override {
     scoped_ptr<Request> request(new Request);
@@ -85,14 +83,14 @@
 }
 
 // Callback from the quit closure. We key off this rather than
-// ApplicationDelegate::Quit() as we don't want to shut down the messageloop
+// mojo::ShellClient::Quit() as we don't want to shut down the messageloop
 // when we quit (the messageloop is shared among multiple
 // HTMLDocumentApplicationDelegates).
 void HTMLDocumentApplicationDelegate::OnTerminate() {
   delete this;
 }
 
-// ApplicationDelegate;
+// mojo::ShellClient;
 void HTMLDocumentApplicationDelegate::Initialize(mojo::Shell* shell,
                                                  const std::string& url,
                                                  uint32_t id) {
@@ -100,7 +98,7 @@
 }
 
 bool HTMLDocumentApplicationDelegate::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+    mojo::Connection* connection) {
   if (initial_response_) {
     OnResponseReceived(nullptr, mojo::URLLoaderPtr(), connection, nullptr,
                        std::move(initial_response_));
@@ -157,7 +155,7 @@
 void HTMLDocumentApplicationDelegate::OnResponseReceived(
     scoped_ptr<mojo::AppRefCount> app_refcount,
     mojo::URLLoaderPtr loader,
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     scoped_ptr<ServiceConnectorQueue> connector_queue,
     mojo::URLResponsePtr response) {
   // HTMLDocument is destroyed when the hosting view is destroyed, or
diff --git a/components/html_viewer/html_document_application_delegate.h b/components/html_viewer/html_document_application_delegate.h
index b28dde5..8870021 100644
--- a/components/html_viewer/html_document_application_delegate.h
+++ b/components/html_viewer/html_document_application_delegate.h
@@ -13,17 +13,17 @@
 #include "components/html_viewer/html_factory.h"
 #include "mojo/public/cpp/bindings/interface_request.h"
 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_impl.h"
 #include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace html_viewer {
 
 class GlobalState;
 class HTMLDocument;
 
-// ApplicationDelegate created by the content handler for a specific url.
-class HTMLDocumentApplicationDelegate : public mojo::ApplicationDelegate,
+// mojo::ShellClient created by the content handler for a specific url.
+class HTMLDocumentApplicationDelegate : public mojo::ShellClient,
                                         public HTMLFactory {
  public:
   HTMLDocumentApplicationDelegate(
@@ -42,21 +42,20 @@
   ~HTMLDocumentApplicationDelegate() override;
 
   // Callback from the quit closure. We key off this rather than
-  // ApplicationDelegate::Quit() as we don't want to shut down the messageloop
+  // ShellClient::Quit() as we don't want to shut down the messageloop
   // when we quit (the messageloop is shared among multiple
   // HTMLDocumentApplicationDelegates).
   void OnTerminate();
 
-  // ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   void OnHTMLDocumentDeleted2(HTMLDocument* document);
   void OnResponseReceived(scoped_ptr<mojo::AppRefCount> app_refcount,
                           mojo::URLLoaderPtr loader,
-                          mojo::ApplicationConnection* connection,
+                          mojo::Connection* connection,
                           scoped_ptr<ServiceConnectorQueue> connector_queue,
                           mojo::URLResponsePtr response);
 
diff --git a/components/html_viewer/html_frame_apptest.cc b/components/html_viewer/html_frame_apptest.cc
index e9bbaf4..a52baad 100644
--- a/components/html_viewer/html_frame_apptest.cc
+++ b/components/html_viewer/html_frame_apptest.cc
@@ -52,12 +52,11 @@
   ignore_result(WindowServerTestBase::QuitRunLoop());
 }
 
-mojo::ApplicationConnection* ApplicationConnectionForFrame(Frame* frame) {
-  return static_cast<FrameConnection*>(frame->user_data())
-      ->application_connection();
+mojo::Connection* ConnectionForFrame(Frame* frame) {
+  return static_cast<FrameConnection*>(frame->user_data())->connection();
 }
 
-std::string GetFrameText(ApplicationConnection* connection) {
+std::string GetFrameText(Connection* connection) {
   html_viewer::TestHTMLViewerPtr test_html_viewer;
   connection->ConnectToService(&test_html_viewer);
   std::string result;
@@ -71,7 +70,7 @@
   return result;
 }
 
-scoped_ptr<base::Value> ExecuteScript(ApplicationConnection* connection,
+scoped_ptr<base::Value> ExecuteScript(Connection* connection,
                                       const std::string& script) {
   html_viewer::TestHTMLViewerPtr test_html_viewer;
   connection->ConnectToService(&test_html_viewer);
@@ -182,8 +181,7 @@
       ADD_FAILURE() << "unable to establish root connection";
       return nullptr;
     }
-    const std::string frame_text =
-        GetFrameText(root_connection->application_connection());
+    const std::string frame_text = GetFrameText(root_connection->connection());
     if (frame_text != "child2") {
       ADD_FAILURE() << "unexpected text " << frame_text;
       return nullptr;
@@ -195,7 +193,7 @@
   Frame* CreateEmptyChildFrame(Frame* parent) {
     const size_t initial_frame_count = parent->children().size();
     // Dynamically add a new frame.
-    ExecuteScript(ApplicationConnectionForFrame(parent),
+    ExecuteScript(ConnectionForFrame(parent),
                   AddPortToString(kAddFrameWithEmptyPageScript));
 
     frame_tree_delegate_->WaitForChildFrameCount(parent,
@@ -278,7 +276,7 @@
   ASSERT_TRUE(root_connection);
 
   ASSERT_EQ("Page with single frame",
-            GetFrameText(root_connection->application_connection()));
+            GetFrameText(root_connection->connection()));
 
   ASSERT_NO_FATAL_FAILURE(
       frame_tree_delegate_->WaitForChildFrameCount(frame_tree_->root(), 1u));
@@ -290,7 +288,7 @@
 
   ASSERT_EQ("child",
             GetFrameText(static_cast<FrameConnection*>(child_frame->user_data())
-                             ->application_connection()));
+                             ->connection()));
 }
 
 // Creates two frames. The parent navigates the child frame by way of changing
@@ -316,14 +314,14 @@
 
   ASSERT_EQ("child",
             GetFrameText(static_cast<FrameConnection*>(child_frame->user_data())
-                             ->application_connection()));
+                             ->connection()));
 
   // Change the location and wait for the navigation to occur.
   const char kNavigateFrame[] =
       "window.frames[0].location = "
       "'http://127.0.0.1:%u/empty_page2.html'";
   frame_tree_delegate_->ClearGotNavigate(child_frame);
-  ExecuteScript(ApplicationConnectionForFrame(frame_tree_->root()),
+  ExecuteScript(ConnectionForFrame(frame_tree_->root()),
                 AddPortToString(kNavigateFrame));
   ASSERT_TRUE(frame_tree_delegate_->WaitForFrameNavigation(child_frame));
 
@@ -334,15 +332,14 @@
   ASSERT_TRUE(child_frame->user_data());
   ASSERT_EQ("child2",
             GetFrameText(static_cast<FrameConnection*>(child_frame->user_data())
-                             ->application_connection()));
+                             ->connection()));
 }
 
 TEST_F(HTMLFrameTest, DynamicallyAddFrameAndVerifyParent) {
   Frame* child_frame = LoadEmptyPageAndCreateFrame();
   ASSERT_TRUE(child_frame);
 
-  mojo::ApplicationConnection* child_frame_connection =
-      ApplicationConnectionForFrame(child_frame);
+  mojo::Connection* child_frame_connection = ConnectionForFrame(child_frame);
 
   ASSERT_EQ("child", GetFrameText(child_frame_connection));
   // The child's parent should not be itself:
@@ -363,8 +360,7 @@
   Frame* child_frame = LoadEmptyPageAndCreateFrame();
   ASSERT_TRUE(child_frame);
 
-  mojo::ApplicationConnection* child_frame_connection =
-      ApplicationConnectionForFrame(child_frame);
+  mojo::Connection* child_frame_connection = ConnectionForFrame(child_frame);
 
   // Change the name of the child's window.
   ExecuteScript(child_frame_connection, "window.name = 'new_child';");
@@ -377,7 +373,7 @@
   do {
     find_window_result.clear();
     scoped_ptr<base::Value> script_value(
-        ExecuteScript(ApplicationConnectionForFrame(frame_tree_->root()),
+        ExecuteScript(ConnectionForFrame(frame_tree_->root()),
                       "window.frames['new_child'] != null ? 'found frame' : "
                       "'unable to find frame';"));
     if (script_value->IsType(base::Value::TYPE_LIST)) {
@@ -414,7 +410,7 @@
   do {
     child_child_frame_count.clear();
     scoped_ptr<base::Value> script_value(
-        ExecuteScript(ApplicationConnectionForFrame(frame_tree_->root()),
+        ExecuteScript(ConnectionForFrame(frame_tree_->root()),
                       kGetChildChildFrameCount));
     if (script_value->IsType(base::Value::TYPE_LIST)) {
       base::ListValue* script_value_as_list;
@@ -431,11 +427,11 @@
   // Remove the child's child and make sure the root doesn't see it anymore.
   const char kRemoveLastIFrame[] =
       "document.body.removeChild(document.body.lastChild);";
-  ExecuteScript(ApplicationConnectionForFrame(child_frame), kRemoveLastIFrame);
+  ExecuteScript(ConnectionForFrame(child_frame), kRemoveLastIFrame);
   do {
     child_child_frame_count.clear();
     scoped_ptr<base::Value> script_value(
-        ExecuteScript(ApplicationConnectionForFrame(frame_tree_->root()),
+        ExecuteScript(ConnectionForFrame(frame_tree_->root()),
                       kGetChildChildFrameCount));
     if (script_value->IsType(base::Value::TYPE_LIST)) {
       base::ListValue* script_value_as_list;
@@ -455,8 +451,7 @@
   Frame* child_frame = LoadEmptyPageAndCreateFrame();
   ASSERT_TRUE(child_frame);
 
-  mojo::ApplicationConnection* child_frame_connection =
-      ApplicationConnectionForFrame(child_frame);
+  mojo::Connection* child_frame_connection = ConnectionForFrame(child_frame);
   ASSERT_EQ("child", GetFrameText(child_frame_connection));
 
   // Register an event handler in the child frame.
@@ -471,7 +466,7 @@
   // Post a message from the parent to the child.
   const char kPostMessageFromParent[] =
       "window.frames[0].postMessage('hello from parent', '*');";
-  ExecuteScript(ApplicationConnectionForFrame(frame_tree_->root()),
+  ExecuteScript(ConnectionForFrame(frame_tree_->root()),
                 kPostMessageFromParent);
 
   // Wait for the child frame to see the message.
diff --git a/components/html_viewer/html_viewer.cc b/components/html_viewer/html_viewer.cc
index d475038..62fcf525 100644
--- a/components/html_viewer/html_viewer.cc
+++ b/components/html_viewer/html_viewer.cc
@@ -8,7 +8,7 @@
 
 #include "components/html_viewer/content_handler_impl.h"
 #include "components/html_viewer/global_state.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 
 namespace html_viewer {
 
@@ -24,14 +24,13 @@
   global_state_.reset(new GlobalState(shell, url));
 }
 
-bool HTMLViewer::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+bool HTMLViewer::AcceptConnection(mojo::Connection* connection) {
   connection->AddService(this);
   return true;
 }
 
 void HTMLViewer::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<mojo::shell::mojom::ContentHandler> request) {
   new ContentHandlerImpl(global_state_.get(), shell_, std::move(request));
 }
diff --git a/components/html_viewer/html_viewer.h b/components/html_viewer/html_viewer.h
index 83597c1..d7123160 100644
--- a/components/html_viewer/html_viewer.h
+++ b/components/html_viewer/html_viewer.h
@@ -7,8 +7,8 @@
 
 #include "base/macros.h"
 #include "base/memory/scoped_ptr.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/public/interfaces/content_handler.mojom.h"
 
 namespace html_viewer {
@@ -16,7 +16,7 @@
 class GlobalState;
 
 class HTMLViewer
-    : public mojo::ApplicationDelegate,
+    : public mojo::ShellClient,
       public mojo::InterfaceFactory<mojo::shell::mojom::ContentHandler> {
  public:
   HTMLViewer();
@@ -26,17 +26,17 @@
   GlobalState* global_state() const { return global_state_.get(); }
   mojo::Shell* shell() const { return shell_; }
 
-  // Overridden from ApplicationDelegate:
+  // Overridden from mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
 
  private:
-  // Overridden from ApplicationDelegate:
+  // Overridden from mojo::ShellClient:
   bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+      mojo::Connection* connection) override;
 
   // Overridden from InterfaceFactory<shell::mojom::ContentHandler>
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<mojo::shell::mojom::ContentHandler>
                   request) override;
 
diff --git a/components/html_viewer/layout_test_html_viewer.cc b/components/html_viewer/layout_test_html_viewer.cc
index 115539e..db7fb60b 100644
--- a/components/html_viewer/layout_test_html_viewer.cc
+++ b/components/html_viewer/layout_test_html_viewer.cc
@@ -45,7 +45,7 @@
 }
 
 void LayoutTestHTMLViewer::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<mojo::shell::mojom::ContentHandler> request) {
   new LayoutTestContentHandlerImpl(global_state(), shell(), std::move(request),
                                    test_interfaces_.get(), &test_delegate_);
diff --git a/components/html_viewer/layout_test_html_viewer.h b/components/html_viewer/layout_test_html_viewer.h
index 861e8c5..701a415 100644
--- a/components/html_viewer/layout_test_html_viewer.h
+++ b/components/html_viewer/layout_test_html_viewer.h
@@ -24,12 +24,12 @@
  private:
   void TestFinished();
 
-  // Overridden from ApplicationDelegate:
+  // Overridden from mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
 
   // Overridden from InterfaceFactory<shell::mojom::ContentHandler>
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<mojo::shell::mojom::ContentHandler>
                   request) override;
 
diff --git a/components/html_viewer/stats_collection_controller.cc b/components/html_viewer/stats_collection_controller.cc
index e6cdf5c..15710ec69 100644
--- a/components/html_viewer/stats_collection_controller.cc
+++ b/components/html_viewer/stats_collection_controller.cc
@@ -82,8 +82,7 @@
 
   v8::Context::Scope context_scope(context);
 
-  scoped_ptr<mojo::ApplicationConnection> connection =
-      shell->ConnectToApplication("mojo:tracing");
+  scoped_ptr<mojo::Connection> connection = shell->Connect("mojo:tracing");
   if (!connection)
     return nullptr;
   tracing::StartupPerformanceDataCollectorPtr collector_for_controller;
diff --git a/components/mus/mus_app.cc b/components/mus/mus_app.cc
index b7ffa4dd..cd7a786 100644
--- a/components/mus/mus_app.cc
+++ b/components/mus/mus_app.cc
@@ -16,7 +16,7 @@
 #include "components/mus/ws/window_tree_impl.h"
 #include "mojo/public/c/system/main.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 #include "ui/events/event_switches.h"
 #include "ui/events/platform/platform_event_source.h"
@@ -30,7 +30,7 @@
 #include "ui/ozone/public/ozone_platform.h"
 #endif
 
-using mojo::ApplicationConnection;
+using mojo::Connection;
 using mojo::InterfaceRequest;
 using mus::mojom::WindowTreeHostFactory;
 using mus::mojom::Gpu;
@@ -90,8 +90,7 @@
   tracing_.Initialize(shell, url);
 }
 
-bool MandolineUIServicesApp::AcceptConnection(
-    ApplicationConnection* connection) {
+bool MandolineUIServicesApp::AcceptConnection(Connection* connection) {
   connection->AddService<Gpu>(this);
   connection->AddService<mojom::DisplayManager>(this);
   connection->AddService<mojom::WindowManagerFactoryService>(this);
@@ -130,7 +129,7 @@
 }
 
 void MandolineUIServicesApp::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<mojom::DisplayManager> request) {
   if (!connection_manager_->has_tree_host_connections()) {
     scoped_ptr<PendingRequest> pending_request(new PendingRequest);
@@ -143,13 +142,13 @@
 }
 
 void MandolineUIServicesApp::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<mojom::WindowManagerFactoryService> request) {
   connection_manager_->CreateWindowManagerFactoryService(std::move(request));
 }
 
 void MandolineUIServicesApp::Create(
-    ApplicationConnection* connection,
+    Connection* connection,
     InterfaceRequest<mojom::WindowTreeFactory> request) {
   if (!connection_manager_->has_tree_host_connections()) {
     scoped_ptr<PendingRequest> pending_request(new PendingRequest);
@@ -167,12 +166,12 @@
 }
 
 void MandolineUIServicesApp::Create(
-    ApplicationConnection* connection,
+    Connection* connection,
     InterfaceRequest<WindowTreeHostFactory> request) {
   factory_bindings_.AddBinding(this, std::move(request));
 }
 
-void MandolineUIServicesApp::Create(mojo::ApplicationConnection* connection,
+void MandolineUIServicesApp::Create(mojo::Connection* connection,
                                     mojo::InterfaceRequest<Gpu> request) {
   DCHECK(gpu_state_);
   new GpuImpl(std::move(request), gpu_state_);
diff --git a/components/mus/mus_app.h b/components/mus/mus_app.h
index 920e6688..61f9632 100644
--- a/components/mus/mus_app.h
+++ b/components/mus/mus_app.h
@@ -19,9 +19,8 @@
 #include "components/mus/ws/connection_manager_delegate.h"
 #include "mojo/common/weak_binding_set.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/app_lifetime_helper.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace mojo {
 class Shell;
@@ -43,7 +42,7 @@
 }
 
 class MandolineUIServicesApp
-    : public mojo::ApplicationDelegate,
+    : public mojo::ShellClient,
       public ws::ConnectionManagerDelegate,
       public mojo::InterfaceFactory<mojom::DisplayManager>,
       public mojo::InterfaceFactory<mojom::WindowManagerFactoryService>,
@@ -60,11 +59,10 @@
   // has been established.
   struct PendingRequest;
 
-  // ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   // ConnectionManagerDelegate:
   void OnFirstRootConnectionCreated() override;
@@ -77,26 +75,26 @@
       mojom::WindowTreeClientPtr client) override;
 
   // mojo::InterfaceFactory<mojom::DisplayManager> implementation.
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<mojom::DisplayManager> request) override;
 
   // mojo::InterfaceFactory<mojom::WindowManagerFactoryService> implementation.
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<mojom::WindowManagerFactoryService>
                   request) override;
 
   // mojo::InterfaceFactory<mojom::WindowTreeFactory>:
   void Create(
-      mojo::ApplicationConnection* connection,
+      mojo::Connection* connection,
       mojo::InterfaceRequest<mojom::WindowTreeFactory> request) override;
 
   // mojo::InterfaceFactory<mojom::WindowTreeHostFactory>:
   void Create(
-      mojo::ApplicationConnection* connection,
+      mojo::Connection* connection,
       mojo::InterfaceRequest<mojom::WindowTreeHostFactory> request) override;
 
   // mojo::InterfaceFactory<mojom::Gpu> implementation.
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<mojom::Gpu> request) override;
 
   // mojom::WindowTreeHostFactory implementation.
diff --git a/components/mus/public/cpp/tests/window_server_test_base.cc b/components/mus/public/cpp/tests/window_server_test_base.cc
index 636e4f7..678fc55 100644
--- a/components/mus/public/cpp/tests/window_server_test_base.cc
+++ b/components/mus/public/cpp/tests/window_server_test_base.cc
@@ -71,12 +71,11 @@
   std::swap(window_manager_, most_recent_connection_);
 }
 
-mojo::ApplicationDelegate* WindowServerTestBase::GetApplicationDelegate() {
+mojo::ShellClient* WindowServerTestBase::GetShellClient() {
   return this;
 }
 
-bool WindowServerTestBase::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+bool WindowServerTestBase::AcceptConnection(mojo::Connection* connection) {
   connection->AddService<mojom::WindowTreeClient>(this);
   return true;
 }
@@ -124,7 +123,7 @@
 }
 
 void WindowServerTestBase::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<mojom::WindowTreeClient> request) {
   WindowTreeConnection::Create(
       this, std::move(request),
diff --git a/components/mus/public/cpp/tests/window_server_test_base.h b/components/mus/public/cpp/tests/window_server_test_base.h
index 03e557fa..e1c3c74 100644
--- a/components/mus/public/cpp/tests/window_server_test_base.h
+++ b/components/mus/public/cpp/tests/window_server_test_base.h
@@ -11,7 +11,6 @@
 #include "components/mus/public/cpp/window_tree_delegate.h"
 #include "components/mus/public/interfaces/window_tree.mojom.h"
 #include "components/mus/public/interfaces/window_tree_host.mojom.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_test_base.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
 
@@ -23,7 +22,7 @@
 // established as part of SetUp().
 class WindowServerTestBase
     : public mojo::test::ApplicationTestBase,
-      public mojo::ApplicationDelegate,
+      public mojo::ShellClient,
       public WindowTreeDelegate,
       public WindowManagerDelegate,
       public mojo::InterfaceFactory<mojom::WindowTreeClient> {
@@ -64,11 +63,10 @@
   void SetUp() override;
 
   // test::ApplicationTestBase:
-  mojo::ApplicationDelegate* GetApplicationDelegate() override;
+  mojo::ShellClient* GetShellClient() override;
 
-  // ApplicationDelegate:
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  // mojo::ShellClient:
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   // WindowTreeDelegate:
   void OnEmbed(Window* root) override;
@@ -85,7 +83,7 @@
   void OnAccelerator(uint32_t id, mojom::EventPtr event) override;
 
   // InterfaceFactory<WindowTreeClient>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<mojom::WindowTreeClient> request) override;
 
   // Used to receive the most recent window tree connection loaded by an embed
diff --git a/components/mus/ws/connection_manager.cc b/components/mus/ws/connection_manager.cc
index ae7fe82c..d40f428 100644
--- a/components/mus/ws/connection_manager.cc
+++ b/components/mus/ws/connection_manager.cc
@@ -17,7 +17,7 @@
 #include "mojo/converters/geometry/geometry_type_converters.h"
 #include "mojo/converters/input_events/input_events_type_converters.h"
 #include "mojo/converters/surfaces/surfaces_type_converters.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "ui/gfx/geometry/size_conversions.h"
 
 namespace mus {
diff --git a/components/mus/ws/display_manager.cc b/components/mus/ws/display_manager.cc
index dea7a83..89682932 100644
--- a/components/mus/ws/display_manager.cc
+++ b/components/mus/ws/display_manager.cc
@@ -27,7 +27,7 @@
 #include "mojo/converters/surfaces/surfaces_type_converters.h"
 #include "mojo/converters/surfaces/surfaces_utils.h"
 #include "mojo/converters/transform/transform_type_converters.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 #include "third_party/skia/include/core/SkXfermode.h"
 #include "ui/base/cursor/cursor_loader.h"
diff --git a/components/mus/ws/window_manager_client_apptest.cc b/components/mus/ws/window_manager_client_apptest.cc
index 2312d72..8d174d78 100644
--- a/components/mus/ws/window_manager_client_apptest.cc
+++ b/components/mus/ws/window_manager_client_apptest.cc
@@ -16,7 +16,6 @@
 #include "components/mus/public/cpp/window_tree_connection_observer.h"
 #include "components/mus/public/cpp/window_tree_delegate.h"
 #include "mojo/converters/geometry/geometry_type_converters.h"
-#include "mojo/shell/public/cpp/application_connection.h"
 #include "mojo/shell/public/cpp/application_test_base.h"
 #include "ui/gfx/geometry/rect.h"
 #include "ui/mojo/geometry/geometry_util.h"
@@ -259,7 +258,7 @@
   EmbedResult Embed(Window* window, uint32_t access_policy_bitmask) {
     DCHECK(!embed_details_);
     embed_details_.reset(new EmbedDetails);
-    window->Embed(ConnectToApplicationAndGetWindowServerClient(),
+    window->Embed(ConnectAndGetWindowServerClient(),
                   access_policy_bitmask,
                   base::Bind(&WindowServerTest::EmbedCallbackImpl,
                              base::Unretained(this)));
@@ -274,8 +273,7 @@
 
   // Establishes a connection to this application and asks for a
   // WindowTreeClient.
-  mus::mojom::WindowTreeClientPtr
-  ConnectToApplicationAndGetWindowServerClient() {
+  mus::mojom::WindowTreeClientPtr ConnectAndGetWindowServerClient() {
     mus::mojom::WindowTreeClientPtr client;
     shell()->ConnectToService(shell_url(), &client);
     return client;
@@ -975,7 +973,7 @@
   window1->AddChild(window2);
 
   WindowRemovedFromParentObserver observer(window2);
-  window1->Embed(ConnectToApplicationAndGetWindowServerClient());
+  window1->Embed(ConnectAndGetWindowServerClient());
   EXPECT_TRUE(observer.was_removed());
   EXPECT_EQ(nullptr, window2->parent());
   EXPECT_TRUE(window1->children().empty());
diff --git a/components/mus/ws/window_tree_apptest.cc b/components/mus/ws/window_tree_apptest.cc
index 8237e58..cb43c7ee 100644
--- a/components/mus/ws/window_tree_apptest.cc
+++ b/components/mus/ws/window_tree_apptest.cc
@@ -16,15 +16,14 @@
 #include "components/mus/ws/test_change_tracker.h"
 #include "mojo/converters/geometry/geometry_type_converters.h"
 #include "mojo/public/cpp/bindings/associated_binding.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_test_base.h"
 
-using mojo::ApplicationConnection;
-using mojo::ApplicationDelegate;
 using mojo::Array;
 using mojo::Callback;
+using mojo::Connection;
 using mojo::InterfaceRequest;
 using mojo::RectPtr;
+using mojo::ShellClient;
 using mojo::String;
 using mus::mojom::ErrorCode;
 using mus::mojom::EventPtr;
@@ -449,7 +448,7 @@
 
  private:
   // InterfaceFactory<WindowTreeClient>:
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<WindowTreeClient> request) override {
     client_impl_.reset(new TestWindowTreeClientImpl());
     client_impl_->Bind(std::move(request));
@@ -466,7 +465,7 @@
 }  // namespace
 
 class WindowTreeAppTest : public mojo::test::ApplicationTestBase,
-                          public ApplicationDelegate {
+                          public mojo::ShellClient {
  public:
   WindowTreeAppTest()
       : connection_id_1_(0), connection_id_2_(0), root_window_id_(0) {}
@@ -561,7 +560,7 @@
   }
 
   // ApplicationTestBase:
-  ApplicationDelegate* GetApplicationDelegate() override { return this; }
+  mojo::ShellClient* GetShellClient() override { return this; }
   void SetUp() override {
     ApplicationTestBase::SetUp();
     client_factory_.reset(new WindowTreeClientFactory());
@@ -592,8 +591,8 @@
     changes1()->clear();
   }
 
-  // ApplicationDelegate implementation.
-  bool AcceptConnection(ApplicationConnection* connection) override {
+  // mojo::ShellClient implementation.
+  bool AcceptConnection(Connection* connection) override {
     connection->AddService(client_factory_.get());
     return true;
   }
diff --git a/components/pdf_viewer/pdf_viewer.cc b/components/pdf_viewer/pdf_viewer.cc
index ed5de3b9..1fa2984 100644
--- a/components/pdf_viewer/pdf_viewer.cc
+++ b/components/pdf_viewer/pdf_viewer.cc
@@ -25,14 +25,12 @@
 #include "mojo/common/data_pipe_utils.h"
 #include "mojo/public/c/system/main.h"
 #include "mojo/public/cpp/bindings/binding.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_connection.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_impl.h"
 #include "mojo/shell/public/cpp/application_runner.h"
-#include "mojo/shell/public/cpp/connect.h"
 #include "mojo/shell/public/cpp/interface_factory_impl.h"
-#include "mojo/shell/public/cpp/service_provider_impl.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/public/interfaces/content_handler.mojom.h"
 #include "mojo/shell/public/interfaces/shell.mojom.h"
 #include "third_party/pdfium/public/fpdf_ext.h"
@@ -55,7 +53,7 @@
   using DeleteCallback = base::Callback<void(PDFView*)>;
 
   PDFView(mojo::Shell* shell,
-          mojo::ApplicationConnection* connection,
+          mojo::Connection* connection,
           FPDF_DOCUMENT doc,
           const DeleteCallback& delete_callback)
       : app_ref_(shell->CreateAppRefCount()),
@@ -216,7 +214,7 @@
 
   // mojo::InterfaceFactory<web_view::mojom::FrameClient>:
   void Create(
-      mojo::ApplicationConnection* connection,
+      mojo::Connection* connection,
       mojo::InterfaceRequest<web_view::mojom::FrameClient> request) override {
     frame_client_binding_.Bind(std::move(request));
   }
@@ -240,7 +238,7 @@
 
 // Responsible for managing all the views for displaying a PDF document.
 class PDFViewerApplicationDelegate
-    : public mojo::ApplicationDelegate,
+    : public mojo::ShellClient,
       public mojo::InterfaceFactory<mus::mojom::WindowTreeClient> {
  public:
   PDFViewerApplicationDelegate(
@@ -277,7 +275,7 @@
   }
 
   // Callback from the quit closure. We key off this rather than
-  // ApplicationDelegate::Quit() as we don't want to shut down the messageloop
+  // ShellClient::Quit() as we don't want to shut down the messageloop
   // when we quit (the messageloop is shared among multiple PDFViews).
   void OnTerminate() { delete this; }
 
@@ -287,16 +285,15 @@
     pdf_views_.erase(std::find(pdf_views_.begin(), pdf_views_.end(), pdf_view));
   }
 
-  // ApplicationDelegate:
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override {
+  // mojo::ShellClient:
+  bool AcceptConnection(mojo::Connection* connection) override {
     connection->AddService<mus::mojom::WindowTreeClient>(this);
     return true;
   }
 
   // mojo::InterfaceFactory<mus::mojom::WindowTreeClient>:
   void Create(
-      mojo::ApplicationConnection* connection,
+      mojo::Connection* connection,
       mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) override {
     PDFView* pdf_view = new PDFView(
         &app_, connection, doc_,
@@ -341,7 +338,7 @@
 };
 
 class PDFViewer
-    : public mojo::ApplicationDelegate,
+    : public mojo::ShellClient,
       public mojo::InterfaceFactory<mojo::shell::mojom::ContentHandler> {
  public:
   PDFViewer() {
@@ -352,20 +349,19 @@
   ~PDFViewer() override { FPDF_DestroyLibrary(); }
 
  private:
-  // ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override {
     tracing_.Initialize(shell, url);
   }
 
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override {
+  bool AcceptConnection(mojo::Connection* connection) override {
     connection->AddService(this);
     return true;
   }
 
   // InterfaceFactory<ContentHandler>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<mojo::shell::mojom::ContentHandler>
                   request) override {
     new ContentHandlerImpl(std::move(request));
diff --git a/components/resource_provider/resource_provider_app.cc b/components/resource_provider/resource_provider_app.cc
index 79e034d1..e62438e 100644
--- a/components/resource_provider/resource_provider_app.cc
+++ b/components/resource_provider/resource_provider_app.cc
@@ -8,7 +8,7 @@
 
 #include "components/resource_provider/file_utils.h"
 #include "components/resource_provider/resource_provider_impl.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "url/gurl.h"
 
 namespace resource_provider {
@@ -26,8 +26,7 @@
   tracing_.Initialize(shell, url);
 }
 
-bool ResourceProviderApp::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+bool ResourceProviderApp::AcceptConnection(mojo::Connection* connection) {
   const base::FilePath app_path(
       GetPathForApplicationUrl(connection->GetRemoteApplicationURL()));
   if (app_path.empty())
@@ -38,7 +37,7 @@
 }
 
 void ResourceProviderApp::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<ResourceProvider> request) {
   const base::FilePath app_path(
       GetPathForApplicationUrl(connection->GetRemoteApplicationURL()));
diff --git a/components/resource_provider/resource_provider_app.h b/components/resource_provider/resource_provider_app.h
index 8831e6c..2d1dd4d5 100644
--- a/components/resource_provider/resource_provider_app.h
+++ b/components/resource_provider/resource_provider_app.h
@@ -12,8 +12,8 @@
 #include "mojo/common/weak_binding_set.h"
 #include "mojo/public/cpp/bindings/binding.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace mojo {
 class Shell;
@@ -21,21 +21,20 @@
 
 namespace resource_provider {
 
-class ResourceProviderApp : public mojo::ApplicationDelegate,
+class ResourceProviderApp : public mojo::ShellClient,
                             public mojo::InterfaceFactory<ResourceProvider> {
  public:
   explicit ResourceProviderApp(const std::string& resource_provider_app_url);
   ~ResourceProviderApp() override;
 
  private:
-  // ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   // mojo::InterfaceFactory<ResourceProvider>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<ResourceProvider> request) override;
 
   mojo::TracingImpl tracing_;
diff --git a/components/resource_provider/resource_provider_apptest.cc b/components/resource_provider/resource_provider_apptest.cc
index 83e77e3..cc5bfe1 100644
--- a/components/resource_provider/resource_provider_apptest.cc
+++ b/components/resource_provider/resource_provider_apptest.cc
@@ -15,9 +15,7 @@
 #include "mojo/platform_handle/platform_handle_functions.h"
 #include "mojo/public/cpp/bindings/array.h"
 #include "mojo/public/cpp/system/macros.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_test_base.h"
-#include "mojo/shell/public/cpp/service_provider_impl.h"
 
 namespace resource_provider {
 namespace {
diff --git a/components/web_view/frame_apptest.cc b/components/web_view/frame_apptest.cc
index be5d6360..cd79680 100644
--- a/components/web_view/frame_apptest.cc
+++ b/components/web_view/frame_apptest.cc
@@ -26,10 +26,7 @@
 #include "components/web_view/frame_tree_delegate.h"
 #include "components/web_view/frame_user_data.h"
 #include "components/web_view/test_frame_tree_delegate.h"
-#include "mojo/shell/public/cpp/application_connection.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_test_base.h"
-#include "mojo/shell/public/cpp/service_provider_impl.h"
 
 using mus::Window;
 using mus::WindowTreeConnection;
@@ -286,7 +283,7 @@
 };
 
 class FrameTest : public mojo::test::ApplicationTestBase,
-                  public mojo::ApplicationDelegate,
+                  public mojo::ShellClient,
                   public mus::WindowTreeDelegate,
                   public mojo::InterfaceFactory<mus::mojom::WindowTreeClient>,
                   public mojo::InterfaceFactory<mojom::FrameClient> {
@@ -353,11 +350,10 @@
 
  private:
   // ApplicationTestBase:
-  ApplicationDelegate* GetApplicationDelegate() override { return this; }
+  mojo::ShellClient* GetShellClient() override { return this; }
 
-  // ApplicationDelegate implementation.
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override {
+  // mojo::ShellClient implementation.
+  bool AcceptConnection(mojo::Connection* connection) override {
     connection->AddService<mus::mojom::WindowTreeClient>(this);
     connection->AddService<mojom::FrameClient>(this);
     return true;
@@ -406,7 +402,7 @@
 
   // Overridden from mojo::InterfaceFactory<mus::mojom::WindowTreeClient>:
   void Create(
-      mojo::ApplicationConnection* connection,
+      mojo::Connection* connection,
       mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) override {
     if (window_and_frame_) {
       mus::WindowTreeConnection::Create(
@@ -420,7 +416,7 @@
   }
 
   // Overridden from mojo::InterfaceFactory<mojom::FrameClient>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<mojom::FrameClient> request) override {
     ASSERT_TRUE(window_and_frame_);
     window_and_frame_->Bind(std::move(request));
diff --git a/components/web_view/frame_connection.cc b/components/web_view/frame_connection.cc
index c3417d7..af40457 100644
--- a/components/web_view/frame_connection.cc
+++ b/components/web_view/frame_connection.cc
@@ -22,7 +22,7 @@
 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h"
 #include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h"
 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 
 #if defined(OS_LINUX) && !defined(OS_ANDROID)
@@ -50,7 +50,7 @@
 
 }  // namespace
 
-FrameConnection::FrameConnection() : application_connection_(nullptr) {
+FrameConnection::FrameConnection() : connection_(nullptr) {
 }
 
 FrameConnection::~FrameConnection() {
@@ -72,7 +72,7 @@
 void FrameConnection::Init(mojo::Shell* shell,
                            mojo::URLRequestPtr request,
                            const base::Closure& on_got_id_callback) {
-  DCHECK(!application_connection_);
+  DCHECK(!connection_);
 
   mojo::shell::mojom::CapabilityFilterPtr filter(
       mojo::shell::mojom::CapabilityFilter::New());
@@ -119,22 +119,22 @@
 
   mojo::Shell::ConnectParams params(std::move(request));
   params.set_filter(std::move(filter));
-  application_connection_ = shell->ConnectToApplication(&params);
-  application_connection_->ConnectToService(&frame_client_);
-  application_connection_->AddRemoteIDCallback(on_got_id_callback);
+  connection_ = shell->Connect(&params);
+  connection_->ConnectToService(&frame_client_);
+  connection_->AddRemoteIDCallback(on_got_id_callback);
 }
 
 mus::mojom::WindowTreeClientPtr FrameConnection::GetWindowTreeClient() {
-  DCHECK(application_connection_);
+  DCHECK(connection_);
   mus::mojom::WindowTreeClientPtr window_tree_client;
-  application_connection_->ConnectToService(&window_tree_client);
+  connection_->ConnectToService(&window_tree_client);
   return window_tree_client;
 }
 
 uint32_t FrameConnection::GetContentHandlerID() const {
   uint32_t content_handler_id =
       mojo::shell::mojom::Shell::kInvalidApplicationID;
-  if (!application_connection_->GetRemoteContentHandlerID(&content_handler_id))
+  if (!connection_->GetRemoteContentHandlerID(&content_handler_id))
     NOTREACHED();
   return content_handler_id;
 }
diff --git a/components/web_view/frame_connection.h b/components/web_view/frame_connection.h
index cd29edd..a1488af 100644
--- a/components/web_view/frame_connection.h
+++ b/components/web_view/frame_connection.h
@@ -17,7 +17,7 @@
 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
 
 namespace mojo {
-class ApplicationConnection;
+class Connection;
 class Shell;
 }
 
@@ -51,9 +51,7 @@
 
   mojom::FrameClient* frame_client() { return frame_client_.get(); }
 
-  mojo::ApplicationConnection* application_connection() {
-    return application_connection_.get();
-  }
+  mojo::Connection* connection() { return connection_.get(); }
 
   // Asks the remote application for a WindowTreeClient.
   mus::mojom::WindowTreeClientPtr GetWindowTreeClient();
@@ -65,7 +63,7 @@
  private:
   mojom::FrameClientPtr frame_client_;
 
-  scoped_ptr<mojo::ApplicationConnection> application_connection_;
+  scoped_ptr<mojo::Connection> connection_;
 
   DISALLOW_COPY_AND_ASSIGN(FrameConnection);
 };
diff --git a/components/web_view/test_runner/test_runner_application_delegate.cc b/components/web_view/test_runner/test_runner_application_delegate.cc
index fc0f698..e470cc38 100644
--- a/components/web_view/test_runner/test_runner_application_delegate.cc
+++ b/components/web_view/test_runner/test_runner_application_delegate.cc
@@ -24,7 +24,7 @@
 #include "components/test_runner/blink_test_platform_support.h"
 #include "mojo/converters/geometry/geometry_type_converters.h"
 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 #include "ui/gfx/geometry/rect.h"
 #include "ui/gfx/geometry/size.h"
@@ -61,7 +61,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-// mojo::ApplicationDelegate implementation:
+// mojo::ShellClient implementation:
 
 void TestRunnerApplicationDelegate::Initialize(mojo::Shell* shell,
                                                const std::string& url,
@@ -74,7 +74,7 @@
 }
 
 bool TestRunnerApplicationDelegate::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+    mojo::Connection* connection) {
   connection->AddService<web_view::LayoutTestRunner>(this);
   return true;
 }
@@ -158,7 +158,7 @@
 // mojo::InterfaceFactory<LayoutTestRunner> implementation:
 
 void TestRunnerApplicationDelegate::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<web_view::LayoutTestRunner> request) {
   layout_test_runner_.AddBinding(this, std::move(request));
 }
diff --git a/components/web_view/test_runner/test_runner_application_delegate.h b/components/web_view/test_runner/test_runner_application_delegate.h
index 4fd2c80..fc1d3d9 100644
--- a/components/web_view/test_runner/test_runner_application_delegate.h
+++ b/components/web_view/test_runner/test_runner_application_delegate.h
@@ -17,15 +17,15 @@
 #include "components/web_view/public/interfaces/web_view.mojom.h"
 #include "components/web_view/test_runner/public/interfaces/layout_test_runner.mojom.h"
 #include "mojo/common/weak_binding_set.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 class GURL;
 
 namespace web_view {
 
 class TestRunnerApplicationDelegate
-    : public mojo::ApplicationDelegate,
+    : public mojo::ShellClient,
       public mus::WindowTreeDelegate,
       public mojom::WebViewClient,
       public LayoutTestRunner,
@@ -38,11 +38,10 @@
   void LaunchURL(const GURL& test_url);
   void Terminate();
 
-  // mojo::ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   // mus::WindowTreeDelegate:
   void OnEmbed(mus::Window* root) override;
@@ -65,7 +64,7 @@
   void TestFinished() override;
 
   // mojo::InterfaceFactory<LayoutTestRunner>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<LayoutTestRunner> request) override;
 
   mojo::Shell* shell_;
diff --git a/components/web_view/web_view_application_delegate.cc b/components/web_view/web_view_application_delegate.cc
index f264fe5..1c9c5c7 100644
--- a/components/web_view/web_view_application_delegate.cc
+++ b/components/web_view/web_view_application_delegate.cc
@@ -7,7 +7,7 @@
 #include <utility>
 
 #include "components/web_view/web_view_impl.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 
 namespace web_view {
 
@@ -22,7 +22,7 @@
 }
 
 bool WebViewApplicationDelegate::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+    mojo::Connection* connection) {
   connection->AddService<mojom::WebViewFactory>(this);
   return true;
 }
@@ -34,7 +34,7 @@
 }
 
 void WebViewApplicationDelegate::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<mojom::WebViewFactory> request) {
   factory_bindings_.AddBinding(this, std::move(request));
 }
diff --git a/components/web_view/web_view_application_delegate.h b/components/web_view/web_view_application_delegate.h
index 38b46e6..943f5e87 100644
--- a/components/web_view/web_view_application_delegate.h
+++ b/components/web_view/web_view_application_delegate.h
@@ -9,13 +9,13 @@
 #include "components/web_view/public/interfaces/web_view.mojom.h"
 #include "mojo/common/weak_binding_set.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace web_view {
 
 class WebViewApplicationDelegate
-    : public mojo::ApplicationDelegate,
+    : public mojo::ShellClient,
       public mojom::WebViewFactory,
       public mojo::InterfaceFactory<mojom::WebViewFactory> {
  public:
@@ -23,18 +23,17 @@
   ~WebViewApplicationDelegate() override;
 
  private:
-  // Overridden from mojo::ApplicationDelegate:
+  // Overridden from mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   // Overridden from mojom::WebViewFactory:
   void CreateWebView(mojom::WebViewClientPtr client,
                      mojo::InterfaceRequest<mojom::WebView> web_view) override;
 
   // Overridden from mojo::InterfaceFactory<mojom::WebView>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<mojom::WebViewFactory> request) override;
 
   mojo::Shell* shell_;
diff --git a/components/web_view/web_view_apptest.cc b/components/web_view/web_view_apptest.cc
index 475141d..391ca010 100644
--- a/components/web_view/web_view_apptest.cc
+++ b/components/web_view/web_view_apptest.cc
@@ -96,7 +96,7 @@
     }
   }
 
-  // Overridden from ApplicationDelegate:
+  // Overridden from mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override {
     WindowServerTestBase::Initialize(shell, url, id);
diff --git a/components/web_view/web_view_impl.cc b/components/web_view/web_view_impl.cc
index c7d7ac2..00861b56 100644
--- a/components/web_view/web_view_impl.cc
+++ b/components/web_view/web_view_impl.cc
@@ -80,8 +80,7 @@
   Frame::ClientPropertyMap client_properties;
   if (devtools_agent_) {
     devtools_service::DevToolsAgentPtr forward_agent;
-    frame_connection->application_connection()->ConnectToService(
-        &forward_agent);
+    frame_connection->connection()->ConnectToService(&forward_agent);
     devtools_agent_->AttachFrame(std::move(forward_agent), &client_properties);
   }
 
diff --git a/content/browser/mojo/mojo_shell_context.cc b/content/browser/mojo/mojo_shell_context.cc
index 012dc5f..f9a1f1c 100644
--- a/content/browser/mojo/mojo_shell_context.cc
+++ b/content/browser/mojo/mojo_shell_context.cc
@@ -27,7 +27,7 @@
 #include "mojo/shell/connect_to_application_params.h"
 #include "mojo/shell/identity.h"
 #include "mojo/shell/package_manager/package_manager_impl.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/static_application_loader.h"
 
 namespace content {
diff --git a/content/browser/mojo/mojo_shell_context.h b/content/browser/mojo/mojo_shell_context.h
index 846142c..7f4f5de 100644
--- a/content/browser/mojo/mojo_shell_context.h
+++ b/content/browser/mojo/mojo_shell_context.h
@@ -19,7 +19,7 @@
 class GURL;
 
 namespace mojo {
-class ApplicationDelegate;
+class ShellClient;
 }
 
 namespace content {
@@ -29,7 +29,7 @@
 class CONTENT_EXPORT MojoShellContext {
  public:
   using StaticApplicationMap =
-      std::map<GURL, base::Callback<scoped_ptr<mojo::ApplicationDelegate>()>>;
+      std::map<GURL, base::Callback<scoped_ptr<mojo::ShellClient>()>>;
 
   MojoShellContext();
   ~MojoShellContext();
diff --git a/content/browser/mojo_shell_browsertest.cc b/content/browser/mojo_shell_browsertest.cc
index b291961..75a263c 100644
--- a/content/browser/mojo_shell_browsertest.cc
+++ b/content/browser/mojo_shell_browsertest.cc
@@ -25,8 +25,8 @@
   }
 
  private:
-  static scoped_ptr<mojo::ApplicationDelegate> CreateTestApp() {
-    return scoped_ptr<mojo::ApplicationDelegate>(new TestMojoApp);
+  static scoped_ptr<mojo::ShellClient> CreateTestApp() {
+    return scoped_ptr<mojo::ShellClient>(new TestMojoApp);
   }
 
   MojoShellContext::StaticApplicationMap test_apps_;
diff --git a/content/child/blink_platform_impl.cc b/content/child/blink_platform_impl.cc
index c63fbb87..fa8c782 100644
--- a/content/child/blink_platform_impl.cc
+++ b/content/child/blink_platform_impl.cc
@@ -852,6 +852,12 @@
     {"InspectorOverlayPage.html",
      IDR_INSPECTOR_OVERLAY_PAGE_HTML,
      ui::SCALE_FACTOR_NONE},
+    {"InjectedScriptSource.js",
+     IDR_INSPECTOR_INJECTED_SCRIPT_SOURCE_JS,
+     ui::SCALE_FACTOR_NONE},
+    {"DebuggerScriptSource.js",
+     IDR_INSPECTOR_DEBUGGER_SCRIPT_SOURCE_JS,
+     ui::SCALE_FACTOR_NONE},
     {"DocumentExecCommand.js",
      IDR_PRIVATE_SCRIPT_DOCUMENTEXECCOMMAND_JS,
      ui::SCALE_FACTOR_NONE},
diff --git a/content/common/mojo/mojo_shell_connection_impl.cc b/content/common/mojo/mojo_shell_connection_impl.cc
index 95b9668..36004514 100644
--- a/content/common/mojo/mojo_shell_connection_impl.cc
+++ b/content/common/mojo/mojo_shell_connection_impl.cc
@@ -11,8 +11,8 @@
 #include "base/stl_util.h"
 #include "base/threading/thread_local.h"
 #include "mojo/converters/network/network_type_converters.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_impl.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/runner/child/runner_connection.h"
 
 namespace content {
@@ -78,8 +78,7 @@
   initialized_ = true;
 }
 
-bool MojoShellConnectionImpl::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+bool MojoShellConnectionImpl::AcceptConnection(mojo::Connection* connection) {
   bool found = false;
   for (auto listener : listeners_)
     found |= listener->AcceptConnection(connection);
diff --git a/content/common/mojo/mojo_shell_connection_impl.h b/content/common/mojo/mojo_shell_connection_impl.h
index 2438138..d85fe0e4 100644
--- a/content/common/mojo/mojo_shell_connection_impl.h
+++ b/content/common/mojo/mojo_shell_connection_impl.h
@@ -11,7 +11,8 @@
 #include "base/memory/scoped_ptr.h"
 #include "content/public/common/mojo_shell_connection.h"
 #include "mojo/public/cpp/system/message_pipe.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
+#include "mojo/shell/public/cpp/application_impl.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace mojo {
 namespace shell {
@@ -25,7 +26,7 @@
 bool IsRunningInMojoShell();
 
 class MojoShellConnectionImpl : public MojoShellConnection,
-                                public mojo::ApplicationDelegate {
+                                public mojo::ShellClient {
  public:
   // Creates an instance of this class and stuffs it in TLS on the calling
   // thread. Retrieve it using MojoShellConnection::Get().
@@ -49,11 +50,10 @@
   MojoShellConnectionImpl();
   ~MojoShellConnectionImpl() override;
 
-  // mojo::ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   // MojoShellConnection:
   mojo::Shell* GetShell() override;
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
index e64048a..9e6c174 100644
--- a/content/public/browser/content_browser_client.h
+++ b/content/public/browser/content_browser_client.h
@@ -62,7 +62,7 @@
 }
 
 namespace mojo {
-class ApplicationDelegate;
+class ShellClient;
 }
 
 namespace net {
@@ -658,7 +658,7 @@
       RenderFrameHost* render_frame_host) {}
 
   using StaticMojoApplicationMap =
-      std::map<GURL, base::Callback<scoped_ptr<mojo::ApplicationDelegate>()>>;
+      std::map<GURL, base::Callback<scoped_ptr<mojo::ShellClient>()>>;
 
   // Registers Mojo applications to be loaded in the browser process by the
   // browser's global Mojo shell.
diff --git a/content/public/common/mojo_shell_connection.h b/content/public/common/mojo_shell_connection.h
index 584073ce..4f8d759b 100644
--- a/content/public/common/mojo_shell_connection.h
+++ b/content/public/common/mojo_shell_connection.h
@@ -8,7 +8,7 @@
 #include "content/common/content_export.h"
 
 namespace mojo {
-class ApplicationConnection;
+class Connection;
 class Shell;
 }
 
@@ -24,10 +24,10 @@
 class CONTENT_EXPORT MojoShellConnection {
  public:
   // Override to add additional services to inbound connections.
+  // TODO(beng): This should just be ShellClient.
   class Listener {
    public:
-    virtual bool AcceptConnection(
-        mojo::ApplicationConnection* connection) = 0;
+    virtual bool AcceptConnection(mojo::Connection* connection) = 0;
 
     virtual ~Listener() {}
   };
diff --git a/content/public/test/test_mojo_app.cc b/content/public/test/test_mojo_app.cc
index fe9b875..20a83f7 100644
--- a/content/public/test/test_mojo_app.cc
+++ b/content/public/test/test_mojo_app.cc
@@ -7,7 +7,7 @@
 #include <utility>
 
 #include "base/logging.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 
 namespace content {
@@ -25,14 +25,13 @@
   shell_ = shell;
 }
 
-bool TestMojoApp::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+bool TestMojoApp::AcceptConnection(mojo::Connection* connection) {
   requestor_url_ = GURL(connection->GetRemoteApplicationURL());
   connection->AddService<TestMojoService>(this);
   return true;
 }
 
-void TestMojoApp::Create(mojo::ApplicationConnection* connection,
+void TestMojoApp::Create(mojo::Connection* connection,
                          mojo::InterfaceRequest<TestMojoService> request) {
   DCHECK(!service_binding_.is_bound());
   service_binding_.Bind(std::move(request));
diff --git a/content/public/test/test_mojo_app.h b/content/public/test/test_mojo_app.h
index 6659ad1..c354613 100644
--- a/content/public/test/test_mojo_app.h
+++ b/content/public/test/test_mojo_app.h
@@ -8,8 +8,8 @@
 #include "base/macros.h"
 #include "content/public/test/test_mojo_service.mojom.h"
 #include "mojo/public/cpp/bindings/binding.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "url/gurl.h"
 
 namespace content {
@@ -18,7 +18,7 @@
 
 // Simple Mojo app which provides a TestMojoService impl. The app terminates
 // itself after its TestService fulfills a single DoSomething call.
-class TestMojoApp : public mojo::ApplicationDelegate,
+class TestMojoApp : public mojo::ShellClient,
                     public mojo::InterfaceFactory<TestMojoService>,
                     public TestMojoService {
  public:
@@ -26,14 +26,13 @@
   ~TestMojoApp() override;
 
  private:
-  // mojo::ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   // mojo::InterfaceFactory<TestMojoService>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<TestMojoService> request) override;
 
   // TestMojoService:
diff --git a/content/public/utility/content_utility_client.h b/content/public/utility/content_utility_client.h
index b326eae..6ac42db 100644
--- a/content/public/utility/content_utility_client.h
+++ b/content/public/utility/content_utility_client.h
@@ -14,7 +14,7 @@
 class GURL;
 
 namespace mojo {
-class ApplicationDelegate;
+class ShellClient;
 }
 
 namespace content {
@@ -25,7 +25,7 @@
 class CONTENT_EXPORT ContentUtilityClient {
  public:
   using StaticMojoApplicationMap =
-      std::map<GURL, base::Callback<scoped_ptr<mojo::ApplicationDelegate>()>>;
+      std::map<GURL, base::Callback<scoped_ptr<mojo::ShellClient>()>>;
 
   virtual ~ContentUtilityClient() {}
 
diff --git a/content/renderer/mus/render_widget_window_tree_client_factory.cc b/content/renderer/mus/render_widget_window_tree_client_factory.cc
index 81fb0f7..c2ed7483 100644
--- a/content/renderer/mus/render_widget_window_tree_client_factory.cc
+++ b/content/renderer/mus/render_widget_window_tree_client_factory.cc
@@ -13,7 +13,7 @@
 #include "content/public/common/mojo_shell_connection.h"
 #include "content/renderer/mus/render_widget_mus_connection.h"
 #include "mojo/common/weak_binding_set.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
 #include "url/gurl.h"
 
@@ -37,14 +37,13 @@
 
  private:
   // MojoShellConnection::Listener implementation:
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override {
+  bool AcceptConnection(mojo::Connection* connection) override {
     connection->AddService<mojom::RenderWidgetWindowTreeClientFactory>(this);
     return true;
   }
 
   // mojo::InterfaceFactory<mojom::RenderWidgetWindowTreeClientFactory>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<mojom::RenderWidgetWindowTreeClientFactory>
                   request) override {
     bindings_.AddBinding(this, std::move(request));
diff --git a/content/shell/utility/shell_content_utility_client.cc b/content/shell/utility/shell_content_utility_client.cc
index d6c2982..a21c083 100644
--- a/content/shell/utility/shell_content_utility_client.cc
+++ b/content/shell/utility/shell_content_utility_client.cc
@@ -13,8 +13,8 @@
 
 namespace {
 
-scoped_ptr<mojo::ApplicationDelegate> CreateTestApp() {
-  return scoped_ptr<mojo::ApplicationDelegate>(new TestMojoApp);
+scoped_ptr<mojo::ShellClient> CreateTestApp() {
+  return scoped_ptr<mojo::ShellClient>(new TestMojoApp);
 }
 
 }  // namespace
diff --git a/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py b/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py
index 70e7647..3b991168 100644
--- a/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py
+++ b/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py
@@ -79,14 +79,18 @@
 
     self.Fail('conformance2/glsl3/array-complex-indexing.html', bug=483282)
     self.Fail('conformance2/glsl3/forbidden-operators.html', bug=483282)
-    self.Fail('conformance2/samplers/sampler-drawing-test.html', bug=483282)
     self.Fail('conformance2/state/gl-object-get-calls.html', bug=483282)
     # Note that this test fails on ['win', 'intel'] with bug=483282
     self.Fail('conformance2/buffers/uniform-buffers.html', bug=577368)
 
-    # Remove the following after roll in ToT WebGL conformance tests.
-    self.Fail('conformance2/reading/read-pixels-into-pixel-pack-buffer.html',
-        ['mac', 'linux'], bug=570453)
+    # The following two entries are due to validation of TEXTURE_3D target on
+    # 2D texture calls.
+    # compressed-tex-image.html fails on Mac with bug ID 565438.
+    self.Fail('conformance2/textures/misc/compressed-tex-image.html',
+        bug=483282)
+    # tex-input-validation fails on Win and ['mac', ('nvidia', 0xfe9)].
+    self.Fail('conformance2/textures/misc/tex-input-validation.html',
+        bug=483282)
 
     # Windows only.
     self.Fail('conformance2/textures/canvas/tex-image-and-sub-image-2d' +
@@ -210,8 +214,6 @@
         ['win'], bug=483282)
     self.Fail('conformance2/textures/misc/gl-get-tex-parameter.html',
         ['win'], bug=483282)
-    self.Fail('conformance2/textures/misc/tex-input-validation.html',
-        ['win'], bug=483282)
     self.Skip('conformance2/textures/misc/tex-mipmap-levels.html',
         ['win'], bug=483282)
     self.Skip('conformance2/transform_feedback/transform_feedback.html',
@@ -220,6 +222,8 @@
         ['win'], bug=1198) # angle bug ID
     self.Skip('conformance2/reading/read-pixels-into-pixel-pack-buffer.html',
         ['win'], bug=1266) # angle bug ID
+    self.Skip('conformance2/textures/misc/copy-texture-image.html',
+        ['win'], bug=577144) # crash on debug
 
     # Windows 8 only.
     self.Fail('conformance2/textures/image_data/tex-image-and-sub-image-2d' +
@@ -246,6 +250,12 @@
     self.Fail('conformance2/textures/video/tex-image-and-sub-image-2d' +
         '-with-video-rgb5_a1-rgba-unsigned_byte.html',
         ['win8'], bug=483282)
+    self.Fail('conformance2/textures/image_bitmap/tex-image-and-sub-image-2d' +
+        '-with-image-bitmap-rgb565-rgb-unsigned_byte.html',
+        ['win8'], bug=483282)
+    self.Fail('conformance2/textures/image_bitmap/tex-image-and-sub-image-2d' +
+        '-with-image-bitmap-rgb5_a1-rgba-unsigned_byte.html',
+        ['win8'], bug=483282)
     self.Fail('conformance2/textures/video/tex-image-and-sub-image-3d' +
         '-with-video-rgb5_a1-rgba-unsigned_byte.html',
         ['win8'], bug=560555)
@@ -270,6 +280,12 @@
     self.Fail('conformance2/textures/svg_image/tex-image-and-sub-image-3d' +
         '-with-svg-image-rgb5_a1-rgba-unsigned_byte.html',
         ['win8'], bug=560555)
+    self.Fail('conformance2/textures/image_bitmap/tex-image-and-sub-image-3d' +
+        '-with-image-bitmap-rgb565-rgb-unsigned_byte.html',
+        ['win8'], bug=483282)
+    self.Fail('conformance2/textures/image_bitmap/tex-image-and-sub-image-3d' +
+        '-with-image-bitmap-rgb5_a1-rgba-unsigned_byte.html',
+        ['win8'], bug=483282)
 
     # Windows Debug. Causing assertions in the GPU process which raise
     # a dialog box, so have to skip them rather than mark them as
@@ -278,6 +294,10 @@
         '-with-canvas-rgba8-rgba-unsigned_byte.html',
         ['win', 'debug'], bug=542901)
 
+    # Windows AMD/ATI only.
+    self.Fail('deqp/functional/gles3/fbostencilbuffer.html',
+        ['win', 'amd'], bug=483282)
+
     # Mac only.
     self.Skip('deqp/data/gles3/shaders/qualification_order.html',
         ['mac'], bug=483282)
@@ -327,16 +347,17 @@
         ['mac'], bug=483282)
     self.Fail('conformance2/renderbuffers/readbuffer.html',
         ['mac'], bug=570453)
-    self.Fail('conformance2/textures/misc/compressed-tex-image.html',
-        ['mac'], bug=565438)
     self.Fail('conformance2/textures/misc/tex-mipmap-levels.html',
         ['mac'], bug=483282)
+    self.Fail('conformance2/textures/misc/copy-texture-image.html',
+        ['mac'], bug=577144)
+    # The following failure is 10.10 only, but we don't have a keyword yet.
+    self.Fail('conformance2/reading/read-pixels-from-fbo-test.html',
+        ['mac'], bug=584994)
 
     # Mac Retina NVIDIA
     self.Fail('conformance2/rendering/draw-buffers.html',
         ['mac', ('nvidia', 0xfe9)], bug=483282)
-    self.Fail('conformance2/textures/misc/tex-input-validation.html',
-        ['mac', ('nvidia', 0xfe9)], bug=483282)
 
     # Linux only.
     self.Skip('deqp/functional/gles3/shaderswitch.html',
diff --git a/device/devices_app/devices_app.cc b/device/devices_app/devices_app.cc
index 29a7484..a3406440 100644
--- a/device/devices_app/devices_app.cc
+++ b/device/devices_app/devices_app.cc
@@ -18,7 +18,7 @@
 #include "device/devices_app/usb/device_manager_impl.h"
 #include "device/usb/usb_service.h"
 #include "mojo/public/cpp/bindings/interface_request.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 #include "url/gurl.h"
 
@@ -88,7 +88,7 @@
   StartIdleTimer();
 }
 
-bool DevicesApp::AcceptConnection(mojo::ApplicationConnection* connection) {
+bool DevicesApp::AcceptConnection(mojo::Connection* connection) {
   connection->AddService<usb::DeviceManager>(this);
   return true;
 }
@@ -98,7 +98,7 @@
   shell_ = nullptr;
 }
 
-void DevicesApp::Create(mojo::ApplicationConnection* connection,
+void DevicesApp::Create(mojo::Connection* connection,
                         mojo::InterfaceRequest<usb::DeviceManager> request) {
   // Bind the new device manager to the connecting application's permission
   // provider.
diff --git a/device/devices_app/devices_app.h b/device/devices_app/devices_app.h
index d247702..0fecb42 100644
--- a/device/devices_app/devices_app.h
+++ b/device/devices_app/devices_app.h
@@ -11,8 +11,8 @@
 #include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/memory/scoped_ptr.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace mojo {
 class Shell;
@@ -24,7 +24,7 @@
 class DeviceManager;
 }
 
-class DevicesApp : public mojo::ApplicationDelegate,
+class DevicesApp : public mojo::ShellClient,
                    public mojo::InterfaceFactory<usb::DeviceManager> {
  public:
   DevicesApp();
@@ -33,15 +33,15 @@
  private:
   class USBServiceInitializer;
 
-  // mojo::ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell,
                   const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
   void Quit() override;
 
   // mojo::InterfaceFactory<usb::DeviceManager>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<usb::DeviceManager> request) override;
 
   // Mojo error handler to track device manager count.
diff --git a/device/devices_app/main.cc b/device/devices_app/main.cc
index a43d8ff3..1694aac 100644
--- a/device/devices_app/main.cc
+++ b/device/devices_app/main.cc
@@ -5,8 +5,8 @@
 #include "base/sequenced_task_runner.h"
 #include "device/devices_app/public/cpp/devices_app_factory.h"
 #include "mojo/public/c/system/main.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_runner.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 MojoResult MojoMain(MojoHandle shell_handle) {
   mojo::ApplicationRunner runner(
diff --git a/device/devices_app/public/cpp/devices_app_factory.cc b/device/devices_app/public/cpp/devices_app_factory.cc
index a6ffe4e..154f67c 100644
--- a/device/devices_app/public/cpp/devices_app_factory.cc
+++ b/device/devices_app/public/cpp/devices_app_factory.cc
@@ -9,8 +9,8 @@
 namespace device {
 
 // static
-scoped_ptr<mojo::ApplicationDelegate> DevicesAppFactory::CreateApp() {
-  return scoped_ptr<mojo::ApplicationDelegate>(new DevicesApp());
+scoped_ptr<mojo::ShellClient> DevicesAppFactory::CreateApp() {
+  return scoped_ptr<mojo::ShellClient>(new DevicesApp());
 }
 
 }  // namespace device
diff --git a/device/devices_app/public/cpp/devices_app_factory.h b/device/devices_app/public/cpp/devices_app_factory.h
index ba03185..6ba7447e 100644
--- a/device/devices_app/public/cpp/devices_app_factory.h
+++ b/device/devices_app/public/cpp/devices_app_factory.h
@@ -9,7 +9,7 @@
 #include "base/memory/scoped_ptr.h"
 
 namespace mojo {
-class ApplicationDelegate;
+class ShellClient;
 }
 
 namespace device {
@@ -20,7 +20,7 @@
   // Creates a DevicesApp delegate which can be used to launch a new instance
   // of the devices app on a mojo application runner. The caller owns the
   // delegate.
-  static scoped_ptr<mojo::ApplicationDelegate> CreateApp();
+  static scoped_ptr<mojo::ShellClient> CreateApp();
 };
 
 }  // namespace device
diff --git a/extensions/browser/api/execute_code_function.cc b/extensions/browser/api/execute_code_function.cc
index 0f98df3..53fcb44a 100644
--- a/extensions/browser/api/execute_code_function.cc
+++ b/extensions/browser/api/execute_code_function.cc
@@ -8,6 +8,7 @@
 #include "extensions/browser/api/execute_code_function.h"
 
 #include "extensions/browser/component_extension_resource_manager.h"
+#include "extensions/browser/extension_api_frame_id_map.h"
 #include "extensions/browser/extensions_browser_client.h"
 #include "extensions/browser/file_reader.h"
 #include "extensions/common/error_utils.h"
@@ -139,8 +140,11 @@
 
   ScriptExecutor::FrameScope frame_scope =
       details_->all_frames.get() && *details_->all_frames
-          ? ScriptExecutor::ALL_FRAMES
-          : ScriptExecutor::TOP_FRAME;
+          ? ScriptExecutor::INCLUDE_SUB_FRAMES
+          : ScriptExecutor::SINGLE_FRAME;
+
+  int frame_id = details_->frame_id.get() ? *details_->frame_id
+                                          : ExtensionApiFrameIdMap::kTopFrameId;
 
   ScriptExecutor::MatchAboutBlank match_about_blank =
       details_->match_about_blank.get() && *details_->match_about_blank
@@ -163,18 +167,11 @@
   CHECK_NE(UserScript::UNDEFINED, run_at);
 
   executor->ExecuteScript(
-      host_id_,
-      script_type,
-      code_string,
-      frame_scope,
-      match_about_blank,
-      run_at,
-      ScriptExecutor::ISOLATED_WORLD,
+      host_id_, script_type, code_string, frame_scope, frame_id,
+      match_about_blank, run_at, ScriptExecutor::ISOLATED_WORLD,
       IsWebView() ? ScriptExecutor::WEB_VIEW_PROCESS
                   : ScriptExecutor::DEFAULT_PROCESS,
-      GetWebViewSrc(),
-      file_url_,
-      user_gesture_,
+      GetWebViewSrc(), file_url_, user_gesture_,
       has_callback() ? ScriptExecutor::JSON_SERIALIZED_RESULT
                      : ScriptExecutor::NO_RESULT,
       base::Bind(&ExecuteCodeFunction::OnExecuteCodeFinished, this));
diff --git a/extensions/browser/extension_api_frame_id_map.cc b/extensions/browser/extension_api_frame_id_map.cc
index 72949be..e844fac 100644
--- a/extensions/browser/extension_api_frame_id_map.cc
+++ b/extensions/browser/extension_api_frame_id_map.cc
@@ -24,6 +24,7 @@
 }  // namespace
 
 const int ExtensionApiFrameIdMap::kInvalidFrameId = -1;
+const int ExtensionApiFrameIdMap::kTopFrameId = 0;
 
 ExtensionApiFrameIdMap::CachedFrameIdPair::CachedFrameIdPair()
     : frame_id(kInvalidFrameId), parent_frame_id(kInvalidFrameId) {}
@@ -75,7 +76,7 @@
     return kInvalidFrameId;
   if (rfh->GetParent())
     return rfh->GetFrameTreeNodeId();
-  return 0;  // Main frame.
+  return kTopFrameId;
 }
 
 int ExtensionApiFrameIdMap::GetParentFrameId(content::RenderFrameHost* rfh) {
@@ -96,7 +97,7 @@
   if (frame_id == kInvalidFrameId)
     return nullptr;
 
-  if (frame_id == 0)
+  if (frame_id == kTopFrameId)
     return web_contents->GetMainFrame();
 
   DCHECK_GE(frame_id, 1);
diff --git a/extensions/browser/extension_api_frame_id_map.h b/extensions/browser/extension_api_frame_id_map.h
index c3af8b3d..8bb1422 100644
--- a/extensions/browser/extension_api_frame_id_map.h
+++ b/extensions/browser/extension_api_frame_id_map.h
@@ -48,6 +48,9 @@
   // An invalid extension API frame ID.
   static const int kInvalidFrameId;
 
+  // Extension API frame ID of the top-level frame.
+  static const int kTopFrameId;
+
   static ExtensionApiFrameIdMap* Get();
 
   // Get the extension API frame ID for |rfh|.
diff --git a/extensions/browser/script_executor.cc b/extensions/browser/script_executor.cc
index 687be48..230bca3b 100644
--- a/extensions/browser/script_executor.cc
+++ b/extensions/browser/script_executor.cc
@@ -13,6 +13,7 @@
 #include "content/public/browser/render_view_host.h"
 #include "content/public/browser/web_contents.h"
 #include "content/public/browser/web_contents_observer.h"
+#include "extensions/browser/extension_api_frame_id_map.h"
 #include "extensions/browser/extension_registry.h"
 #include "extensions/browser/script_execution_observer.h"
 #include "extensions/common/extension_messages.h"
@@ -28,6 +29,7 @@
 namespace {
 
 const char* kRendererDestroyed = "The tab was closed.";
+const char* kFrameRemoved = "The frame was removed.";
 
 // A handler for a single injection request. On creation this will send the
 // injection request to the renderer, and it will be destroyed after either the
@@ -38,18 +40,28 @@
           content::WebContents* web_contents,
           const ExtensionMsg_ExecuteCode_Params& params,
           ScriptExecutor::FrameScope scope,
+          int frame_id,
           const ScriptExecutor::ExecuteScriptCallback& callback)
       : content::WebContentsObserver(web_contents),
         script_observers_(AsWeakPtr(script_observers)),
         host_id_(params.host_id),
         request_id_(params.request_id),
+        include_sub_frames_(scope == ScriptExecutor::INCLUDE_SUB_FRAMES),
+        root_rfh_(ExtensionApiFrameIdMap::GetRenderFrameHostById(web_contents,
+                                                                 frame_id)),
+        root_is_main_frame_(root_rfh_ ? !root_rfh_->GetParent() : false),
         callback_(callback) {
-    if (scope == ScriptExecutor::ALL_FRAMES) {
-      web_contents->ForEachFrame(base::Bind(&Handler::SendExecuteCode,
-                                            base::Unretained(this), params));
-    } else {
-      SendExecuteCode(params, web_contents->GetMainFrame());
+    if (root_rfh_) {
+      if (include_sub_frames_) {
+        web_contents->ForEachFrame(base::Bind(&Handler::SendExecuteCode,
+                                              base::Unretained(this), params));
+      } else {
+        SendExecuteCode(params, root_rfh_);
+      }
     }
+
+    if (pending_render_frames_.empty())
+      Finish();
   }
 
  private:
@@ -92,10 +104,25 @@
   // the number of pending messages.
   void SendExecuteCode(const ExtensionMsg_ExecuteCode_Params& params,
                        content::RenderFrameHost* frame) {
+    if (!frame->IsRenderFrameLive())
+      return;
+    DCHECK(!root_is_main_frame_ || ShouldIncludeFrame(frame));
+    if (!root_is_main_frame_ && !ShouldIncludeFrame(frame))
+      return;
     pending_render_frames_.insert(frame);
     frame->Send(new ExtensionMsg_ExecuteCode(frame->GetRoutingID(), params));
   }
 
+  // Returns whether a frame is the root frame or a descendant of it.
+  bool ShouldIncludeFrame(content::RenderFrameHost* frame) {
+    while (frame) {
+      if (frame == root_rfh_)
+        return true;
+      frame = frame->GetParent();
+    }
+    return false;
+  }
+
   // Handles the ExecuteCodeFinished message.
   void OnExecuteCodeFinished(content::RenderFrameHost* render_frame_host,
                              int request_id,
@@ -106,22 +133,22 @@
     DCHECK(!pending_render_frames_.empty());
     bool erased = pending_render_frames_.erase(render_frame_host) == 1;
     DCHECK(erased);
-    bool is_main_frame = web_contents()->GetMainFrame() == render_frame_host;
+    bool is_root_frame = root_rfh_ == render_frame_host;
 
     // Set the result, if there is one.
     const base::Value* script_value = nullptr;
     if (result_list.Get(0u, &script_value)) {
       // If this is the main result, we put it at index 0. Otherwise, we just
       // append it at the end.
-      if (is_main_frame && !results_.empty())
+      if (is_root_frame && !results_.empty())
         CHECK(results_.Insert(0u, script_value->DeepCopy()));
       else
         results_.Append(script_value->DeepCopy());
     }
 
-    if (is_main_frame) {  // Only use the main frame's error and url.
-      main_frame_error_ = error;
-      main_frame_url_ = on_url;
+    if (is_root_frame) {  // Only use the root frame's error and url.
+      root_frame_error_ = error;
+      root_frame_url_ = on_url;
     }
 
     // Wait until the final request finishes before reporting back.
@@ -130,23 +157,24 @@
   }
 
   void Finish() {
-    if (main_frame_url_.is_empty()) {
-      // We never finished the main frame injection.
-      main_frame_error_ = kRendererDestroyed;
+    if (root_frame_url_.is_empty()) {
+      // We never finished the root frame injection.
+      root_frame_error_ =
+          root_is_main_frame_ ? kRendererDestroyed : kFrameRemoved;
       results_.Clear();
     }
 
-    if (script_observers_.get() && main_frame_error_.empty() &&
+    if (script_observers_.get() && root_frame_error_.empty() &&
         host_id_.type() == HostID::EXTENSIONS) {
       ScriptExecutionObserver::ExecutingScriptsMap id_map;
       id_map[host_id_.id()] = std::set<std::string>();
       FOR_EACH_OBSERVER(
           ScriptExecutionObserver, *script_observers_,
-          OnScriptsExecuted(web_contents(), id_map, main_frame_url_));
+          OnScriptsExecuted(web_contents(), id_map, root_frame_url_));
     }
 
     if (!callback_.is_null())
-      callback_.Run(main_frame_error_, main_frame_url_, results_);
+      callback_.Run(root_frame_error_, root_frame_url_, results_);
     delete this;
   }
 
@@ -158,17 +186,27 @@
   // The request id of the injection.
   int request_id_;
 
+  // Whether to inject in |root_rfh_| and all of its descendant frames.
+  bool include_sub_frames_;
+
+  // The frame (and optionally its descendant frames) where the injection will
+  // occur.
+  content::RenderFrameHost* root_rfh_;
+
+  // Whether |root_rfh_| is the main frame of a tab.
+  bool root_is_main_frame_;
+
   // The hosts of the still-running injections.
   std::set<content::RenderFrameHost*> pending_render_frames_;
 
   // The results of the injection.
   base::ListValue results_;
 
-  // The error from injecting into the main frame.
-  std::string main_frame_error_;
+  // The error from injecting into the root frame.
+  std::string root_frame_error_;
 
-  // The url of the main frame.
-  GURL main_frame_url_;
+  // The url of the root frame.
+  GURL root_frame_url_;
 
   // The callback to run after all injections complete.
   ScriptExecutor::ExecuteScriptCallback callback_;
@@ -197,6 +235,7 @@
                                    ScriptExecutor::ScriptType script_type,
                                    const std::string& code,
                                    ScriptExecutor::FrameScope frame_scope,
+                                   int frame_id,
                                    ScriptExecutor::MatchAboutBlank about_blank,
                                    UserScript::RunLocation run_at,
                                    ScriptExecutor::WorldType world_type,
@@ -232,7 +271,8 @@
   params.user_gesture = user_gesture;
 
   // Handler handles IPCs and deletes itself on completion.
-  new Handler(script_observers_, web_contents_, params, frame_scope, callback);
+  new Handler(script_observers_, web_contents_, params, frame_scope, frame_id,
+              callback);
 }
 
 }  // namespace extensions
diff --git a/extensions/browser/script_executor.h b/extensions/browser/script_executor.h
index 4f81b78f..25e6c54 100644
--- a/extensions/browser/script_executor.h
+++ b/extensions/browser/script_executor.h
@@ -44,8 +44,8 @@
 
   // The scope of the script injection across the frames.
   enum FrameScope {
-    TOP_FRAME,
-    ALL_FRAMES,
+    SINGLE_FRAME,
+    INCLUDE_SUB_FRAMES,
   };
 
   // Whether to insert the script in about: frames when its origin matches
@@ -82,6 +82,10 @@
   // Executes a script. The arguments match ExtensionMsg_ExecuteCode_Params in
   // extension_messages.h (request_id is populated automatically).
   //
+  // The script will be executed in the frame identified by |frame_id| (which is
+  // an extension API frame ID). If |frame_scope| is INCLUDE_SUB_FRAMES, then
+  // the script will also be executed in all descendants of the frame.
+  //
   // |callback| will always be called even if the IPC'd renderer is destroyed
   // before a response is received (in this case the callback will be with a
   // failure and appropriate error message).
@@ -89,6 +93,7 @@
                      ScriptType script_type,
                      const std::string& code,
                      FrameScope frame_scope,
+                     int frame_id,
                      MatchAboutBlank match_about_blank,
                      UserScript::RunLocation run_at,
                      WorldType world_type,
diff --git a/extensions/common/api/extension_types.json b/extensions/common/api/extension_types.json
index 29562ee..9f27590 100644
--- a/extensions/common/api/extension_types.json
+++ b/extensions/common/api/extension_types.json
@@ -45,7 +45,17 @@
         "properties": {
           "code": {"type": "string", "optional": true, "description": "JavaScript or CSS code to inject.<br><br><b>Warning:</b><br>Be careful using the <code>code</code> parameter. Incorrect use of it may open your extension to <a href=\"https://en.wikipedia.org/wiki/Cross-site_scripting\">cross site scripting</a> attacks."},
           "file": {"type": "string", "optional": true, "description": "JavaScript or CSS file to inject."},
-          "allFrames": {"type": "boolean", "optional": true, "description": "If allFrames is <code>true</code>, implies that the JavaScript or CSS should be injected into all frames of current page. By default, it's <code>false</code> and is only injected into the top frame."},
+          "allFrames": {
+            "type": "boolean",
+            "optional": true,
+            "description": "If allFrames is <code>true</code>, implies that the JavaScript or CSS should be injected into all frames of current page. By default, it's <code>false</code> and is only injected into the top frame. If <code>true</code> and <code>frameId</code> is set, then the code is inserted in the selected frame and all of its child frames."
+          },
+          "frameId": {
+            "type": "integer",
+            "optional": true,
+            "minimum": 0,
+            "description": "The <a href='webNavigation#frame_ids'>frame</a> where the script or CSS should be injected. Defaults to 0 (the top-level frame)."
+          },
           "matchAboutBlank": {"type": "boolean", "optional": true, "description": "If matchAboutBlank is true, then the code is also injected in about:blank and about:srcdoc frames if your extension has access to its parent document. Code cannot be inserted in top-level about:-frames. By default it is <code>false</code>."},
           "runAt": {
             "$ref": "RunAt",
diff --git a/extensions/renderer/programmatic_script_injector.cc b/extensions/renderer/programmatic_script_injector.cc
index 13f0a20..e19a4c98 100644
--- a/extensions/renderer/programmatic_script_injector.cc
+++ b/extensions/renderer/programmatic_script_injector.cc
@@ -13,14 +13,15 @@
 #include "extensions/common/error_utils.h"
 #include "extensions/common/extension_messages.h"
 #include "extensions/common/manifest_constants.h"
+#include "extensions/common/permissions/api_permission.h"
 #include "extensions/common/permissions/permissions_data.h"
 #include "extensions/renderer/injection_host.h"
+#include "extensions/renderer/renderer_extension_registry.h"
 #include "extensions/renderer/script_context.h"
 #include "third_party/WebKit/public/platform/WebString.h"
 #include "third_party/WebKit/public/web/WebDocument.h"
 #include "third_party/WebKit/public/web/WebLocalFrame.h"
 #include "third_party/WebKit/public/web/WebScriptSource.h"
-#include "url/origin.h"
 
 namespace extensions {
 
@@ -31,8 +32,10 @@
       url_(
           ScriptContext::GetDataSourceURLForFrame(render_frame->GetWebFrame())),
       finished_(false) {
-  effective_url_ = ScriptContext::GetEffectiveDocumentURL(
-      render_frame->GetWebFrame(), url_, params.match_about_blank);
+  if (url_.SchemeIs(url::kAboutScheme)) {
+    origin_for_about_error_ =
+        render_frame->GetWebFrame()->securityOrigin().toString().utf8();
+  }
 }
 
 ProgrammaticScriptInjector::~ProgrammaticScriptInjector() {
@@ -130,16 +133,15 @@
   std::string error;
   switch (reason) {
     case NOT_ALLOWED:
-      if (url_.SchemeIs(url::kAboutScheme)) {
+      if (!CanShowUrlInError()) {
+        error = manifest_errors::kCannotAccessPage;
+      } else if (!origin_for_about_error_.empty()) {
         error = ErrorUtils::FormatErrorMessage(
             manifest_errors::kCannotAccessAboutUrl, url_.spec(),
-            url::Origin(effective_url_).Serialize());
+            origin_for_about_error_);
       } else {
-        // TODO(?) It would be nice to show kCannotAccessPageWithUrl here if
-        // this is triggered by an extension with tabs permission. See
-        // https://codereview.chromium.org/1414223005/diff/1/extensions/
-        // common/manifest_constants.cc#newcode269
-        error = manifest_errors::kCannotAccessPage;
+        error = ErrorUtils::FormatErrorMessage(
+            manifest_errors::kCannotAccessPageWithUrl, url_.spec());
       }
       break;
     case EXTENSION_REMOVED:  // no special error here.
@@ -149,6 +151,17 @@
   Finish(error, render_frame);
 }
 
+bool ProgrammaticScriptInjector::CanShowUrlInError() const {
+  if (params_->host_id.type() != HostID::EXTENSIONS)
+    return false;
+  const Extension* extension =
+      RendererExtensionRegistry::Get()->GetByID(params_->host_id.id());
+  if (!extension)
+    return false;
+  return extension->permissions_data()->active_permissions().HasAPIPermission(
+      APIPermission::kTab);
+}
+
 UserScript::RunLocation ProgrammaticScriptInjector::GetRunLocation() const {
   return static_cast<UserScript::RunLocation>(params_->run_at);
 }
diff --git a/extensions/renderer/programmatic_script_injector.h b/extensions/renderer/programmatic_script_injector.h
index 159ff1c5..a7af9ff38 100644
--- a/extensions/renderer/programmatic_script_injector.h
+++ b/extensions/renderer/programmatic_script_injector.h
@@ -50,6 +50,9 @@
   void OnWillNotInject(InjectFailureReason reason,
                        content::RenderFrame* render_frame) override;
 
+  // Whether it is safe to include information about the URL in error messages.
+  bool CanShowUrlInError() const;
+
   // Return the run location for this injector.
   UserScript::RunLocation GetRunLocation() const;
 
@@ -63,10 +66,9 @@
   // The url of the frame into which we are injecting.
   GURL url_;
 
-  // The URL of the frame's origin. This is usually identical to |url_|, but
-  // could be different for e.g. about:blank URLs. Do not use this value to make
-  // security decisions, to avoid race conditions (e.g. due to navigation).
-  GURL effective_url_;
+  // The serialization of the frame's origin if the frame is an about:-URL. This
+  // is used to provide user-friendly messages.
+  std::string origin_for_about_error_;
 
   // The results of the script execution.
   base::ListValue results_;
diff --git a/mandoline/services/core_services/application_delegate_factory.h b/mandoline/services/core_services/application_delegate_factory.h
index 537d9f9..60adff06 100644
--- a/mandoline/services/core_services/application_delegate_factory.h
+++ b/mandoline/services/core_services/application_delegate_factory.h
@@ -10,20 +10,20 @@
 #include "base/memory/scoped_ptr.h"
 
 namespace mojo {
-class ApplicationDelegate;
+class ShellClient;
 }
 
 namespace core_services {
 
-// This is always called to create a platform specific ApplicationDelegate.
-scoped_ptr<mojo::ApplicationDelegate> CreatePlatformSpecificApplicationDelegate(
+// This is always called to create a platform specific ShellClient.
+scoped_ptr<mojo::ShellClient> CreatePlatformSpecificApplicationDelegate(
     const std::string& url);
 
 // The following are conditionally called. You do not need to call these from
 // CreatePlatformSpecificApplicationDelegate(), they are called (if appropriate)
 // before CreatePlatformSpecificApplicationDelegate().
 #if !defined(OS_ANDROID)
-scoped_ptr<mojo::ApplicationDelegate> CreateApplicationDelegateNotAndroid(
+scoped_ptr<mojo::ShellClient> CreateApplicationDelegateNotAndroid(
     const std::string& url);
 #endif
 
diff --git a/mandoline/services/core_services/application_delegate_factory_default.cc b/mandoline/services/core_services/application_delegate_factory_default.cc
index d0691347..6a62978 100644
--- a/mandoline/services/core_services/application_delegate_factory_default.cc
+++ b/mandoline/services/core_services/application_delegate_factory_default.cc
@@ -4,11 +4,11 @@
 
 #include "mandoline/services/core_services/application_delegate_factory.h"
 
-#include "mojo/shell/public/cpp/application_delegate.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace core_services {
 
-scoped_ptr<mojo::ApplicationDelegate> CreatePlatformSpecificApplicationDelegate(
+scoped_ptr<mojo::ShellClient> CreatePlatformSpecificApplicationDelegate(
     const std::string& url) {
   return nullptr;
 }
diff --git a/mandoline/services/core_services/application_delegate_factory_linux.cc b/mandoline/services/core_services/application_delegate_factory_linux.cc
index fe14ee4..652d597 100644
--- a/mandoline/services/core_services/application_delegate_factory_linux.cc
+++ b/mandoline/services/core_services/application_delegate_factory_linux.cc
@@ -8,7 +8,7 @@
 
 namespace core_services {
 
-scoped_ptr<mojo::ApplicationDelegate> CreatePlatformSpecificApplicationDelegate(
+scoped_ptr<mojo::ShellClient> CreatePlatformSpecificApplicationDelegate(
     const std::string& url) {
   return url == "mojo://font_service/"
              ? make_scoped_ptr(new font_service::FontServiceApp)
diff --git a/mandoline/services/core_services/application_delegate_factory_notandroid.cc b/mandoline/services/core_services/application_delegate_factory_notandroid.cc
index 6756c99..8ea2af03 100644
--- a/mandoline/services/core_services/application_delegate_factory_notandroid.cc
+++ b/mandoline/services/core_services/application_delegate_factory_notandroid.cc
@@ -10,7 +10,7 @@
 
 namespace core_services {
 
-scoped_ptr<mojo::ApplicationDelegate> CreateApplicationDelegateNotAndroid(
+scoped_ptr<mojo::ShellClient> CreateApplicationDelegateNotAndroid(
     const std::string& url) {
   if (url == "mojo://network_service/")
     return make_scoped_ptr(new mojo::NetworkServiceDelegate);
diff --git a/mandoline/services/core_services/core_services_application_delegate.cc b/mandoline/services/core_services/core_services_application_delegate.cc
index efd21d037..f20b7df6 100644
--- a/mandoline/services/core_services/core_services_application_delegate.cc
+++ b/mandoline/services/core_services/core_services_application_delegate.cc
@@ -19,8 +19,8 @@
 #include "mojo/message_pump/message_pump_mojo.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
 #include "mojo/services/tracing/tracing_app.h"
-#include "mojo/shell/public/cpp/application_connection.h"
 #include "mojo/shell/public/cpp/application_runner.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "url/gurl.h"
 
 namespace core_services {
@@ -32,7 +32,7 @@
       const base::WeakPtr<CoreServicesApplicationDelegate>
           core_services_application,
       const std::string& url,
-      scoped_ptr<mojo::ApplicationDelegate> delegate,
+      scoped_ptr<mojo::ShellClient> delegate,
       mojo::InterfaceRequest<mojo::shell::mojom::Application> request,
       const mojo::Callback<void()>& destruct_callback)
       : base::SimpleThread(url),
@@ -72,7 +72,7 @@
   scoped_refptr<base::SingleThreadTaskRunner>
       core_services_application_task_runner_;
   std::string url_;
-  scoped_ptr<mojo::ApplicationDelegate> delegate_;
+  scoped_ptr<mojo::ShellClient> delegate_;
   mojo::InterfaceRequest<mojo::shell::mojom::Application> request_;
   mojo::Callback<void()> destruct_callback_;
 
@@ -105,7 +105,7 @@
 }
 
 bool CoreServicesApplicationDelegate::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+    mojo::Connection* connection) {
   connection->AddService(this);
   return true;
 }
@@ -118,7 +118,7 @@
 }
 
 void CoreServicesApplicationDelegate::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<mojo::shell::mojom::ContentHandler> request) {
   handler_bindings_.AddBinding(this, std::move(request));
 }
@@ -129,7 +129,7 @@
     const mojo::Callback<void()>& destruct_callback) {
   const std::string url = response->url;
 
-  scoped_ptr<mojo::ApplicationDelegate> delegate;
+  scoped_ptr<mojo::ShellClient> delegate;
   if (url == "mojo://clipboard/") {
     delegate.reset(new clipboard::ClipboardApplicationDelegate);
   } else if (url == "mojo://filesystem/") {
diff --git a/mandoline/services/core_services/core_services_application_delegate.h b/mandoline/services/core_services/core_services_application_delegate.h
index b50b491..55f53879 100644
--- a/mandoline/services/core_services/core_services_application_delegate.h
+++ b/mandoline/services/core_services/core_services_application_delegate.h
@@ -11,8 +11,8 @@
 #include "components/clipboard/public/interfaces/clipboard.mojom.h"
 #include "mojo/common/weak_binding_set.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory_impl.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/public/interfaces/content_handler.mojom.h"
 
 namespace core_services {
@@ -22,7 +22,7 @@
 // The CoreServices application is a singleton ServiceProvider. There is one
 // instance of the CoreServices ServiceProvider.
 class CoreServicesApplicationDelegate
-    : public mojo::ApplicationDelegate,
+    : public mojo::ShellClient,
       public mojo::InterfaceFactory<mojo::shell::mojom::ContentHandler>,
       public mojo::shell::mojom::ContentHandler {
  public:
@@ -32,16 +32,15 @@
   void ApplicationThreadDestroyed(ApplicationThread* thread);
 
  private:
-  // Overridden from mojo::ApplicationDelegate:
+  // Overridden from mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
   void Quit() override;
 
   // Overridden from mojo::InterfaceFactory<mojo::shell::mojom::ContentHandler>:
   void Create(
-      mojo::ApplicationConnection* connection,
+      mojo::Connection* connection,
       mojo::InterfaceRequest<mojo::shell::mojom::ContentHandler>
           request) override;
 
diff --git a/mandoline/services/updater/updater_app.cc b/mandoline/services/updater/updater_app.cc
index e94dff4..ffb9493 100644
--- a/mandoline/services/updater/updater_app.cc
+++ b/mandoline/services/updater/updater_app.cc
@@ -9,8 +9,8 @@
 #include "base/logging.h"
 #include "mandoline/services/updater/updater_impl.h"
 #include "mojo/public/c/system/main.h"
-#include "mojo/shell/public/cpp/application_connection.h"
 #include "mojo/shell/public/cpp/application_runner.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 
 namespace updater {
@@ -26,13 +26,12 @@
   shell_ = shell;
 }
 
-bool UpdaterApp::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+bool UpdaterApp::AcceptConnection(mojo::Connection* connection) {
   connection->AddService<Updater>(this);
   return true;
 }
 
-void UpdaterApp::Create(mojo::ApplicationConnection* connection,
+void UpdaterApp::Create(mojo::Connection* connection,
                         mojo::InterfaceRequest<Updater> request) {
   new UpdaterImpl(this, std::move(request));
 }
diff --git a/mandoline/services/updater/updater_app.h b/mandoline/services/updater/updater_app.h
index 818efb9..134d1eab 100644
--- a/mandoline/services/updater/updater_app.h
+++ b/mandoline/services/updater/updater_app.h
@@ -6,11 +6,11 @@
 #define MANDOLINE_SERVICES_UPDATER_UPDATER_APP_H_
 
 #include "base/macros.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace mojo {
-class ApplicationConnection;
+class Connection;
 class Shell;
 }  // namespace mojo
 
@@ -18,20 +18,19 @@
 
 class Updater;
 
-class UpdaterApp : public mojo::ApplicationDelegate,
+class UpdaterApp : public mojo::ShellClient,
                    public mojo::InterfaceFactory<Updater> {
  public:
   UpdaterApp();
   ~UpdaterApp() override;
 
-  // mojo::ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   // InterfaceFactory<Updater> implementation.
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<Updater> request) override;
 
  private:
diff --git a/mandoline/ui/desktop_ui/browser_manager.cc b/mandoline/ui/desktop_ui/browser_manager.cc
index b3a5123..b43b18e 100644
--- a/mandoline/ui/desktop_ui/browser_manager.cc
+++ b/mandoline/ui/desktop_ui/browser_manager.cc
@@ -70,13 +70,12 @@
     CreateBrowser(GURL(kGoogleURL));
 }
 
-bool BrowserManager::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+bool BrowserManager::AcceptConnection(mojo::Connection* connection) {
   connection->AddService<LaunchHandler>(this);
   return true;
 }
 
-void BrowserManager::Create(mojo::ApplicationConnection* connection,
+void BrowserManager::Create(mojo::Connection* connection,
                             mojo::InterfaceRequest<LaunchHandler> request) {
   launch_handler_bindings_.AddBinding(this, std::move(request));
 }
diff --git a/mandoline/ui/desktop_ui/browser_manager.h b/mandoline/ui/desktop_ui/browser_manager.h
index 77becea..aec4171 100644
--- a/mandoline/ui/desktop_ui/browser_manager.h
+++ b/mandoline/ui/desktop_ui/browser_manager.h
@@ -12,7 +12,7 @@
 #include "mandoline/ui/desktop_ui/public/interfaces/launch_handler.mojom.h"
 #include "mojo/common/weak_binding_set.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "url/gurl.h"
 
 namespace mojo {
@@ -24,7 +24,7 @@
 class BrowserWindow;
 
 // BrowserManager creates and manages the lifetime of Browsers.
-class BrowserManager : public mojo::ApplicationDelegate,
+class BrowserManager : public mojo::ShellClient,
                        public LaunchHandler,
                        public mojo::InterfaceFactory<LaunchHandler> {
  public:
@@ -43,14 +43,13 @@
   // Overridden from LaunchHandler:
   void LaunchURL(const mojo::String& url) override;
 
-  // Overridden from mojo::ApplicationDelegate:
+  // Overridden from mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   // Overridden from mojo::InterfaceFactory<LaunchHandler>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<LaunchHandler> request) override;
 
   mojo::Shell* shell_;
diff --git a/mandoline/ui/desktop_ui/browser_window.cc b/mandoline/ui/desktop_ui/browser_window.cc
index b87a604..6b4f15e 100644
--- a/mandoline/ui/desktop_ui/browser_window.cc
+++ b/mandoline/ui/desktop_ui/browser_window.cc
@@ -151,7 +151,7 @@
 void BrowserWindow::ShowOmnibox() {
   TRACE_EVENT0("desktop_ui", "BrowserWindow::ShowOmnibox");
   if (!omnibox_.get()) {
-    omnibox_connection_ = shell_->ConnectToApplication("mojo:omnibox");
+    omnibox_connection_ = shell_->Connect("mojo:omnibox");
     omnibox_connection_->AddService<ViewEmbedder>(this);
     omnibox_connection_->ConnectToService(&omnibox_);
     omnibox_connection_->SetRemoteServiceProviderConnectionErrorHandler(
@@ -391,7 +391,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 // BrowserWindow, mojo::InterfaceFactory<ViewEmbedder> implementation:
 
-void BrowserWindow::Create(mojo::ApplicationConnection* connection,
+void BrowserWindow::Create(mojo::Connection* connection,
                            mojo::InterfaceRequest<ViewEmbedder> request) {
   view_embedder_bindings_.AddBinding(this, std::move(request));
 }
diff --git a/mandoline/ui/desktop_ui/browser_window.h b/mandoline/ui/desktop_ui/browser_window.h
index 31d18805..08e7999 100644
--- a/mandoline/ui/desktop_ui/browser_window.h
+++ b/mandoline/ui/desktop_ui/browser_window.h
@@ -22,7 +22,7 @@
 #include "url/gurl.h"
 
 namespace mojo {
-class ApplicationConnection;
+class Connection;
 class Shell;
 }
 
@@ -101,7 +101,7 @@
   void Embed(mojo::URLRequestPtr request) override;
 
   // Overridden from mojo::InterfaceFactory<ViewEmbedder>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<ViewEmbedder> request) override;
 
 
@@ -141,7 +141,7 @@
   web_view::WebView web_view_;
 
   OmniboxPtr omnibox_;
-  scoped_ptr<mojo::ApplicationConnection> omnibox_connection_;
+  scoped_ptr<mojo::Connection> omnibox_connection_;
 
   DISALLOW_COPY_AND_ASSIGN(BrowserWindow);
 };
diff --git a/mandoline/ui/omnibox/omnibox_application.cc b/mandoline/ui/omnibox/omnibox_application.cc
index 7674d0d..0ee9c5b8 100644
--- a/mandoline/ui/omnibox/omnibox_application.cc
+++ b/mandoline/ui/omnibox/omnibox_application.cc
@@ -37,7 +37,7 @@
                     public Omnibox {
  public:
   OmniboxImpl(mojo::Shell* shell,
-              mojo::ApplicationConnection* connection,
+              mojo::Connection* connection,
               mojo::InterfaceRequest<Omnibox> request);
   ~OmniboxImpl() override;
 
@@ -81,7 +81,7 @@
 OmniboxApplication::~OmniboxApplication() {}
 
 ////////////////////////////////////////////////////////////////////////////////
-// OmniboxApplication, mojo::ApplicationDelegate implementation:
+// OmniboxApplication, mojo::ShellClient implementation:
 
 void OmniboxApplication::Initialize(mojo::Shell* shell, const std::string& url,
                                     uint32_t id) {
@@ -89,8 +89,7 @@
   tracing_.Initialize(shell, url);
 }
 
-bool OmniboxApplication::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+bool OmniboxApplication::AcceptConnection(mojo::Connection* connection) {
   connection->AddService<Omnibox>(this);
   return true;
 }
@@ -98,7 +97,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 // OmniboxApplication, mojo::InterfaceFactory<Omnibox> implementation:
 
-void OmniboxApplication::Create(mojo::ApplicationConnection* connection,
+void OmniboxApplication::Create(mojo::Connection* connection,
                                 mojo::InterfaceRequest<Omnibox> request) {
   new OmniboxImpl(shell_, connection, std::move(request));
 }
@@ -107,7 +106,7 @@
 // OmniboxImpl, public:
 
 OmniboxImpl::OmniboxImpl(mojo::Shell* shell,
-                         mojo::ApplicationConnection* connection,
+                         mojo::Connection* connection,
                          mojo::InterfaceRequest<Omnibox> request)
     : shell_(shell),
       root_(nullptr),
diff --git a/mandoline/ui/omnibox/omnibox_application.h b/mandoline/ui/omnibox/omnibox_application.h
index 91df2a0..cb705c34 100644
--- a/mandoline/ui/omnibox/omnibox_application.h
+++ b/mandoline/ui/omnibox/omnibox_application.h
@@ -8,8 +8,8 @@
 #include "base/macros.h"
 #include "mandoline/ui/desktop_ui/public/interfaces/omnibox.mojom.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace mojo {
 class Shell;
@@ -17,21 +17,20 @@
 
 namespace mandoline {
 
-class OmniboxApplication : public mojo::ApplicationDelegate,
+class OmniboxApplication : public mojo::ShellClient,
                            public mojo::InterfaceFactory<Omnibox> {
  public:
   OmniboxApplication();
   ~OmniboxApplication() override;
 
  private:
-  // Overridden from mojo::ApplicationDelegate:
+  // Overridden from mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   // Overridden from mojo::InterfaceFactory<Omnibox>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<Omnibox> request) override;
 
   mojo::Shell* shell_;
diff --git a/mandoline/ui/phone_ui/phone_browser_application_delegate.cc b/mandoline/ui/phone_ui/phone_browser_application_delegate.cc
index 666cafb..4cafb3c 100644
--- a/mandoline/ui/phone_ui/phone_browser_application_delegate.cc
+++ b/mandoline/ui/phone_ui/phone_browser_application_delegate.cc
@@ -10,7 +10,7 @@
 #include "components/mus/public/cpp/window_tree_host_factory.h"
 #include "mojo/converters/geometry/geometry_type_converters.h"
 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 #include "ui/gfx/geometry/size.h"
 #include "url/gurl.h"
@@ -34,7 +34,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-// PhoneBrowserApplicationDelegate, mojo::ApplicationDelegate implementation:
+// PhoneBrowserApplicationDelegate, mojo::ShellClient implementation:
 
 void PhoneBrowserApplicationDelegate::Initialize(mojo::Shell* shell,
                                                  const std::string& url,
@@ -53,7 +53,7 @@
 }
 
 bool PhoneBrowserApplicationDelegate::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+    mojo::Connection* connection) {
   connection->AddService<LaunchHandler>(this);
   return true;
 }
@@ -127,7 +127,7 @@
 //       mojo::InterfaceFactory<LaunchHandler> implementation:
 
 void PhoneBrowserApplicationDelegate::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<LaunchHandler> request) {
   launch_handler_bindings_.AddBinding(this, request.Pass());
 }
diff --git a/mandoline/ui/phone_ui/phone_browser_application_delegate.h b/mandoline/ui/phone_ui/phone_browser_application_delegate.h
index 6d85257..050c6d90 100644
--- a/mandoline/ui/phone_ui/phone_browser_application_delegate.h
+++ b/mandoline/ui/phone_ui/phone_browser_application_delegate.h
@@ -17,8 +17,8 @@
 // TODO(beng): move this file somewhere common.
 #include "mandoline/ui/desktop_ui/public/interfaces/launch_handler.mojom.h"
 #include "mojo/common/weak_binding_set.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace mus {
 class View;
@@ -27,7 +27,7 @@
 namespace mandoline {
 
 class PhoneBrowserApplicationDelegate
-    : public mojo::ApplicationDelegate,
+    : public mojo::ShellClient,
       public LaunchHandler,
       public mus::WindowTreeDelegate,
       public mus::WindowObserver,
@@ -38,11 +38,10 @@
   ~PhoneBrowserApplicationDelegate() override;
 
  private:
-  // Overridden from mojo::ApplicationDelegate:
+  // Overridden from mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   // Overridden from LaunchHandler:
   void LaunchURL(const mojo::String& url) override;
@@ -70,7 +69,7 @@
                                   int32_t active_match_ordinal) override {}
 
   // Overridden from mojo::InterfaceFactory<LaunchHandler>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<LaunchHandler> request) override;
 
   mojo::Shell* shell_;
diff --git a/mash/browser_driver/browser_driver_application_delegate.cc b/mash/browser_driver/browser_driver_application_delegate.cc
index 7314f08..98ac6482 100644
--- a/mash/browser_driver/browser_driver_application_delegate.cc
+++ b/mash/browser_driver/browser_driver_application_delegate.cc
@@ -8,7 +8,7 @@
 
 #include "base/bind.h"
 #include "components/mus/public/cpp/event_matcher.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 
 namespace mash {
@@ -58,7 +58,7 @@
 }
 
 bool BrowserDriverApplicationDelegate::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+    mojo::Connection* connection) {
   return true;
 }
 
@@ -68,7 +68,7 @@
     case Accelerator::NewWindow:
     case Accelerator::NewTab:
     case Accelerator::NewIncognitoWindow:
-      shell_->ConnectToApplication("exe:chrome");
+      shell_->Connect("exe:chrome");
       // TODO(beng): have Chrome export a service that allows it to be driven by
       //             this driver, e.g. to open new tabs, incognito windows, etc.
       break;
diff --git a/mash/browser_driver/browser_driver_application_delegate.h b/mash/browser_driver/browser_driver_application_delegate.h
index f832308b..2c1f981 100644
--- a/mash/browser_driver/browser_driver_application_delegate.h
+++ b/mash/browser_driver/browser_driver_application_delegate.h
@@ -14,27 +14,22 @@
 #include "base/memory/scoped_ptr.h"
 #include "components/mus/public/interfaces/accelerator_registrar.mojom.h"
 #include "mojo/public/cpp/bindings/binding.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
-
-namespace mojo {
-class ApplicationConnection;
-}
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace mash {
 namespace browser_driver {
 
-class BrowserDriverApplicationDelegate : public mojo::ApplicationDelegate,
+class BrowserDriverApplicationDelegate : public mojo::ShellClient,
                                          public mus::mojom::AcceleratorHandler {
  public:
   BrowserDriverApplicationDelegate();
   ~BrowserDriverApplicationDelegate() override;
 
  private:
-  // mojo::ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   // mus::mojom::AcceleratorHandler:
   void OnAccelerator(uint32_t id, mus::mojom::EventPtr event) override;
diff --git a/mash/example/views_examples/views_examples_application_delegate.cc b/mash/example/views_examples/views_examples_application_delegate.cc
index dc675ab3..ccdb1afc 100644
--- a/mash/example/views_examples/views_examples_application_delegate.cc
+++ b/mash/example/views_examples/views_examples_application_delegate.cc
@@ -4,7 +4,7 @@
 
 #include "mash/example/views_examples/views_examples_application_delegate.h"
 
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 #include "ui/views/examples/example_base.h"
 #include "ui/views/examples/examples_window.h"
@@ -29,6 +29,6 @@
 }
 
 bool ViewsExamplesApplicationDelegate::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+    mojo::Connection* connection) {
   return false;
 }
diff --git a/mash/example/views_examples/views_examples_application_delegate.h b/mash/example/views_examples/views_examples_application_delegate.h
index 29091266..a8d9a4f 100644
--- a/mash/example/views_examples/views_examples_application_delegate.h
+++ b/mash/example/views_examples/views_examples_application_delegate.h
@@ -8,23 +8,22 @@
 #include "base/macros.h"
 #include "base/memory/scoped_ptr.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace views {
 class AuraInit;
 }
 
-class ViewsExamplesApplicationDelegate : public mojo::ApplicationDelegate {
+class ViewsExamplesApplicationDelegate : public mojo::ShellClient {
  public:
   ViewsExamplesApplicationDelegate();
   ~ViewsExamplesApplicationDelegate() override;
 
  private:
-  // ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   mojo::TracingImpl tracing_;
 
diff --git a/mash/example/window_type_launcher/window_type_launcher.cc b/mash/example/window_type_launcher/window_type_launcher.cc
index 6f4d5b14..14ffd164 100644
--- a/mash/example/window_type_launcher/window_type_launcher.cc
+++ b/mash/example/window_type_launcher/window_type_launcher.cc
@@ -8,7 +8,7 @@
 #include "base/strings/utf_string_conversions.h"
 #include "mash/shell/public/interfaces/shell.mojom.h"
 #include "mojo/converters/geometry/geometry_type_converters.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 #include "ui/aura/window.h"
 #include "ui/aura/window_event_dispatcher.h"
@@ -355,11 +355,6 @@
 WindowTypeLauncher::WindowTypeLauncher() {}
 WindowTypeLauncher::~WindowTypeLauncher() {}
 
-bool WindowTypeLauncher::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
-  return false;
-}
-
 void WindowTypeLauncher::Initialize(mojo::Shell* shell, const std::string& url,
                                     uint32_t id) {
   aura_init_.reset(new views::AuraInit(shell, "views_mus_resources.pak"));
diff --git a/mash/example/window_type_launcher/window_type_launcher.h b/mash/example/window_type_launcher/window_type_launcher.h
index 34e283c8..e1d9c6e 100644
--- a/mash/example/window_type_launcher/window_type_launcher.h
+++ b/mash/example/window_type_launcher/window_type_launcher.h
@@ -7,23 +7,21 @@
 
 #include "base/macros.h"
 #include "base/memory/scoped_ptr.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace views {
 class AuraInit;
 }
 
-class WindowTypeLauncher : public mojo::ApplicationDelegate {
+class WindowTypeLauncher : public mojo::ShellClient {
  public:
   WindowTypeLauncher();
   ~WindowTypeLauncher() override;
 
  private:
-  // ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
 
   scoped_ptr<views::AuraInit> aura_init_;
 
diff --git a/mash/quick_launch/quick_launch.cc b/mash/quick_launch/quick_launch.cc
index 369cd7c..8a37d52 100644
--- a/mash/quick_launch/quick_launch.cc
+++ b/mash/quick_launch/quick_launch.cc
@@ -7,9 +7,9 @@
 #include "base/strings/utf_string_conversions.h"
 #include "mojo/public/c/system/main.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_runner.h"
 #include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "ui/views/background.h"
 #include "ui/views/controls/textfield/textfield.h"
 #include "ui/views/controls/textfield/textfield_controller.h"
@@ -62,7 +62,7 @@
                       const ui::KeyEvent& key_event) override {
     if (key_event.key_code() == ui::VKEY_RETURN) {
       std::string url = Canonicalize(prompt_->text());
-      connections_.push_back(shell_->ConnectToApplication(url));
+      connections_.push_back(shell_->Connect(url));
       prompt_->SetText(base::string16());
     }
     return false;
@@ -79,18 +79,18 @@
 
   mojo::Shell* shell_;
   views::Textfield* prompt_;
-  std::vector<scoped_ptr<mojo::ApplicationConnection>> connections_;
+  std::vector<scoped_ptr<mojo::Connection>> connections_;
 
   DISALLOW_COPY_AND_ASSIGN(QuickLaunchUI);
 };
 
-class QuickLaunchApplicationDelegate : public mojo::ApplicationDelegate {
+class QuickLaunchApplicationDelegate : public mojo::ShellClient {
  public:
   QuickLaunchApplicationDelegate() {}
   ~QuickLaunchApplicationDelegate() override {}
 
  private:
-  // mojo::ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override {
     tracing_.Initialize(shell, url);
diff --git a/mash/screenlock/screenlock.h b/mash/screenlock/screenlock.h
index ff6b9bb..3d6bfb6 100644
--- a/mash/screenlock/screenlock.h
+++ b/mash/screenlock/screenlock.h
@@ -12,7 +12,7 @@
 #include "mash/shell/public/interfaces/shell.mojom.h"
 #include "mojo/common/weak_binding_set.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace views {
 class AuraInit;
@@ -21,14 +21,14 @@
 namespace mash {
 namespace screenlock {
 
-class Screenlock : public mojo::ApplicationDelegate,
+class Screenlock : public mojo::ShellClient,
                    public shell::mojom::ScreenlockStateListener {
  public:
   Screenlock();
   ~Screenlock() override;
 
  private:
-  // mojo::ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
 
diff --git a/mash/shelf/shelf_application.h b/mash/shelf/shelf_application.h
index ab74f2c..ea9354c 100644
--- a/mash/shelf/shelf_application.h
+++ b/mash/shelf/shelf_application.h
@@ -8,7 +8,7 @@
 #include "base/macros.h"
 #include "base/memory/scoped_ptr.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace views {
 class AuraInit;
@@ -17,13 +17,13 @@
 namespace mash {
 namespace shelf {
 
-class ShelfApplication : public mojo::ApplicationDelegate {
+class ShelfApplication : public mojo::ShellClient {
  public:
   ShelfApplication();
   ~ShelfApplication() override;
 
  private:
-  // mojo::ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
 
diff --git a/mash/shell/shell_application_delegate.cc b/mash/shell/shell_application_delegate.cc
index 560eddea..68c01fd 100644
--- a/mash/shell/shell_application_delegate.cc
+++ b/mash/shell/shell_application_delegate.cc
@@ -5,7 +5,7 @@
 #include "mash/shell/shell_application_delegate.h"
 
 #include "base/bind.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 
 namespace mash {
@@ -27,8 +27,7 @@
   StartQuickLaunch();
 }
 
-bool ShellApplicationDelegate::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+bool ShellApplicationDelegate::AcceptConnection(mojo::Connection* connection) {
   connection->AddService<mash::shell::mojom::Shell>(this);
   return true;
 }
@@ -61,7 +60,7 @@
 }
 
 void ShellApplicationDelegate::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<mash::shell::mojom::Shell> r) {
   bindings_.AddBinding(this, std::move(r));
 }
@@ -117,8 +116,7 @@
     const base::Closure& restart_callback) {
   // TODO(beng): This would be the place to insert logic that counted restarts
   //             to avoid infinite crash-restart loops.
-  scoped_ptr<mojo::ApplicationConnection> connection =
-      shell_->ConnectToApplication(url);
+  scoped_ptr<mojo::Connection> connection = shell_->Connect(url);
   connection->SetRemoteServiceProviderConnectionErrorHandler(restart_callback);
   connections_[url] = std::move(connection);
 }
diff --git a/mash/shell/shell_application_delegate.h b/mash/shell/shell_application_delegate.h
index a36a91a7..dc81282 100644
--- a/mash/shell/shell_application_delegate.h
+++ b/mash/shell/shell_application_delegate.h
@@ -13,18 +13,18 @@
 #include "mash/shell/public/interfaces/shell.mojom.h"
 #include "mojo/common/weak_binding_set.h"
 #include "mojo/common/weak_interface_ptr_set.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace mojo {
-class ApplicationConnection;
+class Connection;
 }
 
 namespace mash {
 namespace shell {
 
 class ShellApplicationDelegate
-    : public mojo::ApplicationDelegate,
+    : public mojo::ShellClient,
       public mash::shell::mojom::Shell,
       public mojo::InterfaceFactory<mash::shell::mojom::Shell> {
  public:
@@ -32,11 +32,10 @@
   ~ShellApplicationDelegate() override;
 
  private:
-  // mojo::ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   // mash::shell::mojom::Shell:
   void AddScreenlockStateListener(
@@ -45,7 +44,7 @@
   void UnlockScreen() override;
 
   // mojo::InterfaceFactory<mash::shell::mojom::Shell>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<mash::shell::mojom::Shell> r) override;
 
   void StartWindowManager();
@@ -63,7 +62,7 @@
                                const base::Closure& restart_callback);
 
   mojo::Shell* shell_;
-  std::map<std::string, scoped_ptr<mojo::ApplicationConnection>> connections_;
+  std::map<std::string, scoped_ptr<mojo::Connection>> connections_;
   bool screen_locked_;
   mojo::WeakBindingSet<mash::shell::mojom::Shell> bindings_;
   mojo::WeakInterfacePtrSet<mojom::ScreenlockStateListener>
diff --git a/mash/task_viewer/task_viewer_application_delegate.cc b/mash/task_viewer/task_viewer_application_delegate.cc
index cac01ee3..ff3f9d3 100644
--- a/mash/task_viewer/task_viewer_application_delegate.cc
+++ b/mash/task_viewer/task_viewer_application_delegate.cc
@@ -13,7 +13,7 @@
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
 #include "mojo/public/cpp/bindings/binding.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 #include "mojo/shell/public/interfaces/application_manager.mojom.h"
 #include "ui/base/models/table_model.h"
diff --git a/mash/task_viewer/task_viewer_application_delegate.h b/mash/task_viewer/task_viewer_application_delegate.h
index efd84c6..d6d122da 100644
--- a/mash/task_viewer/task_viewer_application_delegate.h
+++ b/mash/task_viewer/task_viewer_application_delegate.h
@@ -11,11 +11,7 @@
 #include "base/macros.h"
 #include "base/memory/scoped_ptr.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
-
-namespace mojo {
-class ApplicationConnection;
-}
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace views {
 class AuraInit;
@@ -24,13 +20,13 @@
 namespace mash {
 namespace task_viewer {
 
-class TaskViewerApplicationDelegate : public mojo::ApplicationDelegate {
+class TaskViewerApplicationDelegate : public mojo::ShellClient {
  public:
   TaskViewerApplicationDelegate();
   ~TaskViewerApplicationDelegate() override;
 
  private:
-  // mojo::ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
 
diff --git a/mash/wallpaper/wallpaper.cc b/mash/wallpaper/wallpaper.cc
index ab50ddcf..d53c9f5 100644
--- a/mash/wallpaper/wallpaper.cc
+++ b/mash/wallpaper/wallpaper.cc
@@ -9,10 +9,9 @@
 #include "mash/wm/public/interfaces/container.mojom.h"
 #include "mojo/public/c/system/main.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_connection.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_runner.h"
 #include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "ui/gfx/canvas.h"
 #include "ui/views/mus/aura_init.h"
 #include "ui/views/mus/native_widget_mus.h"
@@ -39,7 +38,7 @@
   DISALLOW_COPY_AND_ASSIGN(Wallpaper);
 };
 
-class WallpaperApplicationDelegate : public mojo::ApplicationDelegate {
+class WallpaperApplicationDelegate : public mojo::ShellClient {
  public:
   WallpaperApplicationDelegate() {}
   ~WallpaperApplicationDelegate() override {}
@@ -49,7 +48,7 @@
   }
 
  private:
-  // mojo::ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override {
     tracing_.Initialize(shell, url);
diff --git a/mash/wm/window_manager_application.cc b/mash/wm/window_manager_application.cc
index 47570a51..5a0a5ab 100644
--- a/mash/wm/window_manager_application.cc
+++ b/mash/wm/window_manager_application.cc
@@ -15,7 +15,7 @@
 #include "mash/wm/root_windows_observer.h"
 #include "mash/wm/user_window_controller_impl.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 #include "ui/mojo/init/ui_init.h"
 #include "ui/views/mus/aura_init.h"
@@ -120,15 +120,14 @@
       RootWindowController::CreateUsingWindowTreeHost(this));
 }
 
-bool WindowManagerApplication::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+bool WindowManagerApplication::AcceptConnection(mojo::Connection* connection) {
   connection->AddService<mash::wm::mojom::UserWindowController>(this);
   connection->AddService<mus::mojom::AcceleratorRegistrar>(this);
   return true;
 }
 
 void WindowManagerApplication::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<mash::wm::mojom::UserWindowController> request) {
   if (!root_controllers_.empty() && (*root_controllers_.begin())->root()) {
     user_window_controller_binding_.AddBinding(user_window_controller_.get(),
@@ -141,7 +140,7 @@
 }
 
 void WindowManagerApplication::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) {
   static int accelerator_registrar_count = 0;
   if (accelerator_registrar_count == std::numeric_limits<int>::max()) {
diff --git a/mash/wm/window_manager_application.h b/mash/wm/window_manager_application.h
index 19c7d33f..f5ef9e1 100644
--- a/mash/wm/window_manager_application.h
+++ b/mash/wm/window_manager_application.h
@@ -21,7 +21,7 @@
 #include "mojo/common/weak_binding_set.h"
 #include "mojo/public/cpp/bindings/binding.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace ui {
 namespace mojo {
@@ -42,7 +42,7 @@
 class UserWindowControllerImpl;
 
 class WindowManagerApplication
-    : public mojo::ApplicationDelegate,
+    : public mojo::ShellClient,
       public mus::mojom::WindowManagerFactory,
       public mojo::InterfaceFactory<mash::wm::mojom::UserWindowController>,
       public mojo::InterfaceFactory<mus::mojom::AcceleratorRegistrar> {
@@ -77,19 +77,18 @@
  private:
   void OnAcceleratorRegistrarDestroyed(AcceleratorRegistrarImpl* registrar);
 
-  // ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override;
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   // InterfaceFactory<mash::wm::mojom::UserWindowController>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<mash::wm::mojom::UserWindowController>
                   request) override;
 
   // InterfaceFactory<mus::mojom::AcceleratorRegistrar>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request)
       override;
 
diff --git a/mash/wm/window_manager_apptest.cc b/mash/wm/window_manager_apptest.cc
index 51a68f4..6e6e9fbb 100644
--- a/mash/wm/window_manager_apptest.cc
+++ b/mash/wm/window_manager_apptest.cc
@@ -39,7 +39,7 @@
   WindowTreeDelegateImpl window_tree_delegate;
 
   // Bring up the the desktop_wm.
-  shell()->ConnectToApplication("mojo:desktop_wm");
+  shell()->Connect("mojo:desktop_wm");
 
   // Connect to mus and create a new top level window. The request goes to
   // the |desktop_wm|, but is async.
diff --git a/media/mojo/services/main.cc b/media/mojo/services/main.cc
index 046fa0c4..b3df5c8 100644
--- a/media/mojo/services/main.cc
+++ b/media/mojo/services/main.cc
@@ -14,7 +14,7 @@
   mojo::ApplicationRunner::InitBaseCommandLine();
   mojo::InitLogging();
 
-  scoped_ptr<mojo::ApplicationDelegate> app_delegate =
+  scoped_ptr<mojo::ShellClient> app_delegate =
       media::MojoMediaApplication::CreateApp();
   mojo::ApplicationRunner runner(app_delegate.release());
   return runner.Run(mojo_handle, false /* init_base */);
diff --git a/media/mojo/services/media_apptest.cc b/media/mojo/services/media_apptest.cc
index 27b525d..eb6dbd6 100644
--- a/media/mojo/services/media_apptest.cc
+++ b/media/mojo/services/media_apptest.cc
@@ -20,7 +20,6 @@
 #include "media/mojo/interfaces/service_factory.mojom.h"
 #include "media/mojo/services/media_type_converters.h"
 #include "media/mojo/services/mojo_demuxer_stream_impl.h"
-#include "mojo/shell/public/cpp/application_connection.h"
 #include "mojo/shell/public/cpp/application_test_base.h"
 #include "testing/gmock/include/gmock/gmock.h"
 
@@ -60,7 +59,7 @@
   void SetUp() override {
     ApplicationTestBase::SetUp();
 
-    connection_ = shell()->ConnectToApplication("mojo:media");
+    connection_ = shell()->Connect("mojo:media");
     connection_->SetRemoteServiceProviderConnectionErrorHandler(
         base::Bind(&MediaAppTest::ConnectionClosed, base::Unretained(this)));
 
@@ -124,7 +123,7 @@
   StrictMock<MockDemuxerStream> video_demuxer_stream_;
 
  private:
-  scoped_ptr<mojo::ApplicationConnection> connection_;
+  scoped_ptr<mojo::Connection> connection_;
 
   DISALLOW_COPY_AND_ASSIGN(MediaAppTest);
 };
diff --git a/media/mojo/services/mojo_media_application.cc b/media/mojo/services/mojo_media_application.cc
index 4722908c..a84ef88 100644
--- a/media/mojo/services/mojo_media_application.cc
+++ b/media/mojo/services/mojo_media_application.cc
@@ -9,14 +9,14 @@
 #include "media/base/media_log.h"
 #include "media/mojo/services/mojo_media_client.h"
 #include "media/mojo/services/service_factory_impl.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 
 namespace media {
 
 // static
-scoped_ptr<mojo::ApplicationDelegate> MojoMediaApplication::CreateApp() {
-  return scoped_ptr<mojo::ApplicationDelegate>(
+scoped_ptr<mojo::ShellClient> MojoMediaApplication::CreateApp() {
+  return scoped_ptr<mojo::ShellClient>(
       new MojoMediaApplication(MojoMediaClient::Create()));
 }
 
@@ -37,14 +37,13 @@
   mojo_media_client_->Initialize();
 }
 
-bool MojoMediaApplication::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+bool MojoMediaApplication::AcceptConnection(mojo::Connection* connection) {
   connection->AddService<interfaces::ServiceFactory>(this);
   return true;
 }
 
 void MojoMediaApplication::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<interfaces::ServiceFactory> request) {
   // The created object is owned by the pipe.
   new ServiceFactoryImpl(std::move(request), connection->GetServiceProvider(),
diff --git a/media/mojo/services/mojo_media_application.h b/media/mojo/services/mojo_media_application.h
index c3ee1b7a..71b1e06 100644
--- a/media/mojo/services/mojo_media_application.h
+++ b/media/mojo/services/mojo_media_application.h
@@ -4,8 +4,8 @@
 
 #include "base/memory/ref_counted.h"
 #include "media/mojo/interfaces/service_factory.mojom.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory_impl.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "url/gurl.h"
 
 namespace media {
@@ -14,23 +14,23 @@
 class MojoMediaClient;
 
 class MojoMediaApplication
-    : public mojo::ApplicationDelegate,
+    : public mojo::ShellClient,
       public mojo::InterfaceFactory<interfaces::ServiceFactory> {
  public:
-  static scoped_ptr<mojo::ApplicationDelegate> CreateApp();
+  static scoped_ptr<mojo::ShellClient> CreateApp();
 
   explicit MojoMediaApplication(scoped_ptr<MojoMediaClient> mojo_media_client);
   ~MojoMediaApplication() final;
 
  private:
-  // mojo::ApplicationDelegate implementation.
+  // mojo::ShellClient implementation.
   void Initialize(mojo::Shell* shell,
                   const std::string& url,
                   uint32_t id) final;
-  bool AcceptConnection(mojo::ApplicationConnection* connection) final;
+  bool AcceptConnection(mojo::Connection* connection) final;
 
   // mojo::InterfaceFactory<interfaces::ServiceFactory> implementation.
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<interfaces::ServiceFactory> request) final;
 
   scoped_ptr<MojoMediaClient> mojo_media_client_;
diff --git a/media/mojo/services/mojo_renderer_service.h b/media/mojo/services/mojo_renderer_service.h
index 78dea699..7c43d3f 100644
--- a/media/mojo/services/mojo_renderer_service.h
+++ b/media/mojo/services/mojo_renderer_service.h
@@ -17,7 +17,7 @@
 #include "mojo/public/cpp/bindings/strong_binding.h"
 
 namespace mojo {
-class ApplicationConnection;
+class Connection;
 }
 
 namespace media {
@@ -27,7 +27,7 @@
 class Renderer;
 
 // A interfaces::Renderer implementation that uses media::AudioRenderer to
-// decode and render audio to a sink obtained from the ApplicationConnection.
+// decode and render audio to a sink obtained from the Connection.
 class MojoRendererService : interfaces::Renderer {
  public:
   // |cdm_context_provider| can be used to find the CdmContext to support
diff --git a/mojo/edk/embedder/platform_channel_utils_posix.cc b/mojo/edk/embedder/platform_channel_utils_posix.cc
index c0940e0..0bb8c62 100644
--- a/mojo/edk/embedder/platform_channel_utils_posix.cc
+++ b/mojo/edk/embedder/platform_channel_utils_posix.cc
@@ -147,7 +147,8 @@
 ssize_t PlatformChannelRecvmsg(PlatformHandle h,
                                void* buf,
                                size_t num_bytes,
-                               std::deque<PlatformHandle>* platform_handles) {
+                               std::deque<PlatformHandle>* platform_handles,
+                               bool block) {
   DCHECK(buf);
   DCHECK_GT(num_bytes, 0u);
   DCHECK(platform_handles);
@@ -160,7 +161,8 @@
   msg.msg_control = cmsg_buf;
   msg.msg_controllen = sizeof(cmsg_buf);
 
-  ssize_t result = HANDLE_EINTR(recvmsg(h.handle, &msg, MSG_DONTWAIT));
+  ssize_t result =
+      HANDLE_EINTR(recvmsg(h.handle, &msg, block ? 0 : MSG_DONTWAIT));
   if (result < 0)
     return result;
 
diff --git a/mojo/edk/embedder/platform_channel_utils_posix.h b/mojo/edk/embedder/platform_channel_utils_posix.h
index ad58753e..e08f2a1 100644
--- a/mojo/edk/embedder/platform_channel_utils_posix.h
+++ b/mojo/edk/embedder/platform_channel_utils_posix.h
@@ -67,7 +67,8 @@
 PlatformChannelRecvmsg(PlatformHandle h,
                        void* buf,
                        size_t num_bytes,
-                       std::deque<PlatformHandle>* platform_handles);
+                       std::deque<PlatformHandle>* platform_handles,
+                       bool block = false);
 
 }  // namespace edk
 }  // namespace mojo
diff --git a/mojo/edk/system/BUILD.gn b/mojo/edk/system/BUILD.gn
index 9aa7b70..112dac2 100644
--- a/mojo/edk/system/BUILD.gn
+++ b/mojo/edk/system/BUILD.gn
@@ -31,6 +31,10 @@
     "awakable.h",
     "awakable_list.cc",
     "awakable_list.h",
+    "broker.h",
+    "broker_host.h",
+    "broker_host_posix.cc",
+    "broker_posix.cc",
     "channel.cc",
     "channel.h",
     "channel_posix.cc",
diff --git a/mojo/edk/system/broker.h b/mojo/edk/system/broker.h
new file mode 100644
index 0000000..1577972
--- /dev/null
+++ b/mojo/edk/system/broker.h
@@ -0,0 +1,52 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_EDK_SYSTEM_BROKER_H_
+#define MOJO_EDK_SYSTEM_BROKER_H_
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/synchronization/lock.h"
+#include "mojo/edk/embedder/scoped_platform_handle.h"
+
+namespace mojo {
+namespace edk {
+
+class PlatformSharedBuffer;
+
+// The Broker is a channel to the parent process, which allows synchronous IPCs.
+class Broker {
+ public:
+  // Note: This is blocking, and will wait for the first message over
+  // |platform_handle|.
+  explicit Broker(ScopedPlatformHandle platform_handle);
+  ~Broker();
+
+  // Returns the platform handle that should be used to establish a NodeChannel
+  // to the parent process.
+  ScopedPlatformHandle GetParentPlatformHandle();
+
+  // Request a shared buffer from the parent process. Blocks the current thread.
+  scoped_refptr<PlatformSharedBuffer> GetSharedBuffer(size_t num_bytes);
+
+ private:
+  // Handle to the parent process, used for synchronous IPCs.
+  ScopedPlatformHandle sync_channel_;
+
+  // Handle to the parent process which is recieved in the first first message
+  // over |sync_channel_|.
+  ScopedPlatformHandle parent_channel_;
+
+  // Lock to only allow one sync message at a time. This avoids having to deal
+  // with message ordering since we can only have one request at a time
+  // in-flight.
+  base::Lock lock_;
+
+  DISALLOW_COPY_AND_ASSIGN(Broker);
+};
+
+}  // namespace edk
+}  // namespace mojo
+
+#endif  // MOJO_EDK_SYSTEM_BROKER_H_
diff --git a/mojo/edk/system/broker_host.h b/mojo/edk/system/broker_host.h
new file mode 100644
index 0000000..2029cb0a
--- /dev/null
+++ b/mojo/edk/system/broker_host.h
@@ -0,0 +1,42 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_EDK_SYSTEM_BROKER_HOST_H_
+#define MOJO_EDK_SYSTEM_BROKER_HOST_H_
+
+#include "base/macros.h"
+#include "mojo/edk/embedder/scoped_platform_handle.h"
+#include "mojo/edk/system/channel.h"
+
+namespace mojo {
+namespace edk {
+
+// The BrokerHost is a channel to the child process, which services synchronous
+// IPCs.
+class BrokerHost : public Channel::Delegate {
+ public:
+  explicit BrokerHost(ScopedPlatformHandle platform_handle);
+  ~BrokerHost() override;
+
+  // Send |handle| to the child, to be used to establish a NodeChannel to us.
+  void SendChannel(ScopedPlatformHandle handle);
+
+ private:
+  // Channel::Delegate:
+  void OnChannelMessage(const void* payload,
+                        size_t payload_size,
+                        ScopedPlatformHandleVectorPtr handles) override;
+  void OnChannelError() override;
+
+  void OnBufferRequest(size_t num_bytes);
+
+  scoped_refptr<Channel> channel_;
+
+  DISALLOW_COPY_AND_ASSIGN(BrokerHost);
+};
+
+}  // namespace edk
+}  // namespace mojo
+
+#endif  // MOJO_EDK_SYSTEM_BROKER_HOST_H_
diff --git a/mojo/edk/system/broker_host_posix.cc b/mojo/edk/system/broker_host_posix.cc
new file mode 100644
index 0000000..7a3ff94
--- /dev/null
+++ b/mojo/edk/system/broker_host_posix.cc
@@ -0,0 +1,104 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/edk/system/broker_host.h"
+
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <utility>
+
+#include "base/logging.h"
+#include "base/memory/ref_counted.h"
+#include "base/message_loop/message_loop.h"
+#include "mojo/edk/embedder/embedder_internal.h"
+#include "mojo/edk/embedder/platform_channel_utils_posix.h"
+#include "mojo/edk/embedder/platform_handle_vector.h"
+#include "mojo/edk/embedder/platform_shared_buffer.h"
+#include "mojo/edk/embedder/platform_support.h"
+#include "mojo/edk/system/broker_messages.h"
+
+namespace mojo {
+namespace edk {
+
+namespace {
+// To prevent abuse, limit the maximum size of shared memory buffers.
+// TODO(amistry): Re-consider this limit, or do something smarter.
+const size_t kMaxSharedBufferSize = 16 * 1024 * 1024;
+}
+
+BrokerHost::BrokerHost(ScopedPlatformHandle platform_handle) {
+  CHECK(platform_handle.is_valid());
+
+  channel_ = Channel::Create(this, std::move(platform_handle),
+                             base::MessageLoop::current()->task_runner());
+  channel_->Start();
+}
+
+BrokerHost::~BrokerHost() {
+  if (channel_)
+    channel_->ShutDown();
+}
+
+void BrokerHost::SendChannel(ScopedPlatformHandle handle) {
+  CHECK(handle.is_valid());
+  CHECK(channel_);
+
+  Channel::MessagePtr message =
+      CreateBrokerMessage(BrokerMessageType::INIT, 1, nullptr);
+  ScopedPlatformHandleVectorPtr handles;
+  handles.reset(new PlatformHandleVector(1));
+  handles->at(0) = handle.release();
+  message->SetHandles(std::move(handles));
+
+  channel_->Write(std::move(message));
+}
+
+void BrokerHost::OnBufferRequest(size_t num_bytes) {
+  scoped_refptr<PlatformSharedBuffer> buffer;
+  if (num_bytes <= kMaxSharedBufferSize) {
+    buffer = internal::g_platform_support->CreateSharedBuffer(num_bytes);
+  } else {
+    LOG(ERROR) << "Shared buffer request too large: " << num_bytes;
+  }
+
+  Channel::MessagePtr message = CreateBrokerMessage(
+      BrokerMessageType::BUFFER_RESPONSE, buffer ? 1 : 0, nullptr);
+  if (buffer) {
+    ScopedPlatformHandleVectorPtr handles;
+    handles.reset(new PlatformHandleVector(1));
+    handles->at(0) = buffer->PassPlatformHandle().release();
+    message->SetHandles(std::move(handles));
+  }
+
+  channel_->Write(std::move(message));
+}
+
+void BrokerHost::OnChannelMessage(const void* payload,
+                                  size_t payload_size,
+                                  ScopedPlatformHandleVectorPtr handles) {
+  const BrokerMessageHeader* header =
+      static_cast<const BrokerMessageHeader*>(payload);
+  switch (header->type) {
+    case BrokerMessageType::BUFFER_REQUEST: {
+      const BufferRequestData* request =
+          reinterpret_cast<const BufferRequestData*>(header + 1);
+      OnBufferRequest(request->size);
+      break;
+    }
+    default:
+      LOG(ERROR) << "Unexpected broker message type: " << header->type;
+      break;
+  }
+}
+
+void BrokerHost::OnChannelError() {
+  if (channel_) {
+    channel_->ShutDown();
+    channel_ = nullptr;
+  }
+}
+
+}  // namespace edk
+}  // namespace mojo
diff --git a/mojo/edk/system/broker_messages.h b/mojo/edk/system/broker_messages.h
new file mode 100644
index 0000000..6ae92bb8
--- /dev/null
+++ b/mojo/edk/system/broker_messages.h
@@ -0,0 +1,63 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_
+#define MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_
+
+#include "mojo/edk/system/channel.h"
+
+namespace mojo {
+namespace edk {
+
+#pragma pack(push, 1)
+
+enum BrokerMessageType : uint32_t {
+  INIT,
+  BUFFER_REQUEST,
+  BUFFER_RESPONSE,
+};
+
+struct BrokerMessageHeader {
+  BrokerMessageType type;
+  uint32_t padding;
+};
+
+static_assert(sizeof(BrokerMessageHeader) % kChannelMessageAlignment == 0,
+              "Invalid header size.");
+
+struct BufferRequestData {
+  uint32_t size;
+};
+
+#pragma pack(pop)
+
+template <typename T>
+inline Channel::MessagePtr CreateBrokerMessage(BrokerMessageType type,
+                                               size_t num_handles,
+                                               T** out_message_data) {
+  const size_t message_size = sizeof(BrokerMessageHeader) + sizeof(T);
+  Channel::MessagePtr message(new Channel::Message(message_size, num_handles));
+  BrokerMessageHeader* header =
+      reinterpret_cast<BrokerMessageHeader*>(message->mutable_payload());
+  header->type = type;
+  *out_message_data = reinterpret_cast<T*>(header + 1);
+  return message;
+}
+
+inline Channel::MessagePtr CreateBrokerMessage(
+    BrokerMessageType type,
+    size_t num_handles,
+    std::nullptr_t** dummy_out_data) {
+  Channel::MessagePtr message(
+      new Channel::Message(sizeof(BrokerMessageHeader), num_handles));
+  BrokerMessageHeader* header =
+      reinterpret_cast<BrokerMessageHeader*>(message->mutable_payload());
+  header->type = type;
+  return message;
+}
+
+}  // namespace edk
+}  // namespace mojo
+
+#endif  // MOJO_EDK_SYSTEM_BROKER_MESSAGES_H_
diff --git a/mojo/edk/system/broker_posix.cc b/mojo/edk/system/broker_posix.cc
new file mode 100644
index 0000000..a1ac43e
--- /dev/null
+++ b/mojo/edk/system/broker_posix.cc
@@ -0,0 +1,123 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/edk/system/broker.h"
+
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <utility>
+
+#include "base/logging.h"
+#include "mojo/edk/embedder/embedder_internal.h"
+#include "mojo/edk/embedder/platform_channel_utils_posix.h"
+#include "mojo/edk/embedder/platform_handle_utils.h"
+#include "mojo/edk/embedder/platform_handle_vector.h"
+#include "mojo/edk/embedder/platform_shared_buffer.h"
+#include "mojo/edk/embedder/platform_support.h"
+#include "mojo/edk/system/broker_messages.h"
+#include "mojo/edk/system/channel.h"
+
+namespace mojo {
+namespace edk {
+
+namespace {
+
+bool WaitForBrokerMessage(PlatformHandle platform_handle,
+                          BrokerMessageType expected_type,
+                          size_t expected_num_handles,
+                          std::deque<PlatformHandle>* incoming_handles) {
+  Channel::MessagePtr message(
+      new Channel::Message(sizeof(BrokerMessageHeader), expected_num_handles));
+  std::deque<PlatformHandle> incoming_platform_handles;
+  ssize_t read_result = PlatformChannelRecvmsg(
+      platform_handle, const_cast<void*>(message->data()),
+      message->data_num_bytes(), &incoming_platform_handles, true /* block */);
+  bool error = false;
+  if (read_result < 0) {
+    PLOG(ERROR) << "Recvmsg error";
+    error = true;
+  } else if (static_cast<size_t>(read_result) != message->data_num_bytes()) {
+    LOG(ERROR) << "Invalid node channel message";
+    error = true;
+  } else if (incoming_platform_handles.size() != expected_num_handles) {
+    LOG(ERROR) << "Received unexpected number of handles";
+    error = true;
+  }
+
+  if (!error) {
+    const BrokerMessageHeader* header =
+        reinterpret_cast<const BrokerMessageHeader*>(message->payload());
+    if (header->type != expected_type) {
+      LOG(ERROR) << "Unexpected message";
+      error = true;
+    }
+  }
+
+  if (error) {
+    CloseAllPlatformHandles(&incoming_platform_handles);
+  } else {
+    if (incoming_handles)
+      incoming_handles->swap(incoming_platform_handles);
+  }
+  return !error;
+}
+
+}  // namespace
+
+Broker::Broker(ScopedPlatformHandle platform_handle)
+    : sync_channel_(std::move(platform_handle)) {
+  CHECK(sync_channel_.is_valid());
+
+  // Mark the channel as blocking.
+  int flags = fcntl(sync_channel_.get().handle, F_GETFL);
+  PCHECK(flags != -1);
+  flags = fcntl(sync_channel_.get().handle, F_SETFL, flags & ~O_NONBLOCK);
+  PCHECK(flags != -1);
+
+  // Wait for the first message, which should contain a handle.
+  std::deque<PlatformHandle> incoming_platform_handles;
+  if (WaitForBrokerMessage(sync_channel_.get(), BrokerMessageType::INIT, 1,
+                           &incoming_platform_handles)) {
+    parent_channel_ = ScopedPlatformHandle(incoming_platform_handles.front());
+  }
+}
+
+Broker::~Broker() = default;
+
+ScopedPlatformHandle Broker::GetParentPlatformHandle() {
+  return std::move(parent_channel_);
+}
+
+scoped_refptr<PlatformSharedBuffer> Broker::GetSharedBuffer(size_t num_bytes) {
+  base::AutoLock lock(lock_);
+
+  BufferRequestData* buffer_request;
+  Channel::MessagePtr out_message = CreateBrokerMessage(
+      BrokerMessageType::BUFFER_REQUEST, 0, &buffer_request);
+  buffer_request->size = num_bytes;
+  ssize_t write_result = PlatformChannelWrite(
+      sync_channel_.get(), out_message->data(), out_message->data_num_bytes());
+  if (write_result < 0) {
+    PLOG(ERROR) << "Error sending sync broker message";
+    return nullptr;
+  } else if (static_cast<size_t>(write_result) !=
+             out_message->data_num_bytes()) {
+    LOG(ERROR) << "Error sending complete broker message";
+    return nullptr;
+  }
+
+  std::deque<PlatformHandle> incoming_platform_handles;
+  if (WaitForBrokerMessage(sync_channel_.get(),
+                           BrokerMessageType::BUFFER_RESPONSE, 1,
+                           &incoming_platform_handles)) {
+    return internal::g_platform_support->CreateSharedBufferFromHandle(
+        num_bytes, ScopedPlatformHandle(incoming_platform_handles.front()));
+  }
+
+  return nullptr;
+}
+
+}  // namespace edk
+}  // namespace mojo
diff --git a/mojo/edk/system/node_controller.cc b/mojo/edk/system/node_controller.cc
index 11c3a376..e872b54 100644
--- a/mojo/edk/system/node_controller.cc
+++ b/mojo/edk/system/node_controller.cc
@@ -17,6 +17,8 @@
 #include "mojo/edk/embedder/embedder_internal.h"
 #include "mojo/edk/embedder/platform_channel_pair.h"
 #include "mojo/edk/embedder/platform_support.h"
+#include "mojo/edk/system/broker.h"
+#include "mojo/edk/system/broker_host.h"
 #include "mojo/edk/system/core.h"
 #include "mojo/edk/system/ports_message.h"
 
@@ -136,6 +138,14 @@
 }
 
 void NodeController::ConnectToParent(ScopedPlatformHandle platform_handle) {
+// TODO(amistry): Consider the need for a broker on Windows.
+#if defined(OS_POSIX)
+  // On posix, use the bootstrap channel for the broker and receive the node's
+  // channel synchronously as the first message from the broker.
+  broker_.reset(new Broker(std::move(platform_handle)));
+  platform_handle = broker_->GetParentPlatformHandle();
+#endif
+
   io_task_runner_->PostTask(
       FROM_HERE,
       base::Bind(&NodeController::ConnectToParentOnIOThread,
@@ -187,8 +197,16 @@
 
 scoped_refptr<PlatformSharedBuffer> NodeController::CreateSharedBuffer(
     size_t num_bytes) {
-  // TODO: Broker through the parent over a sync channel. :(
-  return internal::g_platform_support->CreateSharedBuffer(num_bytes);
+  scoped_refptr<PlatformSharedBuffer> buffer =
+      internal::g_platform_support->CreateSharedBuffer(num_bytes);
+#if defined(OS_POSIX)
+  if (!buffer && broker_) {
+    // On POSIX, creating a shared buffer in a sandboxed process will fail, so
+    // fall back to the broker if there is one.
+    buffer = broker_->GetSharedBuffer(num_bytes);
+  }
+#endif
+  return buffer;
 }
 
 void NodeController::ConnectToParentPort(const ports::PortRef& local_port,
@@ -241,8 +259,16 @@
     ScopedPlatformHandle platform_handle) {
   DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
 
+#if defined(OS_POSIX)
+  PlatformChannelPair node_channel;
+  broker_host_.reset(new BrokerHost(std::move(platform_handle)));
+  broker_host_->SendChannel(node_channel.PassClientHandle());
+  scoped_refptr<NodeChannel> channel = NodeChannel::Create(
+      this, node_channel.PassServerHandle(), io_task_runner_);
+#else
   scoped_refptr<NodeChannel> channel =
       NodeChannel::Create(this, std::move(platform_handle), io_task_runner_);
+#endif
 
   ports::NodeName token;
   GenerateRandomName(&token);
diff --git a/mojo/edk/system/node_controller.h b/mojo/edk/system/node_controller.h
index d382492..2b1012d2 100644
--- a/mojo/edk/system/node_controller.h
+++ b/mojo/edk/system/node_controller.h
@@ -28,6 +28,8 @@
 namespace mojo {
 namespace edk {
 
+class Broker;
+class BrokerHost;
 class Core;
 class PortsMessage;
 
@@ -297,6 +299,14 @@
   // Must only be accessed from the IO thread.
   bool destroy_on_io_thread_shutdown_ = false;
 
+#if defined(OS_POSIX)
+  // Broker for sync shared buffer creation (posix-only) in children.
+  scoped_ptr<Broker> broker_;
+
+  // Broker host for sync shared buffer creation (posix-only).
+  scoped_ptr<BrokerHost> broker_host_;
+#endif
+
   DISALLOW_COPY_AND_ASSIGN(NodeController);
 };
 
diff --git a/mojo/mojo_base.gyp b/mojo/mojo_base.gyp
index 5667558..f541dcdb 100644
--- a/mojo/mojo_base.gyp
+++ b/mojo/mojo_base.gyp
@@ -225,17 +225,15 @@
       'type': 'static_library',
       'sources': [
         'shell/public/cpp/app_lifetime_helper.h',
-        'shell/public/cpp/application_connection.h',
-        'shell/public/cpp/application_delegate.h',
         'shell/public/cpp/application_impl.h',
         'shell/public/cpp/application_runner.h',
         'shell/public/cpp/connect.h',
+        'shell/public/cpp/connection.h',
         'shell/public/cpp/initialize_base_and_icu.cc',
         'shell/public/cpp/initialize_base_and_icu.h',
         'shell/public/cpp/interface_factory.h',
         'shell/public/cpp/interface_factory_impl.h',
         'shell/public/cpp/lib/app_lifetime_helper.cc',
-        'shell/public/cpp/lib/application_delegate.cc',
         'shell/public/cpp/lib/application_impl.cc',
         'shell/public/cpp/lib/application_runner.cc',
         'shell/public/cpp/lib/interface_factory_connector.h',
@@ -244,9 +242,11 @@
         'shell/public/cpp/lib/service_provider_impl.cc',
         'shell/public/cpp/lib/service_registry.cc',
         'shell/public/cpp/lib/service_registry.h',
-        'shell/public/cpp/shell.h',
+        'shell/public/cpp/lib/shell_client.cc',
         'shell/public/cpp/service_connector.h',
         'shell/public/cpp/service_provider_impl.h',
+        'shell/public/cpp/shell.h',
+        'shell/public/cpp/shell_client.h',
       ],
       'dependencies': [
         '../base/base.gyp:base_i18n',
diff --git a/mojo/mojo_edk.gyp b/mojo/mojo_edk.gyp
index a4e96e7..5e071c41 100644
--- a/mojo/mojo_edk.gyp
+++ b/mojo/mojo_edk.gyp
@@ -69,6 +69,10 @@
         'edk/system/awakable_list.h',
         'edk/system/async_waiter.cc',
         'edk/system/async_waiter.h',
+        'edk/system/broker.h',
+        'edk/system/broker_host.h',
+        'edk/system/broker_host_posix.cc',
+        'edk/system/broker_posix.cc',
         'edk/system/channel.cc',
         'edk/system/channel.h',
         'edk/system/channel_posix.cc',
diff --git a/mojo/public/cpp/bindings/tests/versioning_test_service.cc b/mojo/public/cpp/bindings/tests/versioning_test_service.cc
index 1c6beb41..007a82a 100644
--- a/mojo/public/cpp/bindings/tests/versioning_test_service.cc
+++ b/mojo/public/cpp/bindings/tests/versioning_test_service.cc
@@ -10,10 +10,9 @@
 #include "mojo/public/cpp/bindings/strong_binding.h"
 #include "mojo/public/cpp/system/macros.h"
 #include "mojo/public/interfaces/bindings/tests/versioning_test_service.mojom.h"
-#include "mojo/shell/public/cpp/application_connection.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_runner.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace mojo {
 namespace test {
@@ -95,19 +94,19 @@
 };
 
 class HumanResourceSystemServer
-    : public ApplicationDelegate,
+    : public ShellClient,
       public InterfaceFactory<HumanResourceDatabase> {
  public:
   HumanResourceSystemServer() {}
 
-  // ApplicationDelegate implementation.
-  bool AcceptConnection(ApplicationConnection* connection) override {
+  // mojo::ShellClient implementation.
+  bool AcceptConnection(Connection* connection) override {
     connection->AddService<HumanResourceDatabase>(this);
     return true;
   }
 
   // InterfaceFactory<HumanResourceDatabase> implementation.
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<HumanResourceDatabase> request) override {
     // It will be deleted automatically when the underlying pipe encounters a
     // connection error.
diff --git a/mojo/services/network/http_server_apptest.cc b/mojo/services/network/http_server_apptest.cc
index 34f5161d..aefc973 100644
--- a/mojo/services/network/http_server_apptest.cc
+++ b/mojo/services/network/http_server_apptest.cc
@@ -26,7 +26,6 @@
 #include "mojo/services/network/public/interfaces/network_service.mojom.h"
 #include "mojo/services/network/public/interfaces/web_socket.mojom.h"
 #include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h"
-#include "mojo/shell/public/cpp/application_connection.h"
 #include "mojo/shell/public/cpp/application_test_base.h"
 #include "net/base/io_buffer.h"
 #include "net/base/net_errors.h"
@@ -557,8 +556,8 @@
   void SetUp() override {
     ApplicationTestBase::SetUp();
 
-    scoped_ptr<ApplicationConnection> connection =
-        shell()->ConnectToApplication("mojo:network_service");
+    scoped_ptr<Connection> connection =
+        shell()->Connect("mojo:network_service");
     connection->ConnectToService(&network_service_);
     connection->ConnectToService(&web_socket_factory_);
   }
diff --git a/mojo/services/network/mojo_persistent_cookie_store.h b/mojo/services/network/mojo_persistent_cookie_store.h
index dd5eecd..97e8b6d02 100644
--- a/mojo/services/network/mojo_persistent_cookie_store.h
+++ b/mojo/services/network/mojo_persistent_cookie_store.h
@@ -20,7 +20,7 @@
 class NetworkServiceDelegate;
 
 // A PersistentCookieStore that listens to NetworkContext's and tries to
-// gracefully shutdown when our ApplicationConnection is about to be closed.
+// gracefully shutdown when our Connection is about to be closed.
 class MojoPersistentCookieStore
     : public net::CookieMonster::PersistentCookieStore,
       public NetworkServiceDelegateObserver {
diff --git a/mojo/services/network/network_service_delegate.cc b/mojo/services/network/network_service_delegate.cc
index d677f01..8caebfbd 100644
--- a/mojo/services/network/network_service_delegate.cc
+++ b/mojo/services/network/network_service_delegate.cc
@@ -20,7 +20,7 @@
 #include "mojo/services/network/network_service_impl.h"
 #include "mojo/services/network/url_loader_factory_impl.h"
 #include "mojo/services/network/web_socket_factory_impl.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/util/capture_util.h"
 #include "sql/mojo/mojo_vfs.h"
 
@@ -131,8 +131,7 @@
   tracing_.Initialize(shell_, url);
 }
 
-bool NetworkServiceDelegate::AcceptConnection(
-    ApplicationConnection* connection) {
+bool NetworkServiceDelegate::AcceptConnection(Connection* connection) {
   DCHECK(context_);
   connection->AddService<CookieStore>(this);
   connection->AddService<NetworkService>(this);
@@ -155,12 +154,12 @@
   context_.reset();
 }
 
-void NetworkServiceDelegate::Create(ApplicationConnection* connection,
+void NetworkServiceDelegate::Create(Connection* connection,
                                     InterfaceRequest<NetworkService> request) {
   new NetworkServiceImpl(shell_->CreateAppRefCount(), std::move(request));
 }
 
-void NetworkServiceDelegate::Create(ApplicationConnection* connection,
+void NetworkServiceDelegate::Create(Connection* connection,
                                     InterfaceRequest<CookieStore> request) {
   new CookieStoreImpl(
       context_.get(), GURL(connection->GetRemoteApplicationURL()).GetOrigin(),
@@ -168,14 +167,14 @@
 }
 
 void NetworkServiceDelegate::Create(
-    ApplicationConnection* connection,
+    Connection* connection,
     InterfaceRequest<WebSocketFactory> request) {
   new WebSocketFactoryImpl(context_.get(), shell_->CreateAppRefCount(),
                            std::move(request));
 }
 
 void NetworkServiceDelegate::Create(
-    ApplicationConnection* connection,
+    Connection* connection,
     InterfaceRequest<URLLoaderFactory> request) {
   new URLLoaderFactoryImpl(context_.get(), shell_->CreateAppRefCount(),
                            std::move(request));
diff --git a/mojo/services/network/network_service_delegate.h b/mojo/services/network/network_service_delegate.h
index 167d983..367eb9a 100644
--- a/mojo/services/network/network_service_delegate.h
+++ b/mojo/services/network/network_service_delegate.h
@@ -14,9 +14,9 @@
 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h"
 #include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h"
 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
 #include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace sql {
 class ScopedMojoFilesystemVFS;
@@ -25,7 +25,7 @@
 namespace mojo {
 class NetworkServiceDelegateObserver;
 
-class NetworkServiceDelegate : public ApplicationDelegate,
+class NetworkServiceDelegate : public ShellClient,
                                public InterfaceFactory<NetworkService>,
                                public InterfaceFactory<CookieStore>,
                                public InterfaceFactory<WebSocketFactory>,
@@ -43,26 +43,26 @@
   // multiple times.
   void EnsureIOThreadShutdown();
 
-  // ApplicationDelegate implementation.
+  // mojo::ShellClient implementation.
   void Initialize(Shell* shell, const std::string& url, uint32_t id) override;
-  bool AcceptConnection(ApplicationConnection* connection) override;
+  bool AcceptConnection(Connection* connection) override;
   bool ShellConnectionLost() override;
   void Quit() override;
 
   // InterfaceFactory<NetworkService> implementation.
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<NetworkService> request) override;
 
   // InterfaceFactory<CookieStore> implementation.
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<CookieStore> request) override;
 
   // InterfaceFactory<WebSocketFactory> implementation.
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<WebSocketFactory> request) override;
 
   // InterfaceFactory<URLLoaderFactory> implementation.
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<URLLoaderFactory> request) override;
 
   // Overridden from FileSystemClient:
diff --git a/mojo/services/network/udp_socket_apptest.cc b/mojo/services/network/udp_socket_apptest.cc
index da1634df..dfc7f3c2 100644
--- a/mojo/services/network/udp_socket_apptest.cc
+++ b/mojo/services/network/udp_socket_apptest.cc
@@ -14,7 +14,6 @@
 #include "mojo/services/network/public/cpp/udp_socket_wrapper.h"
 #include "mojo/services/network/public/interfaces/network_service.mojom.h"
 #include "mojo/services/network/public/interfaces/udp_socket.mojom.h"
-#include "mojo/shell/public/cpp/application_connection.h"
 #include "mojo/shell/public/cpp/application_test_base.h"
 #include "net/base/net_errors.h"
 #include "testing/gtest/include/gtest/gtest.h"
diff --git a/mojo/services/test_service/test_request_tracker_application.cc b/mojo/services/test_service/test_request_tracker_application.cc
index cf5d831..4e657cb 100644
--- a/mojo/services/test_service/test_request_tracker_application.cc
+++ b/mojo/services/test_service/test_request_tracker_application.cc
@@ -9,8 +9,8 @@
 
 #include "mojo/public/c/system/main.h"
 #include "mojo/services/test_service/test_time_service_impl.h"
-#include "mojo/shell/public/cpp/application_connection.h"
 #include "mojo/shell/public/cpp/application_runner.h"
+#include "mojo/shell/public/cpp/connection.h"
 
 namespace mojo {
 namespace test {
@@ -25,8 +25,7 @@
   shell_ = shell;
 }
 
-bool TestRequestTrackerApplication::AcceptConnection(
-    ApplicationConnection* connection) {
+bool TestRequestTrackerApplication::AcceptConnection(Connection* connection) {
   // Every instance of the service and recorder shares the context.
   // Note, this app is single-threaded, so this is thread safe.
   connection->AddService<TestTimeService>(this);
@@ -36,19 +35,19 @@
 }
 
 void TestRequestTrackerApplication::Create(
-    ApplicationConnection* connection,
+    Connection* connection,
     InterfaceRequest<TestTimeService> request) {
   new TestTimeServiceImpl(shell_, std::move(request));
 }
 
 void TestRequestTrackerApplication::Create(
-    ApplicationConnection* connection,
+    Connection* connection,
     InterfaceRequest<TestRequestTracker> request) {
   new TestRequestTrackerImpl(std::move(request), &context_);
 }
 
 void TestRequestTrackerApplication::Create(
-    ApplicationConnection* connection,
+    Connection* connection,
     InterfaceRequest<TestTrackedRequestService> request) {
   new TestTrackedRequestServiceImpl(std::move(request), &context_);
 }
diff --git a/mojo/services/test_service/test_request_tracker_application.h b/mojo/services/test_service/test_request_tracker_application.h
index 8d7f84c..74aa39c 100644
--- a/mojo/services/test_service/test_request_tracker_application.h
+++ b/mojo/services/test_service/test_request_tracker_application.h
@@ -7,8 +7,8 @@
 
 #include "mojo/public/cpp/system/macros.h"
 #include "mojo/services/test_service/test_request_tracker_impl.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory_impl.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace mojo {
 class ApplicationImpl;
@@ -17,7 +17,7 @@
 
 // Embeds TestRequestTracker mojo services into an application.
 class TestRequestTrackerApplication
-    : public ApplicationDelegate,
+    : public ShellClient,
       public InterfaceFactory<TestTimeService>,
       public InterfaceFactory<TestRequestTracker>,
       public InterfaceFactory<TestTrackedRequestService> {
@@ -25,20 +25,20 @@
   TestRequestTrackerApplication();
   ~TestRequestTrackerApplication() override;
 
-  // ApplicationDelegate methods:
+  // mojo::ShellClient methods:
   void Initialize(Shell* shell, const std::string& url, uint32_t id) override;
-  bool AcceptConnection(ApplicationConnection* connection) override;
+  bool AcceptConnection(Connection* connection) override;
 
   // InterfaceFactory<TestTimeService> methods:
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<TestTimeService> request) override;
 
   // InterfaceFactory<TestRequestTracker> methods:
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<TestRequestTracker> request) override;
 
   // InterfaceFactory<TestTrackedRequestService> methods:
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<TestTrackedRequestService> request) override;
 
  private:
diff --git a/mojo/services/test_service/test_request_tracker_impl.h b/mojo/services/test_service/test_request_tracker_impl.h
index 5251e57..97fd8649 100644
--- a/mojo/services/test_service/test_request_tracker_impl.h
+++ b/mojo/services/test_service/test_request_tracker_impl.h
@@ -13,7 +13,6 @@
 #include "mojo/services/test_service/test_request_tracker.mojom.h"
 
 namespace mojo {
-class ApplicationConnection;
 namespace test {
 
 typedef std::map<uint64_t, std::vector<ServiceStats> > AllRecordsMap;
diff --git a/mojo/services/test_service/test_service_application.cc b/mojo/services/test_service/test_service_application.cc
index 0f82eb9..940ce60 100644
--- a/mojo/services/test_service/test_service_application.cc
+++ b/mojo/services/test_service/test_service_application.cc
@@ -10,8 +10,8 @@
 #include "mojo/public/c/system/main.h"
 #include "mojo/services/test_service/test_service_impl.h"
 #include "mojo/services/test_service/test_time_service_impl.h"
-#include "mojo/shell/public/cpp/application_connection.h"
 #include "mojo/shell/public/cpp/application_runner.h"
+#include "mojo/shell/public/cpp/connection.h"
 
 namespace mojo {
 namespace test {
@@ -28,20 +28,19 @@
   shell_ = shell;
 }
 
-bool TestServiceApplication::AcceptConnection(
-    ApplicationConnection* connection) {
+bool TestServiceApplication::AcceptConnection(Connection* connection) {
   connection->AddService<TestService>(this);
   connection->AddService<TestTimeService>(this);
   return true;
 }
 
-void TestServiceApplication::Create(ApplicationConnection* connection,
+void TestServiceApplication::Create(Connection* connection,
                                     InterfaceRequest<TestService> request) {
   new TestServiceImpl(shell_, this, std::move(request));
   AddRef();
 }
 
-void TestServiceApplication::Create(ApplicationConnection* connection,
+void TestServiceApplication::Create(Connection* connection,
                                     InterfaceRequest<TestTimeService> request) {
   new TestTimeServiceImpl(shell_, std::move(request));
 }
diff --git a/mojo/services/test_service/test_service_application.h b/mojo/services/test_service/test_service_application.h
index e4a527a..fd107fb 100644
--- a/mojo/services/test_service/test_service_application.h
+++ b/mojo/services/test_service/test_service_application.h
@@ -6,33 +6,32 @@
 #define SERVICES_TEST_SERVICE_TEST_SERVICE_APPLICATION_H_
 
 #include "mojo/public/cpp/system/macros.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace mojo {
-class ApplicationConnection;
-
+class Connection;
 namespace test {
 class TestService;
 class TestTimeService;
 
-class TestServiceApplication : public ApplicationDelegate,
+class TestServiceApplication : public ShellClient,
                                public InterfaceFactory<TestService>,
                                public InterfaceFactory<TestTimeService> {
  public:
   TestServiceApplication();
   ~TestServiceApplication() override;
 
-  // ApplicationDelegate implementation.
+  // mojo::ShellClient implementation.
   void Initialize(Shell* shell, const std::string& url, uint32_t id) override;
-  bool AcceptConnection(ApplicationConnection* connection) override;
+  bool AcceptConnection(Connection* connection) override;
 
   // InterfaceFactory<TestService> implementation.
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<TestService> request) override;
 
   // InterfaceFactory<TestTimeService> implementation.
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<TestTimeService> request) override;
 
   void AddRef();
diff --git a/mojo/services/test_service/test_time_service_impl.h b/mojo/services/test_service/test_time_service_impl.h
index ead6899..6b50982a 100644
--- a/mojo/services/test_service/test_time_service_impl.h
+++ b/mojo/services/test_service/test_time_service_impl.h
@@ -14,8 +14,7 @@
 #include "mojo/services/test_service/test_service.mojom.h"
 
 namespace mojo {
-
-class ApplicationConnection;
+class Connection;
 class Shell;
 
 namespace test {
diff --git a/mojo/services/tracing/public/cpp/trace_provider_impl.cc b/mojo/services/tracing/public/cpp/trace_provider_impl.cc
index d4ff597..12842e5 100644
--- a/mojo/services/tracing/public/cpp/trace_provider_impl.cc
+++ b/mojo/services/tracing/public/cpp/trace_provider_impl.cc
@@ -12,7 +12,7 @@
 #include "base/time/time.h"
 #include "base/trace_event/trace_config.h"
 #include "base/trace_event/trace_event.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 
 namespace mojo {
 
diff --git a/mojo/services/tracing/public/cpp/tracing_impl.cc b/mojo/services/tracing/public/cpp/tracing_impl.cc
index 04cd7d15..3c61790 100644
--- a/mojo/services/tracing/public/cpp/tracing_impl.cc
+++ b/mojo/services/tracing/public/cpp/tracing_impl.cc
@@ -53,7 +53,7 @@
   // up to something like CoreServices to name its own child threads.
   base::PlatformThread::SetName(url);
 
-  connection_ = shell->ConnectToApplication("mojo:tracing");
+  connection_ = shell->Connect("mojo:tracing");
   connection_->AddService(this);
 
 #ifdef NDEBUG
@@ -66,7 +66,7 @@
 #endif
 }
 
-void TracingImpl::Create(ApplicationConnection* connection,
+void TracingImpl::Create(Connection* connection,
                          InterfaceRequest<tracing::TraceProvider> request) {
   provider_impl_.Bind(std::move(request));
 }
diff --git a/mojo/services/tracing/public/cpp/tracing_impl.h b/mojo/services/tracing/public/cpp/tracing_impl.h
index 97db143..42d0a746 100644
--- a/mojo/services/tracing/public/cpp/tracing_impl.h
+++ b/mojo/services/tracing/public/cpp/tracing_impl.h
@@ -12,7 +12,7 @@
 
 namespace mojo {
 
-class ApplicationConnection;
+class Connection;
 class Shell;
 
 // Connects to mojo:tracing during your Application's Initialize() call once
@@ -36,10 +36,10 @@
 
  private:
   // InterfaceFactory<tracing::TraceProvider> implementation.
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<tracing::TraceProvider> request) override;
 
-  scoped_ptr<ApplicationConnection> connection_;
+  scoped_ptr<Connection> connection_;
   TraceProviderImpl provider_impl_;
 
   DISALLOW_COPY_AND_ASSIGN(TracingImpl);
diff --git a/mojo/services/tracing/tracing_app.cc b/mojo/services/tracing/tracing_app.cc
index 13829b6..09d1f3b 100644
--- a/mojo/services/tracing/tracing_app.cc
+++ b/mojo/services/tracing/tracing_app.cc
@@ -12,7 +12,6 @@
 #include "base/bind.h"
 #include "base/logging.h"
 #include "base/message_loop/message_loop.h"
-#include "mojo/shell/public/cpp/application_connection.h"
 
 namespace tracing {
 
@@ -22,8 +21,7 @@
 TracingApp::~TracingApp() {
 }
 
-bool TracingApp::AcceptConnection(
-    mojo::ApplicationConnection* connection) {
+bool TracingApp::AcceptConnection(mojo::Connection* connection) {
   connection->AddService<TraceCollector>(this);
   connection->AddService<StartupPerformanceDataCollector>(this);
 
@@ -44,13 +42,13 @@
   return true;
 }
 
-void TracingApp::Create(mojo::ApplicationConnection* connection,
+void TracingApp::Create(mojo::Connection* connection,
                         mojo::InterfaceRequest<TraceCollector> request) {
   collector_binding_.Bind(std::move(request));
 }
 
 void TracingApp::Create(
-    mojo::ApplicationConnection* connection,
+    mojo::Connection* connection,
     mojo::InterfaceRequest<StartupPerformanceDataCollector> request) {
   startup_performance_data_collector_bindings_.AddBinding(this,
                                                           std::move(request));
diff --git a/mojo/services/tracing/tracing_app.h b/mojo/services/tracing/tracing_app.h
index d7b19dcf..8f14dcb9 100644
--- a/mojo/services/tracing/tracing_app.h
+++ b/mojo/services/tracing/tracing_app.h
@@ -16,13 +16,13 @@
 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h"
 #include "mojo/services/tracing/trace_data_sink.h"
 #include "mojo/services/tracing/trace_recorder_impl.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace tracing {
 
 class TracingApp
-    : public mojo::ApplicationDelegate,
+    : public mojo::ShellClient,
       public mojo::InterfaceFactory<TraceCollector>,
       public TraceCollector,
       public mojo::InterfaceFactory<StartupPerformanceDataCollector>,
@@ -32,17 +32,16 @@
   ~TracingApp() override;
 
  private:
-  // mojo::ApplicationDelegate implementation.
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override;
+  // mojo::ShellClient implementation.
+  bool AcceptConnection(mojo::Connection* connection) override;
 
   // mojo::InterfaceFactory<TraceCollector> implementation.
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<TraceCollector> request) override;
 
   // mojo::InterfaceFactory<StartupPerformanceDataCollector> implementation.
   void Create(
-      mojo::ApplicationConnection* connection,
+      mojo::Connection* connection,
       mojo::InterfaceRequest<StartupPerformanceDataCollector> request) override;
 
   // tracing::TraceCollector implementation.
diff --git a/mojo/shell/application_manager_apptest.cc b/mojo/shell/application_manager_apptest.cc
index fb6517e..92c7272 100644
--- a/mojo/shell/application_manager_apptest.cc
+++ b/mojo/shell/application_manager_apptest.cc
@@ -26,7 +26,7 @@
 namespace {
 
 class ApplicationManagerAppTestDelegate
-    : public ApplicationDelegate,
+    : public ShellClient,
       public InterfaceFactory<CreateInstanceForHandleTest>,
       public CreateInstanceForHandleTest {
  public:
@@ -38,17 +38,16 @@
   uint32_t target_id() const { return target_id_; }
 
  private:
-  // ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(Shell* shell, const std::string& url, uint32_t id) override {}
-  bool AcceptConnection(ApplicationConnection* connection) override {
+  bool AcceptConnection(Connection* connection) override {
     connection->AddService<CreateInstanceForHandleTest>(this);
     return true;
   }
 
   // InterfaceFactory<CreateInstanceForHandleTest>:
-  void Create(
-      ApplicationConnection* connection,
-      InterfaceRequest<CreateInstanceForHandleTest> request) override {
+  void Create(Connection* connection,
+              InterfaceRequest<CreateInstanceForHandleTest> request) override {
     binding_.Bind(std::move(request));
   }
 
@@ -123,7 +122,7 @@
 
  private:
   // test::ApplicationTestBase:
-  ApplicationDelegate* GetApplicationDelegate() override {
+  ShellClient* GetShellClient() override {
     delegate_ = new ApplicationManagerAppTestDelegate;
     return delegate_;
   }
@@ -174,8 +173,8 @@
   // 1. Launch a process. (Actually, have the runner launch a process that
   //    launches a process. #becauselinkerrors).
   mojo::shell::test::mojom::DriverPtr driver;
-  scoped_ptr<ApplicationConnection> connection =
-      shell()->ConnectToApplication("exe:application_manager_apptest_driver");
+  scoped_ptr<Connection> connection =
+      shell()->Connect("exe:application_manager_apptest_driver");
   connection->ConnectToService(&driver);
 
   // 2. Wait for the target to connect to us. (via
diff --git a/mojo/shell/application_manager_apptest_driver.cc b/mojo/shell/application_manager_apptest_driver.cc
index 3b575f5..2bd0de3 100644
--- a/mojo/shell/application_manager_apptest_driver.cc
+++ b/mojo/shell/application_manager_apptest_driver.cc
@@ -24,10 +24,10 @@
 #include "mojo/edk/embedder/platform_channel_pair.h"
 #include "mojo/edk/embedder/scoped_platform_handle.h"
 #include "mojo/shell/application_manager_apptests.mojom.h"
-#include "mojo/shell/public/cpp/application_connection.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
 #include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/public/interfaces/application_manager.mojom.h"
 #include "mojo/shell/runner/child/test_native_main.h"
 #include "mojo/shell/runner/common/switches.h"
@@ -38,7 +38,7 @@
 
 namespace {
 
-class TargetApplicationDelegate : public mojo::ApplicationDelegate,
+class TargetApplicationDelegate : public mojo::ShellClient,
                                   public mojo::InterfaceFactory<Driver>,
                                   public Driver {
  public:
@@ -46,7 +46,7 @@
   ~TargetApplicationDelegate() override {}
 
  private:
-  // mojo::ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override {
     shell_ = shell;
@@ -110,13 +110,13 @@
                                     platform_channel_pair.PassServerHandle());
   }
 
-  bool AcceptConnection(mojo::ApplicationConnection* connection) override {
+  bool AcceptConnection(mojo::Connection* connection) override {
     connection->AddService<Driver>(this);
     return true;
   }
 
   // mojo::InterfaceFactory<Driver>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<Driver> request) override {
     bindings_.AddBinding(this, std::move(request));
   }
diff --git a/mojo/shell/application_manager_apptest_target.cc b/mojo/shell/application_manager_apptest_target.cc
index 24676088..e0c23b8 100644
--- a/mojo/shell/application_manager_apptest_target.cc
+++ b/mojo/shell/application_manager_apptest_target.cc
@@ -6,9 +6,9 @@
 #include "base/command_line.h"
 #include "base/macros.h"
 #include "mojo/shell/application_manager_apptests.mojom.h"
-#include "mojo/shell/public/cpp/application_connection.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/runner/child/test_native_main.h"
 #include "mojo/shell/runner/init.h"
 
@@ -16,13 +16,13 @@
 
 namespace {
 
-class TargetApplicationDelegate : public mojo::ApplicationDelegate {
+class TargetApplicationDelegate : public mojo::ShellClient {
  public:
   TargetApplicationDelegate() {}
   ~TargetApplicationDelegate() override {}
 
  private:
-  // mojo::ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override {
     CreateInstanceForHandleTestPtr service;
diff --git a/mojo/shell/application_manager_unittest.cc b/mojo/shell/application_manager_unittest.cc
index 94b92c6..b83f320 100644
--- a/mojo/shell/application_manager_unittest.cc
+++ b/mojo/shell/application_manager_unittest.cc
@@ -17,10 +17,9 @@
 #include "mojo/shell/connect_util.h"
 #include "mojo/shell/fetcher.h"
 #include "mojo/shell/package_manager.h"
-#include "mojo/shell/public/cpp/application_connection.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_impl.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/public/interfaces/service_provider.mojom.h"
 #include "mojo/shell/test.mojom.h"
 #include "mojo/shell/test_package_manager.h"
@@ -95,7 +94,7 @@
 };
 
 class TestApplicationLoader : public ApplicationLoader,
-                              public ApplicationDelegate,
+                              public ShellClient,
                               public InterfaceFactory<TestService> {
  public:
   TestApplicationLoader()
@@ -119,15 +118,15 @@
     test_app_.reset(new ApplicationImpl(this, std::move(application_request)));
   }
 
-  // ApplicationDelegate implementation.
-  bool AcceptConnection(ApplicationConnection* connection) override {
+  // mojo::ShellClient implementation.
+  bool AcceptConnection(Connection* connection) override {
     connection->AddService<TestService>(this);
     last_requestor_url_ = GURL(connection->GetRemoteApplicationURL());
     return true;
   }
 
   // InterfaceFactory<TestService> implementation.
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<TestService> request) override {
     new TestServiceImpl(context_, std::move(request));
   }
@@ -251,7 +250,7 @@
             InterfaceRequest<TestA> request,
             InterfaceFactory<TestC>* factory)
       : test_context_(test_context), binding_(this, std::move(request)) {
-    connection_ = app_impl->ConnectToApplication(kTestBURLString);
+    connection_ = app_impl->Connect(kTestBURLString);
     connection_->AddService<TestC>(factory);
     connection_->ConnectToService(&b_);
   }
@@ -277,7 +276,7 @@
     test_context_->QuitSoon();
   }
 
-  scoped_ptr<ApplicationConnection> connection_;
+  scoped_ptr<Connection> connection_;
   TesterContext* test_context_;
   TestBPtr b_;
   StrongBinding<TestA> binding_;
@@ -285,7 +284,7 @@
 
 class TestBImpl : public TestB {
  public:
-  TestBImpl(ApplicationConnection* connection,
+  TestBImpl(Connection* connection,
             TesterContext* test_context,
             InterfaceRequest<TestB> request)
       : test_context_(test_context), binding_(this, std::move(request)) {
@@ -317,7 +316,7 @@
 
 class TestCImpl : public TestC {
  public:
-  TestCImpl(ApplicationConnection* connection,
+  TestCImpl(Connection* connection,
             TesterContext* test_context,
             InterfaceRequest<TestC> request)
       : test_context_(test_context), binding_(this, std::move(request)) {}
@@ -334,7 +333,7 @@
   StrongBinding<TestC> binding_;
 };
 
-class Tester : public ApplicationDelegate,
+class Tester : public ShellClient,
                public ApplicationLoader,
                public InterfaceFactory<TestA>,
                public InterfaceFactory<TestB>,
@@ -350,7 +349,7 @@
     app_.reset(new ApplicationImpl(this, std::move(application_request)));
   }
 
-  bool AcceptConnection(ApplicationConnection* connection) override {
+  bool AcceptConnection(Connection* connection) override {
     if (!requestor_url_.empty() &&
         requestor_url_ != connection->GetRemoteApplicationURL()) {
       context_->set_tester_called_quit();
@@ -366,18 +365,18 @@
     return true;
   }
 
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<TestA> request) override {
     a_bindings_.push_back(
         new TestAImpl(app_.get(), context_, std::move(request), this));
   }
 
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<TestB> request) override {
     new TestBImpl(connection, context_, std::move(request));
   }
 
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<TestC> request) override {
     new TestCImpl(connection, context_, std::move(request));
   }
diff --git a/mojo/shell/application_package_apptest.cc b/mojo/shell/application_package_apptest.cc
index 981f2455..3d19daf7 100644
--- a/mojo/shell/application_package_apptest.cc
+++ b/mojo/shell/application_package_apptest.cc
@@ -30,7 +30,7 @@
     test::mojom::ApplicationPackageApptestService::GetNameCallback;
 
 class ProvidedApplicationDelegate
-    : public ApplicationDelegate,
+    : public ShellClient,
       public InterfaceFactory<test::mojom::ApplicationPackageApptestService>,
       public test::mojom::ApplicationPackageApptestService,
       public base::SimpleThread {
@@ -50,16 +50,16 @@
   }
 
  private:
-  // ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(Shell* shell, const std::string& url, uint32_t id) override {}
-  bool AcceptConnection(ApplicationConnection* connection) override {
+  bool AcceptConnection(Connection* connection) override {
     connection->AddService<test::mojom::ApplicationPackageApptestService>(this);
     return true;
   }
 
   // InterfaceFactory<test::mojom::ApplicationPackageApptestService>:
   void Create(
-      ApplicationConnection* connection,
+      Connection* connection,
       InterfaceRequest<test::mojom::ApplicationPackageApptestService> request)
           override {
     bindings_.AddBinding(this, std::move(request));
@@ -86,7 +86,7 @@
 };
 
 class ApplicationPackageApptestDelegate
-    : public ApplicationDelegate,
+    : public ShellClient,
       public InterfaceFactory<mojom::ContentHandler>,
       public InterfaceFactory<test::mojom::ApplicationPackageApptestService>,
       public mojom::ContentHandler,
@@ -96,22 +96,22 @@
   ~ApplicationPackageApptestDelegate() override {}
 
  private:
-  // ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(Shell* shell, const std::string& url, uint32_t id) override {}
-  bool AcceptConnection(ApplicationConnection* connection) override {
+  bool AcceptConnection(Connection* connection) override {
     connection->AddService<ContentHandler>(this);
     connection->AddService<test::mojom::ApplicationPackageApptestService>(this);
     return true;
   }
 
   // InterfaceFactory<mojom::ContentHandler>:
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<mojom::ContentHandler> request) override {
     content_handler_bindings_.AddBinding(this, std::move(request));
   }
 
   // InterfaceFactory<test::mojom::ApplicationPackageApptestService>:
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<test::mojom::ApplicationPackageApptestService>
                   request) override {
     bindings_.AddBinding(this, std::move(request));
@@ -136,7 +136,7 @@
     callback.Run("ROOT");
   }
 
-  std::vector<scoped_ptr<ApplicationDelegate>> delegates_;
+  std::vector<scoped_ptr<ShellClient>> delegates_;
   WeakBindingSet<mojom::ContentHandler> content_handler_bindings_;
   WeakBindingSet<test::mojom::ApplicationPackageApptestService> bindings_;
 
@@ -159,7 +159,7 @@
 
  private:
   // test::ApplicationTestBase:
-  ApplicationDelegate* GetApplicationDelegate() override {
+  ShellClient* GetShellClient() override {
     delegate_ = new ApplicationPackageApptestDelegate;
     return delegate_;
   }
diff --git a/mojo/shell/capability_filter_test.cc b/mojo/shell/capability_filter_test.cc
index 8363bcbc..7a97f68 100644
--- a/mojo/shell/capability_filter_test.cc
+++ b/mojo/shell/capability_filter_test.cc
@@ -13,9 +13,8 @@
 #include "mojo/public/cpp/bindings/strong_binding.h"
 #include "mojo/shell/application_loader.h"
 #include "mojo/shell/package_manager.h"
-#include "mojo/shell/public/cpp/application_connection.h"
 #include "mojo/shell/public/cpp/application_impl.h"
-#include "mojo/shell/public/cpp/connect.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
 #include "mojo/shell/public/cpp/service_provider_impl.h"
 
@@ -27,7 +26,7 @@
 // Listens for services exposed/blocked and for application connections being
 // closed. Quits |loop| when all expectations are met.
 class ConnectionValidator : public ApplicationLoader,
-                            public ApplicationDelegate,
+                            public ShellClient,
                             public InterfaceFactory<Validator>,
                             public Validator {
  public:
@@ -56,14 +55,14 @@
     app_.reset(new ApplicationImpl(this, std::move(request)));
   }
 
-  // Overridden from ApplicationDelegate:
-  bool AcceptConnection(ApplicationConnection* connection) override {
+  // Overridden from ShellClient:
+  bool AcceptConnection(Connection* connection) override {
     connection->AddService<Validator>(this);
     return true;
   }
 
   // Overridden from InterfaceFactory<Validator>:
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<Validator> request) override {
     validator_bindings_.AddBinding(this, std::move(request));
   }
@@ -107,7 +106,7 @@
 
 // This class models a system service that exposes two interfaces, Safe and
 // Unsafe. The interface Unsafe is not to be exposed to untrusted applications.
-class ServiceApplication : public ApplicationDelegate,
+class ServiceApplication : public ShellClient,
                            public InterfaceFactory<Safe>,
                            public InterfaceFactory<Unsafe>,
                            public Safe,
@@ -117,33 +116,33 @@
   ~ServiceApplication() override {}
 
  private:
-  // Overridden from ApplicationDelegate:
+  // Overridden from ShellClient:
   void Initialize(Shell* shell, const std::string& url, uint32_t id) override {
     shell_ = shell;
     // ServiceApplications have no capability filter and can thus connect
     // directly to the validator application.
     shell_->ConnectToService("test:validator", &validator_);
   }
-  bool AcceptConnection(ApplicationConnection* connection) override {
+  bool AcceptConnection(Connection* connection) override {
     AddService<Safe>(connection);
     AddService<Unsafe>(connection);
     return true;
   }
 
   // Overridden from InterfaceFactory<Safe>:
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<Safe> request) override {
     safe_bindings_.AddBinding(this, std::move(request));
   }
 
   // Overridden from InterfaceFactory<Unsafe>:
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<Unsafe> request) override {
     unsafe_bindings_.AddBinding(this, std::move(request));
   }
 
   template <typename Interface>
-  void AddService(ApplicationConnection* connection) {
+  void AddService(Connection* connection) {
     validator_->AddServiceCalled(connection->GetRemoteApplicationURL(),
                                  connection->GetConnectionURL(),
                                  Interface::Name_,
@@ -169,17 +168,16 @@
   shell_ = shell;
   url_ = url;
 }
-bool TestApplication::AcceptConnection(
-    ApplicationConnection* connection) {
+bool TestApplication::AcceptConnection(Connection* connection) {
   // TestApplications receive their Validator via the inbound connection.
   connection->ConnectToService(&validator_);
 
-  connection1_ = shell_->ConnectToApplication("test:service");
+  connection1_ = shell_->Connect("test:service");
   connection1_->SetRemoteServiceProviderConnectionErrorHandler(
       base::Bind(&TestApplication::ConnectionClosed,
                   base::Unretained(this), "test:service"));
 
-  connection2_ = shell_->ConnectToApplication("test:service2");
+  connection2_ = shell_->Connect("test:service2");
   connection2_->SetRemoteServiceProviderConnectionErrorHandler(
       base::Bind(&TestApplication::ConnectionClosed,
                   base::Unretained(this), "test:service2"));
@@ -193,7 +191,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 // TestLoader:
 
-TestLoader::TestLoader(ApplicationDelegate* delegate) : delegate_(delegate) {}
+TestLoader::TestLoader(ShellClient* delegate) : delegate_(delegate) {}
 TestLoader::~TestLoader() {}
 
 void TestLoader::Load(const GURL& url,
diff --git a/mojo/shell/capability_filter_test.h b/mojo/shell/capability_filter_test.h
index 459cfe8..9052d182 100644
--- a/mojo/shell/capability_filter_test.h
+++ b/mojo/shell/capability_filter_test.h
@@ -9,7 +9,8 @@
 #include "mojo/shell/application_loader.h"
 #include "mojo/shell/application_manager.h"
 #include "mojo/shell/capability_filter_unittest.mojom.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
+#include "mojo/shell/public/cpp/application_impl.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace mojo {
@@ -21,30 +22,30 @@
 // This class models an application who will use the shell to interact with a
 // system service. The shell may limit this application's visibility of the full
 // set of interfaces exposed by that service.
-class TestApplication : public ApplicationDelegate {
+class TestApplication : public ShellClient {
  public:
   TestApplication();
   ~TestApplication() override;
 
  private:
-  // Overridden from ApplicationDelegate:
+  // Overridden from ShellClient:
   void Initialize(Shell* shell, const std::string& url, uint32_t id) override;
-  bool AcceptConnection(ApplicationConnection* connection) override;
+  bool AcceptConnection(Connection* connection) override;
 
   void ConnectionClosed(const std::string& service_url);
 
   Shell* shell_;
   std::string url_;
   ValidatorPtr validator_;
-  scoped_ptr<ApplicationConnection> connection1_;
-  scoped_ptr<ApplicationConnection> connection2_;
+  scoped_ptr<Connection> connection1_;
+  scoped_ptr<Connection> connection2_;
 
   DISALLOW_COPY_AND_ASSIGN(TestApplication);
 };
 
 class TestLoader : public ApplicationLoader {
  public:
-  explicit TestLoader(ApplicationDelegate* delegate);
+  explicit TestLoader(ShellClient* delegate);
   ~TestLoader() override;
 
  private:
@@ -52,7 +53,7 @@
   void Load(const GURL& url,
             InterfaceRequest<mojom::Application> request) override;
 
-  scoped_ptr<ApplicationDelegate> delegate_;
+  scoped_ptr<ShellClient> delegate_;
   scoped_ptr<ApplicationImpl> app_;
 
   DISALLOW_COPY_AND_ASSIGN(TestLoader);
@@ -93,8 +94,8 @@
   void RunTest();
 
   template<class T>
-  scoped_ptr<ApplicationDelegate> CreateApplicationDelegate() {
-    return scoped_ptr<ApplicationDelegate>(new T);
+  scoped_ptr<ShellClient> CreateShellClient() {
+    return scoped_ptr<ShellClient>(new T);
   }
 
   base::ShadowingAtExitManager at_exit_;
diff --git a/mojo/shell/fetcher/about_fetcher_unittest.cc b/mojo/shell/fetcher/about_fetcher_unittest.cc
index a280525..b9e60462 100644
--- a/mojo/shell/fetcher/about_fetcher_unittest.cc
+++ b/mojo/shell/fetcher/about_fetcher_unittest.cc
@@ -18,10 +18,9 @@
 #include "mojo/shell/application_loader.h"
 #include "mojo/shell/application_manager.h"
 #include "mojo/shell/package_manager/package_manager_impl.h"
-#include "mojo/shell/public/cpp/application_connection.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_impl.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/public/interfaces/content_handler.mojom.h"
 #include "mojo/util/filename_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -30,7 +29,7 @@
 namespace shell {
 namespace {
 
-class TestContentHandler : public ApplicationDelegate,
+class TestContentHandler : public ShellClient,
                            public InterfaceFactory<mojom::ContentHandler>,
                            public mojom::ContentHandler {
  public:
@@ -41,15 +40,15 @@
   const URLResponse* latest_response() const { return latest_response_.get(); }
 
  private:
-  // Overridden from ApplicationDelegate:
+  // Overridden from ShellClient:
   void Initialize(Shell* shell, const std::string& url, uint32_t id) override {}
-  bool AcceptConnection(ApplicationConnection* connection) override {
+  bool AcceptConnection(Connection* connection) override {
     connection->AddService<mojom::ContentHandler>(this);
     return true;
   }
 
   // Overridden from InterfaceFactory<mojom::ContentHandler>:
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<mojom::ContentHandler> request) override {
     bindings_.AddBinding(this, std::move(request));
   }
@@ -79,7 +78,7 @@
 
 class TestLoader : public ApplicationLoader {
  public:
-  explicit TestLoader(ApplicationDelegate* delegate) : delegate_(delegate) {}
+  explicit TestLoader(ShellClient* delegate) : delegate_(delegate) {}
   ~TestLoader() override {}
 
  private:
@@ -89,7 +88,7 @@
     app_.reset(new ApplicationImpl(delegate_, std::move(request)));
   }
 
-  ApplicationDelegate* delegate_;
+  ShellClient* delegate_;
   scoped_ptr<ApplicationImpl> app_;
 
   DISALLOW_COPY_AND_ASSIGN(TestLoader);
diff --git a/mojo/shell/package_manager/capability_filter_content_handler_unittest.cc b/mojo/shell/package_manager/capability_filter_content_handler_unittest.cc
index 7e9ace8..fe88fe9 100644
--- a/mojo/shell/package_manager/capability_filter_content_handler_unittest.cc
+++ b/mojo/shell/package_manager/capability_filter_content_handler_unittest.cc
@@ -12,10 +12,9 @@
 #include "mojo/shell/capability_filter_test.h"
 #include "mojo/shell/fetcher.h"
 #include "mojo/shell/package_manager/package_manager_impl.h"
-#include "mojo/shell/public/cpp/application_connection.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_impl.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/public/interfaces/content_handler.mojom.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -77,7 +76,7 @@
   DISALLOW_COPY_AND_ASSIGN(TestPackageManager);
 };
 
-class TestContentHandler : public ApplicationDelegate,
+class TestContentHandler : public ShellClient,
                            public InterfaceFactory<mojom::ContentHandler>,
                            public mojom::ContentHandler {
  public:
@@ -85,15 +84,15 @@
   ~TestContentHandler() override {}
 
  private:
-  // Overridden from ApplicationDelegate:
+  // Overridden from ShellClient:
   void Initialize(Shell* shell, const std::string& url, uint32_t id) override {}
-  bool AcceptConnection(ApplicationConnection* connection) override {
+  bool AcceptConnection(Connection* connection) override {
     connection->AddService<mojom::ContentHandler>(this);
     return true;
   }
 
   // Overridden from InterfaceFactory<mojom::ContentHandler>:
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<mojom::ContentHandler> request) override {
     bindings_.AddBinding(this, std::move(request));
   }
@@ -103,7 +102,7 @@
       InterfaceRequest<mojom::Application> application,
       URLResponsePtr response,
       const Callback<void()>& destruct_callback) override {
-    scoped_ptr<ApplicationDelegate> delegate(new test::TestApplication);
+    scoped_ptr<ShellClient> delegate(new test::TestApplication);
     embedded_apps_.push_back(
         new ApplicationImpl(delegate.get(), std::move(application)));
     embedded_app_delegates_.push_back(std::move(delegate));
@@ -111,7 +110,7 @@
   }
 
   WeakBindingSet<mojom::ContentHandler> bindings_;
-  ScopedVector<ApplicationDelegate> embedded_app_delegates_;
+  ScopedVector<ShellClient> embedded_app_delegates_;
   ScopedVector<ApplicationImpl> embedded_apps_;
 
   DISALLOW_COPY_AND_ASSIGN(TestContentHandler);
diff --git a/mojo/shell/package_manager/content_handler_unittest.cc b/mojo/shell/package_manager/content_handler_unittest.cc
index 95870f39..4d743af 100644
--- a/mojo/shell/package_manager/content_handler_unittest.cc
+++ b/mojo/shell/package_manager/content_handler_unittest.cc
@@ -19,10 +19,9 @@
 #include "mojo/shell/connect_util.h"
 #include "mojo/shell/fetcher.h"
 #include "mojo/shell/package_manager/package_manager_impl.h"
-#include "mojo/shell/public/cpp/application_connection.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_impl.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/public/interfaces/content_handler.mojom.h"
 #include "mojo/shell/public/interfaces/service_provider.mojom.h"
 #include "mojo/shell/test_package_manager.h"
@@ -73,9 +72,9 @@
 }
 
 class TestContentHandler : public mojom::ContentHandler,
-                           public ApplicationDelegate {
+                           public ShellClient{
  public:
-  TestContentHandler(ApplicationConnection* connection,
+  TestContentHandler(Connection* connection,
                      InterfaceRequest<mojom::ContentHandler> request)
       : binding_(this, std::move(request)) {}
 
@@ -96,7 +95,7 @@
 };
 
 class TestApplicationLoader : public ApplicationLoader,
-                              public ApplicationDelegate,
+                              public ShellClient,
                               public InterfaceFactory<mojom::ContentHandler> {
  public:
   TestApplicationLoader() : num_loads_(0) {}
@@ -113,14 +112,14 @@
     test_app_.reset(new ApplicationImpl(this, std::move(application_request)));
   }
 
-  // ApplicationDelegate implementation.
-  bool AcceptConnection(ApplicationConnection* connection) override {
+  // mojo::ShellClient implementation.
+  bool AcceptConnection(Connection* connection) override {
     connection->AddService<mojom::ContentHandler>(this);
     last_requestor_url_ = GURL(connection->GetRemoteApplicationURL());
     return true;
   }
   // InterfaceFactory<mojom::ContentHandler> implementation.
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<mojom::ContentHandler> request) override {
     new TestContentHandler(connection, std::move(request));
   }
diff --git a/mojo/shell/public/cpp/BUILD.gn b/mojo/shell/public/cpp/BUILD.gn
index 81da818..1d8ad189 100644
--- a/mojo/shell/public/cpp/BUILD.gn
+++ b/mojo/shell/public/cpp/BUILD.gn
@@ -21,16 +21,14 @@
 source_set("sources") {
   sources = [
     "app_lifetime_helper.h",
-    "application_connection.h",
-    "application_delegate.h",
     "application_impl.h",
     "application_runner.h",
     "connect.h",
+    "connection.h",
     "initialize_base_and_icu.cc",
     "interface_factory.h",
     "interface_factory_impl.h",
     "lib/app_lifetime_helper.cc",
-    "lib/application_delegate.cc",
     "lib/application_impl.cc",
     "lib/application_runner.cc",
     "lib/interface_factory_connector.h",
@@ -39,9 +37,11 @@
     "lib/service_provider_impl.cc",
     "lib/service_registry.cc",
     "lib/service_registry.h",
+    "lib/shell_client.cc",
     "service_connector.h",
     "service_provider_impl.h",
     "shell.h",
+    "shell_client.h",
   ]
 
   deps = [
diff --git a/mojo/shell/public/cpp/application_delegate.h b/mojo/shell/public/cpp/application_delegate.h
deleted file mode 100644
index b0a537f7..0000000
--- a/mojo/shell/public/cpp/application_delegate.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MOJO_SHELL_PUBLIC_CPP_APPLICATION_DELEGATE_H_
-#define MOJO_SHELL_PUBLIC_CPP_APPLICATION_DELEGATE_H_
-
-#include <stdint.h>
-#include <string>
-
-#include "mojo/public/cpp/system/macros.h"
-
-namespace mojo {
-
-class ApplicationConnection;
-class ApplicationImpl;
-class Shell;
-
-// An abstract class that the application may subclass to control various
-// behaviors of ApplicationImpl.
-class ApplicationDelegate {
- public:
-  ApplicationDelegate();
-  virtual ~ApplicationDelegate();
-
-  // Called exactly once before any other method.
-  virtual void Initialize(Shell* app, const std::string& url, uint32_t id);
-
-  // Override this method to configure what services a connection supports when
-  // being connected to from an app.
-  // Return false to reject the connection entirely.
-  virtual bool AcceptConnection(ApplicationConnection* connection);
-
-  // Called when the shell connection has a connection error.
-  //
-  // Return true to shutdown the application. Return false to skip shutting
-  // down the connection, but user is then required to call
-  // ApplicationImpl::QuitNow() when done.
-  virtual bool ShellConnectionLost();
-
-  // Called before ApplicationImpl::Terminate(). After returning from this call
-  // the delegate can no longer rely on the main run loop still running.
-  virtual void Quit();
-
- private:
-  MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationDelegate);
-};
-
-}  // namespace mojo
-
-#endif  // MOJO_SHELL_PUBLIC_CPP_APPLICATION_DELEGATE_H_
diff --git a/mojo/shell/public/cpp/application_impl.h b/mojo/shell/public/cpp/application_impl.h
index 18d82d42..9f35a0d0 100644
--- a/mojo/shell/public/cpp/application_impl.h
+++ b/mojo/shell/public/cpp/application_impl.h
@@ -15,10 +15,9 @@
 #include "mojo/public/cpp/bindings/callback.h"
 #include "mojo/public/cpp/system/core.h"
 #include "mojo/shell/public/cpp/app_lifetime_helper.h"
-#include "mojo/shell/public/cpp/application_connection.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/lib/service_registry.h"
 #include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/public/interfaces/application.mojom.h"
 #include "mojo/shell/public/interfaces/shell.mojom.h"
 
@@ -77,12 +76,12 @@
 
   // Does not take ownership of |delegate|, which must remain valid for the
   // lifetime of ApplicationImpl.
-  ApplicationImpl(ApplicationDelegate* delegate,
+  ApplicationImpl(ShellClient* client,
                   InterfaceRequest<shell::mojom::Application> request);
   // Constructs an ApplicationImpl with a custom termination closure. This
   // closure is invoked on Quit() instead of the default behavior of quitting
   // the current base::MessageLoop.
-  ApplicationImpl(ApplicationDelegate* delegate,
+  ApplicationImpl(ShellClient* client,
                   InterfaceRequest<shell::mojom::Application> request,
                   const Closure& termination_closure);
   ~ApplicationImpl() override;
@@ -97,10 +96,8 @@
   void WaitForInitialize();
 
   // Shell.
-  scoped_ptr<ApplicationConnection> ConnectToApplication(
-      const std::string& url) override;
-  scoped_ptr<ApplicationConnection> ConnectToApplication(
-      ConnectParams* params) override;
+  scoped_ptr<Connection> Connect(const std::string& url) override;
+  scoped_ptr<Connection> Connect(ConnectParams* params) override;
   void Quit() override;
   scoped_ptr<AppRefCount> CreateAppRefCount() override;
 
@@ -132,8 +129,8 @@
 
   // We track the lifetime of incoming connection registries as it more
   // convenient for the client.
-  ScopedVector<ApplicationConnection> incoming_connections_;
-  ApplicationDelegate* delegate_;
+  ScopedVector<Connection> incoming_connections_;
+  ShellClient* client_;
   Binding<shell::mojom::Application> binding_;
   shell::mojom::ShellPtr shell_;
   Closure termination_closure_;
diff --git a/mojo/shell/public/cpp/application_runner.h b/mojo/shell/public/cpp/application_runner.h
index 10eb0a7..ddebcd74 100644
--- a/mojo/shell/public/cpp/application_runner.h
+++ b/mojo/shell/public/cpp/application_runner.h
@@ -11,7 +11,7 @@
 
 namespace mojo {
 
-class ApplicationDelegate;
+class ShellClient;
 
 // A utility for running a chromium based mojo Application. The typical use
 // case is to use when writing your MojoMain:
@@ -27,7 +27,7 @@
 class ApplicationRunner {
  public:
   // Takes ownership of |delegate|.
-  explicit ApplicationRunner(ApplicationDelegate* delegate);
+  explicit ApplicationRunner(ShellClient* client);
   ~ApplicationRunner();
 
   static void InitBaseCommandLine();
@@ -47,7 +47,7 @@
   MojoResult Run(MojoHandle shell_handle);
 
  private:
-  scoped_ptr<ApplicationDelegate> delegate_;
+  scoped_ptr<ShellClient> client_;
 
   // MessageLoop type. TYPE_CUSTOM is default (MessagePumpMojo will be used as
   // the underlying message pump).
diff --git a/mojo/shell/public/cpp/application_test_base.h b/mojo/shell/public/cpp/application_test_base.h
index 1dc3516..eec60d81 100644
--- a/mojo/shell/public/cpp/application_test_base.h
+++ b/mojo/shell/public/cpp/application_test_base.h
@@ -9,8 +9,8 @@
 #include "mojo/public/cpp/bindings/array.h"
 #include "mojo/public/cpp/bindings/string.h"
 #include "mojo/public/cpp/system/macros.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_impl.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/public/interfaces/application.mojom.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -29,15 +29,15 @@
 // ApplicationTestBase.
 class TestHelper {
  public:
-  explicit TestHelper(ApplicationDelegate* delegate);
+  explicit TestHelper(ShellClient* client);
   ~TestHelper();
 
   Shell* shell() { return application_impl_.get(); }
   std::string shell_url() { return url_; }
 
  private:
-  // The application delegate used if GetApplicationDelegate is not overridden.
-  ApplicationDelegate default_application_delegate_;
+  // The application delegate used if GetShellClient is not overridden.
+  ShellClient default_shell_client_;
 
   // The application implementation instance, reconstructed for each test.
   scoped_ptr<ApplicationImpl> application_impl_;
@@ -61,8 +61,8 @@
     return test_helper_ ? test_helper_->shell_url() : std::string();
   }
 
-  // Get the ApplicationDelegate for the application to be tested.
-  virtual ApplicationDelegate* GetApplicationDelegate();
+  // Get the ShellClient for the application to be tested.
+  virtual ShellClient* GetShellClient();
 
   // testing::Test:
   void SetUp() override;
diff --git a/mojo/shell/public/cpp/application_connection.h b/mojo/shell/public/cpp/connection.h
similarity index 73%
rename from mojo/shell/public/cpp/application_connection.h
rename to mojo/shell/public/cpp/connection.h
index 28a3a856..a21657ff 100644
--- a/mojo/shell/public/cpp/application_connection.h
+++ b/mojo/shell/public/cpp/connection.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 MOJO_SHELL_PUBLIC_CPP_APPLICATION_CONNECTION_H_
-#define MOJO_SHELL_PUBLIC_CPP_APPLICATION_CONNECTION_H_
+#ifndef MOJO_SHELL_PUBLIC_CPP_CONNECTION_H_
+#define MOJO_SHELL_PUBLIC_CPP_CONNECTION_H_
 
 #include <stdint.h>
 
@@ -19,7 +19,7 @@
 class ServiceConnector;
 
 // Represents a connection to another application. An instance of this class is
-// passed to ApplicationDelegate's AcceptConnection() method each
+// passed to ShellClient's AcceptConnection() method each
 // time a connection is made to this app.
 //
 // To use, define a class that implements your specific service API (e.g.,
@@ -35,32 +35,29 @@
 //   connection->AddService<Foo>(&my_foo_and_bar_factory_);
 //   connection->AddService<Bar>(&my_foo_and_bar_factory_);
 //
-// The InterfaceFactory must outlive the ApplicationConnection.
+// The InterfaceFactory must outlive the Connection.
 //
 // Additionally you specify a ServiceConnector. If a ServiceConnector has
 // been set and an InterfaceFactory has not been registered for the interface
 // request, than the interface request is sent to the ServiceConnector.
 //
-// Just as with InterfaceFactory, ServiceConnector must outlive
-// ApplicationConnection.
+// Just as with InterfaceFactory, ServiceConnector must outlive Connection.
 //
-// An ApplicationConnection's lifetime is managed by an ApplicationImpl. To
-// close a connection, call CloseConnection which will destroy this object.
-class ApplicationConnection {
+// An Connection's lifetime is managed by an ApplicationImpl. To close a
+// connection, call CloseConnection which will destroy this object.
+class Connection {
  public:
-  virtual ~ApplicationConnection() {}
+  virtual ~Connection() {}
 
   class TestApi {
    public:
-    explicit TestApi(ApplicationConnection* connection)
-        : connection_(connection) {
-    }
-    base::WeakPtr<ApplicationConnection> GetWeakPtr() {
+    explicit TestApi(Connection* connection) : connection_(connection) {}
+    base::WeakPtr<Connection> GetWeakPtr() {
       return connection_->GetWeakPtr();
     }
 
    private:
-    ApplicationConnection* connection_;
+    Connection* connection_;
   };
 
   // See class description for details.
@@ -92,13 +89,13 @@
   // Returns the URL that was used by the source application to establish a
   // connection to the destination application.
   //
-  // When ApplicationConnection is representing an incoming connection this can
-  // be different than the URL the application was initially loaded from, if the
+  // When Connection is representing an incoming connection this can be
+  // different than the URL the application was initially loaded from, if the
   // application handles multiple URLs. Note that this is the URL after all
   // URL rewriting and HTTP redirects have been performed.
   //
-  // When ApplicationConnection is representing and outgoing connection, this
-  // will be the same as the value returned by GetRemoveApplicationURL().
+  // When Connection is representing and outgoing connection, this will be the
+  // same as the value returned by GetRemoveApplicationURL().
   virtual const std::string& GetConnectionURL() = 0;
 
   // Returns the URL identifying the remote application on this connection.
@@ -118,13 +115,12 @@
   virtual void SetRemoteServiceProviderConnectionErrorHandler(
       const Closure& handler) = 0;
 
-  // Returns the id of the remote application. For ApplicationConnections
-  // created via ApplicationImpl::ConnectToApplication(), this will not be
-  // determined until ConnectToApplication()'s callback is run, and this
-  // function will return false. Use AddRemoteIDCallback() to schedule a
-  // callback to be run when the remote application id is available. A value of
-  // Shell::kInvalidApplicationID indicates no remote application connection
-  // has been established.
+  // Returns the id of the remote application. For Connections created via
+  // Shell::Connect(), this will not be determined until Connect()'s callback is
+  // run, and this function will return false. Use AddRemoteIDCallback() to
+  // schedule a callback to be run when the remote application id is available.
+  // A value of Shell::kInvalidApplicationID indicates the connection has not
+  // been established.
   virtual bool GetRemoteApplicationID(uint32_t* remote_id) const = 0;
 
   // Returns the id of the deepest content handler used in connecting to
@@ -144,9 +140,9 @@
   virtual bool SetServiceConnectorForName(ServiceConnector* service_connector,
                                           const std::string& name) = 0;
 
-  virtual base::WeakPtr<ApplicationConnection> GetWeakPtr() = 0;
+  virtual base::WeakPtr<Connection> GetWeakPtr() = 0;
 };
 
 }  // namespace mojo
 
-#endif  // MOJO_SHELL_PUBLIC_CPP_APPLICATION_CONNECTION_H_
+#endif  // MOJO_SHELL_PUBLIC_CPP_CONNECTION_H_
diff --git a/mojo/shell/public/cpp/content_handler_factory.h b/mojo/shell/public/cpp/content_handler_factory.h
index a8aa8c3..a174cdd 100644
--- a/mojo/shell/public/cpp/content_handler_factory.h
+++ b/mojo/shell/public/cpp/content_handler_factory.h
@@ -54,7 +54,7 @@
 
  private:
   // From InterfaceFactory:
-  void Create(ApplicationConnection* connection,
+  void Create(Connection* connection,
               InterfaceRequest<shell::mojom::ContentHandler> request) override;
 
   Delegate* delegate_;
diff --git a/mojo/shell/public/cpp/interface_factory.h b/mojo/shell/public/cpp/interface_factory.h
index 7f8f26e..7edf000 100644
--- a/mojo/shell/public/cpp/interface_factory.h
+++ b/mojo/shell/public/cpp/interface_factory.h
@@ -9,7 +9,7 @@
 
 namespace mojo {
 
-class ApplicationConnection;
+class Connection;
 template <typename Interface>
 class InterfaceRequest;
 
@@ -21,7 +21,7 @@
 class InterfaceFactory {
  public:
   virtual ~InterfaceFactory() {}
-  virtual void Create(ApplicationConnection* connection,
+  virtual void Create(Connection* connection,
                       InterfaceRequest<Interface> request) = 0;
 };
 
diff --git a/mojo/shell/public/cpp/interface_factory_impl.h b/mojo/shell/public/cpp/interface_factory_impl.h
index 7de2449..f849922 100644
--- a/mojo/shell/public/cpp/interface_factory_impl.h
+++ b/mojo/shell/public/cpp/interface_factory_impl.h
@@ -17,7 +17,7 @@
  public:
   virtual ~InterfaceFactoryImpl() {}
 
-  virtual void Create(ApplicationConnection* connection,
+  virtual void Create(Connection* connection,
                       InterfaceRequest<Interface> request) override {
     BindToRequest(new Impl(), &request);
   }
@@ -35,7 +35,7 @@
       : context_(context) {}
   virtual ~InterfaceFactoryImplWithContext() {}
 
-  virtual void Create(ApplicationConnection* connection,
+  virtual void Create(Connection* connection,
                       InterfaceRequest<Interface> request) override {
     BindToRequest(new Impl(context_), &request);
   }
diff --git a/mojo/shell/public/cpp/lib/application_delegate.cc b/mojo/shell/public/cpp/lib/application_delegate.cc
deleted file mode 100644
index 7c84264..0000000
--- a/mojo/shell/public/cpp/lib/application_delegate.cc
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/shell/public/cpp/application_delegate.h"
-
-namespace mojo {
-
-ApplicationDelegate::ApplicationDelegate() {
-}
-ApplicationDelegate::~ApplicationDelegate() {
-}
-
-void ApplicationDelegate::Initialize(Shell* app, const std::string& url,
-                                     uint32_t id) {
-}
-
-bool ApplicationDelegate::AcceptConnection(ApplicationConnection* connection) {
-  return true;
-}
-
-bool ApplicationDelegate::ShellConnectionLost() {
-  return true;
-}
-
-void ApplicationDelegate::Quit() {
-}
-
-}  // namespace mojo
diff --git a/mojo/shell/public/cpp/lib/application_impl.cc b/mojo/shell/public/cpp/lib/application_impl.cc
index ca149a33..132737f 100644
--- a/mojo/shell/public/cpp/lib/application_impl.cc
+++ b/mojo/shell/public/cpp/lib/application_impl.cc
@@ -10,9 +10,9 @@
 #include "mojo/converters/network/network_type_converters.h"
 #include "mojo/public/cpp/bindings/interface_ptr.h"
 #include "mojo/public/cpp/environment/logging.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_impl.h"
 #include "mojo/shell/public/cpp/lib/service_registry.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace mojo {
 
@@ -36,17 +36,17 @@
 ApplicationImpl::ConnectParams::~ConnectParams() {}
 
 ApplicationImpl::ApplicationImpl(
-    ApplicationDelegate* delegate,
+    ShellClient* client,
     InterfaceRequest<shell::mojom::Application> request)
-    : ApplicationImpl(delegate,
+    : ApplicationImpl(client,
                       std::move(request),
                       base::Bind(&DefaultTerminationClosure)) {}
 
 ApplicationImpl::ApplicationImpl(
-    ApplicationDelegate* delegate,
+    ShellClient* client,
     InterfaceRequest<shell::mojom::Application> request,
     const Closure& termination_closure)
-    : delegate_(delegate),
+    : client_(client),
       binding_(this, std::move(request)),
       termination_closure_(termination_closure),
       app_lifetime_helper_(this),
@@ -62,15 +62,13 @@
   binding_.WaitForIncomingMethodCall();
 }
 
-scoped_ptr<ApplicationConnection> ApplicationImpl::ConnectToApplication(
-    const std::string& url) {
+scoped_ptr<Connection> ApplicationImpl::Connect(const std::string& url) {
   ConnectParams params(url);
   params.set_filter(CreatePermissiveCapabilityFilter());
-  return ConnectToApplication(&params);
+  return Connect(&params);
 }
 
-scoped_ptr<ApplicationConnection>
-    ApplicationImpl::ConnectToApplication(ConnectParams* params) {
+scoped_ptr<Connection> ApplicationImpl::Connect(ConnectParams* params) {
   if (!shell_)
     return nullptr;
   DCHECK(params);
@@ -118,7 +116,7 @@
                                  uint32_t id) {
   shell_ = std::move(shell);
   shell_.set_connection_error_handler([this]() { OnConnectionError(); });
-  delegate_->Initialize(this, url, id);
+  client_->Initialize(this, url, id);
 }
 
 void ApplicationImpl::AcceptConnection(
@@ -128,10 +126,10 @@
     ServiceProviderPtr exposed_services,
     Array<String> allowed_interfaces,
     const String& url) {
-  scoped_ptr<ApplicationConnection> registry(new internal::ServiceRegistry(
+  scoped_ptr<Connection> registry(new internal::ServiceRegistry(
       url, requestor_url, requestor_id, std::move(exposed_services),
       std::move(services), allowed_interfaces.To<std::set<std::string>>()));
-  if (!delegate_->AcceptConnection(registry.get()))
+  if (!client_->AcceptConnection(registry.get()))
     return;
 
   // If we were quitting because we thought there were no more services for this
@@ -154,11 +152,11 @@
 void ApplicationImpl::OnConnectionError() {
   base::WeakPtr<ApplicationImpl> ptr(weak_factory_.GetWeakPtr());
 
-  // We give the delegate notice first, since it might want to do something on
+  // We give the client notice first, since it might want to do something on
   // shell connection errors other than immediate termination of the run
   // loop. The application might want to continue servicing connections other
   // than the one to the shell.
-  bool quit_now = delegate_->ShellConnectionLost();
+  bool quit_now = client_->ShellConnectionLost();
   if (quit_now)
     QuitNow();
   if (!ptr)
@@ -167,7 +165,7 @@
 }
 
 void ApplicationImpl::QuitNow() {
-  delegate_->Quit();
+  client_->Quit();
   termination_closure_.Run();
 }
 
diff --git a/mojo/shell/public/cpp/lib/application_runner.cc b/mojo/shell/public/cpp/lib/application_runner.cc
index e95133e..245dcd5 100644
--- a/mojo/shell/public/cpp/lib/application_runner.cc
+++ b/mojo/shell/public/cpp/lib/application_runner.cc
@@ -10,16 +10,16 @@
 #include "base/message_loop/message_loop.h"
 #include "base/process/launch.h"
 #include "mojo/message_pump/message_pump_mojo.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_impl.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 
 namespace mojo {
 
 int g_application_runner_argc;
 const char* const* g_application_runner_argv;
 
-ApplicationRunner::ApplicationRunner(ApplicationDelegate* delegate)
-    : delegate_(scoped_ptr<ApplicationDelegate>(delegate)),
+ApplicationRunner::ApplicationRunner(ShellClient* client)
+    : client_(scoped_ptr<ShellClient>(client)),
       message_loop_type_(base::MessageLoop::TYPE_CUSTOM),
       has_run_(false) {}
 
@@ -54,19 +54,19 @@
     else
       loop.reset(new base::MessageLoop(message_loop_type_));
 
-    ApplicationImpl impl(delegate_.get(),
+    ApplicationImpl impl(client_.get(),
                          MakeRequest<shell::mojom::Application>(
                             MakeScopedHandle(MessagePipeHandle(
                                 application_request_handle))));
     loop->Run();
-    // It's very common for the delegate to cache the app and terminate on
-    // errors. If we don't delete the delegate before the app we run the risk
-    // of the delegate having a stale reference to the app and trying to use it.
+    // It's very common for the client to cache the app and terminate on errors.
+    // If we don't delete the client before the app we run the risk of the
+    // client having a stale reference to the app and trying to use it.
     // Note that we destruct the message loop first because that might trigger
     // connection error handlers and they might access objects created by the
-    // delegate.
+    // client.
     loop.reset();
-    delegate_.reset();
+    client_.reset();
   }
   return MOJO_RESULT_OK;
 }
diff --git a/mojo/shell/public/cpp/lib/application_test_base.cc b/mojo/shell/public/cpp/lib/application_test_base.cc
index 3d6ad90a..2bf6975 100644
--- a/mojo/shell/public/cpp/lib/application_test_base.cc
+++ b/mojo/shell/public/cpp/lib/application_test_base.cc
@@ -113,9 +113,9 @@
   return (result == 0) ? MOJO_RESULT_OK : MOJO_RESULT_UNKNOWN;
 }
 
-TestHelper::TestHelper(ApplicationDelegate* delegate)
+TestHelper::TestHelper(ShellClient* client)
     : application_impl_(new ApplicationImpl(
-          delegate == nullptr ? &default_application_delegate_ : delegate,
+          client == nullptr ? &default_shell_client_ : client,
           std::move(g_application_request))),
       url_(g_url) {
   // Fake application initialization.
@@ -129,7 +129,7 @@
   // ApplicationImpl::TestApi test_api(application_impl_);
   // test_api.UnbindConnections(&g_application_request, &g_shell);
   // }
-  // We may have supplied a member as the delegate. Delete |application_impl_|
+  // We may have supplied a member as the client. Delete |application_impl_|
   // while still valid.
   application_impl_.reset();
 }
@@ -139,7 +139,7 @@
 ApplicationTestBase::~ApplicationTestBase() {
 }
 
-ApplicationDelegate* ApplicationTestBase::GetApplicationDelegate() {
+ShellClient* ApplicationTestBase::GetShellClient() {
   return nullptr;
 }
 
@@ -153,7 +153,7 @@
   MOJO_CHECK(g_shell);
 
   // New applications are constructed for each test to avoid persisting state.
-  test_helper_.reset(new TestHelper(GetApplicationDelegate()));
+  test_helper_.reset(new TestHelper(GetShellClient()));
 }
 
 void ApplicationTestBase::TearDown() {
diff --git a/mojo/shell/public/cpp/lib/content_handler_factory.cc b/mojo/shell/public/cpp/lib/content_handler_factory.cc
index 17714f5..156faf07 100644
--- a/mojo/shell/public/cpp/lib/content_handler_factory.cc
+++ b/mojo/shell/public/cpp/lib/content_handler_factory.cc
@@ -15,7 +15,7 @@
 #include "base/threading/platform_thread.h"
 #include "mojo/message_pump/message_pump_mojo.h"
 #include "mojo/public/cpp/bindings/strong_binding.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/content_handler_factory.h"
 #include "mojo/shell/public/cpp/interface_factory_impl.h"
 
@@ -134,7 +134,7 @@
 }
 
 void ContentHandlerFactory::Create(
-    ApplicationConnection* connection,
+    Connection* connection,
     InterfaceRequest<shell::mojom::ContentHandler> request) {
   new ContentHandlerImpl(delegate_, std::move(request));
 }
diff --git a/mojo/shell/public/cpp/lib/interface_factory_connector.h b/mojo/shell/public/cpp/lib/interface_factory_connector.h
index 5ef7eaa..42c4c038 100644
--- a/mojo/shell/public/cpp/lib/interface_factory_connector.h
+++ b/mojo/shell/public/cpp/lib/interface_factory_connector.h
@@ -21,10 +21,10 @@
       : factory_(factory) {}
   ~InterfaceFactoryConnector() override {}
 
-  void ConnectToService(ApplicationConnection* application_connection,
+  void ConnectToService(Connection* connection,
                         const std::string& interface_name,
                         ScopedMessagePipeHandle client_handle) override {
-    factory_->Create(application_connection,
+    factory_->Create(connection,
                      MakeRequest<Interface>(std::move(client_handle)));
   }
 
diff --git a/mojo/shell/public/cpp/lib/service_connector_registry.cc b/mojo/shell/public/cpp/lib/service_connector_registry.cc
index edc91e08..fc74ef0 100644
--- a/mojo/shell/public/cpp/lib/service_connector_registry.cc
+++ b/mojo/shell/public/cpp/lib/service_connector_registry.cc
@@ -42,17 +42,17 @@
 }
 
 void ServiceConnectorRegistry::ConnectToService(
-    ApplicationConnection* application_connection,
+    Connection* connection,
     const std::string& interface_name,
     ScopedMessagePipeHandle client_handle) {
   auto iter = name_to_service_connector_.find(interface_name);
   if (iter != name_to_service_connector_.end()) {
-    iter->second->ConnectToService(application_connection, interface_name,
+    iter->second->ConnectToService(connection, interface_name,
                                    std::move(client_handle));
     return;
   }
   if (service_connector_) {
-    service_connector_->ConnectToService(application_connection, interface_name,
+    service_connector_->ConnectToService(connection, interface_name,
                                          std::move(client_handle));
   }
 }
diff --git a/mojo/shell/public/cpp/lib/service_connector_registry.h b/mojo/shell/public/cpp/lib/service_connector_registry.h
index 9475436b..4bf400f 100644
--- a/mojo/shell/public/cpp/lib/service_connector_registry.h
+++ b/mojo/shell/public/cpp/lib/service_connector_registry.h
@@ -12,7 +12,7 @@
 
 namespace mojo {
 
-class ApplicationConnection;
+class Connection;
 class ServiceConnector;
 
 namespace internal {
@@ -42,7 +42,7 @@
                                   const std::string& interface_name);
   void RemoveServiceConnectorForName(const std::string& interface_name);
 
-  void ConnectToService(ApplicationConnection* application_connection,
+  void ConnectToService(Connection* connection,
                         const std::string& interface_name,
                         ScopedMessagePipeHandle client_handle);
 
diff --git a/mojo/shell/public/cpp/lib/service_provider_impl.cc b/mojo/shell/public/cpp/lib/service_provider_impl.cc
index 4a411a2..dc31a8b4 100644
--- a/mojo/shell/public/cpp/lib/service_provider_impl.cc
+++ b/mojo/shell/public/cpp/lib/service_provider_impl.cc
@@ -28,7 +28,7 @@
     const String& service_name,
     ScopedMessagePipeHandle client_handle) {
   // TODO(beng): perhaps take app connection thru ctor so that we can pass
-  // ApplicationConnection through?
+  // Connection through?
   service_connector_registry_.ConnectToService(nullptr, service_name,
                                                std::move(client_handle));
 }
diff --git a/mojo/shell/public/cpp/lib/service_registry.cc b/mojo/shell/public/cpp/lib/service_registry.cc
index 1425276d..1df9976 100644
--- a/mojo/shell/public/cpp/lib/service_registry.cc
+++ b/mojo/shell/public/cpp/lib/service_registry.cc
@@ -10,7 +10,7 @@
 
 #include "base/bind.h"
 #include "base/logging.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/service_connector.h"
 
 namespace mojo {
@@ -106,7 +106,7 @@
   remote_id_callbacks_.push_back(callback);
 }
 
-base::WeakPtr<ApplicationConnection> ServiceRegistry::GetWeakPtr() {
+base::WeakPtr<Connection> ServiceRegistry::GetWeakPtr() {
   return weak_factory_.GetWeakPtr();
 }
 
diff --git a/mojo/shell/public/cpp/lib/service_registry.h b/mojo/shell/public/cpp/lib/service_registry.h
index 74c2e345..683e220 100644
--- a/mojo/shell/public/cpp/lib/service_registry.h
+++ b/mojo/shell/public/cpp/lib/service_registry.h
@@ -11,7 +11,7 @@
 #include <string>
 
 #include "mojo/public/cpp/bindings/binding.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/lib/service_connector_registry.h"
 #include "mojo/shell/public/interfaces/service_provider.mojom.h"
 #include "mojo/shell/public/interfaces/shell.mojom.h"
@@ -22,7 +22,7 @@
 // A ServiceRegistry represents each half of a connection between two
 // applications, allowing customization of which services are published to the
 // other.
-class ServiceRegistry : public ServiceProvider, public ApplicationConnection {
+class ServiceRegistry : public ServiceProvider, public Connection {
  public:
   ServiceRegistry();
   // |allowed_interfaces| are the set of interfaces that the shell has allowed
@@ -39,7 +39,7 @@
   shell::mojom::Shell::ConnectToApplicationCallback
       GetConnectToApplicationCallback();
 
-  // ApplicationConnection overrides.
+  // Connection overrides.
   void SetServiceConnector(ServiceConnector* service_connector) override;
   bool SetServiceConnectorForName(ServiceConnector* service_connector,
                                   const std::string& interface_name) override;
@@ -52,7 +52,7 @@
   bool GetRemoteApplicationID(uint32_t* remote_id) const override;
   bool GetRemoteContentHandlerID(uint32_t* content_handler_id) const override;
   void AddRemoteIDCallback(const Closure& callback) override;
-  base::WeakPtr<ApplicationConnection> GetWeakPtr() override;
+  base::WeakPtr<Connection> GetWeakPtr() override;
 
   void RemoveServiceConnectorForName(const std::string& interface_name);
 
diff --git a/mojo/shell/public/cpp/lib/shell_client.cc b/mojo/shell/public/cpp/lib/shell_client.cc
new file mode 100644
index 0000000..b3e83b5
--- /dev/null
+++ b/mojo/shell/public/cpp/lib/shell_client.cc
@@ -0,0 +1,26 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/shell/public/cpp/shell_client.h"
+
+namespace mojo {
+
+ShellClient::ShellClient() {}
+ShellClient::~ShellClient() {}
+
+void ShellClient::Initialize(Shell* app, const std::string& url,
+                                     uint32_t id) {
+}
+
+bool ShellClient::AcceptConnection(Connection* connection) {
+  return false;
+}
+
+bool ShellClient::ShellConnectionLost() {
+  return true;
+}
+
+void ShellClient::Quit() {}
+
+}  // namespace mojo
diff --git a/mojo/shell/public/cpp/service_connector.h b/mojo/shell/public/cpp/service_connector.h
index 8856e3f..5ba0192 100644
--- a/mojo/shell/public/cpp/service_connector.h
+++ b/mojo/shell/public/cpp/service_connector.h
@@ -11,7 +11,7 @@
 
 namespace mojo {
 
-class ApplicationConnection;
+class Connection;
 
 class ServiceConnector {
  public:
@@ -20,7 +20,7 @@
   // Asks the ServiceConnector to connect to the specified service. If the
   // ServiceConnector connects to the service it should take ownership of
   // the handle in |handle|.
-  virtual void ConnectToService(ApplicationConnection* application_connection,
+  virtual void ConnectToService(Connection* connection,
                                 const std::string& interface_name,
                                 ScopedMessagePipeHandle handle) = 0;
 };
diff --git a/mojo/shell/public/cpp/shell.h b/mojo/shell/public/cpp/shell.h
index 2a3acb34e..104cc45 100644
--- a/mojo/shell/public/cpp/shell.h
+++ b/mojo/shell/public/cpp/shell.h
@@ -6,7 +6,7 @@
 #define MOJO_SHELL_PUBLIC_CPP_SHELL_H_
 
 #include "mojo/shell/public/cpp/app_lifetime_helper.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/interfaces/application.mojom.h"
 #include "mojo/shell/public/interfaces/shell.mojom.h"
 
@@ -42,16 +42,14 @@
   // Requests a new connection to an application. Returns a pointer to the
   // connection if the connection is permitted by this application's delegate,
   // or nullptr otherwise. Caller takes ownership.
-  virtual scoped_ptr<ApplicationConnection> ConnectToApplication(
-      const std::string& url) = 0;
-  virtual scoped_ptr<ApplicationConnection> ConnectToApplication(
-      ConnectParams* params) = 0;
+  virtual scoped_ptr<Connection> Connect(const std::string& url) = 0;
+  virtual scoped_ptr<Connection> Connect(ConnectParams* params) = 0;
 
   // Connect to application identified by |request->url| and connect to the
   // service implementation of the interface identified by |Interface|.
   template <typename Interface>
   void ConnectToService(ConnectParams* params, InterfacePtr<Interface>* ptr) {
-    scoped_ptr<ApplicationConnection> connection = ConnectToApplication(params);
+    scoped_ptr<Connection> connection = Connect(params);
     if (!connection.get())
       return;
     connection->ConnectToService(ptr);
diff --git a/mojo/shell/public/cpp/shell_client.h b/mojo/shell/public/cpp/shell_client.h
new file mode 100644
index 0000000..e7c56d9
--- /dev/null
+++ b/mojo/shell/public/cpp/shell_client.h
@@ -0,0 +1,54 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_
+#define MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_
+
+#include <stdint.h>
+#include <string>
+
+#include "mojo/public/cpp/system/macros.h"
+#include "mojo/shell/public/cpp/connection.h"
+
+namespace mojo {
+
+class Shell;
+
+// An abstract class that the application may subclass to control various
+// behaviors of ApplicationImpl.
+class ShellClient {
+ public:
+  ShellClient();
+  virtual ~ShellClient();
+
+  // Called once a bidirectional connection with the shell has been established.
+  // |url| is the URL used to start the application. |id| is a unique identifier
+  // the shell uses to identify this specific instance of the application.
+  // Called exactly once before any other method.
+  virtual void Initialize(Shell* shell, const std::string& url, uint32_t id);
+
+  // Override this method to configure what services a connection supports when
+  // being connected to from an app.
+  // Return false to reject the connection entirely. The default implementation
+  // returns false.
+  virtual bool AcceptConnection(Connection* connection);
+
+  // Called when the shell connection has a connection error.
+  //
+  // Return true to shutdown the application. Return false to skip shutting
+  // down the connection, but user is then required to call
+  // ApplicationImpl::QuitNow() when done. Default implementation returns true.
+  virtual bool ShellConnectionLost();
+
+  // Called before ApplicationImpl::Terminate(). After returning from this call
+  // the delegate can no longer rely on the main run loop still running.
+  virtual void Quit();
+
+ private:
+  MOJO_DISALLOW_COPY_AND_ASSIGN(ShellClient);
+};
+
+}  // namespace mojo
+
+#endif  // MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_
diff --git a/mojo/shell/public/cpp/tests/service_registry_unittest.cc b/mojo/shell/public/cpp/tests/service_registry_unittest.cc
index 349e9aa..dc29d37 100644
--- a/mojo/shell/public/cpp/tests/service_registry_unittest.cc
+++ b/mojo/shell/public/cpp/tests/service_registry_unittest.cc
@@ -16,7 +16,7 @@
  public:
   explicit TestConnector(int* delete_count) : delete_count_(delete_count) {}
   ~TestConnector() override { (*delete_count_)++; }
-  void ConnectToService(ApplicationConnection* application_connection,
+  void ConnectToService(Connection* connection,
                         const std::string& interface_name,
                         ScopedMessagePipeHandle client_handle) override {}
 
diff --git a/mojo/shell/runner/child/native_apptest_target.cc b/mojo/shell/runner/child/native_apptest_target.cc
index ecdbaf4..ff8a8fb 100644
--- a/mojo/shell/runner/child/native_apptest_target.cc
+++ b/mojo/shell/runner/child/native_apptest_target.cc
@@ -8,10 +8,10 @@
 #include "base/command_line.h"
 #include "base/macros.h"
 #include "mojo/common/weak_binding_set.h"
-#include "mojo/shell/public/cpp/application_connection.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
 #include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/runner/child/test_native_main.h"
 #include "mojo/shell/runner/child/test_native_service.mojom.h"
 #include "mojo/shell/runner/init.h"
@@ -19,7 +19,7 @@
 namespace {
 
 class TargetApplicationDelegate
-    : public mojo::ApplicationDelegate,
+    : public mojo::ShellClient,
       public mojo::shell::test::TestNativeService,
       public mojo::InterfaceFactory<mojo::shell::test::TestNativeService> {
  public:
@@ -27,11 +27,10 @@
   ~TargetApplicationDelegate() override {}
 
  private:
-  // mojo::ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(mojo::Shell* shell, const std::string& url,
                   uint32_t id) override {}
-  bool AcceptConnection(
-      mojo::ApplicationConnection* connection) override {
+  bool AcceptConnection(mojo::Connection* connection) override {
     connection->AddService<mojo::shell::test::TestNativeService>(this);
     return true;
   }
@@ -42,7 +41,7 @@
   }
 
   // mojo::InterfaceFactory<mojo::shell::test::TestNativeService>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<mojo::shell::test::TestNativeService>
                   request) override {
     bindings_.AddBinding(this, std::move(request));
diff --git a/mojo/shell/runner/child/test_native_main.cc b/mojo/shell/runner/child/test_native_main.cc
index 3e63eec5..537b32b 100644
--- a/mojo/shell/runner/child/test_native_main.cc
+++ b/mojo/shell/runner/child/test_native_main.cc
@@ -13,8 +13,8 @@
 #include "base/threading/thread.h"
 #include "build/build_config.h"
 #include "mojo/message_pump/message_pump_mojo.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_impl.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/runner/child/runner_connection.h"
 #include "mojo/shell/runner/init.h"
 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h"
@@ -37,7 +37,7 @@
 
 }  // namespace
 
-int TestNativeMain(mojo::ApplicationDelegate* application_delegate) {
+int TestNativeMain(mojo::ShellClient* application_delegate) {
   mojo::shell::WaitForDebuggerIfNecessary();
 
 #if !defined(OFFICIAL_BUILD)
diff --git a/mojo/shell/runner/child/test_native_main.h b/mojo/shell/runner/child/test_native_main.h
index 2a08756..600e814 100644
--- a/mojo/shell/runner/child/test_native_main.h
+++ b/mojo/shell/runner/child/test_native_main.h
@@ -6,10 +6,10 @@
 #define MOJO_SHELL_RUNNER_CHILD_TEST_NATIVE_MAIN_H_
 
 namespace mojo {
-class ApplicationDelegate;
+class ShellClient;
 namespace shell {
 
-int TestNativeMain(mojo::ApplicationDelegate* application_delegate);
+int TestNativeMain(mojo::ShellClient* application_delegate);
 
 }  // namespace shell
 }  // namespace mojo
diff --git a/mojo/shell/shell_application_delegate.cc b/mojo/shell/shell_application_delegate.cc
index e472617..dcac9de 100644
--- a/mojo/shell/shell_application_delegate.cc
+++ b/mojo/shell/shell_application_delegate.cc
@@ -10,7 +10,7 @@
 
 #include "base/process/process.h"
 #include "mojo/shell/application_manager.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h"
 
 namespace mojo {
@@ -23,14 +23,13 @@
 
 void ShellApplicationDelegate::Initialize(Shell* shell, const std::string& url,
                                           uint32_t id) {}
-bool ShellApplicationDelegate::AcceptConnection(
-    ApplicationConnection* connection) {
+bool ShellApplicationDelegate::AcceptConnection(Connection* connection) {
   connection->AddService<mojom::ApplicationManager>(this);
   return true;
 }
 
 void ShellApplicationDelegate::Create(
-    ApplicationConnection* connection,
+    Connection* connection,
     InterfaceRequest<mojom::ApplicationManager> request) {
   bindings_.AddBinding(this, std::move(request));
 }
diff --git a/mojo/shell/shell_application_delegate.h b/mojo/shell/shell_application_delegate.h
index 84e384b..fcc3260 100644
--- a/mojo/shell/shell_application_delegate.h
+++ b/mojo/shell/shell_application_delegate.h
@@ -5,13 +5,12 @@
 #ifndef MOJO_SHELL_SHELL_APPLICATION_DELEGATE_H_
 #define MOJO_SHELL_SHELL_APPLICATION_DELEGATE_H_
 
-#include "mojo/shell/public/cpp/application_delegate.h"
-
 #include <stdint.h>
 
 #include "base/macros.h"
 #include "mojo/common/weak_binding_set.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/public/interfaces/application_manager.mojom.h"
 
 namespace mojo {
@@ -19,7 +18,7 @@
 class ApplicationManager;
 
 class ShellApplicationDelegate
-    : public ApplicationDelegate,
+    : public ShellClient,
       public InterfaceFactory<mojom::ApplicationManager>,
       public mojom::ApplicationManager {
  public:
@@ -27,13 +26,13 @@
   ~ShellApplicationDelegate() override;
 
  private:
-  // Overridden from ApplicationDelegate:
+  // Overridden from ShellClient:
   void Initialize(Shell* shell, const std::string& url, uint32_t id) override;
-  bool AcceptConnection(ApplicationConnection* connection) override;
+  bool AcceptConnection(Connection* connection) override;
 
   // Overridden from InterfaceFactory<mojom::ApplicationManager>:
   void Create(
-      ApplicationConnection* connection,
+      Connection* connection,
       InterfaceRequest<mojom::ApplicationManager> request) override;
 
   // Overridden from mojom::ApplicationManager:
diff --git a/mojo/shell/standalone/android/android_handler.cc b/mojo/shell/standalone/android/android_handler.cc
index 175923b..98788243 100644
--- a/mojo/shell/standalone/android/android_handler.cc
+++ b/mojo/shell/standalone/android/android_handler.cc
@@ -170,7 +170,7 @@
                                 const std::string& url,
                                 uint32_t id) {}
 
-bool AndroidHandler::AcceptConnection(ApplicationConnection* connection) {
+bool AndroidHandler::AcceptConnection(Connection* connection) {
   connection->AddService(&content_handler_factory_);
   return true;
 }
diff --git a/mojo/shell/standalone/android/android_handler.h b/mojo/shell/standalone/android/android_handler.h
index e58d3bf..ed8ad3e 100644
--- a/mojo/shell/standalone/android/android_handler.h
+++ b/mojo/shell/standalone/android/android_handler.h
@@ -7,9 +7,9 @@
 
 #include <jni.h>
 
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/content_handler_factory.h"
 #include "mojo/shell/public/cpp/interface_factory_impl.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/public/interfaces/content_handler.mojom.h"
 
 namespace base {
@@ -19,16 +19,16 @@
 namespace mojo {
 namespace shell {
 
-class AndroidHandler : public ApplicationDelegate,
+class AndroidHandler : public ShellClient,
                        public ContentHandlerFactory::Delegate {
  public:
   AndroidHandler();
   ~AndroidHandler();
 
  private:
-  // ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(Shell* shell, const std::string& url, uint32_t id) override;
-  bool AcceptConnection(ApplicationConnection* connection) override;
+  bool AcceptConnection(Connection* connection) override;
 
   // ContentHandlerFactory::Delegate:
   void RunApplication(InterfaceRequest<mojom::Application> application_request,
diff --git a/mojo/shell/standalone/test/pingable_app.cc b/mojo/shell/standalone/test/pingable_app.cc
index 31613b8..9b43df1 100644
--- a/mojo/shell/standalone/test/pingable_app.cc
+++ b/mojo/shell/standalone/test/pingable_app.cc
@@ -6,10 +6,10 @@
 #include "mojo/public/cpp/bindings/callback.h"
 #include "mojo/public/cpp/bindings/interface_request.h"
 #include "mojo/public/cpp/bindings/strong_binding.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_runner.h"
 #include "mojo/shell/public/cpp/interface_factory.h"
 #include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/standalone/test/pingable.mojom.h"
 
 namespace mojo {
@@ -36,25 +36,25 @@
   std::string connection_url_;
 };
 
-class PingableApp : public mojo::ApplicationDelegate,
+class PingableApp : public mojo::ShellClient,
                     public mojo::InterfaceFactory<Pingable> {
  public:
   PingableApp() {}
   ~PingableApp() override {}
 
  private:
-  // ApplicationDelegate:
+  // mojo::ShellClient:
   void Initialize(Shell* shell, const std::string& url, uint32_t id) override {
     app_url_ = url;
   }
 
-  bool AcceptConnection(mojo::ApplicationConnection* connection) override {
+  bool AcceptConnection(mojo::Connection* connection) override {
     connection->AddService(this);
     return true;
   }
 
   // InterfaceFactory<Pingable>:
-  void Create(mojo::ApplicationConnection* connection,
+  void Create(mojo::Connection* connection,
               mojo::InterfaceRequest<Pingable> request) override {
     new PingableImpl(std::move(request), app_url_,
                      connection->GetConnectionURL());
diff --git a/mojo/shell/static_application_loader.cc b/mojo/shell/static_application_loader.cc
index c7e7f5e..7b510272 100644
--- a/mojo/shell/static_application_loader.cc
+++ b/mojo/shell/static_application_loader.cc
@@ -13,8 +13,8 @@
 #include "base/thread_task_runner_handle.h"
 #include "base/threading/simple_thread.h"
 #include "mojo/public/cpp/bindings/interface_request.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
 #include "mojo/shell/public/cpp/application_runner.h"
+#include "mojo/shell/public/cpp/shell_client.h"
 #include "mojo/shell/public/interfaces/application.mojom.h"
 
 namespace mojo {
diff --git a/mojo/shell/static_application_loader.h b/mojo/shell/static_application_loader.h
index 9cb5cae9..38b4a87 100644
--- a/mojo/shell/static_application_loader.h
+++ b/mojo/shell/static_application_loader.h
@@ -17,20 +17,20 @@
 }
 
 namespace mojo {
-class ApplicationDelegate;
+class ShellClient;
 }
 
 namespace mojo {
 namespace shell {
 
 // An ApplicationLoader which loads a single type of app from a given
-// ApplicationDelegate factory. A Load() request is fulfilled by creating an
+// mojo::ShellClient factory. A Load() request is fulfilled by creating an
 // instance of the app on a new thread. Only one instance of the app will run at
 // a time. Any Load requests received while the app is running will be dropped.
 class StaticApplicationLoader : public mojo::shell::ApplicationLoader {
  public:
   using ApplicationFactory =
-      base::Callback<scoped_ptr<mojo::ApplicationDelegate>()>;
+      base::Callback<scoped_ptr<mojo::ShellClient>()>;
 
   // Constructs a static loader for |factory|.
   explicit StaticApplicationLoader(const ApplicationFactory& factory);
diff --git a/printing/BUILD.gn b/printing/BUILD.gn
index 466388fd..ce6c9d4 100644
--- a/printing/BUILD.gn
+++ b/printing/BUILD.gn
@@ -128,10 +128,16 @@
     configs += [ ":cups" ]
 
     if (is_linux) {
+      # rebase_path does not accept an empty string
+      if (use_sysroot) {
+        cups_sysroot = rebase_path(sysroot)
+      } else {
+        cups_sysroot = ""
+      }
       cups_version = exec_script("cups_config_helper.py",
                                  [
                                    "--api-version",
-                                   rebase_path(sysroot),
+                                   cups_sysroot,
                                  ],
                                  "trim string")
 
@@ -241,10 +247,16 @@
       libs = [ "cups" ]
       lib_dirs = [ "$mac_sdk_path/usr/lib" ]
     } else {
+      # rebase_path does not accept an empty string
+      if (use_sysroot) {
+        cups_sysroot = rebase_path(sysroot)
+      } else {
+        cups_sysroot = ""
+      }
       libs = exec_script("cups_config_helper.py",
                          [
                            "--libs-for-gn",
-                           rebase_path(sysroot),
+                           cups_sysroot,
                          ],
                          "value")
     }
diff --git a/third_party/WebKit/LayoutTests/FlagExpectations/site-per-process b/third_party/WebKit/LayoutTests/FlagExpectations/site-per-process
index c7b8f55d..edb295b6 100644
--- a/third_party/WebKit/LayoutTests/FlagExpectations/site-per-process
+++ b/third_party/WebKit/LayoutTests/FlagExpectations/site-per-process
@@ -1,12 +1,15 @@
 # These tests currently fail when they run with --site-per-process.
 # See https://crbug.com/477150.
 
+# https://crbug.com/584984 - Recent, uninvestigated yet regression.
+http/tests/security/opened-document-security-origin-resets-on-navigation.html [ Crash ]
+
 # https://crbug.com/582494 - [sigsegv / av] blink::Document::styleEngine.
 http/tests/security/mixedContent/insecure-plugin-in-iframe.html [ Crash ]
 
 # https://crbug.com/495132 - [Assert] content::NavigationEntryImpl::SetBindings.
-http/tests/security/aboutBlank/xss-DENIED-navigate-opener-document-write.html [ Crash ]
-http/tests/security/aboutBlank/xss-DENIED-navigate-opener-javascript-url.html [ Crash ]
+http/tests/security/aboutBlank/xss-DENIED-navigate-opener-document-write.html [ Crash Failure ]
+http/tests/security/aboutBlank/xss-DENIED-navigate-opener-javascript-url.html [ Crash Failure ]
 http/tests/security/contentSecurityPolicy/1.1/referrer-always-http-https.html [ Crash ]
 http/tests/security/contentSecurityPolicy/1.1/referrer-default-http-https.html [ Crash ]
 http/tests/security/contentSecurityPolicy/1.1/referrer-empty-http-https.html [ Crash ]
@@ -14,7 +17,7 @@
 http/tests/security/contentSecurityPolicy/1.1/referrer-never-http-https.html [ Crash ]
 http/tests/security/contentSecurityPolicy/1.1/referrer-origin-http-https.html [ Crash ]
 http/tests/security/cross-frame-access-document-direct.html [ Crash ]
-http/tests/security/frameNavigation/xss-ALLOWED-targeted-subframe-navigation-change.html [ Crash ]
+http/tests/security/frameNavigation/xss-ALLOWED-targeted-subframe-navigation-change.html [ Crash Timeout ]
 http/tests/security/listener/xss-inactive-closure.html [ Crash ]
 http/tests/security/listener/xss-JSTargetNode-onclick-addEventListener.html [ Crash ]
 http/tests/security/listener/xss-JSTargetNode-onclick-shortcut.html [ Crash ]
@@ -23,10 +26,10 @@
 http/tests/security/listener/xss-XMLHttpRequest-addEventListener.html [ Crash ]
 http/tests/security/listener/xss-XMLHttpRequest-shortcut.html [ Crash ]
 http/tests/security/object-literals.html [ Crash ]
-http/tests/security/referrer-policy-origin-when-crossorigin-is-crossorigin.html [ Crash ]
+http/tests/security/referrer-policy-origin-when-crossorigin-is-crossorigin.html [ Crash Timeout ]
 http/tests/security/xss-eval.html [ Crash ]
 http/tests/security/xssAuditor/anchor-url-dom-write-location-inline-event.html [ Crash ]
-http/tests/security/xssAuditor/anchor-url-dom-write-location-inline-event-null-char.html [ Crash ]
+http/tests/security/xssAuditor/anchor-url-dom-write-location-inline-event-null-char.html [ Crash Timeout ]
 http/tests/security/xssAuditor/dom-write-location-inline-event.html [ Crash ]
 
 # https://crbug.com/576969 - unique name is not replicated into OOPIFs.
@@ -143,7 +146,7 @@
 http/tests/security/mixedContent/insecure-image-in-main-frame-allowed.html [ Failure Crash ]
 http/tests/security/mixedContent/insecure-image-in-main-frame-blocked.html [ Crash ]
 http/tests/security/mixedContent/insecure-image-in-main-frame.html [ Crash ]
-http/tests/security/mixedContent/insecure-script-in-data-iframe-in-main-frame-blocked.html [ Crash ]
+http/tests/security/mixedContent/insecure-script-in-data-iframe-in-main-frame-blocked.html [ Crash Missing ]
 http/tests/security/mixedContent/insecure-script-in-main-frame-allowed.html [ Failure Crash ]
 http/tests/security/mixedContent/insecure-script-in-main-frame-blocked.html [ Crash ]
 http/tests/security/mixedContent/insecure-script-through-redirection.html [ Crash ]
@@ -224,7 +227,7 @@
 http/tests/history/cross-origin-redirect-on-back.html [ Crash ]
 http/tests/inspector-enabled/console-log-before-frame-navigation.html [ Crash ]
 http/tests/inspector/change-iframe-src.html [ Crash ]
-http/tests/navigation/cross-origin-fragment-navigation-is-async.html [ Crash ]
+http/tests/navigation/cross-origin-fragment-navigation-is-async.html [ Crash Failure ]
 http/tests/serviceworker/windowclient-navigate.html [ Crash ]
 http/tests/xmlhttprequest/detaching-frame-2.html [ Crash ]
 http/tests/inspector-protocol/request-mixed-content-status-blockable.html [ Timeout ]
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations
index 14630612..135cab5 100644
--- a/third_party/WebKit/LayoutTests/TestExpectations
+++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -110,12 +110,6 @@
 crbug.com/537172 [ Mac10.6 Win10 ] virtual/spv2/paint/invalidation/spv2/background-image-paint-invalidation.html [ Failure ]
 crbug.com/564443 [ Mac10.7 Mac10.8 Mac10.9 Mac10.10 Win7 Linux ] virtual/spv2/paint/invalidation/spv2/background-image-paint-invalidation.html [ Failure Pass ]
 
-# SK_SUPPORT_LEGCAY_INSERT_NEW_EDGES, SK_SUPPORT_LEGACY_VERTICAL_EDGE
-crbug.com/573166 svg/batik/text/smallFonts.svg [ NeedsRebaseline ]
-crbug.com/573166 svg/batik/text/textFeatures.svg [ NeedsRebaseline ]
-crbug.com/573166 svg/carto.net/tabgroup.svg [ NeedsRebaseline ]
-crbug.com/573166 svg/repaint/repaint-paintorder.svg [ NeedsRebaseline ]
-
 crbug.com/504613 crbug.com/524248 paint/images/image-backgrounds-not-antialiased.html [ Skip ]
 crbug.com/504613 crbug.com/524248 virtual/spv2/paint/images/image-backgrounds-not-antialiased.html [ Skip ]
 crbug.com/502531 fast/borders/border-antialiasing.html [ Failure ]
diff --git a/third_party/WebKit/LayoutTests/inspector/console/command-line-api-getEventListeners-expected.txt b/third_party/WebKit/LayoutTests/inspector/console/command-line-api-getEventListeners-expected.txt
index 8fd4c3da..94a2b35 100644
--- a/third_party/WebKit/LayoutTests/inspector/console/command-line-api-getEventListeners-expected.txt
+++ b/third_party/WebKit/LayoutTests/inspector/console/command-line-api-getEventListeners-expected.txt
@@ -8,13 +8,13 @@
 [page]         listener: function listener1() { }
 [page]         useCapture: false
 [page]         type: "keydown"
-[page]         remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);}
+[page]         remove: function () { node.removeEventListener(this.type, this.listener, this.useCapture) }
 [page]     }
 [page]     1: {
 [page]         listener: function listener2() { }
 [page]         useCapture: true
 [page]         type: "keydown"
-[page]         remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);}
+[page]         remove: function () { node.removeEventListener(this.type, this.listener, this.useCapture) }
 [page]     }
 [page] }
 [page] - inner after a removal -
@@ -23,7 +23,7 @@
 [page]         listener: function listener2() { }
 [page]         useCapture: true
 [page]         type: "keydown"
-[page]         remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);}
+[page]         remove: function () { node.removeEventListener(this.type, this.listener, this.useCapture) }
 [page]     }
 [page] }
 [page] - outer -
@@ -32,7 +32,7 @@
 [page]         listener: function listener2() { }
 [page]         useCapture: true
 [page]         type: "keydown"
-[page]         remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);}
+[page]         remove: function () { node.removeEventListener(this.type, this.listener, this.useCapture) }
 [page]     }
 [page] }
 [page] mousedown: {
@@ -40,7 +40,7 @@
 [page]         listener: function listener2() { }
 [page]         useCapture: true
 [page]         type: "mousedown"
-[page]         remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);}
+[page]         remove: function () { node.removeEventListener(this.type, this.listener, this.useCapture) }
 [page]     }
 [page] }
 [page] mousemove: {
@@ -48,7 +48,7 @@
 [page]         listener: function listener1() { }
 [page]         useCapture: false
 [page]         type: "mousemove"
-[page]         remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);}
+[page]         remove: function () { node.removeEventListener(this.type, this.listener, this.useCapture) }
 [page]     }
 [page] }
 [page] - attribute event listeners -
@@ -57,7 +57,7 @@
 [page]         listener: function onclick(event) { alert(1) }
 [page]         useCapture: false
 [page]         type: "click"
-[page]         remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);}
+[page]         remove: function () { node.removeEventListener(this.type, this.listener, this.useCapture) }
 [page]     }
 [page] }
 [page] mouseover: {
@@ -65,7 +65,7 @@
 [page]         listener: function onmouseover(event) { listener2() }
 [page]         useCapture: false
 [page]         type: "mouseover"
-[page]         remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);}
+[page]         remove: function () { node.removeEventListener(this.type, this.listener, this.useCapture) }
 [page]     }
 [page] }
 [page] - window -
@@ -74,7 +74,7 @@
 [page]         listener: function onload(event) { runTest() }
 [page]         useCapture: false
 [page]         type: "load"
-[page]         remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);}
+[page]         remove: function () { node.removeEventListener(this.type, this.listener, this.useCapture) }
 [page]     }
 [page] }
 [page] popstate: {
@@ -82,7 +82,7 @@
 [page]         listener: function listener1() { }
 [page]         useCapture: false
 [page]         type: "popstate"
-[page]         remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);}
+[page]         remove: function () { node.removeEventListener(this.type, this.listener, this.useCapture) }
 [page]     }
 [page] }
 [page] - empty -
diff --git a/third_party/WebKit/LayoutTests/platform/android/svg/batik/text/smallFonts-expected.png b/third_party/WebKit/LayoutTests/platform/android/svg/batik/text/smallFonts-expected.png
new file mode 100644
index 0000000..58f86b1b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/platform/android/svg/batik/text/smallFonts-expected.png
Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/linux/svg/batik/text/smallFonts-expected.png b/third_party/WebKit/LayoutTests/platform/linux/svg/batik/text/smallFonts-expected.png
index 58f86b1b..ffc3055 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/svg/batik/text/smallFonts-expected.png
+++ b/third_party/WebKit/LayoutTests/platform/linux/svg/batik/text/smallFonts-expected.png
Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/linux/svg/batik/text/textFeatures-expected.png b/third_party/WebKit/LayoutTests/platform/linux/svg/batik/text/textFeatures-expected.png
index 6bc8c07..4a2fc639 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/svg/batik/text/textFeatures-expected.png
+++ b/third_party/WebKit/LayoutTests/platform/linux/svg/batik/text/textFeatures-expected.png
Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/linux/svg/carto.net/tabgroup-expected.png b/third_party/WebKit/LayoutTests/platform/linux/svg/carto.net/tabgroup-expected.png
index 1857a79..7c38e6c 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/svg/carto.net/tabgroup-expected.png
+++ b/third_party/WebKit/LayoutTests/platform/linux/svg/carto.net/tabgroup-expected.png
Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/mac/svg/carto.net/tabgroup-expected.png b/third_party/WebKit/LayoutTests/platform/mac/svg/carto.net/tabgroup-expected.png
index f0e016f6..3580bec 100644
--- a/third_party/WebKit/LayoutTests/platform/mac/svg/carto.net/tabgroup-expected.png
+++ b/third_party/WebKit/LayoutTests/platform/mac/svg/carto.net/tabgroup-expected.png
Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/win/svg/carto.net/tabgroup-expected.png b/third_party/WebKit/LayoutTests/platform/win/svg/carto.net/tabgroup-expected.png
index 16642fe..9fabfc7 100644
--- a/third_party/WebKit/LayoutTests/platform/win/svg/carto.net/tabgroup-expected.png
+++ b/third_party/WebKit/LayoutTests/platform/win/svg/carto.net/tabgroup-expected.png
Binary files differ
diff --git a/third_party/WebKit/LayoutTests/svg/repaint/repaint-paintorder-expected.png b/third_party/WebKit/LayoutTests/svg/repaint/repaint-paintorder-expected.png
index 896e4dd..defc984 100644
--- a/third_party/WebKit/LayoutTests/svg/repaint/repaint-paintorder-expected.png
+++ b/third_party/WebKit/LayoutTests/svg/repaint/repaint-paintorder-expected.png
Binary files differ
diff --git a/third_party/WebKit/LayoutTests/typedcssom/matrixTransformComponent.html b/third_party/WebKit/LayoutTests/typedcssom/matrixTransformComponent.html
index 0a22abd..084f680 100644
--- a/third_party/WebKit/LayoutTests/typedcssom/matrixTransformComponent.html
+++ b/third_party/WebKit/LayoutTests/typedcssom/matrixTransformComponent.html
@@ -4,27 +4,27 @@
 
 <script>
 var values = [
-  {input: new MatrixTransformComponent(0, 0, 0, 0, 0, 0),
+  {input: new Matrix(0, 0, 0, 0, 0, 0),
     a: 0, b: 0, c: 0, d: 0, e: 0, f: 0,
     is2DComponent: true, cssString: "matrix(0, 0, 0, 0, 0, 0)"},
-  {input: new MatrixTransformComponent(2, 4, 6, 8, 10, 12),
+  {input: new Matrix(2, 4, 6, 8, 10, 12),
     a: 2, b: 4, c: 6, d: 8, e: 10, f: 12,
     is2DComponent: true, cssString: "matrix(2, 4, 6, 8, 10, 12)"},
-  {input: new MatrixTransformComponent(-2, -4, -6, -8, -10, -12),
+  {input: new Matrix(-2, -4, -6, -8, -10, -12),
     a: -2, b: -4, c: -6, d: -8, e: -10, f: -12,
     is2DComponent: true, cssString: "matrix(-2, -4, -6, -8, -10, -12)"},
-  {input: new MatrixTransformComponent(1.1, -2.2, 3.3, -4.4, 5.5, 0.6),
+  {input: new Matrix(1.1, -2.2, 3.3, -4.4, 5.5, 0.6),
     a: 1.1, b: -2.2, c: 3.3, d: -4.4, e: 5.5, f: 0.6,
     is2DComponent: true, cssString: "matrix(1.1, -2.2, 3.3, -4.4, 5.5, 0.6)"},
-  {input: new MatrixTransformComponent(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+  {input: new Matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
     m11: 0, m12: 0, m13: 0, m14: 0, m21: 0, m22: 0, m23: 0, m24: 0,
     m31: 0, m32: 0, m33: 0, m34: 0, m41: 0, m42: 0, m43: 0, m44: 0,
     is2DComponent: false, cssString: "matrix3d(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)"},
-  {input: new MatrixTransformComponent(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41, 42, 43, 44),
+  {input: new Matrix(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41, 42, 43, 44),
     m11: 11, m12: 12, m13: 13, m14: 14, m21: 21, m22: 22, m23: 23, m24: 24,
     m31: 31, m32: 32, m33: 33, m34: 34, m41: 41, m42: 42, m43: 43, m44: 44,
     is2DComponent: false, cssString: "matrix3d(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41, 42, 43, 44)"},
-  {input: new MatrixTransformComponent(1.1, 1.2, -13, -1.4, 2, 0, -2, 4, 3.1, 3, 3, 3.4, -4.1, 42, 43, 4.4),
+  {input: new Matrix(1.1, 1.2, -13, -1.4, 2, 0, -2, 4, 3.1, 3, 3, 3.4, -4.1, 42, 43, 4.4),
     m11: 1.1, m12: 1.2, m13: -13, m14: -1.4, m21: 2, m22: 0, m23: -2, m24: 4,
     m31: 3.1, m32: 3, m33: 3, m34: 3.4, m41: -4.1, m42: 42, m43: 43, m44: 4.4,
     is2DComponent: false, cssString: "matrix3d(1.1, 1.2, -13, -1.4, 2, 0, -2, 4, 3.1, 3, 3, 3.4, -4.1, 42, 43, 4.4)"},
@@ -41,27 +41,27 @@
       assert_equals(values[i].input[attribute], values[i][attribute]);
     }
   }
-}, "Test that the (a, ... , f) and (m11, ... , m44) attributes for MatrixTransformComponent are correct.");
+}, "Test that the (a, ... , f) and (m11, ... , m44) attributes for Matrix are correct.");
 
 test(function() {
   for (var i = 0; i < values.length; ++i) {
     assert_equals(values[i].input.is2DComponent(), values[i].is2DComponent);
   }
-}, "Test that the is2DComponent values for MatrixTransformComponent is correct.");
+}, "Test that the is2DComponent values for Matrix is correct.");
 
 test(function() {
   for (var i = 0; i < values.length; ++i) {
     assert_equals(values[i].input.cssString, values[i].cssString);
   }
-}, "Test that the cssString for MatrixTransformComponent is correct.");
+}, "Test that the cssString for Matrix is correct.");
 
 test(function() {
-  assert_throws(null, function() { new MatrixTransformComponent(); });
-  assert_throws(null, function() { new MatrixTransformComponent(0); });
-  assert_throws(null, function() { new MatrixTransformComponent(0, 1, 2, 3, 4); });
-  assert_throws(null, function() { new MatrixTransformComponent(0, 1, 2, 3, 4, 5, 6); });
-  assert_throws(null, function() { new MatrixTransformComponent(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14); });
-}, "Test that invalid number of arguments for MatrixTransformComponent throws an exception.");
+  assert_throws(null, function() { new Matrix(); });
+  assert_throws(null, function() { new Matrix(0); });
+  assert_throws(null, function() { new Matrix(0, 1, 2, 3, 4); });
+  assert_throws(null, function() { new Matrix(0, 1, 2, 3, 4, 5, 6); });
+  assert_throws(null, function() { new Matrix(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14); });
+}, "Test that invalid number of arguments for Matrix throws an exception.");
 
 </script>
 
diff --git a/third_party/WebKit/LayoutTests/typedcssom/perspectiveTransformComponent.html b/third_party/WebKit/LayoutTests/typedcssom/perspectiveTransformComponent.html
index 0701b70..eac8663 100644
--- a/third_party/WebKit/LayoutTests/typedcssom/perspectiveTransformComponent.html
+++ b/third_party/WebKit/LayoutTests/typedcssom/perspectiveTransformComponent.html
@@ -6,19 +6,19 @@
 
 test(function() {
   var calcLength = new CalcLength({px: 10, percent: 3.2});
-  assert_throws(null, function() { new PerspectiveTransformComponent(calcLength) });
+  assert_throws(null, function() { new Perspective(calcLength) });
 }, "Constructor should throw an error for CalcLengths with a percentage type");
 
 test(function() {
   var simpleLength = new SimpleLength(10, 'percent');
-  assert_throws(null, function() { new PerspectiveTransformComponent(simpleLength) });
+  assert_throws(null, function() { new Perspective(simpleLength) });
 }, "Constructor should throw an error for SimpleLengths with a percentage type");
 
 test(function() {
   var simpleLength = new SimpleLength(10, 'px');
   var calcLength = new CalcLength({px: 10, em: 3.2});
-  var perspectiveTransformSimple = new PerspectiveTransformComponent(simpleLength);
-  var perspectiveTransformCalc = new PerspectiveTransformComponent(calcLength);
+  var perspectiveTransformSimple = new Perspective(simpleLength);
+  var perspectiveTransformCalc = new Perspective(calcLength);
 
   assert_equals(perspectiveTransformSimple.cssString, 'perspective(10px)');
   assert_equals(perspectiveTransformCalc.cssString,'perspective(calc(3.2em + 10px))');
diff --git a/third_party/WebKit/LayoutTests/typedcssom/rotationTransformComponent.html b/third_party/WebKit/LayoutTests/typedcssom/rotationTransformComponent.html
index a7ec981f0..27f8d56 100644
--- a/third_party/WebKit/LayoutTests/typedcssom/rotationTransformComponent.html
+++ b/third_party/WebKit/LayoutTests/typedcssom/rotationTransformComponent.html
@@ -4,19 +4,19 @@
 
 <script>
 var values = [
-  {input: new RotationTransformComponent(0), angle: 0, x: 0, y: 0, z: 1,
+  {input: new Rotation(0), angle: 0, x: 0, y: 0, z: 1,
     is2DComponent: true, cssString: "rotate(0deg)"},
-  {input: new RotationTransformComponent(10), angle: 10, x: 0, y: 0, z: 1,
+  {input: new Rotation(10), angle: 10, x: 0, y: 0, z: 1,
     is2DComponent: true, cssString: "rotate(10deg)"},
-  {input: new RotationTransformComponent(-21), angle: -21, x: 0, y: 0, z: 1,
+  {input: new Rotation(-21), angle: -21, x: 0, y: 0, z: 1,
     is2DComponent: true, cssString: "rotate(-21deg)"},
-  {input: new RotationTransformComponent(3.2), angle: 3.2, x: 0, y: 0, z: 1,
+  {input: new Rotation(3.2), angle: 3.2, x: 0, y: 0, z: 1,
     is2DComponent: true, cssString: "rotate(3.2deg)"},
-  {input: new RotationTransformComponent(10, 0, 0, 1), angle: 10, x: 0, y: 0, z: 1,
+  {input: new Rotation(10, 0, 0, 1), angle: 10, x: 0, y: 0, z: 1,
     is2DComponent: false, cssString: "rotate3d(0, 0, 1, 10deg)"},
-  {input: new RotationTransformComponent(10, 2, 3, 4), angle: 10, x: 2, y: 3, z: 4,
+  {input: new Rotation(10, 2, 3, 4), angle: 10, x: 2, y: 3, z: 4,
     is2DComponent: false, cssString: "rotate3d(2, 3, 4, 10deg)"},
-  {input: new RotationTransformComponent(-1.2, 2, 3.7, -4), angle: -1.2, x: 2, y: 3.7, z: -4,
+  {input: new Rotation(-1.2, 2, 3.7, -4), angle: -1.2, x: 2, y: 3.7, z: -4,
     is2DComponent: false, cssString: "rotate3d(2, 3.7, -4, -1.2deg)"}
 ];
 
@@ -27,18 +27,18 @@
     assert_equals(values[i].input.y, values[i].y);
     assert_equals(values[i].input.z, values[i].z);
   }
-}, "Test that the (angle, x, y, z) values for RotationTransformComponent are correct.");
+}, "Test that the (angle, x, y, z) values for Rotation are correct.");
 
 test(function() {
   for (var i = 0; i < values.length; ++i) {
     assert_equals(values[i].input.is2DComponent(), values[i].is2DComponent);
   }
-}, "Test that the is2DComponent values for RotationTransformComponent is correct.");
+}, "Test that the is2DComponent values for Rotation is correct.");
 
 test(function() {
   for (var i = 0; i < values.length; ++i) {
     assert_equals(values[i].input.cssString, values[i].cssString);
   }
-}, "Test that cssString values for RotationTransformComponent is correct.");
+}, "Test that cssString values for Rotation is correct.");
 
 </script>
diff --git a/third_party/WebKit/LayoutTests/typedcssom/scaleTransformComponent.html b/third_party/WebKit/LayoutTests/typedcssom/scaleTransformComponent.html
index d8438db4..aa76be06 100644
--- a/third_party/WebKit/LayoutTests/typedcssom/scaleTransformComponent.html
+++ b/third_party/WebKit/LayoutTests/typedcssom/scaleTransformComponent.html
@@ -4,19 +4,19 @@
 
 <script>
 var values = [
-  {input: new ScaleTransformComponent(0, 0), x: 0, y: 0, z: 1, is2DComponent: true,
+  {input: new Scale(0, 0), x: 0, y: 0, z: 1, is2DComponent: true,
     cssString: "scale(0, 0)"},
-  {input: new ScaleTransformComponent(1, 2), x: 1, y: 2, z: 1, is2DComponent: true,
+  {input: new Scale(1, 2), x: 1, y: 2, z: 1, is2DComponent: true,
     cssString: "scale(1, 2)"},
-  {input: new ScaleTransformComponent(-2, -4), x: -2, y: -4, z: 1, is2DComponent: true,
+  {input: new Scale(-2, -4), x: -2, y: -4, z: 1, is2DComponent: true,
     cssString: "scale(-2, -4)"},
-  {input: new ScaleTransformComponent(3.4, 2.7), x: 3.4, y: 2.7, z: 1, is2DComponent: true,
+  {input: new Scale(3.4, 2.7), x: 3.4, y: 2.7, z: 1, is2DComponent: true,
     cssString: "scale(3.4, 2.7)"},
-  {input: new ScaleTransformComponent(0, 0, 0), x: 0, y: 0, z: 0, is2DComponent: false,
+  {input: new Scale(0, 0, 0), x: 0, y: 0, z: 0, is2DComponent: false,
     cssString: "scale3d(0, 0, 0)"},
-  {input: new ScaleTransformComponent(1, 2, 3), x: 1, y: 2, z: 3, is2DComponent: false,
+  {input: new Scale(1, 2, 3), x: 1, y: 2, z: 3, is2DComponent: false,
     cssString: "scale3d(1, 2, 3)"},
-  {input: new ScaleTransformComponent(3.5, -2.7, -2), x: 3.5, y: -2.7, z: -2, is2DComponent: false,
+  {input: new Scale(3.5, -2.7, -2), x: 3.5, y: -2.7, z: -2, is2DComponent: false,
     cssString: "scale3d(3.5, -2.7, -2)"}
 ];
 
@@ -26,50 +26,50 @@
     assert_equals(values[i].input.y, values[i].y);
     assert_equals(values[i].input.z, values[i].z);
   }
-}, "Test that the (x, y, z) values for ScaleTransformComponent are correct.");
+}, "Test that the (x, y, z) values for Scale are correct.");
 
 test(function() {
   for (var i = 0; i < values.length; ++i) {
     assert_equals(values[i].input.is2DComponent(), values[i].is2DComponent);
   }
-}, "Test that the is2DComponent values for ScaleTransformComponent is correct.");
+}, "Test that the is2DComponent values for Scale is correct.");
 
 test(function() {
   for (var i = 0; i < values.length; ++i) {
     assert_equals(values[i].input.cssString, values[i].cssString);
   }
-}, "Test that the cssString for ScaleTransformComponent is correct.");
+}, "Test that the cssString for Scale is correct.");
 
 test(function() {
-  assert_throws(null, () => { new ScaleTransformComponent(); });
-  assert_throws(null, () => { new ScaleTransformComponent(1); });
-}, "Test that invalid number of arguments for ScaleTransformComponent throws an exception.");
+  assert_throws(null, () => { new Scale(); });
+  assert_throws(null, () => { new Scale(1); });
+}, "Test that invalid number of arguments for Scale throws an exception.");
 
 test(function() {
-  assert_throws(null, () => { new ScaleTransformComponent(NaN, 0); });
-  assert_throws(null, () => { new ScaleTransformComponent(0, NaN); });
-  assert_throws(null, () => { new ScaleTransformComponent(NaN, NaN); });
-  assert_throws(null, () => { new ScaleTransformComponent(Infinity, 0); });
-  assert_throws(null, () => { new ScaleTransformComponent(-Infinity, 0); });
-  assert_throws(null, () => { new ScaleTransformComponent("hello", 0); });
-  assert_throws(null, () => { new ScaleTransformComponent(0, "world"); });
-  assert_throws(null, () => { new ScaleTransformComponent(undefined, 0); });
-  assert_throws(null, () => { new ScaleTransformComponent({}, {}); });
+  assert_throws(null, () => { new Scale(NaN, 0); });
+  assert_throws(null, () => { new Scale(0, NaN); });
+  assert_throws(null, () => { new Scale(NaN, NaN); });
+  assert_throws(null, () => { new Scale(Infinity, 0); });
+  assert_throws(null, () => { new Scale(-Infinity, 0); });
+  assert_throws(null, () => { new Scale("hello", 0); });
+  assert_throws(null, () => { new Scale(0, "world"); });
+  assert_throws(null, () => { new Scale(undefined, 0); });
+  assert_throws(null, () => { new Scale({}, {}); });
 
-  assert_throws(null, () => { new ScaleTransformComponent("hello", 0, 0); });
-  assert_throws(null, () => { new ScaleTransformComponent(0, NaN, 0); });
-  assert_throws(null, () => { new ScaleTransformComponent(0, Infinity, 0); });
-  assert_throws(null, () => { new ScaleTransformComponent(0, 0, NaN); });
-  assert_throws(null, () => { new ScaleTransformComponent(0, 0, Infinity); });
-  assert_throws(null, () => { new ScaleTransformComponent(0, 0, -Infinity); });
-  assert_throws(null, () => { new ScaleTransformComponent(0, 0, undefined); });
-  assert_throws(null, () => { new ScaleTransformComponent(undefined, undefined, 0); });
-  assert_throws(null, () => { new ScaleTransformComponent(NaN, undefined, 0); });
-  assert_throws(null, () => { new ScaleTransformComponent(NaN, 0, NaN); });
-  assert_throws(null, () => { new ScaleTransformComponent(0, "hello", "world"); });
-  assert_throws(null, () => { new ScaleTransformComponent(0, {}, {}); });
-  assert_throws(null, () => { new ScaleTransformComponent({}, {}, {}); });
-  assert_throws(null, () => { new ScaleTransformComponent(NaN, NaN, NaN); });
+  assert_throws(null, () => { new Scale("hello", 0, 0); });
+  assert_throws(null, () => { new Scale(0, NaN, 0); });
+  assert_throws(null, () => { new Scale(0, Infinity, 0); });
+  assert_throws(null, () => { new Scale(0, 0, NaN); });
+  assert_throws(null, () => { new Scale(0, 0, Infinity); });
+  assert_throws(null, () => { new Scale(0, 0, -Infinity); });
+  assert_throws(null, () => { new Scale(0, 0, undefined); });
+  assert_throws(null, () => { new Scale(undefined, undefined, 0); });
+  assert_throws(null, () => { new Scale(NaN, undefined, 0); });
+  assert_throws(null, () => { new Scale(NaN, 0, NaN); });
+  assert_throws(null, () => { new Scale(0, "hello", "world"); });
+  assert_throws(null, () => { new Scale(0, {}, {}); });
+  assert_throws(null, () => { new Scale({}, {}, {}); });
+  assert_throws(null, () => { new Scale(NaN, NaN, NaN); });
 }, "Test that invalid input throws an exception.");
 
 </script>
diff --git a/third_party/WebKit/LayoutTests/typedcssom/skewTransformComponent.html b/third_party/WebKit/LayoutTests/typedcssom/skewTransformComponent.html
index 0ce82abe..4e53bcf 100644
--- a/third_party/WebKit/LayoutTests/typedcssom/skewTransformComponent.html
+++ b/third_party/WebKit/LayoutTests/typedcssom/skewTransformComponent.html
@@ -4,10 +4,10 @@
 
 <script>
 var values = [
-  {input: new SkewTransformComponent(0, 0), ax: 0, ay: 0, cssString: "skew(0, 0)"},
-  {input: new SkewTransformComponent(1, 2), ax: 1, ay: 2, cssString: "skew(1, 2)"},
-  {input: new SkewTransformComponent(-2, -4), ax: -2, ay: -4, cssString: "skew(-2, -4)"},
-  {input: new SkewTransformComponent(3.4, 2.7), ax: 3.4, ay: 2.7, cssString: "skew(3.4, 2.7)"}
+  {input: new Skew(0, 0), ax: 0, ay: 0, cssString: "skew(0, 0)"},
+  {input: new Skew(1, 2), ax: 1, ay: 2, cssString: "skew(1, 2)"},
+  {input: new Skew(-2, -4), ax: -2, ay: -4, cssString: "skew(-2, -4)"},
+  {input: new Skew(3.4, 2.7), ax: 3.4, ay: 2.7, cssString: "skew(3.4, 2.7)"}
 ];
 
 test(function() {
@@ -15,23 +15,23 @@
     assert_equals(values[i].input.ax, values[i].ax);
     assert_equals(values[i].input.ay, values[i].ay);
   }
-}, "Test that the (ax, ay) values for SkewTransformComponent are correct.");
+}, "Test that the (ax, ay) values for Skew are correct.");
 
 test(function() {
   for (var i = 0; i < values.length; ++i) {
     assert_true(values[i].input.is2DComponent());
   }
-}, "Test that the is2DComponent values for SkewTransformComponent is correct.");
+}, "Test that the is2DComponent values for Skew is correct.");
 
 test(function() {
   for (var i = 0; i < values.length; ++i) {
     assert_equals(values[i].input.cssString, values[i].cssString);
   }
-}, "Test that the cssString for SkewTransformComponent is correct.");
+}, "Test that the cssString for Skew is correct.");
 
 test(function() {
-  assert_throws(null, function() { new SkewTransformComponent(); });
-  assert_throws(null, function() { new SkewTransformComponent(1); });
-}, "Test that invalid number of arguments for SkewTransformComponent throws an exception.");
+  assert_throws(null, function() { new Skew(); });
+  assert_throws(null, function() { new Skew(1); });
+}, "Test that invalid number of arguments for Skew throws an exception.");
 
 </script>
diff --git a/third_party/WebKit/LayoutTests/typedcssom/transformValue.html b/third_party/WebKit/LayoutTests/typedcssom/transformValue.html
index 375033a..bcbe434b 100644
--- a/third_party/WebKit/LayoutTests/typedcssom/transformValue.html
+++ b/third_party/WebKit/LayoutTests/typedcssom/transformValue.html
@@ -11,22 +11,22 @@
 }, "A TransformValue object can be constructed");
 
 test(function() {
-  var transformArray = [new ScaleTransformComponent(2,2),
-    new MatrixTransformComponent(1,1,1,1,1,1), new ScaleTransformComponent(5,6)];
+  var transformArray = [new Scale(2,2),
+    new Matrix(1,1,1,1,1,1), new Scale(5,6)];
   var transformValue = new TransformValue(transformArray);
   assert_true(transformValue.is2D());
 }, "is2D returns true for transformValues containing only 2D transformComponents");
 
 test(function() {
-  var transformArray = [new ScaleTransformComponent(2,2),
-    new MatrixTransformComponent(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), new ScaleTransformComponent(5,6)];
+  var transformArray = [new Scale(2,2),
+    new Matrix(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), new Scale(5,6)];
   var transformValue = new TransformValue(transformArray);
   assert_false(transformValue.is2D());
 }, "is2D returns false for transformValues containing both 2D and 3D transformComponents");
 
 test(function() {
-  var transformArray = [new ScaleTransformComponent(2,2),
-    new MatrixTransformComponent(1,1,1,1,1,1), new ScaleTransformComponent(5,6)];
+  var transformArray = [new Scale(2,2),
+    new Matrix(1,1,1,1,1,1), new Scale(5,6)];
   var transformValue = new TransformValue(transformArray);
 
   var newTransformArray = [];
@@ -34,9 +34,9 @@
     newTransformArray.push(component);
   }
   assert_true(newTransformArray.length == 3);
-  assert_true(newTransformArray[0] instanceof ScaleTransformComponent);
-  assert_true(newTransformArray[1] instanceof MatrixTransformComponent);
-  assert_true(newTransformArray[2] instanceof ScaleTransformComponent);
+  assert_true(newTransformArray[0] instanceof Scale);
+  assert_true(newTransformArray[1] instanceof Matrix);
+  assert_true(newTransformArray[2] instanceof Scale);
 }, "TransformValue can iterate through all its all its transformComponent members");
 
 </script>
diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
index 4baa3b1..485914b 100644
--- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
+++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
@@ -3249,7 +3249,7 @@
     method constructor
     method open
     setter onstatechange
-interface MatrixTransformComponent : TransformComponent
+interface Matrix : TransformComponent
     getter a
     getter b
     getter c
@@ -3867,7 +3867,7 @@
     method request
     method requestAll
     method revoke
-interface PerspectiveTransformComponent : TransformComponent
+interface Perspective : TransformComponent
     getter length
     method constructor
 interface Plugin
@@ -4065,7 +4065,7 @@
     method constructor
     method json
     method text
-interface RotationTransformComponent : TransformComponent
+interface Rotation : TransformComponent
     getter angle
     getter x
     getter y
@@ -5070,7 +5070,7 @@
     getter previousTranslate
     getter zoomRectScreen
     method constructor
-interface ScaleTransformComponent : TransformComponent
+interface Scale : TransformComponent
     getter x
     getter y
     getter z
@@ -5219,7 +5219,7 @@
     getter value
     method constructor
     setter value
-interface SkewTransformComponent : TransformComponent
+interface Skew : TransformComponent
     getter ax
     getter ay
     method constructor
diff --git a/third_party/WebKit/Source/devtools/scripts/rjsmin.py b/third_party/WebKit/Source/build/scripts/rjsmin.py
similarity index 100%
rename from third_party/WebKit/Source/devtools/scripts/rjsmin.py
rename to third_party/WebKit/Source/build/scripts/rjsmin.py
diff --git a/third_party/WebKit/Source/core/BUILD.gn b/third_party/WebKit/Source/core/BUILD.gn
index 1f20d25..b17343c 100644
--- a/third_party/WebKit/Source/core/BUILD.gn
+++ b/third_party/WebKit/Source/core/BUILD.gn
@@ -51,7 +51,6 @@
     ":prerequisites",
     "inspector:instrumentation_sources",
     "inspector:protocol_sources",
-    "inspector/v8:injected_script_sources",
     "//gin",
     "//skia",
     "//third_party/WebKit/Source/bindings/core/v8:bindings_core_v8_generated",
@@ -100,7 +99,6 @@
     ":make_core_generated",
     "inspector:instrumentation_sources",
     "inspector:protocol_sources",
-    "inspector/v8:injected_script_sources",
     "//third_party/WebKit/Source/bindings/core/v8:bindings_core_v8_generated",
 
     # FIXME: don't depend on bindings_modules http://crbug.com/358074
@@ -400,10 +398,6 @@
     "$blink_core_output_dir/InspectorOverridesInl.h",
     "$blink_core_output_dir/InstrumentingAgentsInl.h",
 
-    # Additional files from injected_script_sources list.
-    "$blink_core_output_dir/inspector/v8/DebuggerScript.h",
-    "$blink_core_output_dir/inspector/v8/InjectedScriptSource.h",
-
     # Additional .cpp files for SVG.
     "$blink_core_output_dir/SVGElementFactory.cpp",
 
@@ -428,7 +422,6 @@
     ":prerequisites",
     "inspector:instrumentation_sources",
     "inspector:protocol_sources",
-    "inspector/v8:injected_script_sources",
     "//gin",
     "//skia",
     "//third_party/WebKit/Source/bindings/core/v8:bindings_core_v8_generated",
diff --git a/third_party/WebKit/Source/core/core.gyp b/third_party/WebKit/Source/core/core.gyp
index 28361dc..1272f45 100644
--- a/third_party/WebKit/Source/core/core.gyp
+++ b/third_party/WebKit/Source/core/core.gyp
@@ -169,9 +169,8 @@
       'dependencies': [
         'webcore_prerequisites',
         'core_generated.gyp:make_core_generated',
-        'inspector_instrumentation_sources',
         'inspector_protocol_sources',
-        'inspector/v8/v8_inspector.gyp:injected_script_sources',
+        'inspector_instrumentation_sources',
         '../bindings/core/v8/generated.gyp:bindings_core_v8_generated',
         # FIXME: don't depend on bindings_modules http://crbug.com/358074
         '../bindings/modules/generated.gyp:modules_event_generated',
@@ -235,9 +234,8 @@
       'target_name': 'webcore_prerequisites',
       'type': 'none',
       'dependencies': [
-        'inspector_instrumentation_sources',
         'inspector_protocol_sources',
-        'inspector/v8/v8_inspector.gyp:injected_script_sources',
+        'inspector_instrumentation_sources',
         'core_generated.gyp:make_core_generated',
         '../bindings/core/v8/generated.gyp:bindings_core_v8_generated',
         # FIXME: don't depend on bindings_modules http://crbug.com/358074
@@ -651,9 +649,8 @@
 
         # webcore_generated dependency
         'core_generated.gyp:make_core_generated',
-        'inspector_instrumentation_sources',
         'inspector_protocol_sources',
-        'inspector/v8/v8_inspector.gyp:injected_script_sources',
+        'inspector_instrumentation_sources',
         '../bindings/core/v8/generated.gyp:bindings_core_v8_generated',
         # FIXME: don't depend on bindings_modules http://crbug.com/358074
         '../bindings/modules/generated.gyp:modules_event_generated',
diff --git a/third_party/WebKit/Source/core/core.gypi b/third_party/WebKit/Source/core/core.gypi
index b3c6a1ad..778bf9a 100644
--- a/third_party/WebKit/Source/core/core.gypi
+++ b/third_party/WebKit/Source/core/core.gypi
@@ -42,14 +42,14 @@
             'css/cssom/CalcLength.idl',
             'css/cssom/KeywordValue.idl',
             'css/cssom/LengthValue.idl',
-            'css/cssom/MatrixTransformComponent.idl',
+            'css/cssom/Matrix.idl',
             'css/cssom/NumberValue.idl',
-            'css/cssom/PerspectiveTransformComponent.idl',
+            'css/cssom/Perspective.idl',
             'css/cssom/PositionValue.idl',
-            'css/cssom/RotationTransformComponent.idl',
-            'css/cssom/ScaleTransformComponent.idl',
+            'css/cssom/Rotation.idl',
+            'css/cssom/Scale.idl',
             'css/cssom/SimpleLength.idl',
-            'css/cssom/SkewTransformComponent.idl',
+            'css/cssom/Skew.idl',
             'css/cssom/StylePropertyMap.idl',
             'css/cssom/StyleValue.idl',
             'css/cssom/TransformComponent.idl',
@@ -1813,16 +1813,6 @@
             'inspector/ScriptArguments.h',
             'inspector/ThreadDebugger.cpp',
             'inspector/ThreadDebugger.h',
-            'inspector/WorkerConsoleAgent.cpp',
-            'inspector/WorkerConsoleAgent.h',
-            'inspector/WorkerDebuggerAgent.cpp',
-            'inspector/WorkerDebuggerAgent.h',
-            'inspector/WorkerInspectorController.cpp',
-            'inspector/WorkerInspectorController.h',
-            'inspector/WorkerRuntimeAgent.cpp',
-            'inspector/WorkerRuntimeAgent.h',
-            'inspector/WorkerThreadDebugger.cpp',
-            'inspector/WorkerThreadDebugger.h',
             'inspector/v8/AsyncCallChain.cpp',
             'inspector/v8/AsyncCallChain.h',
             'inspector/v8/EventListenerInfo.h',
@@ -1877,6 +1867,16 @@
             'inspector/v8/V8StackTraceImpl.h',
             'inspector/v8/V8StringUtil.cpp',
             'inspector/v8/V8StringUtil.h',
+            'inspector/WorkerConsoleAgent.cpp',
+            'inspector/WorkerConsoleAgent.h',
+            'inspector/WorkerDebuggerAgent.cpp',
+            'inspector/WorkerDebuggerAgent.h',
+            'inspector/WorkerInspectorController.cpp',
+            'inspector/WorkerInspectorController.h',
+            'inspector/WorkerRuntimeAgent.cpp',
+            'inspector/WorkerRuntimeAgent.h',
+            'inspector/WorkerThreadDebugger.cpp',
+            'inspector/WorkerThreadDebugger.h',
             'loader/BeaconLoader.cpp',
             'loader/BeaconLoader.h',
             'loader/CookieJar.cpp',
diff --git a/third_party/WebKit/Source/core/core_generated.gypi b/third_party/WebKit/Source/core/core_generated.gypi
index c07b12f..190a07c 100644
--- a/third_party/WebKit/Source/core/core_generated.gypi
+++ b/third_party/WebKit/Source/core/core_generated.gypi
@@ -110,10 +110,6 @@
       '<(blink_core_output_dir)/InstrumentingAgentsInl.h',
       '<(blink_core_output_dir)/InspectorInstrumentationImpl.cpp',
 
-      # Additional files from injected_script_sources list.
-      '<(blink_core_output_dir)/inspector/v8/DebuggerScript.h',
-      '<(blink_core_output_dir)/inspector/v8/InjectedScriptSource.h',
-
       # Additional .cpp files for SVG.
       '<(blink_core_output_dir)/SVGElementFactory.cpp',
 
diff --git a/third_party/WebKit/Source/core/css/MediaValues.cpp b/third_party/WebKit/Source/core/css/MediaValues.cpp
index 68364f6d..661e914a 100644
--- a/third_party/WebKit/Source/core/css/MediaValues.cpp
+++ b/third_party/WebKit/Source/core/css/MediaValues.cpp
@@ -31,21 +31,21 @@
     return MediaValuesCached::create();
 }
 
-double MediaValues::calculateViewportWidth(LocalFrame* frame)
+double MediaValues::calculateViewportWidth(LocalFrame* frame) const
 {
     ASSERT(frame && frame->view() && frame->document());
     int viewportWidth = frame->view()->layoutSize(IncludeScrollbars).width();
     return adjustDoubleForAbsoluteZoom(viewportWidth, *frame->document()->layoutView());
 }
 
-double MediaValues::calculateViewportHeight(LocalFrame* frame)
+double MediaValues::calculateViewportHeight(LocalFrame* frame) const
 {
     ASSERT(frame && frame->view() && frame->document());
     int viewportHeight = frame->view()->layoutSize(IncludeScrollbars).height();
     return adjustDoubleForAbsoluteZoom(viewportHeight, *frame->document()->layoutView());
 }
 
-int MediaValues::calculateDeviceWidth(LocalFrame* frame)
+int MediaValues::calculateDeviceWidth(LocalFrame* frame) const
 {
     ASSERT(frame && frame->view() && frame->settings() && frame->host());
     int deviceWidth = frame->host()->chromeClient().screenInfo().rect.width;
@@ -54,7 +54,7 @@
     return deviceWidth;
 }
 
-int MediaValues::calculateDeviceHeight(LocalFrame* frame)
+int MediaValues::calculateDeviceHeight(LocalFrame* frame) const
 {
     ASSERT(frame && frame->view() && frame->settings() && frame->host());
     int deviceHeight = frame->host()->chromeClient().screenInfo().rect.height;
@@ -63,18 +63,18 @@
     return deviceHeight;
 }
 
-bool MediaValues::calculateStrictMode(LocalFrame* frame)
+bool MediaValues::calculateStrictMode(LocalFrame* frame) const
 {
     ASSERT(frame && frame->document());
     return !frame->document()->inQuirksMode();
 }
 
-float MediaValues::calculateDevicePixelRatio(LocalFrame* frame)
+float MediaValues::calculateDevicePixelRatio(LocalFrame* frame) const
 {
     return frame->devicePixelRatio();
 }
 
-int MediaValues::calculateColorBitsPerComponent(LocalFrame* frame)
+int MediaValues::calculateColorBitsPerComponent(LocalFrame* frame) const
 {
     ASSERT(frame && frame->page() && frame->page()->mainFrame());
     if (!frame->page()->mainFrame()->isLocalFrame()
@@ -83,7 +83,7 @@
     return frame->host()->chromeClient().screenInfo().depthPerComponent;
 }
 
-int MediaValues::calculateMonochromeBitsPerComponent(LocalFrame* frame)
+int MediaValues::calculateMonochromeBitsPerComponent(LocalFrame* frame) const
 {
     ASSERT(frame && frame->page() && frame->page()->mainFrame());
     if (!frame->page()->mainFrame()->isLocalFrame()
@@ -92,12 +92,12 @@
     return frame->host()->chromeClient().screenInfo().depthPerComponent;
 }
 
-int MediaValues::calculateDefaultFontSize(LocalFrame* frame)
+int MediaValues::calculateDefaultFontSize(LocalFrame* frame) const
 {
     return frame->host()->settings().defaultFontSize();
 }
 
-const String MediaValues::calculateMediaType(LocalFrame* frame)
+const String MediaValues::calculateMediaType(LocalFrame* frame) const
 {
     ASSERT(frame);
     if (!frame->view())
@@ -105,7 +105,7 @@
     return frame->view()->mediaType();
 }
 
-WebDisplayMode MediaValues::calculateDisplayMode(LocalFrame* frame)
+WebDisplayMode MediaValues::calculateDisplayMode(LocalFrame* frame) const
 {
     ASSERT(frame);
     WebDisplayMode mode = frame->host()->settings().displayModeOverride();
@@ -119,7 +119,7 @@
     return frame->view()->displayMode();
 }
 
-bool MediaValues::calculateThreeDEnabled(LocalFrame* frame)
+bool MediaValues::calculateThreeDEnabled(LocalFrame* frame) const
 {
     ASSERT(frame && frame->contentLayoutObject() && frame->contentLayoutObject()->compositor());
     bool threeDEnabled = false;
@@ -128,25 +128,25 @@
     return threeDEnabled;
 }
 
-PointerType MediaValues::calculatePrimaryPointerType(LocalFrame* frame)
+PointerType MediaValues::calculatePrimaryPointerType(LocalFrame* frame) const
 {
     ASSERT(frame && frame->settings());
     return frame->settings()->primaryPointerType();
 }
 
-int MediaValues::calculateAvailablePointerTypes(LocalFrame* frame)
+int MediaValues::calculateAvailablePointerTypes(LocalFrame* frame) const
 {
     ASSERT(frame && frame->settings());
     return frame->settings()->availablePointerTypes();
 }
 
-HoverType MediaValues::calculatePrimaryHoverType(LocalFrame* frame)
+HoverType MediaValues::calculatePrimaryHoverType(LocalFrame* frame) const
 {
     ASSERT(frame && frame->settings());
     return frame->settings()->primaryHoverType();
 }
 
-int MediaValues::calculateAvailableHoverTypes(LocalFrame* frame)
+int MediaValues::calculateAvailableHoverTypes(LocalFrame* frame) const
 {
     ASSERT(frame && frame->settings());
     return frame->settings()->availableHoverTypes();
diff --git a/third_party/WebKit/Source/core/css/MediaValues.h b/third_party/WebKit/Source/core/css/MediaValues.h
index 0ef86070..498d41ef 100644
--- a/third_party/WebKit/Source/core/css/MediaValues.h
+++ b/third_party/WebKit/Source/core/css/MediaValues.h
@@ -59,22 +59,22 @@
     virtual bool hasValues() const = 0;
 
 protected:
-    static double calculateViewportWidth(LocalFrame*);
-    static double calculateViewportHeight(LocalFrame*);
-    static int calculateDeviceWidth(LocalFrame*);
-    static int calculateDeviceHeight(LocalFrame*);
-    static bool calculateStrictMode(LocalFrame*);
-    static float calculateDevicePixelRatio(LocalFrame*);
-    static int calculateColorBitsPerComponent(LocalFrame*);
-    static int calculateMonochromeBitsPerComponent(LocalFrame*);
-    static int calculateDefaultFontSize(LocalFrame*);
-    static const String calculateMediaType(LocalFrame*);
-    static WebDisplayMode calculateDisplayMode(LocalFrame*);
-    static bool calculateThreeDEnabled(LocalFrame*);
-    static PointerType calculatePrimaryPointerType(LocalFrame*);
-    static int calculateAvailablePointerTypes(LocalFrame*);
-    static HoverType calculatePrimaryHoverType(LocalFrame*);
-    static int calculateAvailableHoverTypes(LocalFrame*);
+    double calculateViewportWidth(LocalFrame*) const;
+    double calculateViewportHeight(LocalFrame*) const;
+    int calculateDeviceWidth(LocalFrame*) const;
+    int calculateDeviceHeight(LocalFrame*) const;
+    bool calculateStrictMode(LocalFrame*) const;
+    float calculateDevicePixelRatio(LocalFrame*) const;
+    int calculateColorBitsPerComponent(LocalFrame*) const;
+    int calculateMonochromeBitsPerComponent(LocalFrame*) const;
+    int calculateDefaultFontSize(LocalFrame*) const;
+    const String calculateMediaType(LocalFrame*) const;
+    WebDisplayMode calculateDisplayMode(LocalFrame*) const;
+    bool calculateThreeDEnabled(LocalFrame*) const;
+    PointerType calculatePrimaryPointerType(LocalFrame*) const;
+    int calculateAvailablePointerTypes(LocalFrame*) const;
+    HoverType calculatePrimaryHoverType(LocalFrame*) const;
+    int calculateAvailableHoverTypes(LocalFrame*) const;
     static LocalFrame* frameFrom(Document&);
 
 };
diff --git a/third_party/WebKit/Source/core/css/MediaValuesCached.cpp b/third_party/WebKit/Source/core/css/MediaValuesCached.cpp
index 75c3a53..3fd8c56 100644
--- a/third_party/WebKit/Source/core/css/MediaValuesCached.cpp
+++ b/third_party/WebKit/Source/core/css/MediaValuesCached.cpp
@@ -11,51 +11,61 @@
 
 namespace blink {
 
-MediaValuesCached::MediaValuesCachedData::MediaValuesCachedData(Document& document)
-    : MediaValuesCached::MediaValuesCachedData()
-{
-    ASSERT(isMainThread());
-    LocalFrame* frame = MediaValues::frameFrom(document);
-    // TODO(hiroshige): Clean up |frame->view()| conditions.
-    ASSERT(!frame || frame->view());
-    if (frame && frame->view()) {
-        ASSERT(frame->document() && frame->document()->layoutView());
-
-        // In case that frame is missing (e.g. for images that their document does not have a frame)
-        // We simply leave the MediaValues object with the default MediaValuesCachedData values.
-        viewportWidth = MediaValues::calculateViewportWidth(frame);
-        viewportHeight = MediaValues::calculateViewportHeight(frame);
-        deviceWidth = MediaValues::calculateDeviceWidth(frame);
-        deviceHeight = MediaValues::calculateDeviceHeight(frame);
-        devicePixelRatio = MediaValues::calculateDevicePixelRatio(frame);
-        colorBitsPerComponent = MediaValues::calculateColorBitsPerComponent(frame);
-        monochromeBitsPerComponent = MediaValues::calculateMonochromeBitsPerComponent(frame);
-        primaryPointerType = MediaValues::calculatePrimaryPointerType(frame);
-        availablePointerTypes = MediaValues::calculateAvailablePointerTypes(frame);
-        primaryHoverType = MediaValues::calculatePrimaryHoverType(frame);
-        availableHoverTypes = MediaValues::calculateAvailableHoverTypes(frame);
-        defaultFontSize = MediaValues::calculateDefaultFontSize(frame);
-        threeDEnabled = MediaValues::calculateThreeDEnabled(frame);
-        strictMode = MediaValues::calculateStrictMode(frame);
-        displayMode = MediaValues::calculateDisplayMode(frame);
-        mediaType = MediaValues::calculateMediaType(frame);
-    }
-}
-
 PassRefPtrWillBeRawPtr<MediaValuesCached> MediaValuesCached::create()
 {
     return adoptRefWillBeNoop(new MediaValuesCached());
 }
 
-PassRefPtrWillBeRawPtr<MediaValuesCached> MediaValuesCached::create(const MediaValuesCachedData& data)
+PassRefPtrWillBeRawPtr<MediaValuesCached> MediaValuesCached::create(MediaValuesCachedData& data)
 {
     return adoptRefWillBeNoop(new MediaValuesCached(data));
 }
 
+PassRefPtrWillBeRawPtr<MediaValuesCached> MediaValuesCached::create(Document& document)
+{
+    return MediaValuesCached::create(frameFrom(document));
+}
+
+PassRefPtrWillBeRawPtr<MediaValuesCached> MediaValuesCached::create(LocalFrame* frame)
+{
+    // FIXME - Added an assert here so we can better understand when a frame is present without its view().
+    ASSERT(!frame || frame->view());
+    if (!frame || !frame->view())
+        return adoptRefWillBeNoop(new MediaValuesCached());
+    ASSERT(frame->document() && frame->document()->layoutView());
+    return adoptRefWillBeNoop(new MediaValuesCached(frame));
+}
+
 MediaValuesCached::MediaValuesCached()
 {
 }
 
+MediaValuesCached::MediaValuesCached(LocalFrame* frame)
+{
+    ASSERT(isMainThread());
+    ASSERT(frame);
+    // In case that frame is missing (e.g. for images that their document does not have a frame)
+    // We simply leave the MediaValues object with the default MediaValuesCachedData values.
+    m_data.viewportWidth = calculateViewportWidth(frame);
+    m_data.viewportHeight = calculateViewportHeight(frame);
+    m_data.deviceWidth = calculateDeviceWidth(frame);
+    m_data.deviceHeight = calculateDeviceHeight(frame);
+    m_data.devicePixelRatio = calculateDevicePixelRatio(frame);
+    m_data.colorBitsPerComponent = calculateColorBitsPerComponent(frame);
+    m_data.monochromeBitsPerComponent = calculateMonochromeBitsPerComponent(frame);
+    m_data.primaryPointerType = calculatePrimaryPointerType(frame);
+    m_data.availablePointerTypes = calculateAvailablePointerTypes(frame);
+    m_data.primaryHoverType = calculatePrimaryHoverType(frame);
+    m_data.availableHoverTypes = calculateAvailableHoverTypes(frame);
+    m_data.defaultFontSize = calculateDefaultFontSize(frame);
+    m_data.threeDEnabled = calculateThreeDEnabled(frame);
+    m_data.strictMode = calculateStrictMode(frame);
+    m_data.displayMode = calculateDisplayMode(frame);
+    const String mediaType = calculateMediaType(frame);
+    if (!mediaType.isEmpty())
+        m_data.mediaType = mediaType.isolatedCopy();
+}
+
 MediaValuesCached::MediaValuesCached(const MediaValuesCachedData& data)
     : m_data(data)
 {
@@ -76,6 +86,19 @@
     return MediaValues::computeLength(value, type, m_data.defaultFontSize, m_data.viewportWidth, m_data.viewportHeight, result);
 }
 
+bool MediaValuesCached::isSafeToSendToAnotherThread() const
+{
+#if ENABLE(OILPAN)
+    // Oilpan objects are safe to send to another thread as long as the thread
+    // does not outlive the thread used for creation. MediaValues are
+    // allocated on the main thread and may be passed to the parser thread,
+    // so this should be safe.
+    return true;
+#else
+    return hasOneRef();
+#endif
+}
+
 double MediaValuesCached::viewportWidth() const
 {
     return m_data.viewportWidth;
diff --git a/third_party/WebKit/Source/core/css/MediaValuesCached.h b/third_party/WebKit/Source/core/css/MediaValuesCached.h
index 50b1a5a..53c6734 100644
--- a/third_party/WebKit/Source/core/css/MediaValuesCached.h
+++ b/third_party/WebKit/Source/core/css/MediaValuesCached.h
@@ -12,7 +12,7 @@
 
 class CORE_EXPORT MediaValuesCached final : public MediaValues {
 public:
-    struct MediaValuesCachedData final {
+    struct MediaValuesCachedData {
         DISALLOW_NEW();
         // Members variables must be thread safe, since they're copied to the parser thread
         double viewportWidth;
@@ -50,35 +50,14 @@
             , displayMode(WebDisplayModeBrowser)
         {
         }
-
-        explicit MediaValuesCachedData(Document&);
-
-        MediaValuesCachedData deepCopy() const
-        {
-            MediaValuesCachedData data;
-            data.viewportWidth = viewportWidth;
-            data.viewportHeight = viewportHeight;
-            data.deviceWidth = deviceWidth;
-            data.deviceHeight = deviceHeight;
-            data.devicePixelRatio = devicePixelRatio;
-            data.colorBitsPerComponent = colorBitsPerComponent;
-            data.monochromeBitsPerComponent = monochromeBitsPerComponent;
-            data.primaryPointerType = primaryPointerType;
-            data.availablePointerTypes = availablePointerTypes;
-            data.primaryHoverType = primaryHoverType;
-            data.availableHoverTypes = availableHoverTypes;
-            data.defaultFontSize = defaultFontSize;
-            data.threeDEnabled = threeDEnabled;
-            data.strictMode = strictMode;
-            data.mediaType = mediaType.isolatedCopy();
-            data.displayMode = displayMode;
-            return data;
-        }
     };
 
     static PassRefPtrWillBeRawPtr<MediaValuesCached> create();
-    static PassRefPtrWillBeRawPtr<MediaValuesCached> create(const MediaValuesCachedData&);
+    static PassRefPtrWillBeRawPtr<MediaValuesCached> create(Document&);
+    static PassRefPtrWillBeRawPtr<MediaValuesCached> create(LocalFrame*);
+    static PassRefPtrWillBeRawPtr<MediaValuesCached> create(MediaValuesCachedData&);
     PassRefPtrWillBeRawPtr<MediaValues> copy() const override;
+    bool isSafeToSendToAnotherThread() const;
     bool computeLength(double value, CSSPrimitiveValue::UnitType, int& result) const override;
     bool computeLength(double value, CSSPrimitiveValue::UnitType, double& result) const override;
 
@@ -111,11 +90,6 @@
     MediaValuesCachedData m_data;
 };
 
-template<> struct CrossThreadCopierBase<false, false, false, MediaValuesCached::MediaValuesCachedData> {
-    typedef MediaValuesCached::MediaValuesCachedData Type;
-    static Type copy(const MediaValuesCached::MediaValuesCachedData& data) { return data.deepCopy(); }
-};
-
 } // namespace blink
 
 #endif // MediaValuesCached_h
diff --git a/third_party/WebKit/Source/core/css/cssom/MatrixTransformComponent.idl b/third_party/WebKit/Source/core/css/cssom/Matrix.idl
similarity index 93%
rename from third_party/WebKit/Source/core/css/cssom/MatrixTransformComponent.idl
rename to third_party/WebKit/Source/core/css/cssom/Matrix.idl
index 918de3a..92b12a8 100644
--- a/third_party/WebKit/Source/core/css/cssom/MatrixTransformComponent.idl
+++ b/third_party/WebKit/Source/core/css/cssom/Matrix.idl
@@ -8,8 +8,9 @@
         double m21, double m22, double m23, double m24,
         double m31, double m32, double m33, double m34,
         double m41, double m42, double m43, double m44),
+    ImplementedAs=MatrixTransformComponent,
     RuntimeEnabled=CSSTypedOM
-] interface MatrixTransformComponent : TransformComponent {
+] interface Matrix : TransformComponent {
     readonly attribute double a;
     readonly attribute double b;
     readonly attribute double c;
diff --git a/third_party/WebKit/Source/core/css/cssom/PerspectiveTransformComponent.idl b/third_party/WebKit/Source/core/css/cssom/Perspective.idl
similarity index 76%
rename from third_party/WebKit/Source/core/css/cssom/PerspectiveTransformComponent.idl
rename to third_party/WebKit/Source/core/css/cssom/Perspective.idl
index 9e5209f..6baedaa 100644
--- a/third_party/WebKit/Source/core/css/cssom/PerspectiveTransformComponent.idl
+++ b/third_party/WebKit/Source/core/css/cssom/Perspective.idl
@@ -4,8 +4,9 @@
 
 [
     Constructor(LengthValue length),
+    ImplementedAs=PerspectiveTransformComponent,
     RuntimeEnabled=CSSTypedOM,
     RaisesException=Constructor
-] interface PerspectiveTransformComponent : TransformComponent {
+] interface Perspective : TransformComponent {
     readonly attribute LengthValue length;
 };
diff --git a/third_party/WebKit/Source/core/css/cssom/RotationTransformComponent.idl b/third_party/WebKit/Source/core/css/cssom/Rotation.idl
similarity index 82%
rename from third_party/WebKit/Source/core/css/cssom/RotationTransformComponent.idl
rename to third_party/WebKit/Source/core/css/cssom/Rotation.idl
index bbb4d963..7a81cdb 100644
--- a/third_party/WebKit/Source/core/css/cssom/RotationTransformComponent.idl
+++ b/third_party/WebKit/Source/core/css/cssom/Rotation.idl
@@ -5,8 +5,9 @@
 [
     Constructor(double angle),
     Constructor(double angle, double x, double y, double z),
+    ImplementedAs=RotationTransformComponent,
     RuntimeEnabled=CSSTypedOM
-] interface RotationTransformComponent : TransformComponent {
+] interface Rotation : TransformComponent {
     readonly attribute double angle;
     readonly attribute double x;
     readonly attribute double y;
diff --git a/third_party/WebKit/Source/core/css/cssom/ScaleTransformComponent.idl b/third_party/WebKit/Source/core/css/cssom/Scale.idl
similarity index 81%
rename from third_party/WebKit/Source/core/css/cssom/ScaleTransformComponent.idl
rename to third_party/WebKit/Source/core/css/cssom/Scale.idl
index 82b0e25..22ec20d 100644
--- a/third_party/WebKit/Source/core/css/cssom/ScaleTransformComponent.idl
+++ b/third_party/WebKit/Source/core/css/cssom/Scale.idl
@@ -5,8 +5,9 @@
 [
     Constructor(double x, double y),
     Constructor(double x, double y, double z),
+    ImplementedAs=ScaleTransformComponent,
     RuntimeEnabled=CSSTypedOM
-] interface ScaleTransformComponent : TransformComponent {
+] interface Scale : TransformComponent {
     readonly attribute double x;
     readonly attribute double y;
     readonly attribute double z;
diff --git a/third_party/WebKit/Source/core/css/cssom/SkewTransformComponent.idl b/third_party/WebKit/Source/core/css/cssom/Skew.idl
similarity index 78%
rename from third_party/WebKit/Source/core/css/cssom/SkewTransformComponent.idl
rename to third_party/WebKit/Source/core/css/cssom/Skew.idl
index dab9221..5755f2b 100644
--- a/third_party/WebKit/Source/core/css/cssom/SkewTransformComponent.idl
+++ b/third_party/WebKit/Source/core/css/cssom/Skew.idl
@@ -4,8 +4,9 @@
 
 [
     Constructor(double ax, double ay),
+    ImplementedAs=SkewTransformComponent,
     RuntimeEnabled=CSSTypedOM
-] interface SkewTransformComponent : TransformComponent {
+] interface Skew : TransformComponent {
     readonly attribute double ax;
     readonly attribute double ay;
 };
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index 46adc212..d082a8ad 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -218,6 +218,7 @@
 #include "platform/weborigin/SecurityOrigin.h"
 #include "public/platform/Platform.h"
 #include "public/platform/WebFrameScheduler.h"
+#include "public/platform/WebScheduler.h"
 #include "wtf/CurrentTime.h"
 #include "wtf/DateMath.h"
 #include "wtf/Functional.h"
diff --git a/third_party/WebKit/Source/core/fetch/Resource.cpp b/third_party/WebKit/Source/core/fetch/Resource.cpp
index 4f671219..a3e1a0c 100644
--- a/third_party/WebKit/Source/core/fetch/Resource.cpp
+++ b/third_party/WebKit/Source/core/fetch/Resource.cpp
@@ -39,6 +39,7 @@
 #include "platform/weborigin/KURL.h"
 #include "public/platform/Platform.h"
 #include "public/platform/WebProcessMemoryDump.h"
+#include "public/platform/WebScheduler.h"
 #include "wtf/CurrentTime.h"
 #include "wtf/MathExtras.h"
 #include "wtf/StdLibExtras.h"
@@ -47,8 +48,6 @@
 #include "wtf/text/CString.h"
 #include <algorithm>
 
-using namespace WTF;
-
 namespace blink {
 
 // These response headers are not copied from a revalidated response to the
@@ -838,7 +837,7 @@
         ResourceClientWalker<ResourceClient> walker3(m_finishedClients);
         while (ResourceClient* client = walker3.next())
             clientNames.append("(finished) " + client->debugName());
-        std::sort(clientNames.begin(), clientNames.end(), codePointCompareLessThan);
+        std::sort(clientNames.begin(), clientNames.end(), WTF::codePointCompareLessThan);
 
         StringBuilder builder;
         for (size_t i = 0; i < clientNames.size() && i < kMaxResourceClientToShowInMemoryInfra; ++i) {
diff --git a/third_party/WebKit/Source/core/frame/LocalFrame.h b/third_party/WebKit/Source/core/frame/LocalFrame.h
index eb94293..9288d04 100644
--- a/third_party/WebKit/Source/core/frame/LocalFrame.h
+++ b/third_party/WebKit/Source/core/frame/LocalFrame.h
@@ -177,7 +177,7 @@
     // DisplayItemClient methods
     String debugName() const final { return "LocalFrame"; }
     // TODO(chrishtr): fix this.
-    IntRect visualRect() const override { return IntRect(); }
+    LayoutRect visualRect() const override { return LayoutRect(); }
 
     bool shouldThrottleRendering() const;
 
diff --git a/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp b/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp
index ceca5de..cd7165b9 100644
--- a/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp
+++ b/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp
@@ -80,9 +80,9 @@
 
 #endif
 
-void BackgroundHTMLParser::start(PassRefPtr<WeakReference<BackgroundHTMLParser>> reference, PassOwnPtr<Configuration> config, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> cachedDocumentParameters, const MediaValuesCached::MediaValuesCachedData& mediaValuesCachedData, PassOwnPtr<WebTaskRunner> loadingTaskRunner)
+void BackgroundHTMLParser::start(PassRefPtr<WeakReference<BackgroundHTMLParser>> reference, PassOwnPtr<Configuration> config, PassOwnPtr<WebTaskRunner> loadingTaskRunner)
 {
-    new BackgroundHTMLParser(reference, config, documentURL, cachedDocumentParameters, mediaValuesCachedData, loadingTaskRunner);
+    new BackgroundHTMLParser(reference, config, loadingTaskRunner);
     // Caller must free by calling stop().
 }
 
@@ -92,7 +92,7 @@
 {
 }
 
-BackgroundHTMLParser::BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser>> reference, PassOwnPtr<Configuration> config, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> cachedDocumentParameters, const MediaValuesCached::MediaValuesCachedData& mediaValuesCachedData, PassOwnPtr<WebTaskRunner> loadingTaskRunner)
+BackgroundHTMLParser::BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser>> reference, PassOwnPtr<Configuration> config, PassOwnPtr<WebTaskRunner> loadingTaskRunner)
     : m_weakFactory(reference, this)
     , m_token(adoptPtr(new HTMLToken))
     , m_tokenizer(HTMLTokenizer::create(config->options))
@@ -103,7 +103,7 @@
     , m_pendingTokens(adoptPtr(new CompactHTMLTokenStream))
     , m_pendingTokenLimit(config->pendingTokenLimit)
     , m_xssAuditor(config->xssAuditor.release())
-    , m_preloadScanner(adoptPtr(new TokenPreloadScanner(documentURL, cachedDocumentParameters, mediaValuesCachedData)))
+    , m_preloadScanner(config->preloadScanner.release())
     , m_decoder(config->decoder.release())
     , m_loadingTaskRunner(loadingTaskRunner)
     , m_parsedChunkQueue(config->parsedChunkQueue.release())
diff --git a/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.h b/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.h
index f1df65f..895e0ac 100644
--- a/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.h
+++ b/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.h
@@ -56,6 +56,7 @@
         HTMLParserOptions options;
         WeakPtr<HTMLDocumentParser> parser;
         OwnPtr<XSSAuditor> xssAuditor;
+        OwnPtr<TokenPreloadScanner> preloadScanner;
         OwnPtr<TextResourceDecoder> decoder;
         RefPtr<ParsedChunkQueue> parsedChunkQueue;
         // outstandingTokenLimit must be greater than or equal to
@@ -64,7 +65,7 @@
         size_t pendingTokenLimit;
     };
 
-    static void start(PassRefPtr<WeakReference<BackgroundHTMLParser>>, PassOwnPtr<Configuration>, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters>, const MediaValuesCached::MediaValuesCachedData&, PassOwnPtr<WebTaskRunner>);
+    static void start(PassRefPtr<WeakReference<BackgroundHTMLParser>>, PassOwnPtr<Configuration>, PassOwnPtr<WebTaskRunner>);
 
     struct Checkpoint {
         USING_FAST_MALLOC(Checkpoint);
@@ -91,7 +92,7 @@
     void forcePlaintextForTextDocument();
 
 private:
-    BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser>>, PassOwnPtr<Configuration>, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters>, const MediaValuesCached::MediaValuesCachedData&, PassOwnPtr<WebTaskRunner>);
+    BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser>>, PassOwnPtr<Configuration>, PassOwnPtr<WebTaskRunner>);
     ~BackgroundHTMLParser();
 
     void appendDecodedBytes(const String&);
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
index bd84b305..ce7ae53 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
+++ b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
@@ -687,11 +687,9 @@
         // adding paranoia if for speculative crash fix for crbug.com/465478
         if (m_preloader) {
             if (!m_preloadScanner) {
-                m_preloadScanner = HTMLPreloadScanner::create(
-                    m_options,
+                m_preloadScanner = adoptPtr(new HTMLPreloadScanner(m_options,
                     document()->url(),
-                    CachedDocumentParameters::create(document()),
-                    MediaValuesCached::MediaValuesCachedData(*document()));
+                    CachedDocumentParameters::create(document())));
                 m_preloadScanner->appendToEnd(m_input.current());
             }
             m_preloadScanner->scan(m_preloader.get(), document()->baseElementURL());
@@ -773,11 +771,9 @@
         // Check the document.write() output with a separate preload scanner as
         // the main scanner can't deal with insertions.
         if (!m_insertionPreloadScanner) {
-            m_insertionPreloadScanner = HTMLPreloadScanner::create(
-                m_options,
+            m_insertionPreloadScanner = adoptPtr(new HTMLPreloadScanner(m_options,
                 document()->url(),
-                CachedDocumentParameters::create(document()),
-                MediaValuesCached::MediaValuesCachedData(*document()));
+                CachedDocumentParameters::create(document())));
         }
 
         m_insertionPreloadScanner->appendToEnd(source);
@@ -814,6 +810,7 @@
     config->xssAuditor = adoptPtr(new XSSAuditor);
     config->xssAuditor->init(document(), &m_xssAuditorDelegate);
 
+    config->preloadScanner = adoptPtr(new TokenPreloadScanner(document()->url().copy(), CachedDocumentParameters::create(document())));
     config->decoder = takeDecoder();
     config->parsedChunkQueue = m_parsedChunkQueue.get();
     if (document()->settings()) {
@@ -824,13 +821,8 @@
     }
 
     ASSERT(config->xssAuditor->isSafeToSendToAnotherThread());
-    HTMLParserThread::shared()->postTask(threadSafeBind(
-        &BackgroundHTMLParser::start,
-        reference.release(),
-        config.release(),
-        document()->url(),
-        CachedDocumentParameters::create(document()),
-        MediaValuesCached::MediaValuesCachedData(*document()),
+    ASSERT(config->preloadScanner->isSafeToSendToAnotherThread());
+    HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::start, reference.release(), config.release(),
         adoptPtr(m_loadingTaskRunner->clone())));
 }
 
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp b/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp
index 4ba4c75..ddc46de 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp
+++ b/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp
@@ -442,7 +442,7 @@
     IntegrityMetadataSet m_integrityMetadata;
 };
 
-TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> documentParameters, const MediaValuesCached::MediaValuesCachedData& mediaValuesCachedData)
+TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> documentParameters)
     : m_documentURL(documentURL)
     , m_inStyle(false)
     , m_inPicture(false)
@@ -450,10 +450,9 @@
     , m_isCSPEnabled(false)
     , m_templateCount(0)
     , m_documentParameters(documentParameters)
-    , m_mediaValues(MediaValuesCached::create(mediaValuesCachedData))
 {
     ASSERT(m_documentParameters.get());
-    ASSERT(m_mediaValues.get());
+    ASSERT(m_documentParameters->mediaValues.get());
 }
 
 TokenPreloadScanner::~TokenPreloadScanner()
@@ -490,16 +489,16 @@
     scanCommon(token, source, requests);
 }
 
-static void handleMetaViewport(const String& attributeValue, const CachedDocumentParameters* documentParameters, MediaValuesCached* mediaValues)
+static void handleMetaViewport(const String& attributeValue, CachedDocumentParameters* documentParameters)
 {
     if (!documentParameters->viewportMetaEnabled)
         return;
     ViewportDescription description(ViewportDescription::ViewportMeta);
     HTMLMetaElement::getViewportDescriptionFromContentAttribute(attributeValue, description, nullptr, documentParameters->viewportMetaZeroValuesQuirk);
-    FloatSize initialViewport(mediaValues->deviceWidth(), mediaValues->deviceHeight());
+    FloatSize initialViewport(documentParameters->mediaValues->deviceWidth(), documentParameters->mediaValues->deviceHeight());
     PageScaleConstraints constraints = description.resolve(initialViewport, documentParameters->defaultViewportMinWidth);
-    mediaValues->setViewportHeight(constraints.layoutSize.height());
-    mediaValues->setViewportWidth(constraints.layoutSize.width());
+    documentParameters->mediaValues->setViewportHeight(constraints.layoutSize.height());
+    documentParameters->mediaValues->setViewportWidth(constraints.layoutSize.width());
 }
 
 static void handleMetaReferrer(const String& attributeValue, CachedDocumentParameters* documentParameters, CSSPreloadScanner* cssScanner)
@@ -511,7 +510,7 @@
 }
 
 template <typename Token>
-static void handleMetaNameAttribute(const Token& token, CachedDocumentParameters* documentParameters, MediaValuesCached* mediaValues, CSSPreloadScanner* cssScanner)
+static void handleMetaNameAttribute(const Token& token, CachedDocumentParameters* documentParameters, CSSPreloadScanner* cssScanner)
 {
     const typename Token::Attribute* nameAttribute = token.getAttributeItem(nameAttr);
     if (!nameAttribute)
@@ -524,7 +523,7 @@
 
     String contentAttributeValue(contentAttribute->value);
     if (equalIgnoringCase(nameAttributeValue, "viewport")) {
-        handleMetaViewport(contentAttributeValue, documentParameters, mediaValues);
+        handleMetaViewport(contentAttributeValue, documentParameters);
         return;
     }
 
@@ -608,7 +607,7 @@
                 return;
             }
 
-            handleMetaNameAttribute(token, m_documentParameters.get(), m_mediaValues.get(), &m_cssScanner);
+            handleMetaNameAttribute(token, m_documentParameters.get(), &m_cssScanner);
         }
 
         if (match(tagImpl, pictureTag)) {
@@ -617,7 +616,7 @@
             return;
         }
 
-        StartTagScanner scanner(tagImpl, m_mediaValues);
+        StartTagScanner scanner(tagImpl, m_documentParameters->mediaValues);
         scanner.processAttributes(token.attributes());
         if (m_inPicture)
             scanner.handlePictureSourceURL(m_pictureData);
@@ -642,8 +641,8 @@
     }
 }
 
-HTMLPreloadScanner::HTMLPreloadScanner(const HTMLParserOptions& options, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> documentParameters, const MediaValuesCached::MediaValuesCachedData& mediaValuesCachedData)
-    : m_scanner(documentURL, documentParameters, mediaValuesCachedData)
+HTMLPreloadScanner::HTMLPreloadScanner(const HTMLParserOptions& options, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> documentParameters)
+    : m_scanner(documentURL, documentParameters)
     , m_tokenizer(HTMLTokenizer::create(options))
 {
 }
@@ -679,11 +678,16 @@
     preloader->takeAndPreload(requests);
 }
 
-CachedDocumentParameters::CachedDocumentParameters(Document* document)
+CachedDocumentParameters::CachedDocumentParameters(Document* document, PassRefPtrWillBeRawPtr<MediaValuesCached> givenMediaValues)
 {
     ASSERT(isMainThread());
     ASSERT(document);
     doHtmlPreloadScanning = !document->settings() || document->settings()->doHtmlPreloadScanning();
+    if (givenMediaValues)
+        mediaValues = givenMediaValues;
+    else
+        mediaValues = MediaValuesCached::create(*document);
+    ASSERT(mediaValues->isSafeToSendToAnotherThread());
     defaultViewportMinWidth = document->viewportDefaultMinWidth();
     viewportMetaZeroValuesQuirk = document->settings() && document->settings()->viewportMetaZeroValuesQuirk();
     viewportMetaEnabled = document->settings() && document->settings()->viewportMetaEnabled();
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.h b/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.h
index 6c83f3904..a583d02 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.h
+++ b/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.h
@@ -48,25 +48,26 @@
 struct CORE_EXPORT CachedDocumentParameters {
     USING_FAST_MALLOC(CachedDocumentParameters);
 public:
-    static PassOwnPtr<CachedDocumentParameters> create(Document* document)
+    static PassOwnPtr<CachedDocumentParameters> create(Document* document, PassRefPtrWillBeRawPtr<MediaValuesCached> mediaValues = nullptr)
     {
-        return adoptPtr(new CachedDocumentParameters(document));
+        return adoptPtr(new CachedDocumentParameters(document, mediaValues));
     }
 
     bool doHtmlPreloadScanning;
+    RefPtrWillBeCrossThreadPersistent<MediaValuesCached> mediaValues;
     Length defaultViewportMinWidth;
     bool viewportMetaZeroValuesQuirk;
     bool viewportMetaEnabled;
     ReferrerPolicy referrerPolicy;
 
 private:
-    explicit CachedDocumentParameters(Document*);
+    CachedDocumentParameters(Document*, PassRefPtrWillBeRawPtr<MediaValuesCached>);
 };
 
 class TokenPreloadScanner {
     WTF_MAKE_NONCOPYABLE(TokenPreloadScanner); USING_FAST_MALLOC(TokenPreloadScanner);
 public:
-    TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<CachedDocumentParameters>, const MediaValuesCached::MediaValuesCachedData&);
+    TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<CachedDocumentParameters>);
     ~TokenPreloadScanner();
 
     void scan(const HTMLToken&, const SegmentedString&, PreloadRequestStream& requests);
@@ -79,6 +80,12 @@
     TokenPreloadScannerCheckpoint createCheckpoint();
     void rewindTo(TokenPreloadScannerCheckpoint);
 
+    bool isSafeToSendToAnotherThread()
+    {
+        return m_documentURL.isSafeToSendToAnotherThread()
+            && m_predictedBaseElementURL.isSafeToSendToAnotherThread();
+    }
+
 private:
     class StartTagScanner;
 
@@ -128,7 +135,6 @@
     PictureData m_pictureData;
     size_t m_templateCount;
     OwnPtr<CachedDocumentParameters> m_documentParameters;
-    RefPtrWillBePersistent<MediaValuesCached> m_mediaValues;
     ClientHintsPreferences m_clientHintsPreferences;
 
     Vector<Checkpoint> m_checkpoints;
@@ -137,20 +143,19 @@
 class CORE_EXPORT HTMLPreloadScanner {
     WTF_MAKE_NONCOPYABLE(HTMLPreloadScanner); USING_FAST_MALLOC(HTMLPreloadScanner);
 public:
-    static PassOwnPtr<HTMLPreloadScanner> create(const HTMLParserOptions& options, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> documentParameters, const MediaValuesCached::MediaValuesCachedData& mediaValuesCachedData)
+    static PassOwnPtr<HTMLPreloadScanner> create(const HTMLParserOptions& options, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> documentParameters)
     {
-        return adoptPtr(new HTMLPreloadScanner(options, documentURL, documentParameters, mediaValuesCachedData));
+        return adoptPtr(new HTMLPreloadScanner(options, documentURL, documentParameters));
     }
 
 
+    HTMLPreloadScanner(const HTMLParserOptions&, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters>);
     ~HTMLPreloadScanner();
 
     void appendToEnd(const SegmentedString&);
     void scan(ResourcePreloader*, const KURL& documentBaseElementURL);
 
 private:
-    HTMLPreloadScanner(const HTMLParserOptions&, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters>, const MediaValuesCached::MediaValuesCachedData&);
-
     TokenPreloadScanner m_scanner;
     SegmentedString m_source;
     HTMLToken m_token;
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLPreloadScannerTest.cpp b/third_party/WebKit/Source/core/html/parser/HTMLPreloadScannerTest.cpp
index 03a37c1..6e6874b 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLPreloadScannerTest.cpp
+++ b/third_party/WebKit/Source/core/html/parser/HTMLPreloadScannerTest.cpp
@@ -104,7 +104,7 @@
     {
     }
 
-    MediaValuesCached::MediaValuesCachedData createMediaValuesData()
+    PassRefPtrWillBeRawPtr<MediaValuesCached> createMediaValues()
     {
         MediaValuesCached::MediaValuesCachedData data;
         data.viewportWidth = 500;
@@ -120,7 +120,7 @@
         data.mediaType = MediaTypeNames::screen;
         data.strictMode = true;
         data.displayMode = WebDisplayModeBrowser;
-        return data;
+        return MediaValuesCached::create(data);
     }
 
     void runSetUp(ViewportState viewportState, PreloadState preloadState = PreloadEnabled)
@@ -130,7 +130,7 @@
         m_dummyPageHolder->document().settings()->setViewportEnabled(viewportState == ViewportEnabled);
         m_dummyPageHolder->document().settings()->setViewportMetaEnabled(viewportState == ViewportEnabled);
         m_dummyPageHolder->document().settings()->setDoHtmlPreloadScanning(preloadState == PreloadEnabled);
-        m_scanner = HTMLPreloadScanner::create(options, documentURL, CachedDocumentParameters::create(&m_dummyPageHolder->document()), createMediaValuesData());
+        m_scanner = HTMLPreloadScanner::create(options, documentURL, CachedDocumentParameters::create(&m_dummyPageHolder->document(), createMediaValues()));
     }
 
     void SetUp() override
diff --git a/third_party/WebKit/Source/core/inspector/v8/BUILD.gn b/third_party/WebKit/Source/core/inspector/v8/BUILD.gn
deleted file mode 100644
index 35140221..0000000
--- a/third_party/WebKit/Source/core/inspector/v8/BUILD.gn
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-v8_inspector_output_dir = "$root_gen_dir/blink/core/inspector/v8"
-
-group("injected_script_sources") {
-  public_deps = [
-    ":debugger_script",
-    ":injected_script",
-  ]
-}
-
-action("injected_script") {
-  script = "build/xxd.py"
-  inputs = [
-    "InjectedScriptSource.js",
-  ]
-  outputs = [
-    "$v8_inspector_output_dir/InjectedScriptSource.h",
-  ]
-  args = [
-    "InjectedScriptSource_js",
-    rebase_path("InjectedScriptSource.js", root_build_dir),
-    rebase_path("$v8_inspector_output_dir/InjectedScriptSource.h",
-                root_build_dir),
-  ]
-}
-
-action("debugger_script") {
-  script = "build/xxd.py"
-  inputs = [
-    "DebuggerScript.js",
-  ]
-  outputs = [
-    "$v8_inspector_output_dir/DebuggerScript.h",
-  ]
-  args = [
-    "DebuggerScript_js",
-    rebase_path("DebuggerScript.js", root_build_dir),
-    rebase_path("$v8_inspector_output_dir/DebuggerScript.h", root_build_dir),
-  ]
-}
diff --git a/third_party/WebKit/Source/core/inspector/v8/InjectedScriptManager.cpp b/third_party/WebKit/Source/core/inspector/v8/InjectedScriptManager.cpp
index 59b58c7..4433ec55 100644
--- a/third_party/WebKit/Source/core/inspector/v8/InjectedScriptManager.cpp
+++ b/third_party/WebKit/Source/core/inspector/v8/InjectedScriptManager.cpp
@@ -33,12 +33,13 @@
 #include "core/inspector/v8/InjectedScript.h"
 #include "core/inspector/v8/InjectedScriptHost.h"
 #include "core/inspector/v8/InjectedScriptNative.h"
-#include "core/inspector/v8/InjectedScriptSource.h"
 #include "core/inspector/v8/RemoteObjectId.h"
 #include "core/inspector/v8/V8Debugger.h"
 #include "core/inspector/v8/V8DebuggerClient.h"
 #include "core/inspector/v8/V8InjectedScriptHost.h"
 #include "core/inspector/v8/V8StringUtil.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebData.h"
 #include "wtf/PassOwnPtr.h"
 
 namespace blink {
@@ -134,7 +135,9 @@
         return nullptr;
 
     RefPtr<InjectedScriptNative> injectedScriptNative = adoptRef(new InjectedScriptNative(context->GetIsolate()));
-    String injectedScriptSource(reinterpret_cast<const char*>(InjectedScriptSource_js), sizeof(InjectedScriptSource_js));
+
+    const WebData& injectedScriptSourceResource = Platform::current()->loadResource("InjectedScriptSource.js");
+    String injectedScriptSource(injectedScriptSourceResource.data(), injectedScriptSourceResource.size());
 
     v8::Local<v8::Object> object = createInjectedScript(injectedScriptSource, context, contextId, injectedScriptNative.get());
     OwnPtr<InjectedScript> result = adoptPtr(new InjectedScript(this, context, object, m_client, injectedScriptNative.release(), contextId));
diff --git a/third_party/WebKit/Source/core/inspector/v8/V8DebuggerImpl.cpp b/third_party/WebKit/Source/core/inspector/v8/V8DebuggerImpl.cpp
index 3dbec54..f1e6281 100644
--- a/third_party/WebKit/Source/core/inspector/v8/V8DebuggerImpl.cpp
+++ b/third_party/WebKit/Source/core/inspector/v8/V8DebuggerImpl.cpp
@@ -30,7 +30,6 @@
 
 #include "core/inspector/v8/V8DebuggerImpl.h"
 
-#include "core/inspector/v8/DebuggerScript.h"
 #include "core/inspector/v8/JavaScriptCallFrame.h"
 #include "core/inspector/v8/ScriptBreakpoint.h"
 #include "core/inspector/v8/V8DebuggerAgentImpl.h"
@@ -39,6 +38,8 @@
 #include "core/inspector/v8/V8StackTraceImpl.h"
 #include "core/inspector/v8/V8StringUtil.h"
 #include "platform/JSONValues.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebData.h"
 #include "wtf/Atomics.h"
 #include "wtf/Vector.h"
 #include "wtf/text/CString.h"
@@ -717,8 +718,8 @@
 
     v8::HandleScope scope(m_isolate);
     v8::Context::Scope contextScope(debuggerContext());
-
-    v8::Local<v8::String> scriptValue = v8::String::NewFromUtf8(m_isolate, DebuggerScript_js, v8::NewStringType::kInternalized, sizeof(DebuggerScript_js)).ToLocalChecked();
+    const WebData& source = Platform::current()->loadResource("DebuggerScriptSource.js");
+    v8::Local<v8::String> scriptValue = v8::String::NewFromUtf8(m_isolate, source.data(), v8::NewStringType::kInternalized, source.size()).ToLocalChecked();
     v8::Local<v8::Value> value;
     if (!m_client->compileAndRunInternalScript(scriptValue).ToLocal(&value))
         return;
diff --git a/third_party/WebKit/Source/core/inspector/v8/build/rjsmin.py b/third_party/WebKit/Source/core/inspector/v8/build/rjsmin.py
deleted file mode 100755
index 8357a6d..0000000
--- a/third_party/WebKit/Source/core/inspector/v8/build/rjsmin.py
+++ /dev/null
@@ -1,295 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2011 - 2013
-# Andr\xe9 Malo or his licensors, as applicable
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-r"""
-=====================
- Javascript Minifier
-=====================
-
-rJSmin is a javascript minifier written in python.
-
-The minifier is based on the semantics of `jsmin.c by Douglas Crockford`_\.
-
-The module is a re-implementation aiming for speed, so it can be used at
-runtime (rather than during a preprocessing step). Usually it produces the
-same results as the original ``jsmin.c``. It differs in the following ways:
-
-- there is no error detection: unterminated string, regex and comment
-  literals are treated as regular javascript code and minified as such.
-- Control characters inside string and regex literals are left untouched; they
-  are not converted to spaces (nor to \n)
-- Newline characters are not allowed inside string and regex literals, except
-  for line continuations in string literals (ECMA-5).
-- "return /regex/" is recognized correctly.
-- "+ +" and "- -" sequences are not collapsed to '++' or '--'
-- Newlines before ! operators are removed more sensibly
-- rJSmin does not handle streams, but only complete strings. (However, the
-  module provides a "streamy" interface).
-
-Since most parts of the logic are handled by the regex engine it's way
-faster than the original python port of ``jsmin.c`` by Baruch Even. The speed
-factor varies between about 6 and 55 depending on input and python version
-(it gets faster the more compressed the input already is). Compared to the
-speed-refactored python port by Dave St.Germain the performance gain is less
-dramatic but still between 1.2 and 7. See the docs/BENCHMARKS file for
-details.
-
-rjsmin.c is a reimplementation of rjsmin.py in C and speeds it up even more.
-
-Both python 2 and python 3 are supported.
-
-.. _jsmin.c by Douglas Crockford:
-   http://www.crockford.com/javascript/jsmin.c
-"""
-__author__ = "Andr\xe9 Malo"
-__author__ = getattr(__author__, 'decode', lambda x: __author__)('latin-1')
-__docformat__ = "restructuredtext en"
-__license__ = "Apache License, Version 2.0"
-__version__ = '1.0.7'
-__all__ = ['jsmin']
-
-import re as _re
-
-
-def _make_jsmin(python_only=False):
-    """
-    Generate JS minifier based on `jsmin.c by Douglas Crockford`_
-
-    .. _jsmin.c by Douglas Crockford:
-       http://www.crockford.com/javascript/jsmin.c
-
-    :Parameters:
-      `python_only` : ``bool``
-        Use only the python variant. If true, the c extension is not even
-        tried to be loaded.
-
-    :Return: Minifier
-    :Rtype: ``callable``
-    """
-    # pylint: disable = R0912, R0914, W0612
-    if not python_only:
-        try:
-            import _rjsmin
-        except ImportError:
-            pass
-        else:
-            return _rjsmin.jsmin
-    try:
-        xrange
-    except NameError:
-        xrange = range  # pylint: disable = W0622
-
-    space_chars = r'[\000-\011\013\014\016-\040]'
-
-    line_comment = r'(?://[^\r\n]*)'
-    space_comment = r'(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/)'
-    string1 = \
-        r'(?:\047[^\047\\\r\n]*(?:\\(?:[^\r\n]|\r?\n|\r)[^\047\\\r\n]*)*\047)'
-    string2 = r'(?:"[^"\\\r\n]*(?:\\(?:[^\r\n]|\r?\n|\r)[^"\\\r\n]*)*")'
-    strings = r'(?:%s|%s)' % (string1, string2)
-
-    charclass = r'(?:\[[^\\\]\r\n]*(?:\\[^\r\n][^\\\]\r\n]*)*\])'
-    nospecial = r'[^/\\\[\r\n]'
-    regex = r'(?:/(?![\r\n/*])%s*(?:(?:\\[^\r\n]|%s)%s*)*/)' % (
-        nospecial, charclass, nospecial)
-    space = r'(?:%s|%s)' % (space_chars, space_comment)
-    newline = r'(?:%s?[\r\n])' % line_comment
-
-    def fix_charclass(result):
-        """ Fixup string of chars to fit into a regex char class """
-        pos = result.find('-')
-        if pos >= 0:
-            result = r'%s%s-' % (result[:pos], result[pos + 1:])
-
-        def sequentize(string):
-            """
-            Notate consecutive characters as sequence
-
-            (1-4 instead of 1234)
-            """
-            first, last, result = None, None, []
-            for char in map(ord, string):
-                if last is None:
-                    first = last = char
-                elif last + 1 == char:
-                    last = char
-                else:
-                    result.append((first, last))
-                    first = last = char
-            if last is not None:
-                result.append((first, last))
-            return ''.join(['%s%s%s' % (
-                chr(first),
-                last > first + 1 and '-' or '',
-                last != first and chr(last) or '') for first, last in result])
-
-        return _re.sub(r'([\000-\040\047])',  # for better portability
-            lambda m: '\\%03o' % ord(m.group(1)), (sequentize(result)
-                .replace('\\', '\\\\')
-                .replace('[', '\\[')
-                .replace(']', '\\]')))
-
-    def id_literal_(what):
-        """ Make id_literal like char class """
-        match = _re.compile(what).match
-        result = ''.join([chr(c) for c in xrange(127) if not match(chr(c))])
-        return '[^%s]' % fix_charclass(result)
-
-    def not_id_literal_(keep):
-        """ Make negated id_literal like char class """
-        match = _re.compile(id_literal_(keep)).match
-        result = ''.join([chr(c) for c in xrange(127) if not match(chr(c))])
-        return r'[%s]' % fix_charclass(result)
-
-    not_id_literal = not_id_literal_(r'[a-zA-Z0-9_$]')
-    preregex1 = r'[(,=:\[!&|?{};\r\n]'
-    preregex2 = r'%(not_id_literal)sreturn' % locals()
-
-    id_literal = id_literal_(r'[a-zA-Z0-9_$]')
-    id_literal_open = id_literal_(r'[a-zA-Z0-9_${\[(!+-]')
-    id_literal_close = id_literal_(r'[a-zA-Z0-9_$}\])"\047+-]')
-
-    dull = r'[^\047"/\000-\040]'
-
-    space_sub = _re.compile((
-        r'(%(dull)s+)'
-        r'|(%(strings)s%(dull)s*)'
-        r'|(?<=%(preregex1)s)'
-            r'%(space)s*(?:%(newline)s%(space)s*)*'
-            r'(%(regex)s%(dull)s*)'
-        r'|(?<=%(preregex2)s)'
-            r'%(space)s*(?:%(newline)s%(space)s)*'
-            r'(%(regex)s%(dull)s*)'
-        r'|(?<=%(id_literal_close)s)'
-            r'%(space)s*(?:(%(newline)s)%(space)s*)+'
-            r'(?=%(id_literal_open)s)'
-        r'|(?<=%(id_literal)s)(%(space)s)+(?=%(id_literal)s)'
-        r'|(?<=\+)(%(space)s)+(?=\+)'
-        r'|(?<=-)(%(space)s)+(?=-)'
-        r'|%(space)s+'
-        r'|(?:%(newline)s%(space)s*)+') % locals()).sub
-    #print space_sub.__self__.pattern
-
-    def space_subber(match):
-        """ Substitution callback """
-        # pylint: disable = C0321, R0911
-        groups = match.groups()
-        if groups[0]:
-            return groups[0]
-        elif groups[1]:
-            return groups[1]
-        elif groups[2]:
-            return groups[2]
-        elif groups[3]:
-            return groups[3]
-        elif groups[4]:
-            return '\n'
-        elif groups[5] or groups[6] or groups[7]:
-            return ' '
-        else:
-            return ''
-
-    def jsmin(script):  # pylint: disable = W0621
-        r"""
-        Minify javascript based on `jsmin.c by Douglas Crockford`_\.
-
-        Instead of parsing the stream char by char, it uses a regular
-        expression approach which minifies the whole script with one big
-        substitution regex.
-
-        .. _jsmin.c by Douglas Crockford:
-           http://www.crockford.com/javascript/jsmin.c
-
-        :Parameters:
-          `script` : ``str``
-            Script to minify
-
-        :Return: Minified script
-        :Rtype: ``str``
-        """
-        return space_sub(space_subber, '\n%s\n' % script).strip()
-
-    return jsmin
-
-jsmin = _make_jsmin()
-
-
-def jsmin_for_posers(script):
-    r"""
-    Minify javascript based on `jsmin.c by Douglas Crockford`_\.
-
-    Instead of parsing the stream char by char, it uses a regular
-    expression approach which minifies the whole script with one big
-    substitution regex.
-
-    .. _jsmin.c by Douglas Crockford:
-       http://www.crockford.com/javascript/jsmin.c
-
-    :Warning: This function is the digest of a _make_jsmin() call. It just
-              utilizes the resulting regex. It's just for fun here and may
-              vanish any time. Use the `jsmin` function instead.
-
-    :Parameters:
-      `script` : ``str``
-        Script to minify
-
-    :Return: Minified script
-    :Rtype: ``str``
-    """
-    def subber(match):
-        """ Substitution callback """
-        groups = match.groups()
-        return (
-            groups[0] or
-            groups[1] or
-            groups[2] or
-            groups[3] or
-            (groups[4] and '\n') or
-            (groups[5] and ' ') or
-            (groups[6] and ' ') or
-            (groups[7] and ' ') or
-            '')
-
-    return _re.sub(
-        r'([^\047"/\000-\040]+)|((?:(?:\047[^\047\\\r\n]*(?:\\(?:[^\r\n]|\r?'
-        r'\n|\r)[^\047\\\r\n]*)*\047)|(?:"[^"\\\r\n]*(?:\\(?:[^\r\n]|\r?\n|'
-        r'\r)[^"\\\r\n]*)*"))[^\047"/\000-\040]*)|(?<=[(,=:\[!&|?{};\r\n])(?'
-        r':[\000-\011\013\014\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/))*'
-        r'(?:(?:(?://[^\r\n]*)?[\r\n])(?:[\000-\011\013\014\016-\040]|(?:/\*'
-        r'[^*]*\*+(?:[^/*][^*]*\*+)*/))*)*((?:/(?![\r\n/*])[^/\\\[\r\n]*(?:('
-        r'?:\\[^\r\n]|(?:\[[^\\\]\r\n]*(?:\\[^\r\n][^\\\]\r\n]*)*\]))[^/\\\['
-        r'\r\n]*)*/)[^\047"/\000-\040]*)|(?<=[\000-#%-,./:-@\[-^`{-~-]return'
-        r')(?:[\000-\011\013\014\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/'
-        r'))*(?:(?:(?://[^\r\n]*)?[\r\n])(?:[\000-\011\013\014\016-\040]|(?:'
-        r'/\*[^*]*\*+(?:[^/*][^*]*\*+)*/)))*((?:/(?![\r\n/*])[^/\\\[\r\n]*(?'
-        r':(?:\\[^\r\n]|(?:\[[^\\\]\r\n]*(?:\\[^\r\n][^\\\]\r\n]*)*\]))[^/'
-        r'\\\[\r\n]*)*/)[^\047"/\000-\040]*)|(?<=[^\000-!#%&(*,./:-@\[\\^`{|'
-        r'~])(?:[\000-\011\013\014\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)'
-        r'*/))*(?:((?:(?://[^\r\n]*)?[\r\n]))(?:[\000-\011\013\014\016-\040]'
-        r'|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/))*)+(?=[^\000-\040"#%-\047)*,./'
-        r':-@\\-^`|-~])|(?<=[^\000-#%-,./:-@\[-^`{-~-])((?:[\000-\011\013\01'
-        r'4\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/)))+(?=[^\000-#%-,./:'
-        r'-@\[-^`{-~-])|(?<=\+)((?:[\000-\011\013\014\016-\040]|(?:/\*[^*]*'
-        r'\*+(?:[^/*][^*]*\*+)*/)))+(?=\+)|(?<=-)((?:[\000-\011\013\014\016-'
-        r'\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/)))+(?=-)|(?:[\000-\011\013'
-        r'\014\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/))+|(?:(?:(?://[^'
-        r'\r\n]*)?[\r\n])(?:[\000-\011\013\014\016-\040]|(?:/\*[^*]*\*+(?:[^'
-        r'/*][^*]*\*+)*/))*)+', subber, '\n%s\n' % script).strip()
-
-
-if __name__ == '__main__':
-    import sys as _sys
-    _sys.stdout.write(jsmin(_sys.stdin.read()))
diff --git a/third_party/WebKit/Source/core/inspector/v8/build/xxd.py b/third_party/WebKit/Source/core/inspector/v8/build/xxd.py
deleted file mode 100644
index 635d80c..0000000
--- a/third_party/WebKit/Source/core/inspector/v8/build/xxd.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Represent a file as a C++ constant string.
-
-Usage:
-python xxd.py VAR SOURCE DEST
-"""
-
-
-import sys
-import rjsmin
-
-
-def main():
-    variable_name, input_filename, output_filename = sys.argv[1:]
-    with open(input_filename) as input_file:
-        input_text = input_file.read()
-    input_text = rjsmin.jsmin(input_text)
-    hex_values = ['0x{0:02x}'.format(ord(char)) for char in input_text]
-    const_declaration = 'const char %s[] = {\n%s\n};\n' % (
-        variable_name, ', '.join(hex_values))
-    with open(output_filename, 'w') as output_file:
-        output_file.write(const_declaration)
-
-if __name__ == '__main__':
-    sys.exit(main())
diff --git a/third_party/WebKit/Source/core/inspector/v8/v8_inspector.gyp b/third_party/WebKit/Source/core/inspector/v8/v8_inspector.gyp
deleted file mode 100644
index 512e4a4..0000000
--- a/third_party/WebKit/Source/core/inspector/v8/v8_inspector.gyp
+++ /dev/null
@@ -1,57 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-{
-  'targets': [
-    {
-      # GN version: //third_party/WebKit/Source/core/inspector/v8:injected_script_sources
-      'target_name': 'injected_script_sources',
-      'type': 'none',
-      'dependencies': [
-        'injected_script',
-        'debugger_script',
-      ]
-    },
-    {
-      # GN version: //third_party/WebKit/Source/core/inspector/v8:injected_script
-      'target_name': 'injected_script',
-      'type': 'none',
-      'actions': [
-        {
-          'action_name': 'ConvertFileToHeaderWithCharacterArray',
-          'inputs': [
-            'build/xxd.py',
-            'InjectedScriptSource.js',
-          ],
-          'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/blink/core/inspector/v8/InjectedScriptSource.h', ],
-          'action': [
-            'python', 'build/xxd.py', 'InjectedScriptSource_js', 'InjectedScriptSource.js', '<@(_outputs)'
-          ],
-        },
-      ],
-      # Since this target generates header files, it needs to be a hard dependency.
-      'hard_dependency': 1,
-    },
-    {
-      # GN version: //third_party/WebKit/Source/core/inspector/v8:debugger_script
-      'target_name': 'debugger_script',
-      'type': 'none',
-      'actions': [
-        {
-          'action_name': 'ConvertFileToHeaderWithCharacterArray',
-          'inputs': [
-            'build/xxd.py',
-            'DebuggerScript.js',
-          ],
-          'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/blink/core/inspector/v8/DebuggerScript.h', ],
-          'action': [
-            'python', 'build/xxd.py', 'DebuggerScript_js', 'DebuggerScript.js', '<@(_outputs)'
-          ],
-        },
-      ],
-      # Since this target generates header files, it needs to be a hard dependency.
-      'hard_dependency': 1,
-    },
-  ],  # targets
-}
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
index 96e6990..afc3f54d 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
@@ -1138,9 +1138,9 @@
     return name.toString();
 }
 
-IntRect LayoutObject::visualRect() const
+LayoutRect LayoutObject::visualRect() const
 {
-    return enclosingIntRect(previousPaintInvalidationRect());
+    return previousPaintInvalidationRect();
 }
 
 bool LayoutObject::isPaintInvalidationContainer() const
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.h b/third_party/WebKit/Source/core/layout/LayoutObject.h
index fe24cf4..7fecfe52 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.h
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.h
@@ -221,7 +221,7 @@
     String decoratedName() const;
 
     // DisplayItemClient methods.
-    IntRect visualRect() const override;
+    LayoutRect visualRect() const override;
     String debugName() const final;
 
     LayoutObject* parent() const { return m_parent; }
diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
index 9caa1a55..fe3cff5 100644
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
@@ -2294,6 +2294,11 @@
     return previousInterestRect;
 }
 
+LayoutSize CompositedLayerMapping::subpixelAccumulation() const
+{
+    return m_owningLayer.subpixelAccumulation();
+}
+
 bool CompositedLayerMapping::needsRepaint() const
 {
     return m_owningLayer.needsRepaint();
diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.h b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.h
index 21e31f0..c0f063a 100644
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.h
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.h
@@ -158,6 +158,7 @@
     void notifyFirstImagePaint() override;
 
     IntRect computeInterestRect(const GraphicsLayer*, const IntRect& previousInterestRect) const override;
+    LayoutSize subpixelAccumulation() const final;
     bool needsRepaint() const override;
     void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& interestRect) const override;
 
diff --git a/third_party/WebKit/Source/core/layout/line/InlineBox.cpp b/third_party/WebKit/Source/core/layout/line/InlineBox.cpp
index d07c203..b2fea86 100644
--- a/third_party/WebKit/Source/core/layout/line/InlineBox.cpp
+++ b/third_party/WebKit/Source/core/layout/line/InlineBox.cpp
@@ -93,7 +93,7 @@
     return boxName();
 }
 
-IntRect InlineBox::visualRect() const
+LayoutRect InlineBox::visualRect() const
 {
     // TODO(chrishtr): tighten these bounds.
     return layoutObject().visualRect();
diff --git a/third_party/WebKit/Source/core/layout/line/InlineBox.h b/third_party/WebKit/Source/core/layout/line/InlineBox.h
index 26060cb2..6a8644d 100644
--- a/third_party/WebKit/Source/core/layout/line/InlineBox.h
+++ b/third_party/WebKit/Source/core/layout/line/InlineBox.h
@@ -106,7 +106,7 @@
 
     // DisplayItemClient methods
     String debugName() const override;
-    IntRect visualRect() const override;
+    LayoutRect visualRect() const override;
 
     bool isText() const { return m_bitfields.isText(); }
     void setIsText(bool isText) { m_bitfields.setIsText(isText); }
diff --git a/third_party/WebKit/Source/core/loader/NavigationScheduler.cpp b/third_party/WebKit/Source/core/loader/NavigationScheduler.cpp
index f4a962d..4174be16 100644
--- a/third_party/WebKit/Source/core/loader/NavigationScheduler.cpp
+++ b/third_party/WebKit/Source/core/loader/NavigationScheduler.cpp
@@ -49,6 +49,7 @@
 #include "platform/UserGestureIndicator.h"
 #include "platform/scheduler/CancellableTaskFactory.h"
 #include "public/platform/Platform.h"
+#include "public/platform/WebScheduler.h"
 #include "wtf/CurrentTime.h"
 
 namespace blink {
diff --git a/third_party/WebKit/Source/core/paint/PaintLayer.cpp b/third_party/WebKit/Source/core/paint/PaintLayer.cpp
index 82a679c..b9dff6b 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayer.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayer.cpp
@@ -218,7 +218,7 @@
     return layoutObject()->debugName();
 }
 
-IntRect PaintLayer::visualRect() const
+LayoutRect PaintLayer::visualRect() const
 {
     return m_layoutObject->visualRect();
 }
diff --git a/third_party/WebKit/Source/core/paint/PaintLayer.h b/third_party/WebKit/Source/core/paint/PaintLayer.h
index 5d1baa94..3932a00 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayer.h
+++ b/third_party/WebKit/Source/core/paint/PaintLayer.h
@@ -207,7 +207,7 @@
 
     // DisplayItemClient methods
     String debugName() const final;
-    IntRect visualRect() const final;
+    LayoutRect visualRect() const final;
 
     LayoutBoxModelObject* layoutObject() const { return m_layoutObject; }
     LayoutBox* layoutBox() const { return m_layoutObject && m_layoutObject->isBox() ? toLayoutBox(m_layoutObject) : 0; }
diff --git a/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp b/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
index e3bf7c3..8e54e313 100644
--- a/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
+++ b/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
@@ -78,10 +78,10 @@
     ASSERT(!m_chromeClient || !m_chromeClient->image());
 }
 
-IntRect SVGImage::visualRect() const
+LayoutRect SVGImage::visualRect() const
 {
     // TODO(chrishtr): fix this.
-    return IntRect();
+    return LayoutRect();
 }
 
 bool SVGImage::isInSVGImage(const Node* node)
diff --git a/third_party/WebKit/Source/core/svg/graphics/SVGImage.h b/third_party/WebKit/Source/core/svg/graphics/SVGImage.h
index f78fefd8..3b16084 100644
--- a/third_party/WebKit/Source/core/svg/graphics/SVGImage.h
+++ b/third_party/WebKit/Source/core/svg/graphics/SVGImage.h
@@ -79,7 +79,7 @@
 
     // DisplayItemClient methods.
     String debugName() const final { return "SVGImage"; }
-    IntRect visualRect() const override;
+    LayoutRect visualRect() const override;
 
 private:
     friend class AXLayoutObject;
diff --git a/third_party/WebKit/Source/devtools/scripts/concatenate_application_code.py b/third_party/WebKit/Source/devtools/scripts/concatenate_application_code.py
index d9204a8..c6e1567b 100755
--- a/third_party/WebKit/Source/devtools/scripts/concatenate_application_code.py
+++ b/third_party/WebKit/Source/devtools/scripts/concatenate_application_code.py
@@ -31,6 +31,13 @@
 except ImportError:
     import json
 
+rjsmin_path = path.abspath(join(
+    path.dirname(__file__),
+    '..',
+    '..',
+    'build',
+    'scripts'))
+sys.path.append(rjsmin_path)
 import rjsmin
 
 
diff --git a/third_party/WebKit/Source/platform/exported/WebScrollbarThemeClientImpl.h b/third_party/WebKit/Source/platform/exported/WebScrollbarThemeClientImpl.h
index 5c6a96f..1cee8c5f 100644
--- a/third_party/WebKit/Source/platform/exported/WebScrollbarThemeClientImpl.h
+++ b/third_party/WebKit/Source/platform/exported/WebScrollbarThemeClientImpl.h
@@ -83,7 +83,7 @@
     // DisplayItemClient methods.
     String debugName() const final;
     // TODO(chrishtr): fix this.
-    IntRect visualRect() const override { return IntRect(); }
+    LayoutRect visualRect() const override { return LayoutRect(); }
 
 private:
     WebScrollbar& m_scrollbar;
diff --git a/third_party/WebKit/Source/platform/graphics/ContentLayerDelegate.cpp b/third_party/WebKit/Source/platform/graphics/ContentLayerDelegate.cpp
index 63b2c03..2481727 100644
--- a/third_party/WebKit/Source/platform/graphics/ContentLayerDelegate.cpp
+++ b/third_party/WebKit/Source/platform/graphics/ContentLayerDelegate.cpp
@@ -49,7 +49,8 @@
 {
 }
 
-static void paintArtifactToWebDisplayItemList(WebDisplayItemList* list, const PaintArtifact& artifact, const gfx::Rect& bounds)
+static void paintArtifactToWebDisplayItemList(WebDisplayItemList* list, const GraphicsLayer* graphicsLayer,
+    const PaintArtifact& artifact, const gfx::Rect& bounds)
 {
     if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
         // This is a temporary path to paint the artifact using the paint chunk
@@ -61,7 +62,7 @@
         list->appendDrawingItem(WebRect(bounds.x(), bounds.y(), bounds.width(), bounds.height()), picture.get());
         return;
     }
-    artifact.appendToWebDisplayItemList(list);
+    artifact.appendToWebDisplayItemList(list, graphicsLayer);
 }
 
 gfx::Rect ContentLayerDelegate::paintableRegion()
@@ -93,7 +94,7 @@
         disabledMode = GraphicsContext::FullyDisabled;
 
     m_graphicsLayer->paint(nullptr, disabledMode);
-    paintArtifactToWebDisplayItemList(webDisplayItemList, paintController.paintArtifact(), paintableRegion());
+    paintArtifactToWebDisplayItemList(webDisplayItemList, m_graphicsLayer, paintController.paintArtifact(), paintableRegion());
     paintController.setDisplayItemConstructionIsDisabled(false);
     paintController.setSubsequenceCachingIsDisabled(false);
 }
diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp
index 2ba8104..29eb2eb6 100644
--- a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp
+++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp
@@ -156,9 +156,11 @@
     ASSERT(!m_parent);
 }
 
-IntRect GraphicsLayer::visualRect() const
+LayoutRect GraphicsLayer::visualRect() const
 {
-    return enclosingIntRect(FloatRect(FloatPoint(0, 0), size()));
+    LayoutRect bounds = LayoutRect(FloatPoint(), size());
+    bounds.move(offsetFromLayoutObjectWithSubpixelAccumulation());
+    return bounds;
 }
 
 void GraphicsLayer::setDrawDebugRedFillForTesting(bool enabled)
@@ -299,6 +301,11 @@
         setNeedsDisplay();
 }
 
+LayoutSize GraphicsLayer::offsetFromLayoutObjectWithSubpixelAccumulation() const
+{
+    return LayoutSize(offsetFromLayoutObject()) + client()->subpixelAccumulation();
+}
+
 IntRect GraphicsLayer::interestRect()
 {
     return m_previousInterestRect;
diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.h b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.h
index 57101d5..a23ee2a6 100644
--- a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.h
+++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.h
@@ -123,6 +123,7 @@
     // Offset is origin of the layoutObject minus origin of the graphics layer (so either zero or negative).
     IntSize offsetFromLayoutObject() const { return flooredIntSize(m_offsetFromLayoutObject); }
     void setOffsetFromLayoutObject(const IntSize&, ShouldSetNeedsDisplay = SetNeedsDisplay);
+    LayoutSize offsetFromLayoutObjectWithSubpixelAccumulation() const;
 
     // The double version is only used in |updateScrollingLayerGeometry()| for detecting
     // scroll offset change at floating point precision.
@@ -264,7 +265,7 @@
 
     // DisplayItemClient methods
     String debugName() const final { return m_client->debugName(this); }
-    IntRect visualRect() const override;
+    LayoutRect visualRect() const override;
 
 protected:
     String debugName(cc::Layer*) const;
diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsLayerClient.h b/third_party/WebKit/Source/platform/graphics/GraphicsLayerClient.h
index 6959096b3..ad43c2ff 100644
--- a/third_party/WebKit/Source/platform/graphics/GraphicsLayerClient.h
+++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayerClient.h
@@ -27,6 +27,7 @@
 #define GraphicsLayerClient_h
 
 #include "platform/PlatformExport.h"
+#include "platform/geometry/LayoutSize.h"
 #include "wtf/text/WTFString.h"
 
 namespace blink {
@@ -70,6 +71,7 @@
     virtual void notifyFirstImagePaint() { }
 
     virtual IntRect computeInterestRect(const GraphicsLayer*, const IntRect& previousInterestRect) const = 0;
+    virtual LayoutSize subpixelAccumulation() const { return LayoutSize(); }
     virtual bool needsRepaint() const { return true; }
     virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& interestRect) const = 0;
 
diff --git a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h
index 827d189..1ae212b8 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h
+++ b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h
@@ -6,7 +6,7 @@
 #define DisplayItemClient_h
 
 #include "platform/PlatformExport.h"
-#include "platform/geometry/IntRect.h"
+#include "platform/geometry/LayoutRect.h"
 #include "wtf/text/WTFString.h"
 
 namespace blink {
@@ -27,8 +27,9 @@
 
     virtual String debugName() const = 0;
 
-    // The visual rect of this DisplayItemClient, in the space of its containing GraphicsLayer.
-    virtual IntRect visualRect() const = 0;
+    // The visual rect of this DisplayItemClient, in object space of the object that owns the GraphicsLayer, i.e.
+    // offset by offsetFromLayoutObjectPlusSubpixelAccumulation().
+    virtual LayoutRect visualRect() const = 0;
 
 #if ENABLE(ASSERT)
     // Tests if a DisplayItemClient object has been created and has not been deleted yet.
diff --git a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClientTest.cpp b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClientTest.cpp
index d27e975..9f1e815 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClientTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClientTest.cpp
@@ -14,7 +14,7 @@
 class TestDisplayItemClient : public DisplayItemClient {
 public:
     String debugName() const final { return "TestDisplayItemClient"; }
-    IntRect visualRect() const final { return IntRect(); }
+    LayoutRect visualRect() const final { return LayoutRect(); }
 };
 
 TEST(DisplayItemClientTest, IsAlive)
diff --git a/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp b/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp
index b2fed1c5..733401c 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp
+++ b/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp
@@ -6,6 +6,7 @@
 
 #include "platform/TraceEvent.h"
 #include "platform/geometry/IntRect.h"
+#include "platform/graphics/GraphicsLayer.h"
 #include "platform/graphics/paint/DrawingDisplayItem.h"
 #include "third_party/skia/include/core/SkRegion.h"
 
@@ -90,14 +91,17 @@
         displayItem.replay(graphicsContext);
 }
 
-void PaintArtifact::appendToWebDisplayItemList(WebDisplayItemList* list) const
+void PaintArtifact::appendToWebDisplayItemList(WebDisplayItemList* list, const GraphicsLayer* graphicsLayer) const
 {
     TRACE_EVENT0("blink,benchmark", "PaintArtifact::appendToWebDisplayItemList");
 #if ENABLE(ASSERT)
     m_displayItemList.assertDisplayItemClientsAreAlive();
 #endif
-    for (const DisplayItem& displayItem : m_displayItemList)
-        displayItem.appendToWebDisplayItemList(displayItem.client().visualRect(), list);
+    for (const DisplayItem& displayItem : m_displayItemList) {
+        LayoutRect visualRect = displayItem.client().visualRect();
+        visualRect.move(-graphicsLayer->offsetFromLayoutObjectWithSubpixelAccumulation());
+        displayItem.appendToWebDisplayItemList(enclosingIntRect(visualRect), list);
+    }
 }
 
 } // namespace blink
diff --git a/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.h b/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.h
index 79074732..42084c7e 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.h
+++ b/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.h
@@ -15,6 +15,7 @@
 namespace blink {
 
 class GraphicsContext;
+class GraphicsLayer;
 class WebDisplayItemList;
 
 // The output of painting, consisting of a series of drawings in paint order,
@@ -59,7 +60,7 @@
     void replay(GraphicsContext&) const;
 
     // Writes the paint artifact into a WebDisplayItemList.
-    void appendToWebDisplayItemList(WebDisplayItemList*) const;
+    void appendToWebDisplayItemList(WebDisplayItemList*, const GraphicsLayer*) const;
 
 private:
     DisplayItemList m_displayItemList;
diff --git a/third_party/WebKit/Source/platform/graphics/paint/PaintArtifactToSkCanvasTest.cpp b/third_party/WebKit/Source/platform/graphics/paint/PaintArtifactToSkCanvasTest.cpp
index 829b38b..97a0a2f 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/PaintArtifactToSkCanvasTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/paint/PaintArtifactToSkCanvasTest.cpp
@@ -67,7 +67,7 @@
     SkColor color() const { return m_color; }
     PassRefPtr<SkPicture> makePicture() const { return pictureWithRect(m_rect, m_color); }
     String debugName() const final { return "<dummy>"; }
-    IntRect visualRect() const override { return IntRect(); }
+    LayoutRect visualRect() const override { return LayoutRect(); }
 
 private:
     SkRect m_rect;
diff --git a/third_party/WebKit/Source/platform/graphics/paint/PaintControllerTest.cpp b/third_party/WebKit/Source/platform/graphics/paint/PaintControllerTest.cpp
index 7260c319..4284fd9 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/PaintControllerTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/paint/PaintControllerTest.cpp
@@ -46,7 +46,7 @@
     { }
 
     String debugName() const final { return m_name; }
-    IntRect visualRect() const override { return IntRect(); }
+    LayoutRect visualRect() const override { return LayoutRect(); }
 
 private:
     String m_name;
diff --git a/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactory.cpp b/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactory.cpp
index db3e0164..ea46265 100644
--- a/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactory.cpp
+++ b/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactory.cpp
@@ -5,7 +5,6 @@
 #include "platform/scheduler/CancellableTaskFactory.h"
 
 #include "public/platform/Platform.h"
-#include "wtf/InstanceCounter.h"
 
 namespace blink {
 
diff --git a/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactory.h b/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactory.h
index 5d8a597..46c26bd 100644
--- a/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactory.h
+++ b/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactory.h
@@ -7,13 +7,12 @@
 
 #include "platform/PlatformExport.h"
 #include "platform/heap/Handle.h"
-#include "public/platform/WebScheduler.h"
+#include "public/platform/WebTaskRunner.h"
 #include "wtf/Allocator.h"
 #include "wtf/Functional.h"
 #include "wtf/Noncopyable.h"
 #include "wtf/OwnPtr.h"
 #include "wtf/PassOwnPtr.h"
-#include "wtf/RefCounted.h"
 #include "wtf/WeakPtr.h"
 #include <type_traits>
 
diff --git a/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactoryTest.cpp b/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactoryTest.cpp
index f2346a2..40ff9c4 100644
--- a/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactoryTest.cpp
+++ b/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactoryTest.cpp
@@ -10,7 +10,7 @@
 
 namespace {
 
-class TestCancellableTaskFactory : public CancellableTaskFactory {
+class TestCancellableTaskFactory final : public CancellableTaskFactory {
 public:
     explicit TestCancellableTaskFactory(PassOwnPtr<Closure> closure)
         : CancellableTaskFactory(closure)
diff --git a/third_party/WebKit/Source/platform/scroll/Scrollbar.h b/third_party/WebKit/Source/platform/scroll/Scrollbar.h
index 9b969b21..1396433 100644
--- a/third_party/WebKit/Source/platform/scroll/Scrollbar.h
+++ b/third_party/WebKit/Source/platform/scroll/Scrollbar.h
@@ -158,7 +158,7 @@
     // DisplayItemClient methods.
     String debugName() const final { return m_orientation == HorizontalScrollbar ? "HorizontalScrollbar" : "VerticalScrollbar"; }
     // TODO(chrishtr): fix this.
-    IntRect visualRect() const override { return IntRect(); }
+    LayoutRect visualRect() const override { return LayoutRect(); }
 
     // Marks the scrollbar as needing to be redrawn.
     //
diff --git a/third_party/WebKit/Source/web/PageOverlay.h b/third_party/WebKit/Source/web/PageOverlay.h
index 4595137..e368d09 100644
--- a/third_party/WebKit/Source/web/PageOverlay.h
+++ b/third_party/WebKit/Source/web/PageOverlay.h
@@ -69,7 +69,7 @@
     // DisplayItemClient methods.
     String debugName() const final { return "PageOverlay"; }
     // TODO(chrishtr): fix this.
-    IntRect visualRect() const override { return IntRect(); }
+    LayoutRect visualRect() const override { return LayoutRect(); }
 
     // GraphicsLayerClient implementation
     IntRect computeInterestRect(const GraphicsLayer*, const IntRect&) const override;
diff --git a/third_party/WebKit/Source/web/WebFontImpl.cpp b/third_party/WebKit/Source/web/WebFontImpl.cpp
index c4f4952..fc825f0e 100644
--- a/third_party/WebKit/Source/web/WebFontImpl.cpp
+++ b/third_party/WebKit/Source/web/WebFontImpl.cpp
@@ -55,10 +55,10 @@
     m_font.update(nullptr);
 }
 
-IntRect WebFontImpl::visualRect() const
+LayoutRect WebFontImpl::visualRect() const
 {
     // TODO(chrishtr): fix this.
-    return IntRect();
+    return LayoutRect();
 }
 
 WebFontDescription WebFontImpl::fontDescription() const
diff --git a/third_party/WebKit/Source/web/WebFontImpl.h b/third_party/WebKit/Source/web/WebFontImpl.h
index d3ca362..805872e 100644
--- a/third_party/WebKit/Source/web/WebFontImpl.h
+++ b/third_party/WebKit/Source/web/WebFontImpl.h
@@ -60,7 +60,7 @@
         int height, int from = 0, int to = -1) const override;
 
     String debugName() const final { return "WebFontImpl"; }
-    IntRect visualRect() const override;
+    LayoutRect visualRect() const override;
 
 private:
     Font m_font;
diff --git a/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp b/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
index 46e6577..0d231ae 100644
--- a/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
+++ b/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
@@ -433,7 +433,7 @@
 
     // DisplayItemClient methods
     String debugName() const final { return "ChromePrintContext"; }
-    IntRect visualRect() const override { ASSERT_NOT_REACHED(); return IntRect(); }
+    LayoutRect visualRect() const override { ASSERT_NOT_REACHED(); return LayoutRect(); }
 
 protected:
     // Spools the printed page, a subrect of frame(). Skip the scale step.
diff --git a/third_party/WebKit/Source/web/WebViewImpl.cpp b/third_party/WebKit/Source/web/WebViewImpl.cpp
index 83e5cac1..dec2d18 100644
--- a/third_party/WebKit/Source/web/WebViewImpl.cpp
+++ b/third_party/WebKit/Source/web/WebViewImpl.cpp
@@ -128,6 +128,7 @@
 #include "public/platform/WebGestureCurve.h"
 #include "public/platform/WebImage.h"
 #include "public/platform/WebLayerTreeView.h"
+#include "public/platform/WebScheduler.h"
 #include "public/platform/WebURLRequest.h"
 #include "public/platform/WebVector.h"
 #include "public/platform/WebViewScheduler.h"
diff --git a/third_party/WebKit/public/blink_resources.grd b/third_party/WebKit/public/blink_resources.grd
index 342e8be..0a651fb 100644
--- a/third_party/WebKit/public/blink_resources.grd
+++ b/third_party/WebKit/public/blink_resources.grd
@@ -34,6 +34,8 @@
       <include name="IDR_UASTYLE_VIEWPORT_ANDROID_CSS" file="../Source/core/css/viewportAndroid.css" type="BINDATA"/>
 
       <include name="IDR_INSPECTOR_OVERLAY_PAGE_HTML" file="../Source/core/inspector/InspectorOverlayPage.html" type="BINDATA"/>
+      <include name="IDR_INSPECTOR_INJECTED_SCRIPT_SOURCE_JS" file="../Source/core/inspector/v8/InjectedScriptSource.js" type="BINDATA"/>
+      <include name="IDR_INSPECTOR_DEBUGGER_SCRIPT_SOURCE_JS" file="../Source/core/inspector/v8/DebuggerScript.js" type="BINDATA"/>
       <include name="IDR_PRIVATE_SCRIPT_DOCUMENTEXECCOMMAND_JS" file="../Source/core/editing/js/DocumentExecCommand.js" type="BINDATA"/>
       <include name="IDR_PRIVATE_SCRIPT_DOCUMENTXMLTREEVIEWER_CSS" file="../Source/core/xml/DocumentXMLTreeViewer.css" type="BINDATA"/>
       <include name="IDR_PRIVATE_SCRIPT_DOCUMENTXMLTREEVIEWER_JS" file="../Source/core/xml/DocumentXMLTreeViewer.js" type="BINDATA"/>
diff --git a/ui/views/mus/platform_test_helper_mus.cc b/ui/views/mus/platform_test_helper_mus.cc
index c4faba1..f5d1df05 100644
--- a/ui/views/mus/platform_test_helper_mus.cc
+++ b/ui/views/mus/platform_test_helper_mus.cc
@@ -31,7 +31,7 @@
     mojo_test_helper_.reset(new mojo::test::TestHelper(nullptr));
     // ui/views/mus requires a WindowManager running, for now use the desktop
     // one.
-    mojo_test_helper_->shell()->ConnectToApplication("mojo:desktop_wm");
+    mojo_test_helper_->shell()->Connect("mojo:desktop_wm");
     WindowManagerConnection::Create(mojo_test_helper_->shell());
   }
 
diff --git a/ui/views/mus/screen_mus.cc b/ui/views/mus/screen_mus.cc
index 261f8f09e4..354af1c4 100644
--- a/ui/views/mus/screen_mus.cc
+++ b/ui/views/mus/screen_mus.cc
@@ -6,7 +6,7 @@
 
 // #include "components/mus/public/interfaces/window_manager_constants.mojom.h"
 #include "mojo/converters/geometry/geometry_type_converters.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 #include "ui/gfx/display_finder.h"
 #include "ui/gfx/display_observer.h"
diff --git a/ui/views/mus/window_manager_connection.cc b/ui/views/mus/window_manager_connection.cc
index 04e0db7..173572dd 100644
--- a/ui/views/mus/window_manager_connection.cc
+++ b/ui/views/mus/window_manager_connection.cc
@@ -12,7 +12,7 @@
 #include "components/mus/public/interfaces/window_tree.mojom.h"
 #include "mojo/converters/geometry/geometry_type_converters.h"
 #include "mojo/converters/network/network_type_converters.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
 #include "mojo/shell/public/cpp/shell.h"
 #include "ui/views/mus/native_widget_mus.h"
 #include "ui/views/mus/screen_mus.h"