]> khamidou — GitHub mirrors - electron.git/commitdiff
Implement getId in C++
authorCheng Zhao <zcbenz@gmail.com>
Tue, 23 Jun 2015 08:16:10 +0000 (16:16 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 23 Jun 2015 08:16:10 +0000 (16:16 +0800)
atom/browser/api/atom_api_web_contents.cc
atom/browser/api/atom_api_web_contents.h
atom/browser/api/lib/web-contents.coffee

index 8b26b724fa0636ad458632a4105bd0b8914c4f01..3db913382b7a69ca431f8678da067fdb44c4ab54 100644 (file)
@@ -453,6 +453,14 @@ bool WebContents::IsAlive() const {
   return web_contents() != NULL;
 }
 
+int WebContents::GetID() const {
+  return web_contents()->GetRenderProcessHost()->GetID();
+}
+
+bool WebContents::Equal(const WebContents* web_contents) const {
+  return GetID() == web_contents->GetID();
+}
+
 void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
   content::NavigationController::LoadURLParams params(url);
 
@@ -506,14 +514,6 @@ void WebContents::GoToOffset(int offset) {
   web_contents()->GetController().GoToOffset(offset);
 }
 
-int WebContents::GetRoutingID() const {
-  return web_contents()->GetRoutingID();
-}
-
-int WebContents::GetProcessID() const {
-  return web_contents()->GetRenderProcessHost()->GetID();
-}
-
 bool WebContents::IsCrashed() const {
   return web_contents()->IsCrashed();
 }
@@ -770,6 +770,8 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
     template_.Reset(isolate, mate::ObjectTemplateBuilder(isolate)
         .SetMethod("destroy", &WebContents::Destroy)
         .SetMethod("isAlive", &WebContents::IsAlive)
+        .SetMethod("getId", &WebContents::GetID)
+        .SetMethod("equal", &WebContents::Equal)
         .SetMethod("_loadUrl", &WebContents::LoadURL)
         .SetMethod("getTitle", &WebContents::GetTitle)
         .SetMethod("isLoading", &WebContents::IsLoading)
@@ -779,8 +781,6 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
         .SetMethod("_goBack", &WebContents::GoBack)
         .SetMethod("_goForward", &WebContents::GoForward)
         .SetMethod("_goToOffset", &WebContents::GoToOffset)
-        .SetMethod("getRoutingId", &WebContents::GetRoutingID)
-        .SetMethod("getProcessId", &WebContents::GetProcessID)
         .SetMethod("isCrashed", &WebContents::IsCrashed)
         .SetMethod("setUserAgent", &WebContents::SetUserAgent)
         .SetMethod("insertCSS", &WebContents::InsertCSS)
index 31f54134afacef6638c5e8666e3ef4966833f9c5..a2bfda874cbdbb96530d295ab9103a372fa5b532 100644 (file)
@@ -68,6 +68,8 @@ class WebContents : public mate::EventEmitter,
 
   void Destroy();
   bool IsAlive() const;
+  int GetID() const;
+  bool Equal(const WebContents* web_contents) const;
   void LoadURL(const GURL& url, const mate::Dictionary& options);
   base::string16 GetTitle() const;
   bool IsLoading() const;
@@ -77,8 +79,6 @@ class WebContents : public mate::EventEmitter,
   void GoBack();
   void GoForward();
   void GoToOffset(int offset);
-  int GetRoutingID() const;
-  int GetProcessID() const;
   bool IsCrashed() const;
   void SetUserAgent(const std::string& user_agent);
   void InsertCSS(const std::string& css);
index 67f106f6bb86eea1815f1e8946c95093337556a1..38e6caaaa6e8501c3856aa8544a49e4a56c98930 100644 (file)
@@ -24,10 +24,6 @@ wrapWebContents = (webContents) ->
     else
       webContents.once 'did-finish-load', @_executeJavaScript.bind(this, code)
 
-  # The processId and routingId and identify a webContents.
-  webContents.getId = -> @getProcessId()
-  webContents.equal = (other) -> @getId() is other.getId()
-
   # The navigation controller.
   controller = new NavigationController(webContents)
   for name, method of NavigationController.prototype when method instanceof Function