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

Unified Diff: chrome/browser/ui/views/frame/browser_frame_win.cc

Issue 10291007: Added support in Metro mode for retrieving the information about the currently (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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/browser/ui/views/frame/browser_frame_win.h ('k') | chrome/common/chrome_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/frame/browser_frame_win.cc
===================================================================
--- chrome/browser/ui/views/frame/browser_frame_win.cc (revision 134602)
+++ chrome/browser/ui/views/frame/browser_frame_win.cc (working copy)
@@ -10,6 +10,8 @@
#include <set>
#include "base/command_line.h"
+#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
#include "base/win/metro.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/search_engines/template_url.h"
@@ -24,7 +26,9 @@
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/page_navigator.h"
+#include "content/public/browser/web_contents.h"
#include "content/public/common/page_transition_types.h"
+#include "googleurl/src/gurl.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "ui/base/models/simple_menu_model.h"
@@ -50,7 +54,21 @@
using content::OpenURLParams;
using content::Referrer;
+using content::WebContents;
+namespace {
+
+void LocalAllocAndCopyString(const wchar_t* src, wchar_t** dest) {
+ DCHECK(src);
+ DCHECK(dest);
+
+ size_t dest_size = (wcslen(src) + 1) * sizeof(wchar_t);
+ *dest = reinterpret_cast<wchar_t*>(LocalAlloc(LPTR, dest_size));
+ base::wcslcpy(*dest, src, dest_size);
+}
+
+} // namespace
+
///////////////////////////////////////////////////////////////////////////////
// BrowserFrameWin, public:
@@ -208,9 +226,15 @@
LPARAM l_param) {
static const UINT metro_navigation_search_message =
RegisterWindowMessage(chrome::kMetroNavigationAndSearchMessage);
- if (message == metro_navigation_search_message)
- HandleMetroRequest(w_param, l_param);
+ static const UINT metro_get_current_tab_info_message =
+ RegisterWindowMessage(chrome::kMetroGetCurrentTabInfoMessage);
+
+ if (message == metro_navigation_search_message) {
+ HandleMetroNavSearchRequest(w_param, l_param);
+ } else if (message == metro_get_current_tab_info_message) {
+ GetMetroCurrentTabInfo(w_param);
+ }
return views::NativeWidgetWin::OnWndProc(message, w_param, l_param);
}
@@ -307,7 +331,8 @@
}
}
-void BrowserFrameWin::HandleMetroRequest(WPARAM w_param, LPARAM l_param) {
+void BrowserFrameWin::HandleMetroNavSearchRequest(WPARAM w_param,
+ LPARAM l_param) {
if (!base::win::GetMetroModule()) {
NOTREACHED() << "Received unexpected metro navigation request";
return;
@@ -346,7 +371,36 @@
}
}
+void BrowserFrameWin::GetMetroCurrentTabInfo(WPARAM w_param) {
+ if (!base::win::GetMetroModule()) {
+ NOTREACHED() << "Received unexpected metro request";
+ return;
+ }
+ if (!w_param) {
+ NOTREACHED() << "Invalid metro request parameter";
+ return;
+ }
+
+ base::win::CurrentTabInfo* current_tab_info =
+ reinterpret_cast<base::win::CurrentTabInfo*>(w_param);
+
+ Browser* browser = browser_view()->browser();
+ DCHECK(browser);
+
+ // We allocate memory for the title and url via LocalAlloc. The caller has to
+ // free the memory via LocalFree.
+ LocalAllocAndCopyString(browser->GetWindowTitleForCurrentTab().c_str(),
+ &current_tab_info->title);
+
+ WebContents* current_tab = browser->GetSelectedWebContents();
+ DCHECK(current_tab);
+
+ LocalAllocAndCopyString(UTF8ToWide(current_tab->GetURL().spec()).c_str(),
+ &current_tab_info->url);
+}
+
+
////////////////////////////////////////////////////////////////////////////////
// BrowserFrame, public:
« no previous file with comments | « chrome/browser/ui/views/frame/browser_frame_win.h ('k') | chrome/common/chrome_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698