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

Unified Diff: chrome/browser/chrome_webusb_browser_client.cc

Issue 1360873003: Fix WebUSB notification on Chrome OS with no windows open. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update expected strings. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/chrome_webusb_browser_client_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_webusb_browser_client.cc
diff --git a/chrome/browser/chrome_webusb_browser_client.cc b/chrome/browser/chrome_webusb_browser_client.cc
index 458c3f7a632e5589e7cfa21371e53c93c39431cf..ddfcd58916583b8f203629377e5c9369fc7e833f 100644
--- a/chrome/browser/chrome_webusb_browser_client.cc
+++ b/chrome/browser/chrome_webusb_browser_client.cc
@@ -8,8 +8,8 @@
#include "chrome/browser/net/referrer.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/host_desktop.h"
+#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/common/origin_util.h"
#include "ui/base/l10n/l10n_util.h"
@@ -25,12 +25,17 @@ namespace {
const char kWebUsbDetectorNotificationID[] = "webusb.detector";
+Browser* GetBrowser() {
+ chrome::ScopedTabbedBrowserDisplayer browser_displayer(
+ ProfileManager::GetActiveUserProfile(), chrome::GetActiveDesktop());
+ DCHECK(browser_displayer.browser());
+ return browser_displayer.browser();
+}
+
void OpenURL(const GURL& url) {
- Browser* browser = chrome::FindBrowserWithProfile(
- ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_NATIVE);
- content::OpenURLParams params(url, content::Referrer(), NEW_FOREGROUND_TAB,
- ui::PAGE_TRANSITION_AUTO_TOPLEVEL, true);
- browser->OpenURL(params);
+ GetBrowser()->OpenURL(
+ content::OpenURLParams(url, content::Referrer(), NEW_FOREGROUND_TAB,
+ ui::PAGE_TRANSITION_AUTO_TOPLEVEL, true));
}
// Delegate for webusb notification
@@ -69,23 +74,22 @@ void ChromeWebUsbBrowserClient::OnDeviceAdded(
return;
}
- scoped_ptr<message_center::Notification> notification;
-
message_center::RichNotificationData rich_notification_data;
- rich_notification_data.context_message =
- base::UTF8ToUTF16(landing_page.GetContent());
-
- notification.reset(new message_center::Notification(
- message_center::NOTIFICATION_TYPE_SIMPLE, notification_id,
- l10n_util::GetStringFUTF16(IDS_WEBUSB_DEVICE_DETECTED_NOTIFICATION_TITLE,
- product_name),
- l10n_util::GetStringUTF16(IDS_WEBUSB_DEVICE_DETECTED_NOTIFICATION),
- // TODO(juncai): use generic USB device icon here.
- gfx::Image(), base::string16(), GURL(),
- message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT,
- kWebUsbDetectorNotificationID),
- rich_notification_data,
- new WebUsbNotificationDelegate(landing_page, notification_id)));
+ scoped_ptr<message_center::Notification> notification(
+ new message_center::Notification(
+ message_center::NOTIFICATION_TYPE_SIMPLE, notification_id,
+ l10n_util::GetStringFUTF16(
+ IDS_WEBUSB_DEVICE_DETECTED_NOTIFICATION_TITLE, product_name),
+ l10n_util::GetStringFUTF16(
+ IDS_WEBUSB_DEVICE_DETECTED_NOTIFICATION,
+ base::UTF8ToUTF16(landing_page.GetContent())),
+ // TODO(juncai): use generic USB device icon here.
+ gfx::Image(), base::string16(), GURL(),
+ message_center::NotifierId(
+ message_center::NotifierId::SYSTEM_COMPONENT,
+ kWebUsbDetectorNotificationID),
+ rich_notification_data,
+ new WebUsbNotificationDelegate(landing_page, notification_id)));
notification->SetSystemPriority();
message_center::MessageCenter::Get()->AddNotification(notification.Pass());
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/chrome_webusb_browser_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698