You have access to the window object, from the background page, you can
execute a script on the selected tab like this:

  chrome.tabs.getSelected(null, function(tab) {

    var jsRunner = {'code': 'window.stop()'};

    chrome.tabs.executeScript(tab.id, jsRunner);

  });


Concerning your other question, I don't believe there is a way to intercept
requests, maybe you can listen on every chrome.tabs.onUpdated.addListener event
 and do whatever you think is malicious and draw something over it using
JavaScript to inform the user that its not good. Or you can close the window
using chrome.tabs.remove and open a new window with a custom extension page
stating that page has malicious content using chrome.tabs.create.

But I don't think it will do any good, but it will just stop the user from
browsing that page after he/she/it first enters it.

-Mohamed Mansour


On Thu, Jan 21, 2010 at 7:44 PM, Min Huang <reti...@gmail.com> wrote:

> Hmm, but then I would need to have a window object to begin with.  I
> think I need to back up.  Suppose I want to create an extension that
> stops users from visiting a malicious website; I add an event listener
> to the chrome.tabs.onUpdated event.  When I see a URL that is
> suspicious, I stop the page from loading and ask the user if he really
> wants to visit the site.  How could I implement that?
>
> On Jan 21, 4:29 pm, Mohamed Mansour <m...@chromium.org> wrote:
> > You can use JavaScript's window.stop to stop loading the page
> > programmatically.
> >
> > https://developer.mozilla.org/en/DOM/window.stop
> >
> > -Mohamed Mansour
> >
> > On Thu, Jan 21, 2010 at 7:23 PM, Min Huang <reti...@gmail.com> wrote:
> > > I know can I press ESC to stop a page from loading manually, but is
> > > there no way to do it otherwise?  I feel like an idiot for asking but
> > > I don't see anything in the chrome.* APIs.
> >
> > > -Min
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Chromium-extensions" group.
> > > To post to this group, send email to
> chromium-extensi...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > chromium-extensions+unsubscr...@googlegroups.com<chromium-extensions%2bunsubscr...@googlegroups.com>
> <chromium-extensions%2bunsubscr...@googlegroups.com<chromium-extensions%252bunsubscr...@googlegroups.com>
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/chromium-extensions?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Chromium-extensions" group.
> To post to this group, send email to chromium-extensi...@googlegroups.com.
> To unsubscribe from this group, send email to
> chromium-extensions+unsubscr...@googlegroups.com<chromium-extensions%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/chromium-extensions?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Chromium-extensions" group.
To post to this group, send email to chromium-extensi...@googlegroups.com.
To unsubscribe from this group, send email to 
chromium-extensions+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/chromium-extensions?hl=en.

Reply via email to