Remove NativeWindow::FromWebContents
This commit is contained in:
		
					parent
					
						
							
								eea4e60b73
							
						
					
				
			
			
				commit
				
					
						702f1631a3
					
				
			
		
					 4 changed files with 11 additions and 19 deletions
				
			
		| 
						 | 
					@ -64,8 +64,10 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
 | 
				
			||||||
      checkbox_string = "Prevent this app from creating additional dialogs";
 | 
					      checkbox_string = "Prevent this app from creating additional dialogs";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  auto* relay = NativeWindowRelay::FromWebContents(web_contents);
 | 
				
			||||||
  atom::ShowMessageBox(
 | 
					  atom::ShowMessageBox(
 | 
				
			||||||
      NativeWindow::FromWebContents(web_contents),
 | 
					      relay ? relay->window.get() : nullptr,
 | 
				
			||||||
      atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1, 0,
 | 
					      atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1, 0,
 | 
				
			||||||
      atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
 | 
					      atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
 | 
				
			||||||
      base::UTF16ToUTF8(message_text), "", checkbox_string,
 | 
					      base::UTF16ToUTF8(message_text), "", checkbox_string,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -76,16 +76,6 @@ NativeWindow::~NativeWindow() {
 | 
				
			||||||
  NotifyWindowClosed();
 | 
					  NotifyWindowClosed();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// static
 | 
					 | 
				
			||||||
NativeWindow* NativeWindow::FromWebContents(
 | 
					 | 
				
			||||||
    content::WebContents* web_contents) {
 | 
					 | 
				
			||||||
  for (const auto& window : WindowList::GetWindows()) {
 | 
					 | 
				
			||||||
    if (window->web_contents() == web_contents)
 | 
					 | 
				
			||||||
      return window;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  return nullptr;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
 | 
					void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
 | 
				
			||||||
  // Setup window from options.
 | 
					  // Setup window from options.
 | 
				
			||||||
  int x = -1, y = -1;
 | 
					  int x = -1, y = -1;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -64,9 +64,6 @@ class NativeWindow : public base::SupportsUserData,
 | 
				
			||||||
      const mate::Dictionary& options,
 | 
					      const mate::Dictionary& options,
 | 
				
			||||||
      NativeWindow* parent = nullptr);
 | 
					      NativeWindow* parent = nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Find a window from its WebContents
 | 
					 | 
				
			||||||
  static NativeWindow* FromWebContents(content::WebContents* web_contents);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  void InitFromOptions(const mate::Dictionary& options);
 | 
					  void InitFromOptions(const mate::Dictionary& options);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  virtual void Close() = 0;
 | 
					  virtual void Close() = 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -209,7 +209,9 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
 | 
				
			||||||
    if (manager) {
 | 
					    if (manager) {
 | 
				
			||||||
      auto embedder = manager->GetEmbedder(guest_instance_id);
 | 
					      auto embedder = manager->GetEmbedder(guest_instance_id);
 | 
				
			||||||
      if (embedder) {
 | 
					      if (embedder) {
 | 
				
			||||||
        auto window = NativeWindow::FromWebContents(embedder);
 | 
					        auto* relay = NativeWindowRelay::FromWebContents(web_contents);
 | 
				
			||||||
 | 
					        if (relay) {
 | 
				
			||||||
 | 
					          auto* window = relay->window.get();
 | 
				
			||||||
          if (window) {
 | 
					          if (window) {
 | 
				
			||||||
            const bool visible = window->IsVisible() && !window->IsMinimized();
 | 
					            const bool visible = window->IsVisible() && !window->IsMinimized();
 | 
				
			||||||
            if (!visible) {
 | 
					            if (!visible) {
 | 
				
			||||||
| 
						 | 
					@ -219,6 +221,7 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool WebContentsPreferences::IsPreferenceEnabled(
 | 
					bool WebContentsPreferences::IsPreferenceEnabled(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue