Home | History | Annotate | Download | only in common
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Multiply-included file, no traditional include guard.
      6 #include <map>
      7 #include <set>
      8 #include <string>
      9 #include <vector>
     10 
     11 // TODO(erg): This list has been temporarily annotated by erg while doing work
     12 // on which headers to pull out.
     13 #include "base/basictypes.h"
     14 #include "base/file_path.h"
     15 #include "base/process.h"
     16 #include "base/shared_memory.h"
     17 #include "base/string16.h"
     18 #include "base/values.h"
     19 #include "build/build_config.h"
     20 #include "chrome/common/common_param_traits.h"
     21 #include "chrome/common/instant_types.h"
     22 #include "chrome/common/nacl_types.h"
     23 #include "chrome/common/search_provider.h"
     24 #include "chrome/common/thumbnail_score.h"
     25 #include "chrome/common/translate_errors.h"
     26 #include "chrome/common/view_types.h"
     27 #include "content/common/common_param_traits.h"
     28 #include "ipc/ipc_message_macros.h"
     29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h"
     30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
     31 #include "third_party/skia/include/core/SkBitmap.h"
     32 #include "ui/gfx/rect.h"
     33 
     34 // Singly-included section for enums and custom IPC traits.
     35 #ifndef CHROME_COMMON_RENDER_MESSAGES_H_
     36 #define CHROME_COMMON_RENDER_MESSAGES_H_
     37 
     38 // Command values for the cmd parameter of the
     39 // ViewHost_JavaScriptStressTestControl message. For each command the parameter
     40 // passed has a different meaning:
     41 // For the command kJavaScriptStressTestSetStressRunType the parameter it the
     42 // type taken from the enumeration v8::Testing::StressType.
     43 // For the command kJavaScriptStressTestPrepareStressRun the parameter it the
     44 // number of the stress run about to take place.
     45 enum ViewHostMsg_JavaScriptStressTestControl_Commands {
     46   kJavaScriptStressTestSetStressRunType = 0,
     47   kJavaScriptStressTestPrepareStressRun = 1,
     48 };
     49 
     50 namespace IPC {
     51 
     52 #if defined(OS_POSIX)
     53 
     54 // TODO(port): this shouldn't exist. However, the plugin stuff is really using
     55 // HWNDS (NativeView), and making Windows calls based on them. I've not figured
     56 // out the deal with plugins yet.
     57 template <>
     58 struct ParamTraits<gfx::NativeView> {
     59   typedef gfx::NativeView param_type;
     60   static void Write(Message* m, const param_type& p) {
     61     NOTIMPLEMENTED();
     62   }
     63 
     64   static bool Read(const Message* m, void** iter, param_type* p) {
     65     NOTIMPLEMENTED();
     66     *p = NULL;
     67     return true;
     68   }
     69 
     70   static void Log(const param_type& p, std::string* l) {
     71     l->append(base::StringPrintf("<gfx::NativeView>"));
     72   }
     73 };
     74 
     75 #endif  // defined(OS_POSIX)
     76 
     77 template <>
     78 struct ParamTraits<ContentSettings> {
     79   typedef ContentSettings param_type;
     80   static void Write(Message* m, const param_type& p);
     81   static bool Read(const Message* m, void** iter, param_type* r);
     82   static void Log(const param_type& p, std::string* l);
     83 };
     84 
     85 }  // namespace IPC
     86 
     87 #endif  // CHROME_COMMON_RENDER_MESSAGES_H_
     88 
     89 #define IPC_MESSAGE_START ChromeMsgStart
     90 
     91 IPC_ENUM_TRAITS(InstantCompleteBehavior)
     92 IPC_ENUM_TRAITS(search_provider::OSDDType)
     93 IPC_ENUM_TRAITS(search_provider::InstallState)
     94 IPC_ENUM_TRAITS(TranslateErrors::Type)
     95 IPC_ENUM_TRAITS(ViewType::Type)
     96 IPC_ENUM_TRAITS(WebKit::WebConsoleMessage::Level)
     97 
     98 IPC_STRUCT_TRAITS_BEGIN(ThumbnailScore)
     99   IPC_STRUCT_TRAITS_MEMBER(boring_score)
    100   IPC_STRUCT_TRAITS_MEMBER(good_clipping)
    101   IPC_STRUCT_TRAITS_MEMBER(at_top)
    102   IPC_STRUCT_TRAITS_MEMBER(time_at_snapshot)
    103 IPC_STRUCT_TRAITS_END()
    104 
    105 IPC_STRUCT_TRAITS_BEGIN(WebKit::WebCache::ResourceTypeStat)
    106   IPC_STRUCT_TRAITS_MEMBER(count)
    107   IPC_STRUCT_TRAITS_MEMBER(size)
    108   IPC_STRUCT_TRAITS_MEMBER(liveSize)
    109   IPC_STRUCT_TRAITS_MEMBER(decodedSize)
    110 IPC_STRUCT_TRAITS_END()
    111 
    112 IPC_STRUCT_TRAITS_BEGIN(WebKit::WebCache::ResourceTypeStats)
    113   IPC_STRUCT_TRAITS_MEMBER(images)
    114   IPC_STRUCT_TRAITS_MEMBER(cssStyleSheets)
    115   IPC_STRUCT_TRAITS_MEMBER(scripts)
    116   IPC_STRUCT_TRAITS_MEMBER(xslStyleSheets)
    117   IPC_STRUCT_TRAITS_MEMBER(fonts)
    118 IPC_STRUCT_TRAITS_END()
    119 
    120 IPC_STRUCT_TRAITS_BEGIN(WebKit::WebCache::UsageStats)
    121   IPC_STRUCT_TRAITS_MEMBER(minDeadCapacity)
    122   IPC_STRUCT_TRAITS_MEMBER(maxDeadCapacity)
    123   IPC_STRUCT_TRAITS_MEMBER(capacity)
    124   IPC_STRUCT_TRAITS_MEMBER(liveSize)
    125   IPC_STRUCT_TRAITS_MEMBER(deadSize)
    126 IPC_STRUCT_TRAITS_END()
    127 
    128 //-----------------------------------------------------------------------------
    129 // RenderView messages
    130 // These are messages sent from the browser to the renderer process.
    131 
    132 // Tells the renderer to set its maximum cache size to the supplied value.
    133 IPC_MESSAGE_CONTROL3(ViewMsg_SetCacheCapacities,
    134                      size_t /* min_dead_capacity */,
    135                      size_t /* max_dead_capacity */,
    136                      size_t /* capacity */)
    137 
    138 // Tells the renderer to clear the cache.
    139 IPC_MESSAGE_CONTROL0(ViewMsg_ClearCache)
    140 
    141 // Tells the renderer to dump as much memory as it can, perhaps because we
    142 // have memory pressure or the renderer is (or will be) paged out.  This
    143 // should only result in purging objects we can recalculate, e.g. caches or
    144 // JS garbage, not in purging irreplaceable objects.
    145 IPC_MESSAGE_CONTROL0(ViewMsg_PurgeMemory)
    146 
    147 // Tells the render view to capture a thumbnail image of the page. The
    148 // render view responds with a ViewHostMsg_Snapshot.
    149 IPC_MESSAGE_ROUTED0(ViewMsg_CaptureSnapshot)
    150 
    151 // History system notification that the visited link database has been
    152 // replaced. It has one SharedMemoryHandle argument consisting of the table
    153 // handle. This handle is valid in the context of the renderer
    154 IPC_MESSAGE_CONTROL1(ViewMsg_VisitedLink_NewTable, base::SharedMemoryHandle)
    155 
    156 // History system notification that a link has been added and the link
    157 // coloring state for the given hash must be re-calculated.
    158 IPC_MESSAGE_CONTROL1(ViewMsg_VisitedLink_Add, std::vector<uint64>)
    159 
    160 // History system notification that one or more history items have been
    161 // deleted, which at this point means that all link coloring state must be
    162 // re-calculated.
    163 IPC_MESSAGE_CONTROL0(ViewMsg_VisitedLink_Reset)
    164 
    165 // Set the content settings for a particular url that the renderer is in the
    166 // process of loading.  This will be stored, to be used if the load commits
    167 // and ignored otherwise.
    168 IPC_MESSAGE_ROUTED2(ViewMsg_SetContentSettingsForLoadingURL,
    169                     GURL /* url */,
    170                     ContentSettings /* content_settings */)
    171 
    172 // Set the content settings for a particular url, so all render views
    173 // displaying this host url update their content settings to match.
    174 IPC_MESSAGE_CONTROL2(ViewMsg_SetContentSettingsForCurrentURL,
    175                      GURL /* url */,
    176                      ContentSettings /* content_settings */)
    177 
    178 // Tells the render view to load all blocked plugins.
    179 IPC_MESSAGE_ROUTED0(ViewMsg_LoadBlockedPlugins)
    180 
    181 // Used to instruct the RenderView to go into "view source" mode.
    182 IPC_MESSAGE_ROUTED0(ViewMsg_EnableViewSourceMode)
    183 
    184 // Get all savable resource links from current webpage, include main
    185 // frame and sub-frame.
    186 IPC_MESSAGE_ROUTED1(ViewMsg_GetAllSavableResourceLinksForCurrentPage,
    187                     GURL /* url of page which is needed to save */)
    188 
    189 // Get html data by serializing all frames of current page with lists
    190 // which contain all resource links that have local copy.
    191 IPC_MESSAGE_ROUTED3(ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks,
    192                     std::vector<GURL> /* urls that have local copy */,
    193                     std::vector<FilePath> /* paths of local copy */,
    194                     FilePath /* local directory path */)
    195 
    196 // Asks the renderer to send back stats on the WebCore cache broken down by
    197 // resource types.
    198 IPC_MESSAGE_CONTROL0(ViewMsg_GetCacheResourceStats)
    199 
    200 // Asks the renderer to send back Histograms.
    201 IPC_MESSAGE_CONTROL1(ViewMsg_GetRendererHistograms,
    202                      int /* sequence number of Renderer Histograms. */)
    203 
    204 #if defined(USE_TCMALLOC)
    205 // Asks the renderer to send back tcmalloc stats.
    206 IPC_MESSAGE_CONTROL0(ViewMsg_GetRendererTcmalloc)
    207 #endif
    208 
    209 // Asks the renderer to send back V8 heap stats.
    210 IPC_MESSAGE_CONTROL0(ViewMsg_GetV8HeapStats)
    211 
    212 // Posts a message to the renderer.
    213 IPC_MESSAGE_ROUTED3(ViewMsg_HandleMessageFromExternalHost,
    214                     std::string /* The message */,
    215                     std::string /* The origin */,
    216                     std::string /* The target*/)
    217 
    218 IPC_MESSAGE_ROUTED4(ViewMsg_SearchBoxChange,
    219                     string16 /* value */,
    220                     bool /* verbatim */,
    221                     int /* selection_start */,
    222                     int /* selection_end */)
    223 IPC_MESSAGE_ROUTED2(ViewMsg_SearchBoxSubmit,
    224                     string16 /* value */,
    225                     bool /* verbatim */)
    226 IPC_MESSAGE_ROUTED0(ViewMsg_SearchBoxCancel)
    227 IPC_MESSAGE_ROUTED1(ViewMsg_SearchBoxResize,
    228                     gfx::Rect /* search_box_bounds */)
    229 IPC_MESSAGE_ROUTED4(ViewMsg_DetermineIfPageSupportsInstant,
    230                     string16 /* value*/,
    231                     bool /* verbatim */,
    232                     int /* selection_start */,
    233                     int /* selection_end */)
    234 
    235 // Tell the renderer which browser window it's being attached to.
    236 IPC_MESSAGE_ROUTED1(ViewMsg_UpdateBrowserWindowId,
    237                     int /* id of browser window */)
    238 
    239 // Tell the renderer which type this view is.
    240 IPC_MESSAGE_ROUTED1(ViewMsg_NotifyRenderViewType,
    241                     ViewType::Type /* view_type */)
    242 
    243 // Tells the renderer to translate the page contents from one language to
    244 // another.
    245 IPC_MESSAGE_ROUTED4(ViewMsg_TranslatePage,
    246                     int /* page id */,
    247                     std::string, /* the script injected in the page */
    248                     std::string, /* BCP 47/RFC 5646 language code the page
    249                                     is in */
    250                     std::string /* BCP 47/RFC 5646 language code to translate
    251                                    to */)
    252 
    253 // Tells the renderer to revert the text of translated page to its original
    254 // contents.
    255 IPC_MESSAGE_ROUTED1(ViewMsg_RevertTranslation,
    256                     int /* page id */)
    257 
    258 // Sent on process startup to indicate whether this process is running in
    259 // incognito mode.
    260 IPC_MESSAGE_CONTROL1(ViewMsg_SetIsIncognitoProcess,
    261                      bool /* is_incognito_processs */)
    262 
    263 //-----------------------------------------------------------------------------
    264 // TabContents messages
    265 // These are messages sent from the renderer to the browser process.
    266 
    267 // Provides the contents for the given page that was loaded recently.
    268 IPC_MESSAGE_ROUTED3(ViewHostMsg_PageContents,
    269                     GURL         /* URL of the page */,
    270                     int32        /* page id */,
    271                     string16     /* page contents */)
    272 
    273 // Notification that the language for the tab has been determined.
    274 IPC_MESSAGE_ROUTED2(ViewHostMsg_TranslateLanguageDetermined,
    275                     std::string  /* page ISO639_1 language code */,
    276                     bool         /* whether the page can be translated */)
    277 
    278 IPC_MESSAGE_CONTROL1(ViewHostMsg_UpdatedCacheStats,
    279                      WebKit::WebCache::UsageStats /* stats */)
    280 
    281 // Tells the browser that content in the current page was blocked due to the
    282 // user's content settings.
    283 IPC_MESSAGE_ROUTED2(ViewHostMsg_ContentBlocked,
    284                     ContentSettingsType, /* type of blocked content */
    285                     std::string /* resource identifier */)
    286 
    287 // Specifies the URL as the first parameter (a wstring) and thumbnail as
    288 // binary data as the second parameter.
    289 IPC_MESSAGE_ROUTED3(ViewHostMsg_Thumbnail,
    290                     GURL /* url */,
    291                     ThumbnailScore /* score */,
    292                     SkBitmap /* bitmap */)
    293 
    294 // Send a snapshot of the tab contents to the render host.
    295 IPC_MESSAGE_ROUTED1(ViewHostMsg_Snapshot,
    296                     SkBitmap /* bitmap */)
    297 
    298 // Following message is used to communicate the values received by the
    299 // callback binding the JS to Cpp.
    300 // An instance of browser that has an automation host listening to it can
    301 // have a javascript send a native value (string, number, boolean) to the
    302 // listener in Cpp. (DomAutomationController)
    303 IPC_MESSAGE_ROUTED2(ViewHostMsg_DomOperationResponse,
    304                     std::string  /* json_string */,
    305                     int  /* automation_id */)
    306 
    307 // A message for an external host.
    308 IPC_MESSAGE_ROUTED3(ViewHostMsg_ForwardMessageToExternalHost,
    309                     std::string  /* message */,
    310                     std::string  /* origin */,
    311                     std::string  /* target */)
    312 
    313 // A renderer sends this to the browser process when it wants to start
    314 // a new instance of the Native Client process. The browser will launch
    315 // the process and return a handle to an IMC channel.
    316 IPC_SYNC_MESSAGE_CONTROL2_3(ViewHostMsg_LaunchNaCl,
    317                             std::wstring /* url for the NaCl module */,
    318                             int /* socket count */,
    319                             std::vector<nacl::FileDescriptor>
    320                                 /* imc channel handles */,
    321                             base::ProcessHandle /* NaCl process handle */,
    322                             base::ProcessId /* NaCl process id */)
    323 
    324 // Notification that the page has an OpenSearch description document
    325 // associated with it.
    326 IPC_MESSAGE_ROUTED3(ViewHostMsg_PageHasOSDD,
    327                     int32 /* page_id */,
    328                     GURL /* url of OS description document */,
    329                     search_provider::OSDDType)
    330 
    331 // Find out if the given url's security origin is installed as a search
    332 // provider.
    333 IPC_SYNC_MESSAGE_ROUTED2_1(ViewHostMsg_GetSearchProviderInstallState,
    334                            GURL /* page url */,
    335                            GURL /* inquiry url */,
    336                            search_provider::InstallState /* install */)
    337 
    338 // Send back a string to be recorded by UserMetrics.
    339 IPC_MESSAGE_CONTROL1(ViewHostMsg_UserMetricsRecordAction,
    340                      std::string /* action */)
    341 
    342 // Send back histograms as vector of pickled-histogram strings.
    343 IPC_MESSAGE_CONTROL2(ViewHostMsg_RendererHistograms,
    344                      int, /* sequence number of Renderer Histograms. */
    345                      std::vector<std::string>)
    346 
    347 #if defined USE_TCMALLOC
    348 // Send back tcmalloc stats output.
    349 IPC_MESSAGE_CONTROL2(ViewHostMsg_RendererTcmalloc,
    350                      int          /* pid */,
    351                      std::string  /* tcmalloc debug output */)
    352 #endif
    353 
    354 // Sends back stats about the V8 heap.
    355 IPC_MESSAGE_CONTROL2(ViewHostMsg_V8HeapStats,
    356                      int /* size of heap (allocated from the OS) */,
    357                      int /* bytes in use */)
    358 
    359 // Request for a DNS prefetch of the names in the array.
    360 // NameList is typedef'ed std::vector<std::string>
    361 IPC_MESSAGE_CONTROL1(ViewHostMsg_DnsPrefetch,
    362                      std::vector<std::string> /* hostnames */)
    363 
    364 // Requests the outdated plugins policy.
    365 // |policy| is one of ALLOW, BLOCK or ASK. Anything else is an error.
    366 // ALLOW means that outdated plugins are allowed, and BLOCK that they should
    367 // be blocked. The default is ASK, which blocks the plugin initially but allows
    368 // the user to start them manually.
    369 IPC_SYNC_MESSAGE_ROUTED0_1(ViewHostMsg_GetOutdatedPluginsPolicy,
    370                            ContentSetting   /* policy */)
    371 
    372 // Notifies when a plugin couldn't be loaded because it's outdated.
    373 IPC_MESSAGE_ROUTED2(ViewHostMsg_BlockedOutdatedPlugin,
    374                     string16, /* name */
    375                     GURL      /* update_url */)
    376 
    377 IPC_MESSAGE_ROUTED3(ViewHostMsg_SendCurrentPageAllSavableResourceLinks,
    378                     std::vector<GURL> /* all savable resource links */,
    379                     std::vector<GURL> /* all referrers of resource links */,
    380                     std::vector<GURL> /* all frame links */)
    381 
    382 IPC_MESSAGE_ROUTED3(ViewHostMsg_SendSerializedHtmlData,
    383                     GURL /* frame's url */,
    384                     std::string /* data buffer */,
    385                     int32 /* complete status */)
    386 
    387 // Provide the browser process with information about the WebCore resource
    388 // cache.
    389 IPC_MESSAGE_CONTROL1(ViewHostMsg_ResourceTypeStats,
    390                      WebKit::WebCache::ResourceTypeStats)
    391 
    392 // Message sent from renderer to the browser to update the state of a command.
    393 // The |command| parameter is a RenderViewCommand. The |checked_state| parameter
    394 // is a CommandCheckedState.
    395 IPC_MESSAGE_ROUTED3(ViewHostMsg_CommandStateChanged,
    396                     int /* command */,
    397                     bool /* is_enabled */,
    398                     int /* checked_state */)
    399 
    400 
    401 // Notifies the browser of the language (ISO 639_1 code language, such as fr,
    402 // en, zh...) of the current page.
    403 IPC_MESSAGE_ROUTED1(ViewHostMsg_PageLanguageDetermined,
    404                     std::string /* the language */)
    405 
    406 // Notifies the browser that a page has been translated.
    407 IPC_MESSAGE_ROUTED4(ViewHostMsg_PageTranslated,
    408                     int,                  /* page id */
    409                     std::string           /* the original language */,
    410                     std::string           /* the translated language */,
    411                     TranslateErrors::Type /* the error type if available */)
    412 
    413 // Suggest results -----------------------------------------------------------
    414 
    415 IPC_MESSAGE_ROUTED3(ViewHostMsg_SetSuggestions,
    416                     int32 /* page_id */,
    417                     std::vector<std::string> /* suggestions */,
    418                     InstantCompleteBehavior)
    419 
    420 IPC_MESSAGE_ROUTED2(ViewHostMsg_InstantSupportDetermined,
    421                     int32 /* page_id */,
    422                     bool  /* result */)
    423 
    424 // JavaScript related messages -----------------------------------------------
    425 
    426 // Notify the JavaScript engine in the render to change its parameters
    427 // while performing stress testing.
    428 IPC_MESSAGE_ROUTED2(ViewMsg_JavaScriptStressTestControl,
    429                     int /* cmd */,
    430                     int /* param */)
    431